@aquera/nile-elements 0.0.5-8 → 0.0.6
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/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button/nile-button.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button/nile-button.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-checkbox/nile-checkbox.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-checkbox/nile-checkbox.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-checkbox/nile-checkbox.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-chip/nile-chip.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-chip/nile-chip.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-chip/nile-chip.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-date-picker/nile-date-picker.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dropdown/nile-dropdown.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/index.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/index.js +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/index.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/stringinput.d.ts +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/stringinput.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/stringinput.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-input/nile-input.d.ts +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-input/nile-input.js +8 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-input/nile-input.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-link/nile-link.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-link/nile-link.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio/nile-radio.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio/nile-radio.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-group/nile-radio-group.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-group/nile-radio-group.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-group/nile-radio-group.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-slide-toggle/nile-slide-toggle.d.ts +4 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-slide-toggle/nile-slide-toggle.js +11 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-slide-toggle/nile-slide-toggle.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/index.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.d.ts +12 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +35 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +60 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +124 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-textarea/nile-textarea.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-textarea/nile-textarea.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/demo/filenames.txt +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +71 -15
- package/dist/nile-button/index.cjs.js +1 -1
- package/dist/nile-button/index.esm.js +1 -1
- package/dist/nile-button/nile-button.cjs.js +1 -1
- package/dist/nile-button/nile-button.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.esm.js +2 -2
- package/dist/nile-checkbox/nile-checkbox.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.cjs.js.map +1 -1
- package/dist/nile-checkbox/nile-checkbox.esm.js +1 -1
- package/dist/nile-chip/nile-chip.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.cjs.js.map +1 -1
- package/dist/nile-chip/nile-chip.esm.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.cjs.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.cjs.js.map +1 -1
- package/dist/nile-date-picker/nile-date-picker.esm.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.cjs.js.map +1 -1
- package/dist/nile-dropdown/nile-dropdown.esm.js +1 -1
- package/dist/nile-icon/icons/svg/index.cjs.js +1 -1
- package/dist/nile-icon/icons/svg/index.esm.js +1 -1
- package/dist/nile-icon/icons/svg/stringinput.cjs.js +2 -0
- package/dist/nile-icon/icons/svg/stringinput.cjs.js.map +1 -0
- package/dist/nile-icon/icons/svg/stringinput.esm.js +1 -0
- package/dist/nile-icon/index.cjs.js +1 -1
- package/dist/nile-icon/index.cjs.js.map +1 -1
- package/dist/nile-icon/index.esm.js +2 -2
- package/dist/nile-icon-button/index.cjs.js +1 -1
- package/dist/nile-icon-button/index.esm.js +1 -1
- package/dist/nile-icon-button/nile-icon-button.cjs.js +1 -1
- package/dist/nile-icon-button/nile-icon-button.cjs.js.map +1 -1
- package/dist/nile-icon-button/nile-icon-button.esm.js +1 -1
- package/dist/nile-input/index.cjs.js +1 -1
- package/dist/nile-input/index.esm.js +1 -1
- package/dist/nile-input/nile-input.cjs.js +1 -1
- package/dist/nile-input/nile-input.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.esm.js +1 -1
- package/dist/nile-link/nile-link.cjs.js +1 -1
- package/dist/nile-link/nile-link.cjs.js.map +1 -1
- package/dist/nile-link/nile-link.esm.js +2 -2
- package/dist/nile-menu-item/index.cjs.js +1 -1
- package/dist/nile-menu-item/index.esm.js +1 -1
- package/dist/nile-menu-item/nile-menu-item.cjs.js +1 -1
- package/dist/nile-menu-item/nile-menu-item.cjs.js.map +1 -1
- package/dist/nile-menu-item/nile-menu-item.esm.js +1 -1
- package/dist/nile-option/index.cjs.js +1 -1
- package/dist/nile-option/index.esm.js +1 -1
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.esm.js +1 -1
- package/dist/nile-radio/nile-radio.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.cjs.js.map +1 -1
- package/dist/nile-radio/nile-radio.esm.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.cjs.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.cjs.js.map +1 -1
- package/dist/nile-radio-group/nile-radio-group.esm.js +2 -2
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +1 -1
- package/dist/nile-slide-toggle/index.cjs.js +1 -1
- package/dist/nile-slide-toggle/index.esm.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.cjs.js.map +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.esm.js +4 -4
- package/dist/nile-switcher/index.cjs.js +2 -0
- package/dist/nile-switcher/index.cjs.js.map +1 -0
- package/dist/nile-switcher/index.esm.js +1 -0
- package/dist/nile-switcher/nile-switcher.cjs.js +2 -0
- package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -0
- package/dist/nile-switcher/nile-switcher.css.cjs.js +2 -0
- package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -0
- package/dist/nile-switcher/nile-switcher.css.esm.js +23 -0
- package/dist/nile-switcher/nile-switcher.esm.js +30 -0
- package/dist/nile-tag/index.cjs.js +1 -1
- package/dist/nile-tag/index.esm.js +1 -1
- package/dist/nile-tag/nile-tag.cjs.js +1 -1
- package/dist/nile-tag/nile-tag.cjs.js.map +1 -1
- package/dist/nile-tag/nile-tag.esm.js +1 -1
- package/dist/nile-textarea/nile-textarea.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.esm.js +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-button/nile-button.js +2 -0
- package/dist/src/nile-button/nile-button.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.d.ts +1 -0
- package/dist/src/nile-calendar/nile-calendar.js +5 -0
- package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/dist/src/nile-checkbox/nile-checkbox.d.ts +1 -0
- package/dist/src/nile-checkbox/nile-checkbox.js +5 -0
- package/dist/src/nile-checkbox/nile-checkbox.js.map +1 -1
- package/dist/src/nile-chip/nile-chip.d.ts +1 -0
- package/dist/src/nile-chip/nile-chip.js +5 -0
- package/dist/src/nile-chip/nile-chip.js.map +1 -1
- package/dist/src/nile-date-picker/nile-date-picker.d.ts +1 -0
- package/dist/src/nile-date-picker/nile-date-picker.js +5 -0
- package/dist/src/nile-date-picker/nile-date-picker.js.map +1 -1
- package/dist/src/nile-dropdown/nile-dropdown.js +2 -0
- package/dist/src/nile-dropdown/nile-dropdown.js.map +1 -1
- package/dist/src/nile-icon/icons/svg/index.d.ts +1 -0
- package/dist/src/nile-icon/icons/svg/index.js +1 -0
- package/dist/src/nile-icon/icons/svg/index.js.map +1 -1
- package/dist/src/nile-icon/icons/svg/stringinput.d.ts +5 -0
- package/dist/src/nile-icon/icons/svg/stringinput.js +5 -0
- package/dist/src/nile-icon/icons/svg/stringinput.js.map +1 -0
- package/dist/src/nile-input/nile-input.d.ts +2 -0
- package/dist/src/nile-input/nile-input.js +8 -0
- package/dist/src/nile-input/nile-input.js.map +1 -1
- package/dist/src/nile-link/nile-link.js +2 -0
- package/dist/src/nile-link/nile-link.js.map +1 -1
- package/dist/src/nile-radio/nile-radio.js +2 -0
- package/dist/src/nile-radio/nile-radio.js.map +1 -1
- package/dist/src/nile-radio-group/nile-radio-group.d.ts +1 -0
- package/dist/src/nile-radio-group/nile-radio-group.js +5 -0
- package/dist/src/nile-radio-group/nile-radio-group.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +1 -0
- package/dist/src/nile-select/nile-select.js +5 -0
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-slide-toggle/nile-slide-toggle.d.ts +4 -2
- package/dist/src/nile-slide-toggle/nile-slide-toggle.js +11 -2
- package/dist/src/nile-slide-toggle/nile-slide-toggle.js.map +1 -1
- package/dist/src/nile-switcher/index.d.ts +1 -0
- package/dist/src/nile-switcher/index.js +2 -0
- package/dist/src/nile-switcher/index.js.map +1 -0
- package/dist/src/nile-switcher/nile-switcher.css.d.ts +12 -0
- package/dist/src/nile-switcher/nile-switcher.css.js +35 -0
- package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -0
- package/dist/src/nile-switcher/nile-switcher.d.ts +60 -0
- package/dist/src/nile-switcher/nile-switcher.js +124 -0
- package/dist/src/nile-switcher/nile-switcher.js.map +1 -0
- package/dist/src/nile-textarea/nile-textarea.js +2 -0
- package/dist/src/nile-textarea/nile-textarea.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/nile-button/nile-button.ts +2 -0
- package/src/nile-calendar/nile-calendar.ts +6 -0
- package/src/nile-checkbox/nile-checkbox.ts +6 -0
- package/src/nile-chip/nile-chip.ts +6 -0
- package/src/nile-date-picker/nile-date-picker.ts +5 -2
- package/src/nile-dropdown/nile-dropdown.ts +2 -0
- package/src/nile-icon/icons/svg/index.ts +1 -0
- package/src/nile-icon/icons/svg/stringinput.ts +5 -0
- package/src/nile-input/nile-input.ts +11 -0
- package/src/nile-link/nile-link.ts +2 -0
- package/src/nile-radio/nile-radio.ts +2 -0
- package/src/nile-radio-group/nile-radio-group.ts +6 -0
- package/src/nile-select/nile-select.ts +6 -0
- package/src/nile-slide-toggle/nile-slide-toggle.ts +14 -1
- package/src/nile-switcher/index.ts +1 -0
- package/src/nile-switcher/nile-switcher.css.ts +37 -0
- package/src/nile-switcher/nile-switcher.ts +185 -0
- package/src/nile-textarea/nile-textarea.ts +2 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-chip.cjs.js","sources":["../../../src/nile-chip/nile-chip.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n property,\n CSSResultArray,\n TemplateResult,\n} from 'lit-element';\nimport { customElement, query, state } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport { watch } from '../internal/watch';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // Auto-complete options\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text' }) helpText = '';\n\n @property({ attribute: 'error-message' }) errorMessage = '';\n\n\n @watch('autoCompleteOptions')\n onAutoCompleteOptionsChanged() {\n this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];\n\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n\n @watch('value')\n onValueChanged() {\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n\n @watch('tags')\n onTagsChanged() {\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.tags.includes(option)\n );\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if (\n event.key === 'Enter' &&\n this.inputValue &&\n (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n pill\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .value=${this.inputValue}\n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n openOnFocus\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n <slot\n name=\"help-text\"\n part=\"form-control-help-text\"\n id=\"help-text\"\n class=\"form-control__help-text\"\n aria-hidden=${hasHelpText ? 'false' : 'true'}\n >\n ${this.helpText}\n </slot>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"],"names":["NileChip","c","this","hasSlotController","HasSlotController","tags","inputValue","isDropdownOpen","warning","error","success","noDuplicates","label","acceptUserInput","clearable","placeholder","readonly","disabled","autoCompleteOptions","filteredAutoCompleteOptions","value","noWrap","errorIndexes","helpText","errorMessage","_this","_createClass","key","onAutoCompleteOptionsChanged","filter","option","includes","onValueChanged","onTagsChanged","connectedCallback","super","handleSelect","event","detail","emit","resetInput","handleRemove","tag","handleInputChange","handleInputKeydown","handleFocus","autoComplete","render","_this5","hasLabelSlot","test","hasLabel","hasHelpText","hasErrorMessage","html","_templateObject","_taggedTemplateLiteral","classMap","map","index","_templateObject2","_templateObject3","_templateObject4","__decorate","get","styles","NileElement","state","prototype","query","property","type","Boolean","reflect","Array","attribute","watch","customElement"],"mappings":"iuLA0BaA,CAAAA,uBAAAA,EAAAA,EAAAA,SAAAA,CAAAA,CAAAA,CAAAA,EAAAA,MAAAA,MAAAA,CAAAA,YAAAA,CAAAA,CAAAA,EAAN,SAAAC,EAAA,qEAKYC,EAAAA,KAAAA,CAAiBC,kBAAG,GAAIC,CAAAA,CAAAA,CAAAA,sBAAAA,CAAAA,KAAAA,EAEvC,WAAA,CACA,SAGOF,KAAAA,CAAIG,IAAAA,CAAa,EAEjBH,CAAAA,KAAAA,CAAUI,WAAW,EAErBJ,CAAAA,KAAAA,CAAcK,cAAY,CAAA,CAAA,CAAA,CAKNL,KAAAA,CAAOM,OAAG,CAAA,CAAA,CAAA,CAGVN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AA6B3E,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAoE,UAAA,UAAA,CAAA,IAAA,EAAA,CAAA,CAEVL,CAAA,CAAA,CAAzCO,CAAS,CAAA,CAAEK,SAAW,CAAA,eAAA,CAAA,CAAA,CAAA,CAAqC3E,CAAAoE,CAAAA,SAAAA,CAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAI5DL,CAAA,CAAA,CADCa,EAAM,qBAUN5E,CAAAA,CAAAA,CAAAA,CAAAA,CAAAoE,SAAA,CAAA,8BAAA,CAAA,IAGDL,CAAAA,CAAAA,CAAAA,CAAA,CADCa,CAAM,CAAA,OAAA,CAAA,CAAA,CAIN5E,CAAAoE,CAAAA,SAAAA,CAAA,gBAAA,CAAA,IAAA,CAAA,CAGDL,EAAA,CADCa,CAAAA,CAAM,MAQN5E,CAAAA,CAAAA,CAAAA,CAAAA,CAAAoE,SAAA,CAAA,eAAA,CAAA,IA3FUpE,CAAAA,CAAAA,OAAAA,KAAAA,CAAAA,CAAQ+D,CAAA,CAAA,CADpBc,CAAc,CAAA,WAAA,CAAA,CAAA,CACF7E"}
|
1
|
+
{"version":3,"file":"nile-chip.cjs.js","sources":["../../../src/nile-chip/nile-chip.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n property,\n CSSResultArray,\n TemplateResult,\n} from 'lit-element';\nimport { customElement, query, state } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport { watch } from '../internal/watch';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // Auto-complete options\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text' }) helpText = '';\n\n @property({ attribute: 'error-message' }) errorMessage = '';\n\n\n @watch('autoCompleteOptions')\n onAutoCompleteOptionsChanged() {\n this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];\n\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n\n @watch('value')\n onValueChanged() {\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n\n @watch('tags')\n onTagsChanged() {\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.tags.includes(option)\n );\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if (\n event.key === 'Enter' &&\n this.inputValue &&\n (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n pill\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .value=${this.inputValue}\n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n openOnFocus\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n <slot\n name=\"help-text\"\n part=\"form-control-help-text\"\n id=\"help-text\"\n class=\"form-control__help-text\"\n aria-hidden=${hasHelpText ? 'false' : 'true'}\n >\n ${this.helpText}\n </slot>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"],"names":["NileChip","_a","_inherits","c","_super","_createSuper","this","hasSlotController","HasSlotController","tags","inputValue","isDropdownOpen","warning","error","success","noDuplicates","label","acceptUserInput","clearable","placeholder","readonly","disabled","autoCompleteOptions","filteredAutoCompleteOptions","value","noWrap","errorIndexes","helpText","errorMessage","_this","_createClass","key","onAutoCompleteOptionsChanged","_toConsumableArray","filter","option","includes","onValueChanged","onTagsChanged","connectedCallback","super","emit","disconnectedCallback","handleSelect","event","detail","concat","resetInput","handleRemove","tag","handleInputChange","handleInputKeydown","handleFocus","autoComplete","render","hasLabelSlot","test","hasLabel","hasHelpText","hasErrorMessage","html","_templateObject","_taggedTemplateLiteral","classMap","map","index","_templateObject2","_templateObject3","_templateObject4","__decorate","get","styles","NileElement","state","prototype","query","property","type","Boolean","reflect","Array","attribute","watch","customElement"],"mappings":"iuLA0BaA,CAAN,uBAAAC,EAAA,EAAAC,SAAA,CAAAC,CAAA,CAAAF,EAAA,MAAAG,MAAA,CAAAC,YAAA,CAAAF,CAAA,EAAA,SAAAA,EAAA,uEAKYG,KAAAA,CAAiBC,iBAAAA,CAAG,GAAIC,CAAAA,CACvCF,CAAAA,sBAAAA,CAAAA,KAAAA,EACA,YACA,OAGOA,CAAAA,CAAAA,KAAAA,CAAIG,KAAa,EAEjBH,CAAAA,KAAAA,CAAUI,UAAW,CAAA,EAAA,CAErBJ,KAAAA,CAAcK,cAAY,CAAA,CAAA,CAAA,CAKNL,KAAAA,CAAOM,OAAAA,CAAAA,CAAG,EAGVN,KAAAA,CAAKO,KAAAA,CAAAA,CAAG,CAGRP,CAAAA,KAAAA,CAAOQ,SAAG,CAGVR,CAAAA,KAAAA,CAAYS,YAAG,CAAA,CAAA,CAAA,CAGhCT,KAAAA,CAAKU,KAAG,CAAA,EAAA,CAGSV,KAAAA,CAAeW,eAAAA,CAAAA,CAAG,EAGlBX,KAAAA,CAASY,SAAAA,CAAAA,CAAG,CAG7BZ,CAAAA,KAAAA,CAAWa,YAAG,cAGkBb,CAAAA,KAAAA,CAAQc,QAAG,CAAA,CAAA,CAAA,CAGXd,KAAAA,CAAQe,QAAG,CAAA,CAAA,CAAA,CAG5Bf,KAAAA,CAAm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,CAAA,CAAA,CADCa,EAAM,qBAUNlF,CAAAA,CAAAA,CAAAA,CAAAA,CAAA0E,SAAA,CAAA,8BAAA,CAAA,IAGDL,CAAAA,CAAAA,CAAAA,CAAA,CADCa,CAAM,CAAA,OAAA,CAAA,CAAA,CAINlF,CAAA0E,CAAAA,SAAAA,CAAA,gBAAA,CAAA,IAAA,CAAA,CAGDL,EAAA,CADCa,CAAAA,CAAM,MAQNlF,CAAAA,CAAAA,CAAAA,CAAAA,CAAA0E,SAAA,CAAA,eAAA,CAAA,IA3FU1E,CAAAA,CAAAA,OAAAA,KAAAA,CAAAA,CAAQqE,CAAA,CAAA,CADpBc,CAAc,CAAA,WAAA,CAAA,CAAA,CACFnF"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{x as e}from"../index-cd2f9c12.esm.js";import{state as i,query as s,customElement as o}from"lit/decorators.js";import{s as l}from"./nile-chip.css.esm.js";import{classMap as h}from"lit/directives/class-map.js";import{H as n}from"../internal/slot.esm.js";import{w as r}from"../internal/watch.esm.js";import{N as a}from"../internal/nile-element.esm.js";import{n as p}from"../property-09139d3c.esm.js";import"lit";let c=class extends a{constructor(){super(...arguments),this.hasSlotController=new n(this,"help-text","label"),this.tags=[],this.inputValue="",this.isDropdownOpen=!1,this.warning=!1,this.error=!1,this.success=!1,this.noDuplicates=!1,this.label="",this.acceptUserInput=!1,this.clearable=!1,this.placeholder="type here...",this.readonly=!1,this.disabled=!1,this.autoCompleteOptions=[],this.filteredAutoCompleteOptions=[],this.value=[],this.noWrap=!1,this.errorIndexes=[],this.helpText="",this.errorMessage=""}static get styles(){return[l]}onAutoCompleteOptionsChanged(){this.filteredAutoCompleteOptions=[...this.autoCompleteOptions],this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t))))}onValueChanged(){this.tags=[...this.value],this.onTagsChanged()}onTagsChanged(){this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.tags.includes(t))))}connectedCallback(){super.connectedCallback(),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t))))}handleSelect(t){this.noDuplicates&&this.tags.includes(t.detail.value)||(this.tags=[...this.tags,t.detail.value],this.emit("nile-chip-change",{value:this.tags}),this.resetInput())}handleRemove(t){this.tags=this.tags.filter((e=>e!==t)),this.noDuplicates&&this.autoCompleteOptions.includes(t)&&(this.filteredAutoCompleteOptions=[...this.filteredAutoCompleteOptions,t]),this.emit("nile-chip-change",{value:this.tags})}handleInputChange(t){this.inputValue=t.detail.value}handleInputKeydown(t){this.acceptUserInput&&("Enter"!==t.key||!this.inputValue||this.noDuplicates&&this.tags.includes(this.inputValue)||(this.tags=[...this.tags,this.inputValue],this.resetInput(),this.emit("nile-chip-change",{value:this.tags})))}handleFocus(){this.isDropdownOpen=!0}resetInput(){this.inputValue="",this.isDropdownOpen=!1,this.autoComplete.value="",this.autoComplete.handleFocus()}render(){const t=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const i=!!this.label||!!t,s=!!this.helpText,o=!!this.errorMessage;return e`
|
1
|
+
import{__decorate as t}from"tslib";import{x as e}from"../index-cd2f9c12.esm.js";import{state as i,query as s,customElement as o}from"lit/decorators.js";import{s as l}from"./nile-chip.css.esm.js";import{classMap as h}from"lit/directives/class-map.js";import{H as n}from"../internal/slot.esm.js";import{w as r}from"../internal/watch.esm.js";import{N as a}from"../internal/nile-element.esm.js";import{n as p}from"../property-09139d3c.esm.js";import"lit";let c=class extends a{constructor(){super(...arguments),this.hasSlotController=new n(this,"help-text","label"),this.tags=[],this.inputValue="",this.isDropdownOpen=!1,this.warning=!1,this.error=!1,this.success=!1,this.noDuplicates=!1,this.label="",this.acceptUserInput=!1,this.clearable=!1,this.placeholder="type here...",this.readonly=!1,this.disabled=!1,this.autoCompleteOptions=[],this.filteredAutoCompleteOptions=[],this.value=[],this.noWrap=!1,this.errorIndexes=[],this.helpText="",this.errorMessage=""}static get styles(){return[l]}onAutoCompleteOptionsChanged(){this.filteredAutoCompleteOptions=[...this.autoCompleteOptions],this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t))))}onValueChanged(){this.tags=[...this.value],this.onTagsChanged()}onTagsChanged(){this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.tags.includes(t))))}connectedCallback(){super.connectedCallback(),this.noDuplicates&&(this.filteredAutoCompleteOptions=this.filteredAutoCompleteOptions.filter((t=>!this.value.includes(t)))),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}handleSelect(t){this.noDuplicates&&this.tags.includes(t.detail.value)||(this.tags=[...this.tags,t.detail.value],this.emit("nile-chip-change",{value:this.tags}),this.resetInput())}handleRemove(t){this.tags=this.tags.filter((e=>e!==t)),this.noDuplicates&&this.autoCompleteOptions.includes(t)&&(this.filteredAutoCompleteOptions=[...this.filteredAutoCompleteOptions,t]),this.emit("nile-chip-change",{value:this.tags})}handleInputChange(t){this.inputValue=t.detail.value}handleInputKeydown(t){this.acceptUserInput&&("Enter"!==t.key||!this.inputValue||this.noDuplicates&&this.tags.includes(this.inputValue)||(this.tags=[...this.tags,this.inputValue],this.resetInput(),this.emit("nile-chip-change",{value:this.tags})))}handleFocus(){this.isDropdownOpen=!0}resetInput(){this.inputValue="",this.isDropdownOpen=!1,this.autoComplete.value="",this.autoComplete.handleFocus()}render(){const t=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const i=!!this.label||!!t,s=!!this.helpText,o=!!this.errorMessage;return e`
|
2
2
|
<div
|
3
3
|
part="form-control"
|
4
4
|
class=${h({"form-control":!0,"form-control--medium":!0,"form-control--has-label":i,"form-control--has-help-text":s,"nile-chip--disabled":this.disabled})}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
System.register(["tslib","../index-cd83c5c8.cjs.js","lit/decorators.js","./nile-date-picker.css.cjs.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js","../nile-popup/nile-popup.cjs.js","../property-0f6a51ec.cjs.js","lit","lit/directives/class-map.js","../nile-popup/nile-popup.css.cjs.js"],function(_export,_context){"use strict";var t,e,i,s,n,a,r,l,_templateObject,h;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(typeof call==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_index001CjsJs){e=_index001CjsJs.x;},function(_litDecoratorsJs){i=_litDecoratorsJs.query;s=_litDecoratorsJs.customElement;},function(_nileDatePickerCssCjsJs){n=_nileDatePickerCssCjsJs.s;},function(_internalWatchCjsJs){a=_internalWatchCjsJs.w;},function(_internalNileElementCjsJs){r=_internalNileElementCjsJs.N;},function(_nilePopupNilePopupCjsJs){},function(_property002CjsJs){l=_property002CjsJs.n;},function(_lit){},function(_litDirectivesClassMapJs){},function(_nilePopupNilePopupCssCjsJs){}],execute:function(){_export("N",h=/*#__PURE__*/function(_r){_inherits(h,_r);var _super=_createSuper(h);function h(){var _this;_classCallCheck(this,h);_this=_super.apply(this,arguments),_this.currentMonth=new Date().getMonth(),_this.currentYear=new Date().getFullYear(),_this.dropDownOpened=!1,_this.valueAttribute=null,_this.formattedDate=null,_this.startDate=null,_this.endDate=null,_this.isSelectingStart=!0,_this.range=!1;return _this;}_createClass(h,[{key:"valueChanged",value:function valueChanged(){if(this.range&&this.value)return this.rangeValue=this.value,void(this.value=null);if(this.value&&!isNaN(this.value.getTime())){var _t=this.value.getTimezoneOffset(),_e=new Date(this.value.getTime()-60*_t*1e3);isNaN(_e.getTime())||(this.valueAttribute=_e.toISOString().split("T")[0],this.formattedDate="".concat(String(_e.getDate()).padStart(2,"0"),"/").concat(String(_e.getMonth()+1).padStart(2,"0"),"/").concat(_e.getFullYear()));}}},{key:"updated",value:function updated(t){if(_get(_getPrototypeOf(h.prototype),"updated",this).call(this,t),t.has("valueAttribute")){var _t2=new Date(this.valueAttribute||"");if(!isNaN(_t2.getTime())){var _e2=_t2.getTimezoneOffset();this.value=new Date(_t2.getTime()-60*_e2*1e3),this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear();}}}},{key:"attributeChangedCallback",value:function attributeChangedCallback(t,e,i){"value"===t?(this.valueAttribute=i,this.initializeValue()):"range"===t&&(this.range=null!==i);}},{key:"initializeValue",value:function initializeValue(){if(this.range)try{var _t3=JSON.parse(this.valueAttribute||"");this.startDate=new Date(_t3.startDate),this.endDate=new Date(_t3.endDate),this.startDate=new Date(this.startDate.getTime()),this.endDate=new Date(this.endDate.getTime()),this.rangeValue={startDate:this.startDate,endDate:this.endDate},this.value=null;}catch(t){}else if(this.valueAttribute){var _t4;_t4=new Date(this.valueAttribute),_t4=new Date(_t4.getTime()-6e4*_t4.getTimezoneOffset()),isNaN(_t4.getTime())||(this.value=_t4,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear(),this.rangeValue=null);}this.requestUpdate();}},{key:"handleChanged",value:function handleChanged(t){this.emit("nile-changed",{value:t.detail.value}),this.dropdown&&this.dropdown.hide();}},{key:"connectedCallback",value:function connectedCallback(){if(_get(_getPrototypeOf(h.prototype),"connectedCallback",this).call(this),this.initializeValue(),this.valueAttribute){var _t5=new Date(this.valueAttribute);isNaN(_t5.getTime())||(this.value=_t5,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear());}}},{key:"render",value:function render(){return e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-dropdown .hoist=\"","\">\n <slot\n slot=\"trigger\"\n part=\"trigger\"\n name=\"trigger\"\n ></slot>\n\n<nile-calendar .value=\"","\" .range=\"","\" @nile-changed=\"","\"> </nile-calendar>\n </nile-dropdown>\n "])),!0,this.range,this.range,this.handleChanged);}}],[{key:"styles",get:function get(){return[n];}},{key:"observedAttributes",get:function get(){return["value","range"];}}]);return h;}(r));t([i("nile-dropdown")],h.prototype,"dropdown",void 0),t([l({type:Boolean,reflect:!0})],h.prototype,"dropDownOpened",void 0),t([l({type:Object})],h.prototype,"value",void 0),t([l({type:Object})],h.prototype,"rangeValue",void 0),t([l({type:String,attribute:"value"})],h.prototype,"valueAttribute",void 0),t([l({type:String,attribute:"value"})],h.prototype,"formattedDate",void 0),t([l({type:Object})],h.prototype,"startDate",void 0),t([l({type:Object})],h.prototype,"endDate",void 0),t([l({type:Boolean})],h.prototype,"isSelectingStart",void 0),t([l({type:Boolean})],h.prototype,"range",void 0),t([a("value")],h.prototype,"valueChanged",null),_export("N",h=t([s("nile-date-picker")],h));}};});
|
1
|
+
System.register(["tslib","../index-cd83c5c8.cjs.js","lit/decorators.js","./nile-date-picker.css.cjs.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js","../nile-popup/nile-popup.cjs.js","../property-0f6a51ec.cjs.js","lit","lit/directives/class-map.js","../nile-popup/nile-popup.css.cjs.js"],function(_export,_context){"use strict";var t,e,i,s,n,a,r,l,_templateObject,h;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(typeof call==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_index001CjsJs){e=_index001CjsJs.x;},function(_litDecoratorsJs){i=_litDecoratorsJs.query;s=_litDecoratorsJs.customElement;},function(_nileDatePickerCssCjsJs){n=_nileDatePickerCssCjsJs.s;},function(_internalWatchCjsJs){a=_internalWatchCjsJs.w;},function(_internalNileElementCjsJs){r=_internalNileElementCjsJs.N;},function(_nilePopupNilePopupCjsJs){},function(_property002CjsJs){l=_property002CjsJs.n;},function(_lit){},function(_litDirectivesClassMapJs){},function(_nilePopupNilePopupCssCjsJs){}],execute:function(){_export("N",h=/*#__PURE__*/function(_r){_inherits(h,_r);var _super=_createSuper(h);function h(){var _this;_classCallCheck(this,h);_this=_super.apply(this,arguments),_this.currentMonth=new Date().getMonth(),_this.currentYear=new Date().getFullYear(),_this.dropDownOpened=!1,_this.valueAttribute=null,_this.formattedDate=null,_this.startDate=null,_this.endDate=null,_this.isSelectingStart=!0,_this.range=!1;return _this;}_createClass(h,[{key:"valueChanged",value:function valueChanged(){if(this.range&&this.value)return this.rangeValue=this.value,void(this.value=null);if(this.value&&!isNaN(this.value.getTime())){var _t=this.value.getTimezoneOffset(),_e=new Date(this.value.getTime()-60*_t*1e3);isNaN(_e.getTime())||(this.valueAttribute=_e.toISOString().split("T")[0],this.formattedDate="".concat(String(_e.getDate()).padStart(2,"0"),"/").concat(String(_e.getMonth()+1).padStart(2,"0"),"/").concat(_e.getFullYear()));}}},{key:"updated",value:function updated(t){if(_get(_getPrototypeOf(h.prototype),"updated",this).call(this,t),t.has("valueAttribute")){var _t2=new Date(this.valueAttribute||"");if(!isNaN(_t2.getTime())){var _e2=_t2.getTimezoneOffset();this.value=new Date(_t2.getTime()-60*_e2*1e3),this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear();}}}},{key:"attributeChangedCallback",value:function attributeChangedCallback(t,e,i){"value"===t?(this.valueAttribute=i,this.initializeValue()):"range"===t&&(this.range=null!==i);}},{key:"initializeValue",value:function initializeValue(){if(this.range)try{var _t3=JSON.parse(this.valueAttribute||"");this.startDate=new Date(_t3.startDate),this.endDate=new Date(_t3.endDate),this.startDate=new Date(this.startDate.getTime()),this.endDate=new Date(this.endDate.getTime()),this.rangeValue={startDate:this.startDate,endDate:this.endDate},this.value=null;}catch(t){}else if(this.valueAttribute){var _t4;_t4=new Date(this.valueAttribute),_t4=new Date(_t4.getTime()-6e4*_t4.getTimezoneOffset()),isNaN(_t4.getTime())||(this.value=_t4,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear(),this.rangeValue=null);}this.requestUpdate();}},{key:"handleChanged",value:function handleChanged(t){this.emit("nile-changed",{value:t.detail.value}),this.dropdown&&this.dropdown.hide();}},{key:"connectedCallback",value:function connectedCallback(){if(_get(_getPrototypeOf(h.prototype),"connectedCallback",this).call(this),this.initializeValue(),this.valueAttribute){var _t5=new Date(this.valueAttribute);isNaN(_t5.getTime())||(this.value=_t5,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear());}this.emit("nile-init");}},{key:"disconnectedCallback",value:function disconnectedCallback(){_get(_getPrototypeOf(h.prototype),"disconnectedCallback",this).call(this),this.emit("nile-destroy");}},{key:"render",value:function render(){return e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-dropdown .hoist=\"","\">\n <slot\n slot=\"trigger\"\n part=\"trigger\"\n name=\"trigger\"\n ></slot>\n\n<nile-calendar .value=\"","\" .range=\"","\" @nile-changed=\"","\"> </nile-calendar>\n </nile-dropdown>\n "])),!0,this.range,this.range,this.handleChanged);}}],[{key:"styles",get:function get(){return[n];}},{key:"observedAttributes",get:function get(){return["value","range"];}}]);return h;}(r));t([i("nile-dropdown")],h.prototype,"dropdown",void 0),t([l({type:Boolean,reflect:!0})],h.prototype,"dropDownOpened",void 0),t([l({type:Object})],h.prototype,"value",void 0),t([l({type:Object})],h.prototype,"rangeValue",void 0),t([l({type:String,attribute:"value"})],h.prototype,"valueAttribute",void 0),t([l({type:String,attribute:"value"})],h.prototype,"formattedDate",void 0),t([l({type:Object})],h.prototype,"startDate",void 0),t([l({type:Object})],h.prototype,"endDate",void 0),t([l({type:Boolean})],h.prototype,"isSelectingStart",void 0),t([l({type:Boolean})],h.prototype,"range",void 0),t([a("value")],h.prototype,"valueChanged",null),_export("N",h=t([s("nile-date-picker")],h));}};});
|
2
2
|
//# sourceMappingURL=nile-date-picker.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-date-picker.cjs.js","sources":["../../../src/nile-date-picker/nile-date-picker.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n property,\n CSSResultArray,\n TemplateResult,\n} from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-date-picker.css';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { query } from 'lit/decorators.js';\nimport {\n getAnimation,\n setDefaultAnimation,\n} from '../utilities/animation-registry';\nimport { getTabbableBoundary } from '../internal/tabbable';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup, PropertyValues } from 'lit';\nimport type NileButton from '../nile-button/nile-button';\nimport type NileIconButton from '../nile-icon-button/nile-icon-button';\nimport type { NileMenu } from '../nile-menu';\nimport type { NilePopup } from '../nile-popup';\nimport '../nile-popup';\nimport { NileDropdown } from '../nile-dropdown';\n\n/**\n * Nile icon component.\n *\n * @tag nile-date-picker\n *\n */\n@customElement('nile-date-picker')\nexport class NileDatePicker extends NileElement {\n /**\n * The styles for DatePicker\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private currentMonth: number = new Date().getMonth();\n private currentYear: number = new Date().getFullYear();\n\n @query('nile-dropdown') dropdown: NileDropdown;\n\n @property({ type: Boolean, reflect: true }) dropDownOpened = false;\n\n @property({ type: Object }) value : any;\n\n @property({ type: Object }) rangeValue : any;\n\n @property({ type: String, attribute: 'value' }) valueAttribute:\n | string\n | null = null;\n\n @property({ type: String, attribute: 'value' }) formattedDate: string | null =\n null;\n\n @property({ type: Object }) startDate: Date | null = null;\n @property({ type: Object }) endDate: Date | null = null;\n @property({ type: Boolean }) isSelectingStart = true; // flag to indicate what we're selecting\n\n @property({ type: Boolean }) range = false;\n\n @watch('value')\n valueChanged() {\n\n if (this.range && this.value) {\n this.rangeValue = this.value;\n this.value = null;\n return;\n }\n\n if (this.value && !isNaN(this.value.getTime())) {\n const offset = this.value.getTimezoneOffset();\n const localDate = new Date(this.value.getTime() - offset * 60 * 1000);\n if (!isNaN(localDate.getTime())) {\n this.valueAttribute = localDate.toISOString().split('T')[0];\n this.formattedDate = `${String(localDate.getDate()).padStart(\n 2,\n '0'\n )}/${String(localDate.getMonth() + 1).padStart(\n 2,\n '0'\n )}/${localDate.getFullYear()}`;\n }\n }\n }\n\n\n updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n\n if (changedProperties.has('valueAttribute')) {\n const date = new Date(this.valueAttribute || '');\n if (!isNaN(date.getTime())) {\n const offset = date.getTimezoneOffset();\n this.value = new Date(date.getTime() - offset * 60 * 1000);\n this.currentMonth = this.value.getMonth();\n this.currentYear = this.value.getFullYear();\n }\n }\n }\n\n static get observedAttributes() {\n return ['value', 'range'];\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (name === 'value') {\n this.valueAttribute = newValue;\n this.initializeValue();\n } else if (name === 'range') {\n this.range = newValue !== null;\n }\n }\n\n initializeValue() {\n if (this.range) {\n try {\n const rangeValue = JSON.parse(this.valueAttribute || '');\n this.startDate = new Date(rangeValue.startDate);\n this.endDate = new Date(rangeValue.endDate);\n\n // Convert to local time\n this.startDate = new Date(this.startDate.getTime());\n this.endDate = new Date(this.endDate.getTime());\n\n this.rangeValue = {\n startDate: this.startDate,\n endDate: this.endDate,\n };\n this.value = null;\n } catch (e) {\n // console.error('Invalid range value');\n }\n } else {\n if (this.valueAttribute) {\n let date: Date;\n\n date = new Date(this.valueAttribute);\n\n date = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n\n if (!isNaN(date.getTime())) {\n this.value = date;\n this.currentMonth = this.value.getMonth();\n this.currentYear = this.value.getFullYear();\n this.rangeValue = null;\n }\n }\n }\n this.requestUpdate();\n }\n\n handleChanged(event:any) {\n this.emit('nile-changed', { value: event.detail.value });\n if (this.dropdown) {\n this.dropdown.hide();\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.initializeValue();\n\n if (this.valueAttribute) {\n const date = new Date(this.valueAttribute);\n if (!isNaN(date.getTime())) {\n this.value = date;\n this.currentMonth = this.value.getMonth();\n this.currentYear = this.value.getFullYear();\n }\n }\n }\n\n\n\n\n /* #endregion */\n\n /* #region Methods */\n\n /**\n * Render method\n * @slot This is a slot test\n */\n render(): TemplateResult {\n\n return html`\n <nile-dropdown .hoist=\"${true}\">\n <slot\n slot=\"trigger\"\n part=\"trigger\"\n name=\"trigger\"\n ></slot>\n\n<nile-calendar .value=\"${this.range}\" .range=\"${this.range}\" @nile-changed=\"${this.handleChanged}\"> </nile-calendar>\n </nile-dropdown>\n `;\n }\n}\n\nexport default NileDatePicker;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-date-picker': NileDatePicker;\n }\n}\n"],"names":["NileDatePicker","h","this","currentMonth","Date","getMonth","currentYear","getFullYear","dropDownOpened","valueAttribute","formattedDate","startDate","endDate","isSelectingStart","range","_this","_createClass","key","value","valueChanged","rangeValue","isNaN","getTime","offset","getTimezoneOffset","localDate","toISOString","split","String","getDate","padStart","concat","updated","changedProperties","super","has","date","attributeChangedCallback","name","oldValue","newValue","initializeValue","JSON","parse","e","requestUpdate","handleChanged","event","emit","detail","dropdown","hide","connectedCallback","render","html","_templateObject","_taggedTemplateLiteral","__decorate","get","styles","NileElement","query","prototype","property","type","Boolean","reflect","Object","attribute","watch","customElement"],"mappings":"uoJA0CaA,CAAAA,uBAAAA,EAAAA,EAAAA,SAAAA,CAAAA,CAAAA,CAAAA,EAAAA,MAAAA,MAAAA,CAAAA,YAAAA,CAAAA,CAAAA,EAAN,SAAAC,EAAA,uEASGC,KAAAA,CAAAC,YAAAA,CAAuB,GAAIC,CAAAA,IAAOC,CAAAA,CAAAA,CAAAA,QAAAA,CAAAA,CAAAA,CAClCH,KAAAA,CAAAI,WAAsB,CAAA,GAAIF,CAAAA,OAAOG,WAIGL,CAAAA,CAAAA,CAAAA,KAAAA,CAAcM,gBAAG,CAMbN,CAAAA,KAAAA,CAAcO,eAEnD,IAEqCP,CAAAA,KAAAA,CAAaQ,aAC3D,CAAA,IAAA,CAE0BR,KAAAA,CAASS,SAAgB,CAAA,IAAA,CACzBT,KAAAA,CAAOU,OAAgB,CAAA,IAAA,CACtBV,KAAAA,CAAAW,gBAAmB,CAAA,CAAA,CAAA,CAEnBX,KAAAA,CAAK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A,CAAA,OAAA,CAAA,IAAA,EAG3CL,CAAAA,CAAAA,CAAAA,CAAA,CADCY,CAAAA,CAAM,OAuBNrE,CAAAA,CAAAA,CAAAA,CAAAA,CAAA8D,SAAA,CAAA,cAAA,CAAA,IAxDU9D,CAAAA,CAAAA,OAAAA,KAAAA,CAAAA,CAAcyD,CAAA,CAAA,CAD1Ba,CAAc,CAAA,kBAAA,CAAA,CAAA,CACFtE"}
|
1
|
+
{"version":3,"file":"nile-date-picker.cjs.js","sources":["../../../src/nile-date-picker/nile-date-picker.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n property,\n CSSResultArray,\n TemplateResult,\n} from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-date-picker.css';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { query } from 'lit/decorators.js';\nimport {\n getAnimation,\n setDefaultAnimation,\n} from '../utilities/animation-registry';\nimport { getTabbableBoundary } from '../internal/tabbable';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup, PropertyValues } from 'lit';\nimport type NileButton from '../nile-button/nile-button';\nimport type NileIconButton from '../nile-icon-button/nile-icon-button';\nimport type { NileMenu } from '../nile-menu';\nimport type { NilePopup } from '../nile-popup';\nimport '../nile-popup';\nimport { NileDropdown } from '../nile-dropdown';\n\n/**\n * Nile icon component.\n *\n * @tag nile-date-picker\n *\n */\n@customElement('nile-date-picker')\nexport class NileDatePicker extends NileElement {\n /**\n * The styles for DatePicker\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private currentMonth: number = new Date().getMonth();\n private currentYear: number = new Date().getFullYear();\n\n @query('nile-dropdown') dropdown: NileDropdown;\n\n @property({ type: Boolean, reflect: true }) dropDownOpened = false;\n\n @property({ type: Object }) value : any;\n\n @property({ type: Object }) rangeValue : any;\n\n @property({ type: String, attribute: 'value' }) valueAttribute:\n | string\n | null = null;\n\n @property({ type: String, attribute: 'value' }) formattedDate: string | null =\n null;\n\n @property({ type: Object }) startDate: Date | null = null;\n @property({ type: Object }) endDate: Date | null = null;\n @property({ type: Boolean }) isSelectingStart = true; // flag to indicate what we're selecting\n\n @property({ type: Boolean }) range = false;\n\n @watch('value')\n valueChanged() {\n\n if (this.range && this.value) {\n this.rangeValue = this.value;\n this.value = null;\n return;\n }\n\n if (this.value && !isNaN(this.value.getTime())) {\n const offset = this.value.getTimezoneOffset();\n const localDate = new Date(this.value.getTime() - offset * 60 * 1000);\n if (!isNaN(localDate.getTime())) {\n this.valueAttribute = localDate.toISOString().split('T')[0];\n this.formattedDate = `${String(localDate.getDate()).padStart(\n 2,\n '0'\n )}/${String(localDate.getMonth() + 1).padStart(\n 2,\n '0'\n )}/${localDate.getFullYear()}`;\n }\n }\n }\n\n\n updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n\n if (changedProperties.has('valueAttribute')) {\n const date = new Date(this.valueAttribute || '');\n if (!isNaN(date.getTime())) {\n const offset = date.getTimezoneOffset();\n this.value = new Date(date.getTime() - offset * 60 * 1000);\n this.currentMonth = this.value.getMonth();\n this.currentYear = this.value.getFullYear();\n }\n }\n }\n\n static get observedAttributes() {\n return ['value', 'range'];\n }\n\n attributeChangedCallback(name: string, oldValue: string, newValue: string) {\n if (name === 'value') {\n this.valueAttribute = newValue;\n this.initializeValue();\n } else if (name === 'range') {\n this.range = newValue !== null;\n }\n }\n\n initializeValue() {\n if (this.range) {\n try {\n const rangeValue = JSON.parse(this.valueAttribute || '');\n this.startDate = new Date(rangeValue.startDate);\n this.endDate = new Date(rangeValue.endDate);\n\n // Convert to local time\n this.startDate = new Date(this.startDate.getTime());\n this.endDate = new Date(this.endDate.getTime());\n\n this.rangeValue = {\n startDate: this.startDate,\n endDate: this.endDate,\n };\n this.value = null;\n } catch (e) {\n // console.error('Invalid range value');\n }\n } else {\n if (this.valueAttribute) {\n let date: Date;\n\n date = new Date(this.valueAttribute);\n\n date = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n\n if (!isNaN(date.getTime())) {\n this.value = date;\n this.currentMonth = this.value.getMonth();\n this.currentYear = this.value.getFullYear();\n this.rangeValue = null;\n }\n }\n }\n this.requestUpdate();\n }\n\n handleChanged(event:any) {\n this.emit('nile-changed', { value: event.detail.value });\n if (this.dropdown) {\n this.dropdown.hide();\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.initializeValue();\n\n if (this.valueAttribute) {\n const date = new Date(this.valueAttribute);\n if (!isNaN(date.getTime())) {\n this.value = date;\n this.currentMonth = this.value.getMonth();\n this.currentYear = this.value.getFullYear();\n }\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n /* #endregion */\n\n /* #region Methods */\n\n /**\n * Render method\n * @slot This is a slot test\n */\n render(): TemplateResult {\n\n return html`\n <nile-dropdown .hoist=\"${true}\">\n <slot\n slot=\"trigger\"\n part=\"trigger\"\n name=\"trigger\"\n ></slot>\n\n<nile-calendar .value=\"${this.range}\" .range=\"${this.range}\" @nile-changed=\"${this.handleChanged}\"> </nile-calendar>\n </nile-dropdown>\n `;\n }\n}\n\nexport default NileDatePicker;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-date-picker': NileDatePicker;\n }\n}\n"],"names":["NileDatePicker","_r","_inherits","h","_super","_createSuper","this","currentMonth","Date","getMonth","currentYear","getFullYear","dropDownOpened","valueAttribute","formattedDate","startDate","endDate","isSelectingStart","range","_this","_createClass","key","value","valueChanged","rangeValue","isNaN","getTime","offset","getTimezoneOffset","localDate","toISOString","split","concat","String","getDate","padStart","updated","changedProperties","super","has","date","attributeChangedCallback","name","oldValue","newValue","initializeValue","JSON","parse","e","requestUpdate","handleChanged","event","emit","detail","dropdown","hide","connectedCallback","disconnectedCallback","render","html","_templateObject","_taggedTemplateLiteral","__decorate","get","styles","NileElement","query","prototype","property","type","Boolean","reflect","Object","attribute","watch","customElement"],"mappings":"uoJA0CaA,CAAN,uBAAAC,EAAA,EAAAC,SAAA,CAAAC,CAAA,CAAAF,EAAA,MAAAG,MAAA,CAAAC,YAAA,CAAAF,CAAA,EAAA,SAAAA,EAAA,uEASGG,KAAAA,CAAAC,YAAuB,CAAA,GAAIC,CAAAA,OAAOC,QAClCH,CAAAA,CAAAA,CAAAA,KAAAA,CAAAI,YAAsB,GAAIF,CAAAA,IAAAA,CAAAA,CAAAA,CAAOG,cAIGL,KAAAA,CAAcM,cAAAA,CAAAA,CAAG,EAMbN,KAAAA,CAAcO,cAAAA,CAEnD,KAEqCP,KAAAA,CAAaQ,aAAAA,CAC3D,IAE0BR,CAAAA,KAAAA,CAASS,UAAgB,IACzBT,CAAAA,KAAAA,CAAOU,QAAgB,IACtBV,CAAAA,KAAAA,CAAAW,kBAAmB,CAEnBX,CAAAA,KAAAA,CAAKY,OAAG,CA8ItC,QAAAC,KAAA,EAxKQC,YAAA,CAAAjB,CAAA,GAAAkB,GAAA,gBAAAC,KAAA,CA6BP,SAAAC,aAAA,CAEE,CAAA,GAAIjB,KAAKY,KAASZ,EAAAA,IAAAA,CAAKgB,MAGrB,MAFAhB,KAAAA,CAAKkB,WAAalB,IAAKgB,CAAAA,KAAAA,CAAAA,KACvBhB,KAAKgB,KAAQ,CAAA,IAAA,CAAA,CAIf,GAAIhB,IAAKgB,CAAAA,KAAAA,EAAAA,CAAUG,MAAMnB,IAAKgB,CAAAA,KAAAA,CAAMI,WAAY,CAC9C,GAAMC,CAAAA,GAASrB,IAAKgB,CAAAA,KAAAA,CAAMM,iBACpBC,CAAAA,CAAAA,CAAAA,EAAAA,CAAY,GAAIrB,CAAAA,IAAKF,CAAAA,IAAAA,CAAKgB,MAAMI,OAAqB,CAAA,CAA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EAAA,CAAA,CAEgCL,CAAA,CAAA,CAA/CM,CAAS,CAAA,CAAEC,IAAMpC,CAAAA,MAAAA,CAAQwC,UAAW,OAC9BzE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAmE,SAAA,CAAA,eAAA,CAAA,IAAA,EAEqBL,CAAAA,CAAAA,CAAAA,CAAA,CAA3BM,CAAAA,CAAS,CAAEC,IAAAA,CAAMG,MAAwCxE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAmE,SAAA,CAAA,WAAA,CAAA,IAAA,IAC9BL,CAAA,CAAA,CAA3BM,CAAS,CAAA,CAAEC,IAAMG,CAAAA,MAAAA,CAAAA,CAAAA,CAAAA,CAAsCxE,CAAAmE,CAAAA,SAAAA,CAAA,SAAA,CAAA,IAAA,EAAA,CAAA,CAC3BL,CAAA,CAAA,CAA5BM,CAAS,CAAA,CAAEC,KAAMC,OAAmCtE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAmE,SAAA,CAAA,kBAAA,CAAA,IAAA,EAExBL,CAAAA,CAAAA,CAAAA,CAAA,CAA5BM,CAAAA,CAAS,CAAEC,IAAAA,CAAMC,OAAyBtE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAmE,SAAA,CAAA,OAAA,CAAA,IAAA,EAG3CL,CAAAA,CAAAA,CAAAA,CAAA,CADCY,CAAAA,CAAM,OAuBN1E,CAAAA,CAAAA,CAAAA,CAAAA,CAAAmE,SAAA,CAAA,cAAA,CAAA,IAxDUnE,CAAAA,CAAAA,OAAAA,KAAAA,CAAAA,CAAc8D,CAAA,CAAA,CAD1Ba,CAAc,CAAA,kBAAA,CAAA,CAAA,CACF3E"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{x as e}from"../index-cd2f9c12.esm.js";import{query as i,customElement as s}from"lit/decorators.js";import{s as n}from"./nile-date-picker.css.esm.js";import{w as a}from"../internal/watch.esm.js";import{N as r}from"../internal/nile-element.esm.js";import"../nile-popup/nile-popup.esm.js";import{n as l}from"../property-09139d3c.esm.js";import"lit";import"lit/directives/class-map.js";import"../nile-popup/nile-popup.css.esm.js";let h=class extends r{constructor(){super(...arguments),this.currentMonth=(new Date).getMonth(),this.currentYear=(new Date).getFullYear(),this.dropDownOpened=!1,this.valueAttribute=null,this.formattedDate=null,this.startDate=null,this.endDate=null,this.isSelectingStart=!0,this.range=!1}static get styles(){return[n]}valueChanged(){if(this.range&&this.value)return this.rangeValue=this.value,void(this.value=null);if(this.value&&!isNaN(this.value.getTime())){const t=this.value.getTimezoneOffset(),e=new Date(this.value.getTime()-60*t*1e3);isNaN(e.getTime())||(this.valueAttribute=e.toISOString().split("T")[0],this.formattedDate=`${String(e.getDate()).padStart(2,"0")}/${String(e.getMonth()+1).padStart(2,"0")}/${e.getFullYear()}`)}}updated(t){if(super.updated(t),t.has("valueAttribute")){const t=new Date(this.valueAttribute||"");if(!isNaN(t.getTime())){const e=t.getTimezoneOffset();this.value=new Date(t.getTime()-60*e*1e3),this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear()}}}static get observedAttributes(){return["value","range"]}attributeChangedCallback(t,e,i){"value"===t?(this.valueAttribute=i,this.initializeValue()):"range"===t&&(this.range=null!==i)}initializeValue(){if(this.range)try{const t=JSON.parse(this.valueAttribute||"");this.startDate=new Date(t.startDate),this.endDate=new Date(t.endDate),this.startDate=new Date(this.startDate.getTime()),this.endDate=new Date(this.endDate.getTime()),this.rangeValue={startDate:this.startDate,endDate:this.endDate},this.value=null}catch(t){}else if(this.valueAttribute){let t;t=new Date(this.valueAttribute),t=new Date(t.getTime()-6e4*t.getTimezoneOffset()),isNaN(t.getTime())||(this.value=t,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear(),this.rangeValue=null)}this.requestUpdate()}handleChanged(t){this.emit("nile-changed",{value:t.detail.value}),this.dropdown&&this.dropdown.hide()}connectedCallback(){if(super.connectedCallback(),this.initializeValue(),this.valueAttribute){const t=new Date(this.valueAttribute);isNaN(t.getTime())||(this.value=t,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear())}}render(){return e`
|
1
|
+
import{__decorate as t}from"tslib";import{x as e}from"../index-cd2f9c12.esm.js";import{query as i,customElement as s}from"lit/decorators.js";import{s as n}from"./nile-date-picker.css.esm.js";import{w as a}from"../internal/watch.esm.js";import{N as r}from"../internal/nile-element.esm.js";import"../nile-popup/nile-popup.esm.js";import{n as l}from"../property-09139d3c.esm.js";import"lit";import"lit/directives/class-map.js";import"../nile-popup/nile-popup.css.esm.js";let h=class extends r{constructor(){super(...arguments),this.currentMonth=(new Date).getMonth(),this.currentYear=(new Date).getFullYear(),this.dropDownOpened=!1,this.valueAttribute=null,this.formattedDate=null,this.startDate=null,this.endDate=null,this.isSelectingStart=!0,this.range=!1}static get styles(){return[n]}valueChanged(){if(this.range&&this.value)return this.rangeValue=this.value,void(this.value=null);if(this.value&&!isNaN(this.value.getTime())){const t=this.value.getTimezoneOffset(),e=new Date(this.value.getTime()-60*t*1e3);isNaN(e.getTime())||(this.valueAttribute=e.toISOString().split("T")[0],this.formattedDate=`${String(e.getDate()).padStart(2,"0")}/${String(e.getMonth()+1).padStart(2,"0")}/${e.getFullYear()}`)}}updated(t){if(super.updated(t),t.has("valueAttribute")){const t=new Date(this.valueAttribute||"");if(!isNaN(t.getTime())){const e=t.getTimezoneOffset();this.value=new Date(t.getTime()-60*e*1e3),this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear()}}}static get observedAttributes(){return["value","range"]}attributeChangedCallback(t,e,i){"value"===t?(this.valueAttribute=i,this.initializeValue()):"range"===t&&(this.range=null!==i)}initializeValue(){if(this.range)try{const t=JSON.parse(this.valueAttribute||"");this.startDate=new Date(t.startDate),this.endDate=new Date(t.endDate),this.startDate=new Date(this.startDate.getTime()),this.endDate=new Date(this.endDate.getTime()),this.rangeValue={startDate:this.startDate,endDate:this.endDate},this.value=null}catch(t){}else if(this.valueAttribute){let t;t=new Date(this.valueAttribute),t=new Date(t.getTime()-6e4*t.getTimezoneOffset()),isNaN(t.getTime())||(this.value=t,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear(),this.rangeValue=null)}this.requestUpdate()}handleChanged(t){this.emit("nile-changed",{value:t.detail.value}),this.dropdown&&this.dropdown.hide()}connectedCallback(){if(super.connectedCallback(),this.initializeValue(),this.valueAttribute){const t=new Date(this.valueAttribute);isNaN(t.getTime())||(this.value=t,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear())}this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}render(){return e`
|
2
2
|
<nile-dropdown .hoist="${!0}">
|
3
3
|
<slot
|
4
4
|
slot="trigger"
|
@@ -1,2 +1,2 @@
|
|
1
|
-
System.register(["tslib","../index-cd83c5c8.cjs.js","lit/decorators.js","./nile-dropdown.css.cjs.js","../internal/animate.cjs.js","lit/directives/class-map.js","../utilities/animation-registry.cjs.js","../internal/tabbable.cjs.js","../internal/event.cjs.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js","../nile-popup/nile-popup.cjs.js","../property-0f6a51ec.cjs.js","lit","../nile-popup/nile-popup.css.cjs.js"],function(_export,_context){"use strict";var t,i,s,e,o,n,h,r,a,d,l,p,c,m,u,_templateObject,w;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function(){return e;};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value;},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{define({},"");}catch(t){define=function(t,e,r){return t[e]=r;};}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a;}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)};}catch(t){return{type:"throw",arg:t};}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this;});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach(function(e){define(t,e,function(t){return this._invoke(e,t);});});}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){invoke("next",t,i,a);},function(t){invoke("throw",t,i,a);}):e.resolve(h).then(function(t){u.value=t,i(u);},function(t){return invoke("throw",t,i,a);});}a(c.arg);}var r;o(this,"_invoke",{value:function(t,n){function callInvokeWithMethodAndArg(){return new e(function(e,r){invoke(t,n,e,r);});}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw new Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done};}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg);}};}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y);}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0);}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o<e.length;)if(n.call(e,o))return next.value=e[o],next.done=!1,next;return next.value=t,next.done=!0,next;};return i.next=i;}}throw new TypeError(typeof e+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===GeneratorFunction||"GeneratorFunction"===(e.displayName||e.name));},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t;},e.awrap=function(t){return{__await:t};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this;}),e.AsyncIterator=AsyncIterator,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(wrap(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next();});},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this;}),define(g,"toString",function(){return"[object Generator]";}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function next(){for(;r.length;){var t=r.pop();if(t in e)return next.value=t,next.done=!1,next;}return next.done=!0,next;};},e.values=values,Context.prototype={constructor:Context,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function(e){if(this.done)throw e;var r=this;function handle(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o;}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}else if(c){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break;}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a);},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y;},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y;}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r);}return o;}}throw new Error("illegal catch attempt");},delegateYield:function(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y;}},e;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(typeof call==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_index001CjsJs){i=_index001CjsJs.x;},function(_litDecoratorsJs){s=_litDecoratorsJs.query;e=_litDecoratorsJs.customElement;},function(_nileDropdownCssCjsJs){o=_nileDropdownCssCjsJs.s;},function(_internalAnimateCjsJs){n=_internalAnimateCjsJs.s;h=_internalAnimateCjsJs.a;},function(_litDirectivesClassMapJs){r=_litDirectivesClassMapJs.classMap;},function(_utilitiesAnimationRegistryCjsJs){a=_utilitiesAnimationRegistryCjsJs.s;d=_utilitiesAnimationRegistryCjsJs.g;},function(_internalTabbableCjsJs){l=_internalTabbableCjsJs.g;},function(_internalEventCjsJs){p=_internalEventCjsJs.w;},function(_internalWatchCjsJs){c=_internalWatchCjsJs.w;},function(_internalNileElementCjsJs){m=_internalNileElementCjsJs.N;},function(_nilePopupNilePopupCjsJs){},function(_property002CjsJs){u=_property002CjsJs.n;},function(_lit){},function(_nilePopupNilePopupCssCjsJs){}],execute:function(){_export("N",w=/*#__PURE__*/function(_m){_inherits(w,_m);var _super=_createSuper(w);function w(){var _this;_classCallCheck(this,w);_this=_super.apply(this,arguments),_this.open=!1,_this.placement="bottom-start",_this.disabled=!1,_this.stayOpenOnSelect=!1,_this.distance=0,_this.noOpenOnClick=!1,_this.skidding=0,_this.hoist=!1;return _this;}_createClass(w,[{key:"connectedCallback",value:function connectedCallback(){_get(_getPrototypeOf(w.prototype),"connectedCallback",this).call(this),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this);}},{key:"firstUpdated",value:function firstUpdated(){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0);}},{key:"disconnectedCallback",value:function disconnectedCallback(){_get(_getPrototypeOf(w.prototype),"disconnectedCallback",this).call(this),this.removeOpenListeners(),this.hide();}},{key:"focusOnTrigger",value:function focusOnTrigger(){var t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof(t===null||t===void 0?void 0:t.focus)&&t.focus();}},{key:"getMenu",value:function getMenu(){return this.panel.assignedElements({flatten:!0}).find(function(t){return"nile-menu"===t.tagName.toLowerCase();});}},{key:"handleKeyDown",value:function handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger());}},{key:"handleDocumentKeyDown",value:function handleDocumentKeyDown(t){var _this2=this;if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){var _document$activeEleme;if(this.open&&"nile-menu-item"===((_document$activeEleme=document.activeElement)===null||_document$activeEleme===void 0?void 0:_document$activeEleme.tagName.toLowerCase()))return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout(function(){var _this2$containingElem,_document$activeEleme2;var t=((_this2$containingElem=_this2.containingElement)===null||_this2$containingElem===void 0?void 0:_this2$containingElem.getRootNode())instanceof ShadowRoot?(_document$activeEleme2=document.activeElement)===null||_document$activeEleme2===void 0||(_document$activeEleme2=_document$activeEleme2.shadowRoot)===null||_document$activeEleme2===void 0?void 0:_document$activeEleme2.activeElement:document.activeElement;_this2.containingElement&&(t===null||t===void 0?void 0:t.closest(_this2.containingElement.tagName.toLowerCase()))===_this2.containingElement||_this2.hide();});}}},{key:"handleDocumentMouseDown",value:function handleDocumentMouseDown(t){var i=t.composedPath();this.containingElement&&!i.includes(this.containingElement)&&this.hide();}},{key:"handlePanelSelect",value:function handlePanelSelect(t){var i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()||(this.hide(),this.focusOnTrigger());}},{key:"handleTriggerClick",value:function handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()));}},{key:"handleTriggerKeyDown",value:function handleTriggerKeyDown(t){var i=this.getMenu();if(i){var _s=i.getAllItems(),_e=_s[0],_o=_s[_s.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),_s.length>0&&this.updateComplete.then(function(){"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(_e),_e.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(_o),_o.focus());}));}}},{key:"handleTriggerKeyUp",value:function handleTriggerKeyUp(t){" "===t.key&&t.preventDefault();}},{key:"handleTriggerSlotChange",value:function handleTriggerSlotChange(){this.updateAccessibleTrigger();}},{key:"updateAccessibleTrigger",value:function updateAccessibleTrigger(){var t=this.trigger.assignedElements({flatten:!0}).find(function(t){return l(t).start;});var i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t;}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false");}}},{key:"show",value:function(){var _show=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(this.open){_context2.next=2;break;}return _context2.abrupt("return",(this.open=!0,p(this,"nile-after-show")));case 2:case"end":return _context2.stop();}},_callee,this);}));function show(){return _show.apply(this,arguments);}return show;}()},{key:"hide",value:function(){var _hide=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!this.open){_context3.next=2;break;}return _context3.abrupt("return",(this.open=!1,p(this,"nile-after-hide")));case 2:case"end":return _context3.stop();}},_callee2,this);}));function hide(){return _hide.apply(this,arguments);}return hide;}()},{key:"reposition",value:function reposition(){this.popup.reposition();}},{key:"addOpenListeners",value:function addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"removeOpenListeners",value:function removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"handleOpenChange",value:function(){var _handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var _d,_t,_i,_d2,_t2,_i2;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!this.disabled){_context4.next=4;break;}this.open=!1;_context4.next=27;break;case 4:if(!(this.updateAccessibleTrigger(),this.open)){_context4.next=17;break;}this.emit("nile-show");this.addOpenListeners();_context4.next=9;return n(this);case 9:this.panel.hidden=!1;this.popup.active=!0;_d=d(this,"dropdown.show",{dir:""}),_t=_d.keyframes,_i=_d.options;_context4.next=14;return h(this.popup.popup,_t,_i);case 14:this.emit("nile-after-show");_context4.next=27;break;case 17:this.emit("nile-hide");this.removeOpenListeners();_context4.next=21;return n(this);case 21:_d2=d(this,"dropdown.hide",{dir:""}),_t2=_d2.keyframes,_i2=_d2.options;_context4.next=24;return h(this.popup.popup,_t2,_i2);case 24:this.panel.hidden=!0;this.popup.active=!1;this.emit("nile-after-hide");case 27:case"end":return _context4.stop();}},_callee3,this);}));function handleOpenChange(){return _handleOpenChange.apply(this,arguments);}return handleOpenChange;}()},{key:"render",value:function render(){return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=","\n distance=","\n skidding=","\n strategy=","\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=","\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=","\n @keydown=","\n @keyup=","\n @slotchange=","\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=","\n aria-labelledby=\"dropdown\"\n ></slot>\n </nile-popup>\n "])),this.placement,this.distance,this.skidding,this.hoist?"fixed":"absolute",r({dropdown:!0,"dropdown--open":this.open}),this.handleTriggerClick,this.handleTriggerKeyDown,this.handleTriggerKeyUp,this.handleTriggerSlotChange,this.open?"false":"true");}}]);return w;}(m));w.styles=o,t([s(".dropdown")],w.prototype,"popup",void 0),t([s(".dropdown__trigger")],w.prototype,"trigger",void 0),t([s(".dropdown__panel")],w.prototype,"panel",void 0),t([u({type:Boolean,reflect:!0})],w.prototype,"open",void 0),t([u({reflect:!0})],w.prototype,"placement",void 0),t([u({type:Boolean,reflect:!0})],w.prototype,"disabled",void 0),t([u({attribute:"stay-open-on-select",type:Boolean,reflect:!0})],w.prototype,"stayOpenOnSelect",void 0),t([u({attribute:!1})],w.prototype,"containingElement",void 0),t([u({type:Number})],w.prototype,"distance",void 0),t([u({type:Boolean})],w.prototype,"noOpenOnClick",void 0),t([u({type:Number})],w.prototype,"skidding",void 0),t([u({type:Boolean})],w.prototype,"hoist",void 0),t([c("open",{waitUntilFirstUpdate:!0})],w.prototype,"handleOpenChange",null),_export("N",w=t([e("nile-dropdown")],w)),a("dropdown.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),a("dropdown.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});}};});
|
1
|
+
System.register(["tslib","../index-cd83c5c8.cjs.js","lit/decorators.js","./nile-dropdown.css.cjs.js","../internal/animate.cjs.js","lit/directives/class-map.js","../utilities/animation-registry.cjs.js","../internal/tabbable.cjs.js","../internal/event.cjs.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js","../nile-popup/nile-popup.cjs.js","../property-0f6a51ec.cjs.js","lit","../nile-popup/nile-popup.css.cjs.js"],function(_export,_context){"use strict";var t,i,s,e,o,n,h,r,a,d,l,p,c,m,u,_templateObject,w;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function(){return e;};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value;},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{define({},"");}catch(t){define=function(t,e,r){return t[e]=r;};}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a;}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)};}catch(t){return{type:"throw",arg:t};}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this;});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach(function(e){define(t,e,function(t){return this._invoke(e,t);});});}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){invoke("next",t,i,a);},function(t){invoke("throw",t,i,a);}):e.resolve(h).then(function(t){u.value=t,i(u);},function(t){return invoke("throw",t,i,a);});}a(c.arg);}var r;o(this,"_invoke",{value:function(t,n){function callInvokeWithMethodAndArg(){return new e(function(e,r){invoke(t,n,e,r);});}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw new Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done};}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg);}};}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y);}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0);}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o<e.length;)if(n.call(e,o))return next.value=e[o],next.done=!1,next;return next.value=t,next.done=!0,next;};return i.next=i;}}throw new TypeError(typeof e+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===GeneratorFunction||"GeneratorFunction"===(e.displayName||e.name));},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t;},e.awrap=function(t){return{__await:t};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this;}),e.AsyncIterator=AsyncIterator,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(wrap(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next();});},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this;}),define(g,"toString",function(){return"[object Generator]";}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function next(){for(;r.length;){var t=r.pop();if(t in e)return next.value=t,next.done=!1,next;}return next.done=!0,next;};},e.values=values,Context.prototype={constructor:Context,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function(e){if(this.done)throw e;var r=this;function handle(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o;}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}else if(c){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break;}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a);},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y;},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y;}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r);}return o;}}throw new Error("illegal catch attempt");},delegateYield:function(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y;}},e;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(typeof call==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_index001CjsJs){i=_index001CjsJs.x;},function(_litDecoratorsJs){s=_litDecoratorsJs.query;e=_litDecoratorsJs.customElement;},function(_nileDropdownCssCjsJs){o=_nileDropdownCssCjsJs.s;},function(_internalAnimateCjsJs){n=_internalAnimateCjsJs.s;h=_internalAnimateCjsJs.a;},function(_litDirectivesClassMapJs){r=_litDirectivesClassMapJs.classMap;},function(_utilitiesAnimationRegistryCjsJs){a=_utilitiesAnimationRegistryCjsJs.s;d=_utilitiesAnimationRegistryCjsJs.g;},function(_internalTabbableCjsJs){l=_internalTabbableCjsJs.g;},function(_internalEventCjsJs){p=_internalEventCjsJs.w;},function(_internalWatchCjsJs){c=_internalWatchCjsJs.w;},function(_internalNileElementCjsJs){m=_internalNileElementCjsJs.N;},function(_nilePopupNilePopupCjsJs){},function(_property002CjsJs){u=_property002CjsJs.n;},function(_lit){},function(_nilePopupNilePopupCssCjsJs){}],execute:function(){_export("N",w=/*#__PURE__*/function(_m){_inherits(w,_m);var _super=_createSuper(w);function w(){var _this;_classCallCheck(this,w);_this=_super.apply(this,arguments),_this.open=!1,_this.placement="bottom-start",_this.disabled=!1,_this.stayOpenOnSelect=!1,_this.distance=0,_this.noOpenOnClick=!1,_this.skidding=0,_this.hoist=!1;return _this;}_createClass(w,[{key:"connectedCallback",value:function connectedCallback(){_get(_getPrototypeOf(w.prototype),"connectedCallback",this).call(this),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init");}},{key:"firstUpdated",value:function firstUpdated(){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0);}},{key:"disconnectedCallback",value:function disconnectedCallback(){_get(_getPrototypeOf(w.prototype),"disconnectedCallback",this).call(this),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy");}},{key:"focusOnTrigger",value:function focusOnTrigger(){var t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof(t===null||t===void 0?void 0:t.focus)&&t.focus();}},{key:"getMenu",value:function getMenu(){return this.panel.assignedElements({flatten:!0}).find(function(t){return"nile-menu"===t.tagName.toLowerCase();});}},{key:"handleKeyDown",value:function handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger());}},{key:"handleDocumentKeyDown",value:function handleDocumentKeyDown(t){var _this2=this;if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){var _document$activeEleme;if(this.open&&"nile-menu-item"===((_document$activeEleme=document.activeElement)===null||_document$activeEleme===void 0?void 0:_document$activeEleme.tagName.toLowerCase()))return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout(function(){var _this2$containingElem,_document$activeEleme2;var t=((_this2$containingElem=_this2.containingElement)===null||_this2$containingElem===void 0?void 0:_this2$containingElem.getRootNode())instanceof ShadowRoot?(_document$activeEleme2=document.activeElement)===null||_document$activeEleme2===void 0||(_document$activeEleme2=_document$activeEleme2.shadowRoot)===null||_document$activeEleme2===void 0?void 0:_document$activeEleme2.activeElement:document.activeElement;_this2.containingElement&&(t===null||t===void 0?void 0:t.closest(_this2.containingElement.tagName.toLowerCase()))===_this2.containingElement||_this2.hide();});}}},{key:"handleDocumentMouseDown",value:function handleDocumentMouseDown(t){var i=t.composedPath();this.containingElement&&!i.includes(this.containingElement)&&this.hide();}},{key:"handlePanelSelect",value:function handlePanelSelect(t){var i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()||(this.hide(),this.focusOnTrigger());}},{key:"handleTriggerClick",value:function handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()));}},{key:"handleTriggerKeyDown",value:function handleTriggerKeyDown(t){var i=this.getMenu();if(i){var _s=i.getAllItems(),_e=_s[0],_o=_s[_s.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),_s.length>0&&this.updateComplete.then(function(){"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(_e),_e.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(_o),_o.focus());}));}}},{key:"handleTriggerKeyUp",value:function handleTriggerKeyUp(t){" "===t.key&&t.preventDefault();}},{key:"handleTriggerSlotChange",value:function handleTriggerSlotChange(){this.updateAccessibleTrigger();}},{key:"updateAccessibleTrigger",value:function updateAccessibleTrigger(){var t=this.trigger.assignedElements({flatten:!0}).find(function(t){return l(t).start;});var i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t;}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false");}}},{key:"show",value:function(){var _show=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(this.open){_context2.next=2;break;}return _context2.abrupt("return",(this.open=!0,p(this,"nile-after-show")));case 2:case"end":return _context2.stop();}},_callee,this);}));function show(){return _show.apply(this,arguments);}return show;}()},{key:"hide",value:function(){var _hide=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!this.open){_context3.next=2;break;}return _context3.abrupt("return",(this.open=!1,p(this,"nile-after-hide")));case 2:case"end":return _context3.stop();}},_callee2,this);}));function hide(){return _hide.apply(this,arguments);}return hide;}()},{key:"reposition",value:function reposition(){this.popup.reposition();}},{key:"addOpenListeners",value:function addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"removeOpenListeners",value:function removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"handleOpenChange",value:function(){var _handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var _d,_t,_i,_d2,_t2,_i2;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!this.disabled){_context4.next=4;break;}this.open=!1;_context4.next=27;break;case 4:if(!(this.updateAccessibleTrigger(),this.open)){_context4.next=17;break;}this.emit("nile-show");this.addOpenListeners();_context4.next=9;return n(this);case 9:this.panel.hidden=!1;this.popup.active=!0;_d=d(this,"dropdown.show",{dir:""}),_t=_d.keyframes,_i=_d.options;_context4.next=14;return h(this.popup.popup,_t,_i);case 14:this.emit("nile-after-show");_context4.next=27;break;case 17:this.emit("nile-hide");this.removeOpenListeners();_context4.next=21;return n(this);case 21:_d2=d(this,"dropdown.hide",{dir:""}),_t2=_d2.keyframes,_i2=_d2.options;_context4.next=24;return h(this.popup.popup,_t2,_i2);case 24:this.panel.hidden=!0;this.popup.active=!1;this.emit("nile-after-hide");case 27:case"end":return _context4.stop();}},_callee3,this);}));function handleOpenChange(){return _handleOpenChange.apply(this,arguments);}return handleOpenChange;}()},{key:"render",value:function render(){return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=","\n distance=","\n skidding=","\n strategy=","\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=","\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=","\n @keydown=","\n @keyup=","\n @slotchange=","\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=","\n aria-labelledby=\"dropdown\"\n ></slot>\n </nile-popup>\n "])),this.placement,this.distance,this.skidding,this.hoist?"fixed":"absolute",r({dropdown:!0,"dropdown--open":this.open}),this.handleTriggerClick,this.handleTriggerKeyDown,this.handleTriggerKeyUp,this.handleTriggerSlotChange,this.open?"false":"true");}}]);return w;}(m));w.styles=o,t([s(".dropdown")],w.prototype,"popup",void 0),t([s(".dropdown__trigger")],w.prototype,"trigger",void 0),t([s(".dropdown__panel")],w.prototype,"panel",void 0),t([u({type:Boolean,reflect:!0})],w.prototype,"open",void 0),t([u({reflect:!0})],w.prototype,"placement",void 0),t([u({type:Boolean,reflect:!0})],w.prototype,"disabled",void 0),t([u({attribute:"stay-open-on-select",type:Boolean,reflect:!0})],w.prototype,"stayOpenOnSelect",void 0),t([u({attribute:!1})],w.prototype,"containingElement",void 0),t([u({type:Number})],w.prototype,"distance",void 0),t([u({type:Boolean})],w.prototype,"noOpenOnClick",void 0),t([u({type:Number})],w.prototype,"skidding",void 0),t([u({type:Boolean})],w.prototype,"hoist",void 0),t([c("open",{waitUntilFirstUpdate:!0})],w.prototype,"handleOpenChange",null),_export("N",w=t([e("nile-dropdown")],w)),a("dropdown.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),a("dropdown.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});}};});
|
2
2
|
//# sourceMappingURL=nile-dropdown.cjs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-dropdown.cjs.js","sources":["../../../src/nile-dropdown/nile-dropdown.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {LitElement, html, property, CSSResultArray, TemplateResult} from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport {styles} from './nile-dropdown.css';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { query } from 'lit/decorators.js';\nimport { getAnimation, setDefaultAnimation } from '../utilities/animation-registry';\nimport { getTabbableBoundary } from '../internal/tabbable';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup } from 'lit';\nimport type NileButton from '../nile-button/nile-button';\nimport type NileIconButton from '../nile-icon-button/nile-icon-button';\nimport type { NileMenu } from '../nile-menu';\nimport type { NilePopup } from '../nile-popup';\nimport '../nile-popup';\n\n/**\n * Nile icon component.\n *\n * @tag nile-dropdown\n * @summary Dropdowns expose additional content that \"drops down\" in a panel.\n * @dependency nile-popup\n *\n * @slot - The dropdown's main content.\n * @slot trigger - The dropdown's trigger, usually a `<nile-button>` element.\n *\n * @event nile-show - Emitted when the dropdown opens.\n * @event nile-after-show - Emitted after the dropdown opens and all animations are complete.\n * @event nile-hide - Emitted when the dropdown closes.\n * @event nile-after-hide - Emitted after the dropdown closes and all animations are complete.\n *\n * @csspart base - The component's base wrapper.\n * @csspart trigger - The container that wraps the trigger.\n * @csspart panel - The panel that gets shown when the dropdown is open.\n *\n * @animation dropdown.show - The animation to use when showing the dropdown.\n * @animation dropdown.hide - The animation to use when hiding the dropdown.\n */\n@customElement('nile-dropdown')\nexport class NileDropdown extends NileElement {\n static styles: CSSResultGroup = styles;\n\n @query('.dropdown') popup: NilePopup;\n @query('.dropdown__trigger') trigger: HTMLSlotElement;\n @query('.dropdown__panel') panel: HTMLSlotElement;\n\n\n /**\n * Indicates whether or not the dropdown is open. You can toggle this attribute to show and hide the dropdown, or you\n * can use the `show()` and `hide()` methods and this attribute will reflect the dropdown's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel\n * inside of the viewport.\n */\n @property({ reflect: true }) placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'bottom-start';\n\n /** Disables the dropdown so the panel will not open. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * By default, the dropdown is closed when an item is selected. This attribute will keep it open instead. Useful for\n * dropdowns that allow for multiple interactions.\n */\n @property({ attribute: 'stay-open-on-select', type: Boolean, reflect: true }) stayOpenOnSelect = false;\n\n /**\n * The dropdown will close when the user interacts outside of this element (e.g. clicking). Useful for composing other\n * components that use a dropdown internally.\n */\n @property({ attribute: false }) containingElement?: HTMLElement;\n\n /** The distance in pixels from which to offset the panel away from its trigger. */\n @property({ type: Number }) distance = 0;\n\n\n @property({ type: Boolean }) noOpenOnClick = false;\n\n /** The distance in pixels from which to offset the panel along its trigger. */\n @property({ type: Number }) skidding = 0;\n\n /**\n * Enable this option to prevent the panel from being clipped when the component is placed inside a container with\n * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.\n */\n @property({ type: Boolean }) hoist = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handlePanelSelect = this.handlePanelSelect.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);\n\n if (!this.containingElement) {\n this.containingElement = this;\n }\n }\n\n firstUpdated() {\n this.panel.hidden = !this.open;\n\n // If the dropdown is visible on init, update its position\n if (this.open) {\n this.addOpenListeners();\n this.popup.active = true;\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeOpenListeners();\n this.hide();\n }\n\n focusOnTrigger() {\n const trigger = this.trigger.assignedElements({ flatten: true })[0] as HTMLElement | undefined;\n if (typeof trigger?.focus === 'function') {\n trigger.focus();\n }\n }\n\n getMenu() {\n return this.panel.assignedElements({ flatten: true }).find(el => el.tagName.toLowerCase() === 'nile-menu') as\n | NileMenu\n | undefined;\n }\n\n handleKeyDown(event: KeyboardEvent) {\n // Close when escape is pressed inside an open dropdown. We need to listen on the panel itself and stop propagation\n // in case any ancestors are also listening for this key.\n if (this.open && event.key === 'Escape') {\n event.stopPropagation();\n this.hide();\n this.focusOnTrigger();\n }\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n // Close when escape or tab is pressed\n if (event.key === 'Escape' && this.open) {\n event.stopPropagation();\n this.focusOnTrigger();\n this.hide();\n return;\n }\n\n // Handle tabbing\n if (event.key === 'Tab') {\n // Tabbing within an open menu should close the dropdown and refocus the trigger\n if (this.open && document.activeElement?.tagName.toLowerCase() === 'nile-menu-item') {\n event.preventDefault();\n this.hide();\n this.focusOnTrigger();\n return;\n }\n\n // Tabbing outside of the containing element closes the panel\n //\n // If the dropdown is used within a shadow DOM, we need to obtain the activeElement within that shadowRoot,\n // otherwise `document.activeElement` will only return the name of the parent shadow DOM element.\n setTimeout(() => {\n const activeElement =\n this.containingElement?.getRootNode() instanceof ShadowRoot\n ? document.activeElement?.shadowRoot?.activeElement\n : document.activeElement;\n\n if (\n !this.containingElement ||\n activeElement?.closest(this.containingElement.tagName.toLowerCase()) !== this.containingElement\n ) {\n this.hide();\n }\n });\n }\n }\n\n handleDocumentMouseDown(event: MouseEvent) {\n // Close when clicking outside of the containing element\n const path = event.composedPath();\n if (this.containingElement && !path.includes(this.containingElement)) {\n this.hide();\n }\n }\n\n handlePanelSelect(event: any) {\n const target = event.target as HTMLElement;\n\n // Hide the dropdown when a menu item is selected\n if (!this.stayOpenOnSelect && target.tagName.toLowerCase() === 'nile-menu') {\n this.hide();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerClick() {\n if(this.noOpenOnClick){\n return;\n }\n if (this.open) {\n this.hide();\n } else {\n this.show();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerKeyDown(event: KeyboardEvent) {\n // When spacebar/enter is pressed, show the panel but don't focus on the menu. This let's the user press the same\n // key again to hide the menu in case they don't want to make a selection.\n // if (['Enter'].includes(event.key)) {\n // event.preventDefault();\n // this.handleTriggerClick();\n // return;\n // }\n\n const menu = this.getMenu();\n\n if (menu) {\n const menuItems = menu.getAllItems();\n const firstMenuItem = menuItems[0];\n const lastMenuItem = menuItems[menuItems.length - 1];\n\n // When up/down is pressed, we make the assumption that the user is familiar with the menu and plans to make a\n // selection. Rather than toggle the panel, we focus on the menu (if one exists) and activate the first item for\n // faster navigation.\n if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {\n event.preventDefault();\n\n // Show the menu if it's not already open\n if (!this.open) {\n this.show();\n }\n\n if (menuItems.length > 0) {\n // Focus on the first/last menu item after showing\n this.updateComplete.then(() => {\n if (event.key === 'ArrowDown' || event.key === 'Home') {\n menu.setCurrentItem(firstMenuItem);\n firstMenuItem.focus();\n }\n\n if (event.key === 'ArrowUp' || event.key === 'End') {\n menu.setCurrentItem(lastMenuItem);\n lastMenuItem.focus();\n }\n });\n }\n }\n }\n }\n\n handleTriggerKeyUp(event: KeyboardEvent) {\n // Prevent space from triggering a click event in Firefox\n if (event.key === ' ') {\n event.preventDefault();\n }\n }\n\n handleTriggerSlotChange() {\n this.updateAccessibleTrigger();\n }\n\n //\n // Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and\n // `aria-expanded`. These must be applied to the \"accessible trigger\" (the tabbable portion of the trigger element\n // that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,\n // a child of the slotted element, or an element in the slotted element's shadow root.\n //\n // For example, the accessible trigger of an <nile-button> is a <button> located inside its shadow root.\n //\n // To determine this, we assume the first tabbable element in the trigger slot is the \"accessible trigger.\"\n //\n updateAccessibleTrigger() {\n const assignedElements = this.trigger.assignedElements({ flatten: true }) as HTMLElement[];\n const accessibleTrigger = assignedElements.find(el => getTabbableBoundary(el).start);\n let target: HTMLElement;\n\n if (accessibleTrigger) {\n switch (accessibleTrigger.tagName.toLowerCase()) {\n // nile buttons have to update the internal button so it's announced correctly by screen readers\n case 'nile-button':\n case 'nile-icon-button':\n target = (accessibleTrigger as NileButton | NileIconButton).button;\n break;\n\n default:\n target = accessibleTrigger;\n }\n\n target.setAttribute('aria-haspopup', 'true');\n target.setAttribute('aria-expanded', this.open ? 'true' : 'false');\n }\n }\n\n /** Shows the dropdown panel. */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'nile-after-show');\n }\n\n /** Hides the dropdown panel */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'nile-after-hide');\n }\n\n /**\n * Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu\n * is activated.\n */\n reposition() {\n this.popup.reposition();\n }\n\n addOpenListeners() {\n this.panel.addEventListener('nile-select', this.handlePanelSelect);\n this.panel.addEventListener('keydown', this.handleKeyDown);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n document.addEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n removeOpenListeners() {\n if (this.panel) {\n this.panel.removeEventListener('nile-select', this.handlePanelSelect);\n this.panel.removeEventListener('keydown', this.handleKeyDown);\n }\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n document.removeEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.disabled) {\n this.open = false;\n return;\n }\n\n this.updateAccessibleTrigger();\n\n if (this.open) {\n // Show\n this.emit('nile-show');\n this.addOpenListeners();\n\n await stopAnimations(this);\n this.panel.hidden = false;\n this.popup.active = true;\n const { keyframes, options } = getAnimation(this, 'dropdown.show', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n\n this.emit('nile-after-show');\n } else {\n // Hide\n this.emit('nile-hide');\n this.removeOpenListeners();\n\n await stopAnimations(this);\n const { keyframes, options } = getAnimation(this, 'dropdown.hide', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n this.panel.hidden = true;\n this.popup.active = false;\n\n this.emit('nile-after-hide');\n }\n }\n\n render() {\n return html`\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=${this.placement}\n distance=${this.distance}\n skidding=${this.skidding}\n strategy=${this.hoist ? 'fixed' : 'absolute'}\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=${classMap({\n dropdown: true,\n 'dropdown--open': this.open\n })}\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=${this.handleTriggerClick}\n @keydown=${this.handleTriggerKeyDown}\n @keyup=${this.handleTriggerKeyUp}\n @slotchange=${this.handleTriggerSlotChange}\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=${this.open ? 'false' : 'true'}\n aria-labelledby=\"dropdown\"\n ></slot>\n </nile-popup>\n `;\n }\n}\n\nsetDefaultAnimation('dropdown.show', {\n keyframes: [\n { opacity: 0, scale: 0.9 },\n { opacity: 1, scale: 1 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nsetDefaultAnimation('dropdown.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.9 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nexport default NileDropdown;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-dropdown': NileDropdown;\n }\n}\n"],"names":["NileDropdown","w","this","open","placement","disabled","stayOpenOnSelect","distance","noOpenOnClick","skidding","hoist","_this","_createClass","key","value","connectedCallback","super","handlePanelSelect","bind","handleKeyDown","handleDocumentKeyDown","handleDocumentMouseDown","containingElement","firstUpdated","panel","hidden","addOpenListeners","popup","active","disconnectedCallback","removeOpenListeners","hide","focusOnTrigger","trigger","assignedElements","flatten","focus","getMenu","find","el","tagName","toLowerCase","event","stopPropagation","_document$activeEleme","document","activeElement","preventDefault","setTimeout","getRootNode","ShadowRoot","shadowRoot","closest","path","composedPath","includes","target","handleTriggerClick","show","handleTriggerKeyDown","menu","menuItems","getAllItems","firstMenuItem","lastMenuItem","length","updateComplete","then","setCurrentItem","handleTriggerKeyUp","handleTriggerSlotChange","updateAccessibleTrigger","accessibleTrigger","getTabbableBoundary","start","button","setAttribute","_show","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_callee$","_context2","prev","next","waitForEvent","stop","apply","arguments","_hide","_callee2","_callee2$","_context3","abrupt","reposition","addEventListener","removeEventListener","_handleOpenChange","_callee3","_d","_t","_i","_d2","_t2","_i2","_callee3$","_context4","emit","stopAnimations","getAnimation","dir","animateTo","keyframes","options","handleOpenChange","render","html","_templateObject","_taggedTemplateLiteral","classMap","dropdown","NileElement","styles","__decorate","query","prototype","property","type","Boolean","reflect","attribute","Number","watch","waitUntilFirstUpdate","customElement","setDefaultAnimation","opacity","scale","duration","easing"],"mappings":"wqaAgDaA,CAAAA,uBAAAA,EAAAA,EAAAA,SAAAA,CAAAA,CAAAA,CAAAA,EAAAA,MAAAA,MAAAA,CAAAA,YAAAA,CAAAA,CAAAA,EAAN,SAAAC,EAAA,qEAYuCC,EAAAA,KAAAA,CAAIC,IAAG,CAAA,CAAA,CAAA,CAMtBD,KAAAA,CAASE,SAYrB,CAAA,cAAA,CAG2BF,KAAAA,CAAQG,QAAAA,CAAAA,CAAG,CAMuBH,CAAAA,KAAAA,CAAgBI,gBAAG,CAAA,CAAA,CAAA,CASrEJ,KAAAA,CAAQK,QAAG,CAAA,CAAA,CAGVL,KAAAA,CAAaM,aAAAA,CAAAA,CAAG,CAGjBN,CAAAA,KAAAA,CAAQO,QAAG,CAAA,CAAA,CAMVP,KAAAA,CAAKQ,KAAG,CAAA,CAAA,CAwUtC,QAAAC,KAAA,EAtUCC,YAAA,CAAAX,CAAA,GAAAY,GAAA,qBAAAC,KAAA,UAAAC,kBAAA,EACEC,IAAAA,CAAAA,eAAAA,CAAAA,CAAAA,CAAAA,SAAAA,4BAAAA,IAAAA,OACAd,IAAKe,CAAAA,iBAAAA,CAAoBf,KAAKe,iBAAkBC,CAAAA,IAAAA,CAAKhB,IACrDA,CAAAA,CAAAA,IAAAA,CAAKiB,aAAgBjB,CAAAA,IAAAA,CAAKiB,aAAcD,CAAAA,IAAAA,CAAKhB,MAC7CA,IAAKkB,CAAAA,qBAAAA,CAAwBlB,IAAKkB,CAAAA,qBAAAA,CAAsBF,IAAKhB,CAAAA,IAAAA,CAAAA,CAC7DA,IAAKmB,CAAAA,uBAAAA,CAA0BnB,KAAKmB,uBAAwBH,CAAAA,IAAAA,CAAKhB,IAE5DA,CAAAA,CAAAA,IAAAA,CAAKoB,iBACRpB,GAAAA,IAAAA,CAAKoB,iBAAoBpB,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AS,CAAA,CAAEC,KAAMC,OAAiClI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA+H,UAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAGvBF,EAAA,CAA3BG,CAAAA,CAAS,CAAEC,IAAMI,CAAAA,MAAAA,CAAAA,CAAAA,CAAAA,CAAuBrI,EAAA+H,SAAA,CAAA,UAAA,CAAA,IAAA,IAMZF,CAAA,CAAA,CAA5BG,EAAS,CAAEC,IAAAA,CAAMC,WAAyBlI,CAAA+H,CAAAA,SAAAA,CAAA,YAAA,EA+PrCF,CAAAA,CAAAA,CAAAA,CAAA,CADLS,CAAM,CAAA,MAAA,CAAQ,CAAEC,oBAAsB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAkCtCvI,EAAA+H,SAAA,CAAA,kBAAA,CAAA,kBA5VU/H,CAAY6H,CAAAA,CAAAA,CAAA,CADxBW,CAAAA,CAAc,kBACFxI,CAsYbyI,CAAAA,EAAAA,CAAAA,CAAoB,gBAAiB,CACnCvB,SAAAA,CAAW,CACT,CAAEwB,OAAAA,CAAS,EAAGC,KAAO,CAAA,EAAA,CAAA,CACrB,CAAED,OAAS,CAAA,CAAA,CAAGC,MAAO,CAEvBxB,CAAAA,CAAAA,CAAAA,OAAAA,CAAS,CAAEyB,QAAU,CAAA,GAAA,CAAKC,OAAQ,MAGpCJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAoB,gBAAiB,CACnCvB,SAAAA,CAAW,CACT,CAAEwB,OAAAA,CAAS,EAAGC,KAAO,CAAA,CAAA,CAAA,CACrB,CAAED,OAAS,CAAA,CAAA,CAAGC,MAAO,EAEvBxB,CAAAA,CAAAA,CAAAA,OAAAA,CAAS,CAAEyB,QAAU,CAAA,GAAA,CAAKC,OAAQ"}
|
1
|
+
{"version":3,"file":"nile-dropdown.cjs.js","sources":["../../../src/nile-dropdown/nile-dropdown.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {LitElement, html, property, CSSResultArray, TemplateResult} from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport {styles} from './nile-dropdown.css';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { query } from 'lit/decorators.js';\nimport { getAnimation, setDefaultAnimation } from '../utilities/animation-registry';\nimport { getTabbableBoundary } from '../internal/tabbable';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup } from 'lit';\nimport type NileButton from '../nile-button/nile-button';\nimport type NileIconButton from '../nile-icon-button/nile-icon-button';\nimport type { NileMenu } from '../nile-menu';\nimport type { NilePopup } from '../nile-popup';\nimport '../nile-popup';\n\n/**\n * Nile icon component.\n *\n * @tag nile-dropdown\n * @summary Dropdowns expose additional content that \"drops down\" in a panel.\n * @dependency nile-popup\n *\n * @slot - The dropdown's main content.\n * @slot trigger - The dropdown's trigger, usually a `<nile-button>` element.\n *\n * @event nile-show - Emitted when the dropdown opens.\n * @event nile-after-show - Emitted after the dropdown opens and all animations are complete.\n * @event nile-hide - Emitted when the dropdown closes.\n * @event nile-after-hide - Emitted after the dropdown closes and all animations are complete.\n *\n * @csspart base - The component's base wrapper.\n * @csspart trigger - The container that wraps the trigger.\n * @csspart panel - The panel that gets shown when the dropdown is open.\n *\n * @animation dropdown.show - The animation to use when showing the dropdown.\n * @animation dropdown.hide - The animation to use when hiding the dropdown.\n */\n@customElement('nile-dropdown')\nexport class NileDropdown extends NileElement {\n static styles: CSSResultGroup = styles;\n\n @query('.dropdown') popup: NilePopup;\n @query('.dropdown__trigger') trigger: HTMLSlotElement;\n @query('.dropdown__panel') panel: HTMLSlotElement;\n\n\n /**\n * Indicates whether or not the dropdown is open. You can toggle this attribute to show and hide the dropdown, or you\n * can use the `show()` and `hide()` methods and this attribute will reflect the dropdown's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel\n * inside of the viewport.\n */\n @property({ reflect: true }) placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'bottom-start';\n\n /** Disables the dropdown so the panel will not open. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * By default, the dropdown is closed when an item is selected. This attribute will keep it open instead. Useful for\n * dropdowns that allow for multiple interactions.\n */\n @property({ attribute: 'stay-open-on-select', type: Boolean, reflect: true }) stayOpenOnSelect = false;\n\n /**\n * The dropdown will close when the user interacts outside of this element (e.g. clicking). Useful for composing other\n * components that use a dropdown internally.\n */\n @property({ attribute: false }) containingElement?: HTMLElement;\n\n /** The distance in pixels from which to offset the panel away from its trigger. */\n @property({ type: Number }) distance = 0;\n\n\n @property({ type: Boolean }) noOpenOnClick = false;\n\n /** The distance in pixels from which to offset the panel along its trigger. */\n @property({ type: Number }) skidding = 0;\n\n /**\n * Enable this option to prevent the panel from being clipped when the component is placed inside a container with\n * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.\n */\n @property({ type: Boolean }) hoist = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handlePanelSelect = this.handlePanelSelect.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);\n\n if (!this.containingElement) {\n this.containingElement = this;\n }\n this.emit('nile-init');\n }\n\n firstUpdated() {\n this.panel.hidden = !this.open;\n\n // If the dropdown is visible on init, update its position\n if (this.open) {\n this.addOpenListeners();\n this.popup.active = true;\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeOpenListeners();\n this.hide();\n this.emit('nile-destroy');\n }\n\n focusOnTrigger() {\n const trigger = this.trigger.assignedElements({ flatten: true })[0] as HTMLElement | undefined;\n if (typeof trigger?.focus === 'function') {\n trigger.focus();\n }\n }\n\n getMenu() {\n return this.panel.assignedElements({ flatten: true }).find(el => el.tagName.toLowerCase() === 'nile-menu') as\n | NileMenu\n | undefined;\n }\n\n handleKeyDown(event: KeyboardEvent) {\n // Close when escape is pressed inside an open dropdown. We need to listen on the panel itself and stop propagation\n // in case any ancestors are also listening for this key.\n if (this.open && event.key === 'Escape') {\n event.stopPropagation();\n this.hide();\n this.focusOnTrigger();\n }\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n // Close when escape or tab is pressed\n if (event.key === 'Escape' && this.open) {\n event.stopPropagation();\n this.focusOnTrigger();\n this.hide();\n return;\n }\n\n // Handle tabbing\n if (event.key === 'Tab') {\n // Tabbing within an open menu should close the dropdown and refocus the trigger\n if (this.open && document.activeElement?.tagName.toLowerCase() === 'nile-menu-item') {\n event.preventDefault();\n this.hide();\n this.focusOnTrigger();\n return;\n }\n\n // Tabbing outside of the containing element closes the panel\n //\n // If the dropdown is used within a shadow DOM, we need to obtain the activeElement within that shadowRoot,\n // otherwise `document.activeElement` will only return the name of the parent shadow DOM element.\n setTimeout(() => {\n const activeElement =\n this.containingElement?.getRootNode() instanceof ShadowRoot\n ? document.activeElement?.shadowRoot?.activeElement\n : document.activeElement;\n\n if (\n !this.containingElement ||\n activeElement?.closest(this.containingElement.tagName.toLowerCase()) !== this.containingElement\n ) {\n this.hide();\n }\n });\n }\n }\n\n handleDocumentMouseDown(event: MouseEvent) {\n // Close when clicking outside of the containing element\n const path = event.composedPath();\n if (this.containingElement && !path.includes(this.containingElement)) {\n this.hide();\n }\n }\n\n handlePanelSelect(event: any) {\n const target = event.target as HTMLElement;\n\n // Hide the dropdown when a menu item is selected\n if (!this.stayOpenOnSelect && target.tagName.toLowerCase() === 'nile-menu') {\n this.hide();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerClick() {\n if(this.noOpenOnClick){\n return;\n }\n if (this.open) {\n this.hide();\n } else {\n this.show();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerKeyDown(event: KeyboardEvent) {\n // When spacebar/enter is pressed, show the panel but don't focus on the menu. This let's the user press the same\n // key again to hide the menu in case they don't want to make a selection.\n // if (['Enter'].includes(event.key)) {\n // event.preventDefault();\n // this.handleTriggerClick();\n // return;\n // }\n\n const menu = this.getMenu();\n\n if (menu) {\n const menuItems = menu.getAllItems();\n const firstMenuItem = menuItems[0];\n const lastMenuItem = menuItems[menuItems.length - 1];\n\n // When up/down is pressed, we make the assumption that the user is familiar with the menu and plans to make a\n // selection. Rather than toggle the panel, we focus on the menu (if one exists) and activate the first item for\n // faster navigation.\n if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {\n event.preventDefault();\n\n // Show the menu if it's not already open\n if (!this.open) {\n this.show();\n }\n\n if (menuItems.length > 0) {\n // Focus on the first/last menu item after showing\n this.updateComplete.then(() => {\n if (event.key === 'ArrowDown' || event.key === 'Home') {\n menu.setCurrentItem(firstMenuItem);\n firstMenuItem.focus();\n }\n\n if (event.key === 'ArrowUp' || event.key === 'End') {\n menu.setCurrentItem(lastMenuItem);\n lastMenuItem.focus();\n }\n });\n }\n }\n }\n }\n\n handleTriggerKeyUp(event: KeyboardEvent) {\n // Prevent space from triggering a click event in Firefox\n if (event.key === ' ') {\n event.preventDefault();\n }\n }\n\n handleTriggerSlotChange() {\n this.updateAccessibleTrigger();\n }\n\n //\n // Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and\n // `aria-expanded`. These must be applied to the \"accessible trigger\" (the tabbable portion of the trigger element\n // that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,\n // a child of the slotted element, or an element in the slotted element's shadow root.\n //\n // For example, the accessible trigger of an <nile-button> is a <button> located inside its shadow root.\n //\n // To determine this, we assume the first tabbable element in the trigger slot is the \"accessible trigger.\"\n //\n updateAccessibleTrigger() {\n const assignedElements = this.trigger.assignedElements({ flatten: true }) as HTMLElement[];\n const accessibleTrigger = assignedElements.find(el => getTabbableBoundary(el).start);\n let target: HTMLElement;\n\n if (accessibleTrigger) {\n switch (accessibleTrigger.tagName.toLowerCase()) {\n // nile buttons have to update the internal button so it's announced correctly by screen readers\n case 'nile-button':\n case 'nile-icon-button':\n target = (accessibleTrigger as NileButton | NileIconButton).button;\n break;\n\n default:\n target = accessibleTrigger;\n }\n\n target.setAttribute('aria-haspopup', 'true');\n target.setAttribute('aria-expanded', this.open ? 'true' : 'false');\n }\n }\n\n /** Shows the dropdown panel. */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'nile-after-show');\n }\n\n /** Hides the dropdown panel */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'nile-after-hide');\n }\n\n /**\n * Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu\n * is activated.\n */\n reposition() {\n this.popup.reposition();\n }\n\n addOpenListeners() {\n this.panel.addEventListener('nile-select', this.handlePanelSelect);\n this.panel.addEventListener('keydown', this.handleKeyDown);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n document.addEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n removeOpenListeners() {\n if (this.panel) {\n this.panel.removeEventListener('nile-select', this.handlePanelSelect);\n this.panel.removeEventListener('keydown', this.handleKeyDown);\n }\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n document.removeEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.disabled) {\n this.open = false;\n return;\n }\n\n this.updateAccessibleTrigger();\n\n if (this.open) {\n // Show\n this.emit('nile-show');\n this.addOpenListeners();\n\n await stopAnimations(this);\n this.panel.hidden = false;\n this.popup.active = true;\n const { keyframes, options } = getAnimation(this, 'dropdown.show', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n\n this.emit('nile-after-show');\n } else {\n // Hide\n this.emit('nile-hide');\n this.removeOpenListeners();\n\n await stopAnimations(this);\n const { keyframes, options } = getAnimation(this, 'dropdown.hide', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n this.panel.hidden = true;\n this.popup.active = false;\n\n this.emit('nile-after-hide');\n }\n }\n\n render() {\n return html`\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=${this.placement}\n distance=${this.distance}\n skidding=${this.skidding}\n strategy=${this.hoist ? 'fixed' : 'absolute'}\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=${classMap({\n dropdown: true,\n 'dropdown--open': this.open\n })}\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=${this.handleTriggerClick}\n @keydown=${this.handleTriggerKeyDown}\n @keyup=${this.handleTriggerKeyUp}\n @slotchange=${this.handleTriggerSlotChange}\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=${this.open ? 'false' : 'true'}\n aria-labelledby=\"dropdown\"\n ></slot>\n </nile-popup>\n `;\n }\n}\n\nsetDefaultAnimation('dropdown.show', {\n keyframes: [\n { opacity: 0, scale: 0.9 },\n { opacity: 1, scale: 1 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nsetDefaultAnimation('dropdown.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.9 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nexport default NileDropdown;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-dropdown': NileDropdown;\n }\n}\n"],"names":["NileDropdown","_m","_inherits","w","_super","_createSuper","constructor","this","open","placement","disabled","stayOpenOnSelect","distance","noOpenOnClick","skidding","hoist","_this","_createClass","key","value","connectedCallback","super","handlePanelSelect","bind","handleKeyDown","handleDocumentKeyDown","handleDocumentMouseDown","containingElement","emit","firstUpdated","panel","hidden","addOpenListeners","popup","active","disconnectedCallback","removeOpenListeners","hide","focusOnTrigger","trigger","assignedElements","flatten","focus","getMenu","find","el","tagName","toLowerCase","event","stopPropagation","_this2","_document$activeEleme","document","activeElement","preventDefault","setTimeout","_this2$containingElem","_document$activeEleme2","getRootNode","ShadowRoot","shadowRoot","closest","path","composedPath","includes","target","handleTriggerClick","show","handleTriggerKeyDown","menu","menuItems","getAllItems","firstMenuItem","lastMenuItem","length","updateComplete","then","setCurrentItem","handleTriggerKeyUp","handleTriggerSlotChange","updateAccessibleTrigger","accessibleTrigger","getTabbableBoundary","start","button","setAttribute","_show","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_callee$","_context2","prev","next","abrupt","waitForEvent","stop","apply","arguments","_hide","_callee2","_callee2$","_context3","reposition","addEventListener","removeEventListener","_handleOpenChange","_callee3","_d","_t","_i","_d2","_t2","_i2","_callee3$","_context4","stopAnimations","getAnimation","dir","keyframes","options","animateTo","handleOpenChange","render","html","_templateObject","_taggedTemplateLiteral","classMap","dropdown","NileElement","styles","__decorate","query","prototype","property","type","Boolean","reflect","attribute","Number","watch","waitUntilFirstUpdate","customElement","setDefaultAnimation","opacity","scale","duration","easing"],"mappings":"wqaAgDaA,CAAN,uBAAAC,EAAA,EAAAC,SAAA,CAAAC,CAAA,CAAAF,EAAA,MAAAG,MAAA,CAAAC,YAAA,CAAAF,CAAA,EAAA,SAAAA,EAAA,CAAAG,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,qCAYuCC,KAAAA,CAAIC,IAAAA,CAAAA,CAAG,CAMtBD,CAAAA,KAAAA,CAASE,UAYrB,cAG2BF,CAAAA,KAAAA,CAAQG,QAAG,CAAA,CAAA,CAAA,CAMuBH,KAAAA,CAAgBI,gBAAAA,CAAAA,CAAG,CASrEJ,CAAAA,KAAAA,CAAQK,SAAG,CAGVL,CAAAA,KAAAA,CAAaM,aAAG,CAAA,CAAA,CAAA,CAGjBN,KAAAA,CAAQO,QAAAA,CAAG,CAM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AAoB,gBAAiB,CACnCxB,SAAAA,CAAW,CACT,CAAEyB,OAAAA,CAAS,EAAGC,KAAO,CAAA,EAAA,CAAA,CACrB,CAAED,OAAS,CAAA,CAAA,CAAGC,MAAO,CAEvBzB,CAAAA,CAAAA,CAAAA,OAAAA,CAAS,CAAE0B,QAAU,CAAA,GAAA,CAAKC,OAAQ,MAGpCJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAoB,gBAAiB,CACnCxB,SAAAA,CAAW,CACT,CAAEyB,OAAAA,CAAS,EAAGC,KAAO,CAAA,CAAA,CAAA,CACrB,CAAED,OAAS,CAAA,CAAA,CAAGC,MAAO,EAEvBzB,CAAAA,CAAAA,CAAAA,OAAAA,CAAS,CAAE0B,QAAU,CAAA,GAAA,CAAKC,OAAQ"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{__decorate as t}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";import{query as e,customElement as s}from"lit/decorators.js";import{s as o}from"./nile-dropdown.css.esm.js";import{s as n,a as h}from"../internal/animate.esm.js";import{classMap as r}from"lit/directives/class-map.js";import{s as a,g as d}from"../utilities/animation-registry.esm.js";import{g as l}from"../internal/tabbable.esm.js";import{w as p}from"../internal/event.esm.js";import{w as c}from"../internal/watch.esm.js";import{N as m}from"../internal/nile-element.esm.js";import"../nile-popup/nile-popup.esm.js";import{n as u}from"../property-09139d3c.esm.js";import"lit";import"../nile-popup/nile-popup.css.esm.js";let w=class extends m{constructor(){super(...arguments),this.open=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.noOpenOnClick=!1,this.skidding=0,this.hoist=!1}connectedCallback(){super.connectedCallback(),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this)}firstUpdated(){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0)}disconnectedCallback(){super.disconnectedCallback(),this.removeOpenListeners(),this.hide()}focusOnTrigger(){const t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof t?.focus&&t.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((t=>"nile-menu"===t.tagName.toLowerCase()))}handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(t){if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){if(this.open&&"nile-menu-item"===document.activeElement?.tagName.toLowerCase())return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{const t=this.containingElement?.getRootNode()instanceof ShadowRoot?document.activeElement?.shadowRoot?.activeElement:document.activeElement;this.containingElement&&t?.closest(this.containingElement.tagName.toLowerCase())===this.containingElement||this.hide()}))}}handleDocumentMouseDown(t){const i=t.composedPath();this.containingElement&&!i.includes(this.containingElement)&&this.hide()}handlePanelSelect(t){const i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()||(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()))}handleTriggerKeyDown(t){const i=this.getMenu();if(i){const e=i.getAllItems(),s=e[0],o=e[e.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),e.length>0&&this.updateComplete.then((()=>{"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(s),s.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(o),o.focus())})))}}handleTriggerKeyUp(t){" "===t.key&&t.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const t=this.trigger.assignedElements({flatten:!0}).find((t=>l(t).start));let i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false")}}async show(){if(!this.open)return this.open=!0,p(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,p(this,"nile-after-hide")}reposition(){this.popup.reposition()}addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}async handleOpenChange(){if(this.disabled)this.open=!1;else if(this.updateAccessibleTrigger(),this.open){this.emit("nile-show"),this.addOpenListeners(),await n(this),this.panel.hidden=!1,this.popup.active=!0;const{keyframes:t,options:i}=d(this,"dropdown.show",{dir:""});await h(this.popup.popup,t,i),this.emit("nile-after-show")}else{this.emit("nile-hide"),this.removeOpenListeners(),await n(this);const{keyframes:t,options:i}=d(this,"dropdown.hide",{dir:""});await h(this.popup.popup,t,i),this.panel.hidden=!0,this.popup.active=!1,this.emit("nile-after-hide")}}render(){return i`
|
1
|
+
import{__decorate as t}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";import{query as e,customElement as s}from"lit/decorators.js";import{s as o}from"./nile-dropdown.css.esm.js";import{s as n,a as h}from"../internal/animate.esm.js";import{classMap as r}from"lit/directives/class-map.js";import{s as a,g as d}from"../utilities/animation-registry.esm.js";import{g as l}from"../internal/tabbable.esm.js";import{w as p}from"../internal/event.esm.js";import{w as c}from"../internal/watch.esm.js";import{N as m}from"../internal/nile-element.esm.js";import"../nile-popup/nile-popup.esm.js";import{n as u}from"../property-09139d3c.esm.js";import"lit";import"../nile-popup/nile-popup.css.esm.js";let w=class extends m{constructor(){super(...arguments),this.open=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.noOpenOnClick=!1,this.skidding=0,this.hoist=!1}connectedCallback(){super.connectedCallback(),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init")}firstUpdated(){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0)}disconnectedCallback(){super.disconnectedCallback(),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy")}focusOnTrigger(){const t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof t?.focus&&t.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((t=>"nile-menu"===t.tagName.toLowerCase()))}handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(t){if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){if(this.open&&"nile-menu-item"===document.activeElement?.tagName.toLowerCase())return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{const t=this.containingElement?.getRootNode()instanceof ShadowRoot?document.activeElement?.shadowRoot?.activeElement:document.activeElement;this.containingElement&&t?.closest(this.containingElement.tagName.toLowerCase())===this.containingElement||this.hide()}))}}handleDocumentMouseDown(t){const i=t.composedPath();this.containingElement&&!i.includes(this.containingElement)&&this.hide()}handlePanelSelect(t){const i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()||(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()))}handleTriggerKeyDown(t){const i=this.getMenu();if(i){const e=i.getAllItems(),s=e[0],o=e[e.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),e.length>0&&this.updateComplete.then((()=>{"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(s),s.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(o),o.focus())})))}}handleTriggerKeyUp(t){" "===t.key&&t.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const t=this.trigger.assignedElements({flatten:!0}).find((t=>l(t).start));let i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false")}}async show(){if(!this.open)return this.open=!0,p(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,p(this,"nile-after-hide")}reposition(){this.popup.reposition()}addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}async handleOpenChange(){if(this.disabled)this.open=!1;else if(this.updateAccessibleTrigger(),this.open){this.emit("nile-show"),this.addOpenListeners(),await n(this),this.panel.hidden=!1,this.popup.active=!0;const{keyframes:t,options:i}=d(this,"dropdown.show",{dir:""});await h(this.popup.popup,t,i),this.emit("nile-after-show")}else{this.emit("nile-hide"),this.removeOpenListeners(),await n(this);const{keyframes:t,options:i}=d(this,"dropdown.hide",{dir:""});await h(this.popup.popup,t,i),this.panel.hidden=!0,this.popup.active=!1,this.emit("nile-after-hide")}}render(){return i`
|
2
2
|
<nile-popup
|
3
3
|
part="base"
|
4
4
|
id="dropdown"
|