@cscfi/csc-ui 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/c-autocomplete.cjs.entry.js +15 -23
- package/dist/cjs/c-autocomplete.cjs.entry.js.map +1 -1
- package/dist/cjs/c-checkbox_2.cjs.entry.js +0 -1
- package/dist/cjs/c-checkbox_2.cjs.entry.js.map +1 -1
- package/dist/cjs/{c-dropdown_4.cjs.entry.js → c-dropdown_2.cjs.entry.js} +70 -205
- package/dist/cjs/c-dropdown_2.cjs.entry.js.map +1 -0
- package/dist/cjs/c-message.cjs.entry.js +67 -0
- package/dist/cjs/c-message.cjs.entry.js.map +1 -0
- package/dist/cjs/c-select.cjs.entry.js +12 -18
- package/dist/cjs/c-select.cjs.entry.js.map +1 -1
- package/dist/cjs/csc-ui.cjs.js +1 -1
- package/dist/cjs/index-3cad12b5.js +6 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +0 -1
- package/dist/collection/components/c-autocomplete/c-autocomplete.js +15 -23
- package/dist/collection/components/c-autocomplete/c-autocomplete.js.map +1 -1
- package/dist/collection/components/c-checkbox/c-checkbox.js +0 -1
- package/dist/collection/components/c-checkbox/c-checkbox.js.map +1 -1
- package/dist/collection/components/c-dropdown/c-dropdown.css +15 -16
- package/dist/collection/components/c-dropdown/c-dropdown.js +109 -65
- package/dist/collection/components/c-dropdown/c-dropdown.js.map +1 -1
- package/dist/collection/components/c-input/c-input.css +1 -0
- package/dist/collection/components/c-input/c-input.js +26 -214
- package/dist/collection/components/c-input/c-input.js.map +1 -1
- package/dist/collection/components/c-select/c-select.js +12 -18
- package/dist/collection/components/c-select/c-select.js.map +1 -1
- package/dist/components/c-autocomplete.js +17 -31
- package/dist/components/c-autocomplete.js.map +1 -1
- package/dist/components/c-checkbox2.js +0 -1
- package/dist/components/c-checkbox2.js.map +1 -1
- package/dist/components/c-dropdown2.js +67 -44
- package/dist/components/c-dropdown2.js.map +1 -1
- package/dist/components/c-input2.js +9 -104
- package/dist/components/c-input2.js.map +1 -1
- package/dist/components/c-select.js +14 -26
- package/dist/components/c-select.js.map +1 -1
- package/dist/components/c-text-field.js +1 -19
- package/dist/components/c-text-field.js.map +1 -1
- package/dist/csc-ui/csc-ui.esm.js +1 -1
- package/dist/csc-ui/csc-ui.esm.js.map +1 -1
- package/dist/csc-ui/{p-d94b9e92.entry.js → p-2ff8e8e2.entry.js} +2 -2
- package/dist/csc-ui/p-2ff8e8e2.entry.js.map +1 -0
- package/dist/csc-ui/p-32298609.entry.js +2 -0
- package/dist/csc-ui/p-32298609.entry.js.map +1 -0
- package/dist/csc-ui/p-50db6941.entry.js +2 -0
- package/dist/csc-ui/p-50db6941.entry.js.map +1 -0
- package/dist/csc-ui/{p-ae28ae3f.entry.js → p-7575c2c3.entry.js} +2 -2
- package/dist/csc-ui/p-7575c2c3.entry.js.map +1 -0
- package/dist/csc-ui/p-bf307cb4.entry.js +2 -0
- package/dist/csc-ui/p-bf307cb4.entry.js.map +1 -0
- package/dist/esm/c-autocomplete.entry.js +15 -23
- package/dist/esm/c-autocomplete.entry.js.map +1 -1
- package/dist/esm/c-checkbox_2.entry.js +0 -1
- package/dist/esm/c-checkbox_2.entry.js.map +1 -1
- package/dist/esm/{c-dropdown_4.entry.js → c-dropdown_2.entry.js} +72 -205
- package/dist/esm/c-dropdown_2.entry.js.map +1 -0
- package/dist/esm/c-message.entry.js +63 -0
- package/dist/esm/c-message.entry.js.map +1 -0
- package/dist/esm/c-select.entry.js +12 -18
- package/dist/esm/c-select.entry.js.map +1 -1
- package/dist/esm/csc-ui.js +1 -1
- package/dist/esm/index-cdf029b7.js +6 -2
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/c-autocomplete/c-autocomplete.d.ts +2 -2
- package/dist/types/components/c-dropdown/c-dropdown.d.ts +7 -5
- package/dist/types/components/c-input/c-input.d.ts +2 -15
- package/dist/types/components/c-select/c-select.d.ts +2 -2
- package/dist/types/components.d.ts +17 -56
- package/package.json +1 -1
- package/vscode-data.json +0 -8
- package/dist/cjs/c-dropdown_4.cjs.entry.js.map +0 -1
- package/dist/collection/components/c-dropdowns/c-dropdowns.css +0 -25
- package/dist/collection/components/c-dropdowns/c-dropdowns.js +0 -66
- package/dist/collection/components/c-dropdowns/c-dropdowns.js.map +0 -1
- package/dist/components/c-dropdowns.d.ts +0 -11
- package/dist/components/c-dropdowns.js +0 -8
- package/dist/components/c-dropdowns.js.map +0 -1
- package/dist/components/c-dropdowns2.js +0 -60
- package/dist/components/c-dropdowns2.js.map +0 -1
- package/dist/csc-ui/p-0a423333.entry.js +0 -2
- package/dist/csc-ui/p-0a423333.entry.js.map +0 -1
- package/dist/csc-ui/p-79b90c60.entry.js +0 -2
- package/dist/csc-ui/p-79b90c60.entry.js.map +0 -1
- package/dist/csc-ui/p-ae28ae3f.entry.js.map +0 -1
- package/dist/csc-ui/p-d94b9e92.entry.js.map +0 -1
- package/dist/esm/c-dropdown_4.entry.js.map +0 -1
- package/dist/types/components/c-dropdowns/c-dropdowns.d.ts +0 -29
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cDropdownCss","CDropdown","this","_id","_debounce","_itemRefs","_lastKeyPressTime","_openedOnTop","_searchString","_observer","IntersectionObserver","entries","observer","forEach","entry","isIntersecting","target","scrollIntoView","block","inline","unobserve","threshold","_renderMenuItem","item","index","isActive","_a","items","currentIndex","value","itemId","replace","inputId","parent","setActiveDescendant","listItem","document","createElement","role","ariaPosInSet","toString","ariaSetSize","length","ariaSelected","id","dataset","name","setAttribute","classList","toggle","disabled","addEventListener","event","isDisabled","contains","preventDefault","_onSelect","add","remove","push","Object","keys","options","requestAnimationFrame","option","query","type","optionValue","querySelector","innerHTML","_highlightMatchingText","textContent","appendChild","_listElement","span","onItemsChange","_updateMenuItems","onOptionsChange","updateDropdown","params","_updateStatusText","focusDropdown","focus","open","focusList","_onOpen","_createEventListeners","_outsideClickFn","_handleOutsideClick","bind","_handleCurrentIndexChange","_positionMenu","window","close","_onClose","removeEventListener","focusItem","onCurrentIndexChange","_listSize","_firstSelectableIndex","findIndex","_lastSelectableIndex","findLastIndex","regex","RegExp","highlighted","match","_renderEmptyItem","emptyElement","tabIndex","icon","path","mdiAlert","size","color","append","replaceChildren","map","_renderMenu","dialogElement","listElement","ariaExpanded","isVisible","_dialogElement","host","shadowRoot","_onKeyboardNavigation","_onKeyDown","isOpen","showModal","focusInput","onHideMenu","onItemSelection","i","_getParentPosition","getBoundingClientRect","innerWidth","innerHeight","bottom","parentBottom","left","parentLeft","width","parentWidth","top","parentTop","style","removeProperty","right","height","isInView","x","y","fitsOnTop","maxHeight","topPosition","parseFloat","async","_scrollToElement","itemsPerPage","itemRef","observe","stopPropagation","wasClicked","letterNumber","key","updatedQuery","slice","updateQuery","Date","now","selectedItem","find","toLowerCase","startsWith","element","_b","composedPath","includes","clearTimeout","setTimeout","selection","ending","beginning","selectionText","statusText","componentDidLoad","_resizeObserver","ResizeObserver","body","disconnectedCallback","disconnect","render","h","Host","class","cInputCss","CInput","_hasBlurred","_calculateElementWidths","_onBlur","isFocused","_onReset","_onFocus","click","inputField","variant","itemClick","emit","placeholder","onValidChange","validateOnBlur","_setAriaDescriptionId","onValidationMessageChange","onValueChange","onPlaceholderChange","autofocus","label","_labelRef","_c","_preventNonNumericalInput","title","_d","container","closest","_dropdownElement","removeAttribute","valid","hint","labelWidth","scrollWidth","preSlotWidth","offsetLeft","_renderBorders","shadow","classes","active","_renderLabel","htmlFor","ref","el","required","validation","containerClasses","rows","filled","onClick","hideDetails"],"sources":["src/components/c-dropdown/c-dropdown.scss?tag=c-dropdown&encapsulation=shadow","src/components/c-dropdown/c-dropdown.tsx","src/components/c-input/c-input.scss?tag=c-input","src/components/c-input/c-input.tsx"],"sourcesContent":[":host(c-dropdown) {\n /**\n * @prop --c-dropdown-background-color: Menu background color\n * @prop --c-dropdown-background-color-hover: Menu item hover background color\n * @prop --c-dropdown-text-color: Menu item text color\n * @prop --c-dropdown-text-color-active: Active menu item text color\n */\n --_c-dropdown-background-color: var(--c-dropdown-background-color, var(--c-white));\n --_c-dropdown-background-color-hover: var(--c-dropdown-background-color-hover, var(--c-primary-200));\n --_c-dropdown-text-color: var(--c-dropdown-text-color, var(--c-text-body));\n --_c-dropdown-text-color-active: var(--c-dropdown-text-color-active, var(--c-primary-600));\n\n // private\n --_c-dropdown-font-size: 14px;\n --_c-dropdown-height: 42px;\n\n display: block;\n position: absolute;\n\n mark {\n background-color: transparent;\n box-shadow: 0 2px 0 0 var(--_c-dropdown-text-color-active);\n color: inherit;\n }\n\n dialog {\n background-color: transparent;\n border-radius: 4px;\n border: none;\n box-shadow: 2px 4px 10px #00000029;\n margin: 0;\n overflow-y: scroll;\n padding: 0;\n position: fixed;\n\n &::backdrop {\n display: none;\n }\n }\n\n ul {\n background-color: var(--_c-dropdown-background-color);\n border-radius: 4px;\n list-style: none;\n margin: 0;\n outline: none;\n padding: 0;\n pointer-events: auto;\n visibility: hidden;\n width: 100%;\n\n &.active {\n visibility: visible;\n animation: 0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);\n }\n }\n\n li {\n align-items: center;\n column-gap: 12px;\n cursor: pointer;\n display: flex;\n flex-wrap: nowrap;\n font-size: var(--_c-dropdown-font-size);\n min-height: var(--_c-dropdown-height);\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n pointer-events: auto;\n white-space: nowrap;\n width: 100%;\n border-radius: 4px;\n \n span,\n c-option-value {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n }\n\n &:not(.disabled):hover,\n &.active {\n background: var(--_c-dropdown-background-color-hover);\n color: var(--_c-dropdown-text-color-active);\n box-shadow: inset 0 0 0 1px var(--_c-dropdown-text-color-active);\n }\n\n &.disabled {\n background-color: rgba(var(--c-tertiary-rgb), 0.05);\n cursor: default;\n filter: grayscale(1) opacity(0.75);\n }\n }\n\n .visuallyhidden {\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n }\n\n @keyframes fade-in {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n}\n","import {\n Component,\n Element,\n Host,\n Method,\n Prop,\n State,\n Watch,\n h,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\nimport { mdiAlert } from '@mdi/js';\n\nexport type _CDropdownUpdateParams = {\n items?: CSelectItem[] | CAutocompleteItem[];\n options?: Record<string, HTMLCOptionElement>;\n};\n\n@Component({\n tag: 'c-dropdown',\n styleUrl: 'c-dropdown.scss',\n shadow: true,\n})\nexport class CDropdown {\n @Element() host: HTMLCDropdownElement;\n\n /**\n * Dropdown items\n */\n @Prop() items: CSelectItem[] | CAutocompleteItem[] = [];\n\n @Watch('items')\n onItemsChange() {\n if (!this.items.length) return;\n\n this._updateMenuItems();\n }\n\n /**\n * Dropdown options\n */\n @Prop() options: Record<string, HTMLCOptionElement>;\n\n @Watch('options')\n onOptionsChange() {\n if (!Object.keys(this.options).length) return;\n\n this._updateMenuItems();\n }\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * Dropdown parent\n */\n @Prop() parent: HTMLCSelectElement | HTMLCAutocompleteElement;\n\n /**\n * Initial value index\n */\n @Prop() index: number;\n\n /**\n * Dropdown open state\n */\n @Prop() isOpen = false;\n\n /**\n * Focus dropdown on open\n */\n @Prop() focusList: boolean;\n\n /**\n * Id of the input element\n */\n @Prop() inputId: string;\n\n /**\n * Type of the parent element\n */\n @Prop() type: 'select' | 'autocomplete';\n\n /**\n * @private\n */\n @Prop() wasClicked = false;\n\n @State() currentIndex: number = null;\n\n @State() isVisible = false;\n\n @State() topPosition: number;\n\n @State() statusText = '';\n\n private _id = '';\n\n /**\n * @private\n */\n @Method()\n async updateDropdown(params: _CDropdownUpdateParams) {\n this.items = [];\n this._itemRefs = [];\n this.options = {};\n\n requestAnimationFrame(() => {\n this.currentIndex = null;\n this.items = params.items || this.items;\n this.options = params.options || this.options;\n\n this._updateMenuItems();\n this._updateStatusText();\n });\n }\n\n /**\n * @private\n */\n @Method()\n async focusDropdown() {\n requestAnimationFrame(() => {\n this._listElement.focus();\n });\n }\n\n /**\n * @private\n */\n @Method()\n async open(focusList = false) {\n this._onOpen();\n this._createEventListeners();\n\n this._outsideClickFn = this._handleOutsideClick.bind(this);\n\n requestAnimationFrame(() => {\n if (focusList) {\n this._listElement.focus();\n\n if (this.type === 'autocomplete') {\n this.currentIndex = 0;\n }\n\n this._handleCurrentIndexChange();\n }\n\n this._positionMenu();\n\n window.addEventListener('click', this._outsideClickFn);\n });\n }\n\n /**\n * @private\n */\n @Method()\n async close() {\n this._openedOnTop = false;\n this._onClose();\n\n window.removeEventListener('click', this._outsideClickFn);\n }\n\n /**\n * @private\n */\n @Method()\n async focusItem(type: number) {\n requestAnimationFrame(() => {\n this.currentIndex = type;\n\n this._itemRefs[this.currentIndex].focus();\n });\n }\n\n @Watch('currentIndex')\n onCurrentIndexChange() {\n this._handleCurrentIndexChange();\n }\n\n private _debounce = null;\n\n private _itemRefs: HTMLLIElement[] = [];\n\n private _lastKeyPressTime = null;\n\n private _listElement: HTMLUListElement;\n\n private _dialogElement: HTMLDialogElement;\n\n private _openedOnTop = false;\n\n private _searchString = '';\n\n private _resizeObserver: ResizeObserver;\n\n private _outsideClickFn: () => void;\n\n private get _listSize() {\n return this.items.length || 0;\n }\n\n private get _firstSelectableIndex() {\n return this.items.findIndex((item) => !item.disabled);\n }\n\n private get _lastSelectableIndex() {\n return this.items.findLastIndex((item) => !item.disabled);\n }\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (!entry.isIntersecting) {\n entry.target.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n });\n observer.unobserve(entry.target);\n } else {\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n private _highlightMatchingText(value: string) {\n if (\n this.type === 'select' ||\n (this.parent as HTMLCAutocompleteElement).query === ''\n )\n return value;\n\n const regex = new RegExp(\n (this.parent as HTMLCAutocompleteElement).query,\n 'gi',\n );\n\n const highlighted = value\n .replace(/(<([^>]+)>)/gi, '')\n .replace(regex, (match) => `<mark>${match}</mark>`);\n\n return highlighted;\n }\n\n private _renderMenuItem = (item: CSelectItem, index: number) => {\n const isActive = this.items[this.currentIndex]?.value === item.value;\n\n let itemId = 'none';\n\n if (typeof item?.value === 'string') {\n itemId = item.value.replace(/[^a-zA-Z0-9-_]/g, '');\n }\n\n itemId = `item_${this.inputId}--${itemId}`;\n\n if (isActive) {\n this.currentIndex = index;\n this.parent.setActiveDescendant(itemId);\n }\n\n const listItem = document.createElement('li');\n\n // a11y\n listItem.role = 'option';\n listItem.ariaPosInSet = (index + 1).toString();\n listItem.ariaSetSize = this.items.length.toString();\n\n listItem.ariaSelected = isActive.toString();\n\n listItem.id = itemId;\n listItem.dataset.value = item.name;\n listItem.setAttribute('tabindex', '-1');\n\n listItem.classList.toggle('disabled', !!item.disabled);\n\n listItem.addEventListener('click', (event: MouseEvent) => {\n const isDisabled = this._itemRefs[index].classList.contains('disabled');\n\n if (isDisabled) {\n event.preventDefault();\n\n return;\n }\n\n this.currentIndex = index;\n this._onSelect(index);\n });\n\n listItem.addEventListener('focus', () => {\n listItem.classList.add('active');\n });\n\n listItem.addEventListener('blur', () => {\n listItem.classList.remove('active');\n });\n\n this._itemRefs.push(listItem);\n\n if (Object.keys(this.options).length) {\n requestAnimationFrame(() => {\n const option = this.options[item.value as string];\n\n if (!option) return;\n\n if (\n (this.parent as HTMLCAutocompleteElement).query?.length &&\n this.type === 'autocomplete'\n ) {\n const optionValue = option.querySelector('c-option-value');\n\n if (optionValue) {\n optionValue.innerHTML = this._highlightMatchingText(\n optionValue.textContent,\n );\n }\n }\n\n listItem.appendChild(option);\n\n this._listElement.appendChild(listItem);\n });\n\n return;\n }\n\n const span = document.createElement('span');\n span.innerHTML = this._highlightMatchingText(item.name);\n\n listItem.appendChild(span);\n\n this._listElement.appendChild(listItem);\n };\n\n private _renderEmptyItem() {\n const emptyElement = document.createElement('li');\n emptyElement.tabIndex = -1;\n\n const icon = document.createElement('c-icon');\n icon.path = mdiAlert;\n icon.size = 18;\n icon.color = 'var(--c-warning-600)';\n\n emptyElement.appendChild(icon);\n emptyElement.append('No suggestions found');\n\n this._listElement.replaceChildren(emptyElement);\n }\n\n private _updateMenuItems() {\n if (!this.items.length) {\n this._renderEmptyItem();\n\n return;\n }\n\n this._listElement.replaceChildren();\n this._itemRefs.length = 0;\n\n this.items.map((item, index) => this._renderMenuItem(item, index));\n\n requestAnimationFrame(() => {\n this._positionMenu();\n });\n }\n\n private _renderMenu() {\n this._id = `${this.inputId}--items`;\n\n const dialogElement = document.createElement('dialog');\n\n const listElement = document.createElement('ul');\n\n // a11y\n listElement.role = `listbox`;\n listElement.ariaExpanded = this.isVisible.toString();\n listElement.tabIndex = -1;\n\n listElement.id = this._id;\n\n this._dialogElement = dialogElement;\n\n this._listElement = listElement;\n\n this._dialogElement.appendChild(listElement);\n\n this.host.shadowRoot.appendChild(dialogElement);\n\n this.items.map((item, index) => this._renderMenuItem(item, index));\n\n this._listElement.addEventListener(\n 'keydown',\n this._onKeyboardNavigation.bind(this),\n );\n\n this._listElement.addEventListener('keyup', this._onKeyDown.bind(this));\n }\n\n private _onOpen() {\n this.parent.shadowRoot.querySelector('.c-input').classList.add('active');\n this._listElement.classList.add('active');\n this.isOpen = true;\n this._listElement.ariaExpanded = 'true';\n this._listElement.tabIndex = 0;\n this._dialogElement.showModal();\n }\n\n private _onClose(focusInput = false) {\n this.parent.onHideMenu();\n this.parent.shadowRoot.querySelector('.c-input').classList.remove('active');\n this._listElement.classList.remove('active');\n this._listElement.ariaExpanded = 'false';\n this._listElement.tabIndex = -1;\n this.isOpen = false;\n this.currentIndex = this.index;\n this._dialogElement.close();\n\n if (focusInput) {\n this.parent.shadowRoot.querySelector('input').focus();\n }\n }\n\n private _onSelect(index: number, focusInput = false) {\n if (index === null) return;\n\n const isDisabled = this._itemRefs[index].classList.contains('disabled');\n\n if (isDisabled) return;\n\n this.parent.onItemSelection(index);\n this.index = index;\n this._onClose(focusInput);\n\n this._itemRefs.forEach((item, i) => {\n item.ariaSelected = (i === index).toString();\n });\n }\n\n private _getParentPosition() {\n return this.parent.shadowRoot\n .querySelector('.c-input__slot')\n .getBoundingClientRect();\n }\n\n private _positionMenu() {\n const { innerWidth, innerHeight } = window;\n\n const {\n bottom: parentBottom,\n left: parentLeft,\n width: parentWidth,\n top: parentTop,\n } = this._getParentPosition();\n\n this._dialogElement.style.width = `${parentWidth}px`;\n this._dialogElement.style.top = `${parentBottom}px`;\n this._dialogElement.style.bottom = 'auto';\n this._dialogElement.style.left = `${parentLeft}px`;\n\n this._dialogElement.style.removeProperty('transform');\n\n const { bottom, right, height, width } =\n this._dialogElement.getBoundingClientRect();\n\n const isInView = {\n x: right < innerWidth,\n y: bottom < innerHeight,\n };\n\n const fitsOnTop = parentTop - height > 0;\n\n if (!fitsOnTop && !isInView.y) {\n this._dialogElement.style.maxHeight = `${parentTop}px`;\n }\n\n if (!isInView.y || this._openedOnTop) {\n this._openedOnTop = true;\n\n this._dialogElement.style.top = 'auto';\n this._dialogElement.style.bottom = `${innerHeight - parentTop}px`;\n }\n\n this.topPosition = parentBottom;\n\n if (!isInView.x) {\n this._dialogElement.style.left = `${\n parseFloat(this._dialogElement.style.left) - width + parentWidth\n }px`;\n }\n }\n\n private _createEventListeners() {\n requestAnimationFrame(async () => {\n this._listElement.classList.add('active');\n });\n }\n\n private _scrollToElement() {\n if (this.items.length > this.itemsPerPage) {\n const itemRef = this._itemRefs[this.currentIndex];\n\n if (!!itemRef) {\n this._observer.observe(itemRef);\n }\n }\n }\n\n private _onKeyDown(event: KeyboardEvent) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n private _onKeyboardNavigation(event: KeyboardEvent) {\n this.wasClicked = false;\n\n const letterNumber = /^[0-9a-zA-Z]+$/;\n\n if (\n (event.key.match(letterNumber) && event.key.length === 1) ||\n event.key === 'Backspace'\n ) {\n if (this.type === 'autocomplete') {\n const { query } = this.parent as HTMLCAutocompleteElement;\n\n let updatedQuery = '';\n\n if (event.key === 'Backspace') {\n updatedQuery = query.slice(0, -1);\n } else {\n updatedQuery = `${query}${event.key}`;\n }\n\n (this.parent as HTMLCAutocompleteElement).updateQuery(updatedQuery);\n\n return;\n }\n\n if (\n Date.now() - this._lastKeyPressTime > 3000 ||\n this._searchString.length > 2\n ) {\n this._searchString = event.key;\n } else {\n this._searchString = `${this._searchString}${event.key}`;\n }\n\n this._lastKeyPressTime = Date.now();\n\n const selectedItem = this.items.find((i) =>\n i.name.toLowerCase().startsWith(this._searchString),\n );\n\n if (selectedItem) {\n this.currentIndex = this.items.findIndex(\n (element) => element === selectedItem,\n );\n\n if (this.isOpen) {\n this._scrollToElement();\n } else {\n this._onSelect(this.currentIndex, true);\n }\n }\n }\n\n if (event.key === 'Enter') {\n this._onSelect(this.currentIndex, true);\n }\n\n if (event.key === ' ' && !this.isOpen) {\n event.preventDefault();\n\n this.isOpen = true;\n }\n\n if ('Tab' === event.key) {\n this._onClose();\n }\n\n if (event.key === 'Escape') {\n this._onClose(true);\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n\n if (this.currentIndex === null) {\n this.currentIndex = 0;\n } else if (this.isOpen && this.currentIndex + 1 < this._listSize) {\n this.currentIndex += 1;\n }\n\n this.isOpen = true;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n\n if (this.isOpen && this.currentIndex === 0) {\n this.currentIndex = null;\n this._onClose(true);\n\n return;\n } else if (this.isOpen && this.currentIndex > 0) {\n this.currentIndex -= 1;\n } else if (this.currentIndex === null) {\n this.currentIndex = this._listSize - 1;\n }\n\n this.isOpen = true;\n }\n\n if (event.key === 'Home' && this.isOpen) {\n event.preventDefault();\n\n this.currentIndex = this._firstSelectableIndex;\n }\n\n if (event.key === 'End' && this.isOpen) {\n event.preventDefault();\n\n this.currentIndex = this._lastSelectableIndex;\n }\n }\n\n private _handleCurrentIndexChange() {\n if (this.currentIndex === null) {\n this.parent?.setActiveDescendant('');\n\n return;\n }\n\n this._updateStatusText();\n\n requestAnimationFrame(() => {\n const item = this._itemRefs[this.currentIndex];\n\n if (!item) return;\n\n item?.focus();\n\n this.parent?.setActiveDescendant(item.id ?? null);\n });\n }\n\n private _handleOutsideClick(event) {\n if (!event.composedPath().includes(this._dialogElement)) {\n this.close();\n }\n }\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n const selection = this._itemRefs[this.currentIndex];\n\n const ending = !!this.items.length\n ? ', to navigate use up and down arrows'\n : '';\n\n const isDisabled = !!selection?.classList?.contains('disabled');\n\n const beginning = isDisabled ? 'Disabled option - ' : '';\n\n let selectionText = !!selection\n ? `${beginning}${selection.dataset.value} - ${selection.ariaPosInSet} of ${selection.ariaSetSize} is highlighted`\n : null;\n\n if (this.currentIndex === null && this.type === 'autocomplete') {\n selectionText = this.items.length\n ? `${this.items.length} result${\n this.items.length !== 1 ? 's' : ''\n } available`\n : 'No search results available';\n }\n\n this.statusText = `${selectionText || ending}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n componentDidLoad() {\n this._renderMenu();\n\n this.currentIndex = this.index;\n\n this._resizeObserver = new ResizeObserver(() => {\n if (!this.isOpen) return;\n\n this._positionMenu();\n });\n\n this._resizeObserver.observe(window.document.body);\n }\n\n disconnectedCallback() {\n this._resizeObserver.disconnect();\n }\n\n render() {\n if (\n this._dialogElement &&\n this.itemsPerPage &&\n this.itemsPerPage > 0 &&\n this.items.length > this.itemsPerPage\n ) {\n this._dialogElement.style.maxHeight =\n 42 * (this.itemsPerPage + 0.5) + 'px';\n }\n\n return (\n <Host>\n <div\n id={'announce-' + this._id}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n </Host>\n );\n }\n}\n",":root,\n:host {\n --_c-input-inactive-color: var(--c-tertiary-600);\n --_c-input-active-color: var(--c-primary-600);\n --_c-input-background-color: var(--c-transparent);\n --_c-input-text-color: var(--c-text-body);\n --_c-input-placeholder-color: var(--c-tertiary-500);\n --_c-input-shadow-active-color: var(--_c-input-active-color);\n --_c-input-shadow-background-color: var(--c-white);\n --_c-input-shadow-text-color: var(--_c-input-text-color);\n --_c-input-shadow-placeholder-color: var(--_c-input-placeholder-color);\n\n // private\n --_c-input-error-color: var(--c-error-600);\n}\n\n.visuallyhidden {\n border: 0;\n clip: rect(0 0 0 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n}\n\n.c-input {\n $this: &;\n\n --_c-input-border-width: 1px;\n\n align-items: flex-start;\n border-radius: 4px;\n display: flex;\n flex: 1 1 auto;\n font-family: var(--c-font-family);\n font-size: 16px;\n letter-spacing: normal;\n max-width: 100%;\n text-align: left;\n\n input,\n select,\n textarea {\n background: none;\n border: 0;\n display: inline-block;\n font-family: var(--c-font-family);\n font-size: 16px;\n line-height: 1;\n margin: 0;\n padding: 0;\n vertical-align: middle;\n white-space: normal;\n }\n\n input,\n textarea {\n box-sizing: content-box;\n background-color: transparent;\n border: none;\n color: var(--_c-input-text-color);\n flex: 1 1 auto;\n font-family: var(--c-font-family);\n font-size: 16px;\n line-height: 20px;\n max-width: 100%;\n min-width: 0;\n width: 100%;\n }\n\n input[type=\"checkbox\"],\n input[type=\"radio\"],\n select {\n box-sizing: border-box;\n }\n\n input[type=\"search\"] {\n appearance: textfield;\n box-sizing: content-box;\n }\n\n ::-webkit-search-decoration {\n display: none;\n }\n\n textarea {\n margin-top: 4px;\n min-height: 44px;\n overflow: auto;\n padding: 8px 12px 8px 0;\n resize: vertical;\n vertical-align: top;\n }\n\n input {\n max-height: 32px;\n padding: 8px 0;\n }\n\n input:focus,\n input:active,\n textarea:focus,\n textarea:active {\n outline: none;\n }\n\n .c-input__content {\n align-items: center;\n display: flex;\n width: 100%;\n }\n\n &__control {\n border-radius: inherit;\n color: currentColor;\n display: flex;\n flex-flow: column wrap;\n flex-grow: 1;\n gap: 8px;\n height: auto;\n min-width: 0;\n width: 100%;\n position: relative;\n }\n\n &__slot {\n align-items: stretch;\n background: transparent;\n border-radius: inherit;\n color: inherit;\n cursor: text;\n display: flex;\n min-height: 44px;\n padding: 0 12px;\n position: relative;\n transition: 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);\n width: 100%;\n }\n\n &__field {\n align-items: center;\n display: flex;\n flex: 1 1 auto;\n gap: 8px;\n position: relative;\n\n input,\n textarea {\n flex: 1;\n outline: 0;\n }\n\n label {\n font-size: 16px;\n height: 20px;\n left: 0;\n letter-spacing: normal;\n line-height: 20px;\n max-width: 90%;\n min-height: 8px;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n right: auto;\n text-overflow: ellipsis;\n top: 12px;\n transform-origin: top left;\n transform: translateX(var(--_c-input-label-position)) translateY(0)\n scale(1);\n transition: 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);\n white-space: nowrap;\n\n &.active {\n transform: translateY(-18px) scale(0.75);\n }\n\n span {\n color: var(--_c-input-error-color);\n }\n }\n }\n\n &--select {\n input {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .c-input__slot {\n cursor: pointer;\n }\n }\n\n fieldset {\n background-color: var(--_c-input-background-color);\n border-collapse: collapse;\n border-color: var(--_c-input-inactive-color);\n border-radius: inherit;\n border-style: solid;\n border-width: var(--_c-input-border-width);\n inset: 0;\n margin: 0;\n padding: 0 0 0 8px;\n pointer-events: none;\n position: absolute;\n transition-duration: 0.15s;\n transition-property: color;\n transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);\n\n legend {\n float: none;\n line-height: 11px;\n margin-left: -1px;\n padding: 0;\n text-align: left;\n transition: width 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);\n width: 0;\n\n &.active {\n width: var(--_c-input-legend-width);\n }\n }\n }\n\n &--shadow {\n #{$this} {\n &__slot {\n background-color: var(--_c-input-shadow-background-color);\n box-shadow: rgba(0, 0, 0, 0.15) 0 5px 15px 0;\n\n input,\n textarea {\n color: var(--_c-input-shadow-text-color);\n }\n\n &:focus-within {\n outline: 2px var(--_c-input-active-color) solid;\n\n c-icon {\n --c-icon-color: var(--_c-input-shadow-active-color) !important;\n }\n }\n }\n }\n\n input::placeholder,\n textarea::placeholder {\n color: var(--_c-input-shadow-placeholder-color);\n opacity: 1;\n }\n }\n\n &--disabled {\n input,\n textarea,\n fieldset,\n label {\n --_c-input-error-color: var(--c-tertiary-500);\n\n color: var(--c-tertiary-500);\n }\n }\n\n &--textarea {\n #{$this} {\n &__field {\n margin-right: -12px;\n }\n }\n }\n\n ::placeholder {\n color: var(--_c-input-placeholder-color);\n opacity: 1;\n }\n\n &:focus-within,\n &.active,\n &:not(.c-input--disabled):active {\n --_c-input-border-width: 2px;\n\n color: var(--_c-input-active-color);\n\n fieldset {\n border-color: var(--_c-input-active-color);\n }\n\n label {\n color: var(--_c-input-active-color);\n transform: translateX(0) translateY(-18px) scale(0.75);\n }\n\n legend {\n width: var(--_c-input-legend-width);\n }\n }\n\n &.active:not(.filled) {\n .c-input-menu__input {\n position: relative;\n\n &::after {\n display: flex;\n align-items: center;\n position: absolute;\n inset: 0;\n content: attr(data-placeholder);\n pointer-events: none;\n color: var(--_c-input-placeholder-color);\n }\n }\n }\n\n &--error {\n color: var(--_c-input-error-color);\n\n fieldset {\n border-color: var(--_c-input-error-color) !important;\n }\n\n label {\n color: var(--_c-input-error-color) !important;\n }\n\n &:focus-within {\n color: var(--_c-input-error-color);\n }\n }\n}\n","import {\n Component,\n Host,\n h,\n State,\n Prop,\n Event,\n EventEmitter,\n Element,\n Watch,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\n\n/**\n * @parent None\n */\n@Component({\n tag: 'c-input',\n styleUrl: 'c-input.scss',\n shadow: false,\n})\nexport class CInput {\n @Element() el!: HTMLCInputElement;\n\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Render a hidden input outside the shadow dom\n */\n @Prop() form = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the input\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Id of the input element\n */\n @Prop() inputId: string;\n\n /**\n * Items for the dropdown\n */\n @Prop() items: CSelectItem[];\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage = 6;\n\n /**\n * Label of the input\n */\n @Prop() label: string;\n\n /**\n * Maximum value on a numeric input\n */\n @Prop() max: number = null;\n\n /**\n * Minimum value on a numeric input\n */\n @Prop() min: number = null;\n\n /**\n * Name of the input\n */\n @Prop() name: string;\n\n /**\n * Placeholder of the input\n */\n @Prop() placeholder: string;\n\n /**\n * Mark as readonly\n */\n @Prop() readonly = false;\n\n /**\n * Set the input as required\n */\n @Prop() required = false;\n\n /**\n * Rows on the input\n */\n @Prop() rows = 1;\n\n /**\n * Shadow variant of the input\n */\n @Prop() shadow = false;\n\n /**\n * Step size on a numeric input\n */\n @Prop() step: number = null;\n\n /**\n * Type of the input\n */\n @Prop() type: string;\n\n /**\n * Set the validíty of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Value of the input\n */\n @Prop() value: string | number | boolean | CSelectItem | CAutocompleteItem;\n\n /**\n * Variant\n */\n @Prop() variant: 'text' | 'select' = 'text';\n\n /**\n * Emit changes to the parent\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Emit click to the parent\n * @private\n */\n @Event({ bubbles: false }) itemClick: EventEmitter;\n\n /**\n * Emit close to the parent\n * @private\n */\n @Event({ bubbles: false }) dropdownClose: EventEmitter;\n\n @State() isFocused = false;\n\n @State() labelWidth = 0;\n\n @State() preSlotWidth = 0;\n\n @State() statusText = '';\n\n @State() currentIndex: number = null;\n\n @Watch('valid')\n onValidChange() {\n if (this.validateOnBlur && !this._hasBlurred) return;\n\n this._setAriaDescriptionId();\n }\n\n @Watch('validation')\n onValidationMessageChange() {\n this._updateStatusText();\n }\n\n @Watch('value')\n onValueChange(value) {\n if (!value) {\n this._onReset();\n }\n }\n\n @Watch('placeholder')\n onPlaceholderChange(placeholder) {\n if (placeholder) this._onReset();\n }\n\n private _hasBlurred = false;\n\n private _labelRef: HTMLLabelElement;\n\n private _debounce = null;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n componentDidLoad() {\n if (this.autofocus) {\n setTimeout(() => {\n this._onFocus(false);\n }, 500);\n }\n\n this._calculateElementWidths();\n this._setAriaDescriptionId();\n\n if (this.label) {\n this._observer.observe(this._labelRef);\n }\n\n this.inputField?.addEventListener('focus', () => this._onFocus(false));\n this.inputField?.addEventListener('blur', () => this._onBlur());\n this.inputField?.addEventListener(\n 'keypress',\n this._preventNonNumericalInput,\n );\n\n // hide the placeholder text initially if there is a label\n if (this.inputField) {\n this.inputField.placeholder =\n !!this.label || !this.placeholder ? '' : this.placeholder;\n\n this.inputField.title = this.label ?? this.placeholder;\n\n requestAnimationFrame(() => {\n const container = this.inputField.closest(\n '.c-input-menu__input',\n ) as HTMLDivElement;\n\n if (!container) return;\n\n container.dataset.placeholder = this.placeholder;\n });\n }\n }\n\n disconnectedCallback() {\n this.inputField?.removeEventListener('focus', () => this._onFocus(false));\n this.inputField?.removeEventListener('blur', () => this._onBlur());\n this.inputField?.removeEventListener(\n 'keypress',\n this._preventNonNumericalInput,\n );\n\n this._observer.disconnect();\n\n this._dropdownElement?.remove();\n }\n\n get isActive() {\n return !!this.value || typeof this.value === 'boolean' || this.isFocused;\n }\n\n private _setAriaDescriptionId() {\n this.inputField.removeAttribute('aria-describedby');\n\n let type = null;\n\n if (this.valid && !this.value && this.hint) {\n type = 'hint';\n }\n\n if (!this.valid) {\n type = 'error';\n }\n\n if (type) {\n this.inputField.setAttribute(\n 'aria-describedby',\n `${type}-${this.inputId}`,\n );\n }\n }\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n this._calculateElementWidths();\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n private _calculateElementWidths() {\n this.labelWidth = !!this.label ? this._labelRef.scrollWidth * 0.75 + 6 : 0;\n this.preSlotWidth = this.inputField.offsetLeft;\n }\n\n private _onBlur = () => {\n // delay the blur event to prevent the label from 'flashing' on c-select selection\n setTimeout(() => {\n this.isFocused = false;\n this._hasBlurred = true;\n\n // show the label if there's no label or value\n this._onReset();\n }, 100);\n };\n\n private _onFocus = (click = true) => {\n if (this.disabled) return;\n\n this.isFocused = true;\n\n this.inputField?.focus();\n\n if (click) {\n this.inputField?.click();\n\n if (this.variant === 'select') {\n this.itemClick.emit();\n }\n }\n\n // show the label if there's no value\n if (this.inputField) {\n this.inputField.placeholder =\n !!this.value || !this.placeholder ? '' : this.placeholder;\n }\n };\n\n private _onReset() {\n if (this.inputField) {\n this.inputField.placeholder =\n !this.label && !this.value && !!this.placeholder\n ? this.placeholder\n : '';\n }\n }\n\n /**\n * Prevent non numeric values in the numeric fields\n */\n private _preventNonNumericalInput(event: KeyboardEvent) {\n if (this.type !== 'number') return;\n\n if (!event.key.match(/^[0-9,\\.]+$/)) event.preventDefault();\n }\n\n private _renderBorders() {\n if (this.shadow) return;\n\n const classes = {\n active: this.isActive,\n };\n\n return (\n <fieldset aria-hidden=\"true\">\n <legend\n class={classes}\n style={{\n '--_c-input-legend-width': this.labelWidth + 'px',\n }}\n >\n <span class=\"notranslate\"></span>\n </legend>\n </fieldset>\n );\n }\n\n private _renderLabel() {\n if (!this.label) return;\n\n const classes = {\n active: this.isActive,\n };\n\n return (\n <label\n htmlFor={this.inputId}\n ref={(el) => (this._labelRef = el as HTMLLabelElement)}\n class={classes}\n >\n {this.label}\n {this.required && <span> *</span>}\n </label>\n );\n }\n\n get inputField() {\n return this.el?.querySelector('.c-input__input') as\n | HTMLInputElement\n | HTMLTextAreaElement;\n }\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n this.statusText = this.valid ? '' : `Error: ${this.validation}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n const containerClasses = {\n 'c-input': true,\n 'c-input--disabled': this.disabled,\n 'c-input--shadow': this.shadow,\n 'c-input--textarea': this.rows > 1,\n 'c-input--error': !this.valid,\n filled: !!this.value,\n [`c-input--${this.variant}`]: true,\n };\n\n return (\n <Host disabled={this.disabled}>\n <div\n id={'announce-' + this.inputId}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <div class={containerClasses}>\n <div class=\"c-input__control\">\n <div class=\"c-input__slot\" onClick={() => this._onFocus()}>\n {this._renderBorders()}\n\n <div\n class=\"c-input__field\"\n style={{\n '--_c-input-label-position': this.preSlotWidth + 'px',\n }}\n >\n <slot name=\"pre\"></slot>\n\n {this._renderLabel()}\n\n <slot></slot>\n </div>\n </div>\n\n {this.variant === 'select' && <slot name=\"dropdown\"></slot>}\n\n {!this.hideDetails && (\n <c-message\n hint={this.hint}\n inputId={this.inputId}\n valid={this.valid}\n validation={this.validation}\n />\n )}\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"mappings":"oGAAA,MAAMA,EAAe,4vE,MCuBRC,EAAS,M,yBA2EZC,KAAAC,IAAM,GAsFND,KAAAE,UAAY,KAEZF,KAAAG,UAA6B,GAE7BH,KAAAI,kBA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EACjC,kBAAmBlP,KAAKiO,MACxBkB,SAAUnP,KAAK2B,MACf,CAAC,YAAY3B,KAAK4M,WAAY,MAGhC,OACEb,EAACC,EAAI,CAAChJ,SAAUhD,KAAKgD,UACnB+I,EAAA,OACErJ,GAAI,YAAc1C,KAAK8B,QACvBmK,MAAM,iBAAgB,YACZ,SAAQ,cACN,QAEXjM,KAAKuL,YAGRQ,EAAA,OAAKE,MAAOgD,GACVlD,EAAA,OAAKE,MAAM,oBACTF,EAAA,OAAKE,MAAM,gBAAgBmD,QAAS,IAAMpP,KAAKyM,YAC5CzM,KAAKuO,iBAENxC,EAAA,OACEE,MAAM,iBACNjD,MAAO,CACL,4BAA6BhJ,KAAKqO,aAAe,OAGnDtC,EAAA,QAAMnJ,KAAK,QAEV5C,KAAK2O,eAEN5C,EAAA,eAIH/L,KAAK4M,UAAY,UAAYb,EAAA,QAAMnJ,KAAK,cAEvC5C,KAAKqP,aACLtD,EAAA,aACEmC,KAAMlO,KAAKkO,KACXpM,QAAS9B,KAAK8B,QACdmM,MAAOjO,KAAKiO,MACZe,WAAYhP,KAAKgP,e"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,H as o,g as s}from"./p-9d54e9a4.js";import{g as n}from"./p-dffa1f9f.js";const r="html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-autocomplete-option-background-color:var(--c-autocomplete-option-background-color, var(--c-white));--_c-autocomplete-option-background-hover-color:var(--c-autocomplete-option-background-hover-color, var(--c-primary-100));--_c-autocomplete-active-color:var(--c-autocomplete-active-color, var(--c-primary-600));--_c-autocomplete-inactive-color:var(--c-autocomplete-inactive-color, var(--c-tertiary-600));--_c-autocomplete-background-color:var(--c-autocomplete-background-color, var(--c-transparent));--_c-autocomplete-text-color:var(--c-autocomplete-text-color, var(--c-text-body));--_c-autocomplete-option-text-color:var(--c-autocomplete-option-text-color, var(--c-text-body));--_c-autocomplete-placeholder-color:var(--c-autocomplete-placeholder-color, var(--c-tertiary-500));--c-select-option-background-color:var(\n --_c-autocomplete-option-background-color\n );--c-select-option-background-color-hover:var(\n --_c-autocomplete-option-background-hover-color\n );--c-select-option-text-color:var(--_c-autocomplete-option-text-color);--_c-input-active-color:var(--_c-autocomplete-active-color);--_c-input-inactive-color:var(--_c-autocomplete-inactive-color);--_c-input-background-color:var(--_c-autocomplete-background-color);--_c-input-text-color:var(--_c-autocomplete-text-color);--_c-input-placeholder-color:var(--_c-autocomplete-placeholder-color)}:host{display:block;cursor:text}.c-input-menu__chevron{fill:currentColor;height:22px;width:22px;min-width:22px;transform:rotate(0deg);transition:transform 0.3s ease-in-out}.c-input-menu__chevron--active{transform:rotate(180deg)}.c-input-menu__input{width:100%;display:flex;justify-items:stretch}.c-input-menu__selection{display:none;pointer-events:none}.c-input-menu__selection--show{align-items:center;display:flex;width:100%;color:var(--_c-select-active-color)}.c-input-menu__item-wrapper{position:absolute;width:100%;top:44px;z-index:10;margin-left:calc(var(--_c-input-label-position) * -1)}.c-input-menu__item-wrapper--shadow{top:47px}.c-input-menu__items{position:absolute;background-color:var(--_c-select-option-background-color);min-width:calc(100% + 24px);box-shadow:0 8px 16px 0 rgba(0, 0, 0, 0.2);z-index:10;user-select:none;border-radius:4px;margin:0 -12px;overflow-y:scroll;list-style:none;padding:0}.c-input-menu__items--hidden{display:none}.c-input-menu__items li{cursor:pointer;display:flex;min-height:48px;padding:0 12px;transition:background-color 0.3s;font-size:14px;align-items:center;justify-content:flex-start;color:var(--_c-select-option-text-color)}.c-input-menu__items li.disabled{background-color:var(--c-tertiary-100);filter:grayscale(1) opacity(0.6);cursor:default}.c-input-menu__items li.disabled:hover{background-color:var(--c-tertiary-100)}.c-input-menu__items li.dense{padding:10px 14px}.c-input-menu__items li:hover{background-color:var(--_c-select-option-background-color-hover)}.c-input-menu__items li[aria-selected=true]{background-color:var(--_c-select-option-background-color-hover);box-shadow:inset 0 0 0 1px var(--_c-select-active-color);border-radius:4px;backface-visibility:hidden;transform:translate3d(0, 0, 0)}.c-input-menu__items li.none{color:rgba(0, 0, 0, 0.5)}.c-input-menu__items--empty li{color:var(--c-text-system);cursor:default;gap:8px;pointer-events:none}.c-input-menu__items--empty li svg{fill:var(--c-warning-600);height:18px;width:18px}input{max-height:32px;padding:8px 0;background-color:transparent;border:none;color:var(--c-text-body);flex:1 1 auto;font-family:var(--c-font-family);font-size:16px;line-height:20px;max-width:100%;min-width:0;width:100%;pointer-events:none}input:focus,input:active{outline:none}input::-ms-reveal{display:none}svg{fill:currentColor;height:22px;width:22px}.c-input--disabled{color:var(--c-tertiary-400)}.c-input:focus-within{color:var(--c-primary-600)}.c-input--error{color:var(--c-error-600)}.c-input--error:focus-within{color:var(--c-error-600)}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}";const a=class{constructor(i){t(this,i);this.changeQuery=e(this,"changeQuery",7);this.changeValue=e(this,"changeValue",3);if(i.$hostElement$["s-ei"]){this.internals=i.$hostElement$["s-ei"]}else{this.internals=i.$hostElement$.attachInternals();i.$hostElement$["s-ei"]=this.internals}this._cOptionElements={};this._optionItems=[];this._direction=null;this._observer=new IntersectionObserver(((t,e)=>{t.forEach((t=>{if(!t.isIntersecting){t.target.scrollIntoView({block:this._direction,inline:"nearest"});e.unobserve(t.target)}else{e.unobserve(t.target)}}))}),{threshold:1});this._handleSlotChange=()=>{this._getOptionItems()};this.autofocus=false;this.disabled=false;this.hideDetails=false;this.hint="";this.hostId=undefined;this.shadow=false;this.name=undefined;this.label=undefined;this.query=null;this.value=null;this.dense=undefined;this.required=false;this.valid=true;this.validate=false;this.validateOnBlur=false;this.validation="Required field";this.placeholder="";this.returnValue=undefined;this.items=[];this.itemsPerPage=undefined;this.optionAsSelection=undefined;this.menuVisible=false;this.currentIndex=null;this.hasOptionItems=false;this.options={}}async setValue(t,e){this._select(t,e)}async onHideMenu(){this.menuVisible=false}async setActiveDescendant(t){if(!t){this._inputElement.removeAttribute("aria-activedescendant");return}this._inputElement.setAttribute("aria-activedescendant",t)}async updateQuery(t){this.query=t;this.changeQuery.emit(this.query);this.changeValue.emit(null)}async onItemSelection(t){this.currentIndex=t;const e=this._items[this.currentIndex];this.value=e;this.query=e.name}_setFormValue(t){if(!t)return;const e=this.returnValue?t:t.value;this.internals.setFormValue(e)}_valueChangedHandler(t){function e(e){return e===t}this.currentIndex=this.items.findIndex(e);const i=this.returnValue?t===null||t===void 0?void 0:t.value:t;this._setFormValue(t);this.changeValue.emit(i)}get _items(){return this.hasOptionItems?this._optionItems:this.items}get _itemValues(){return this.items.map((t=>t.value))}get _filteredOptions(){if(!Object.keys(this._cOptionElements).length)return{};return this._itemValues.reduce(((t,e)=>{if(!this._cOptionElements[e])return t;t[e]=this._cOptionElements[e].cloneNode(true);return t}),{})}watchHandler(t){this.currentIndex=!!t.length?0:null;this._optionItems=this._optionItems.filter((t=>this._itemValues.includes(t.value)));requestAnimationFrame((async()=>{await this._cInput.updateDropdown({items:t,options:this._filteredOptions})}))}onValueChange(){if(!this.value)return;requestAnimationFrame((()=>{var t;const e=!((t=this.value)===null||t===void 0?void 0:t.value)?this._items.find((t=>t.value===this.value)):this.value;this._valueChangedHandler(e)}))}handleKeyDown(t){const e=/^[0-9a-zA-Z]+$/;if(t.key.match(e)&&t.key.length===1){this._showMenu(false)}if(t.key==="Tab"){this._cInput.closeDropdown()}if(t.key==="ArrowDown"){t.preventDefault();this._cInput.openDropdown();this._cInput.focusItem("first")}if(t.key==="ArrowUp"){t.preventDefault();this._cInput.openDropdown();this._cInput.focusItem("last")}if(t.key===" "){t.preventDefault();this._showMenu()}}_showMenu(t=true){if(this.disabled)return;this._cInput.openDropdown(t);if(t){this._cInput.focusDropdown()}}_getOptionItems(){requestAnimationFrame((()=>{this._cOptionElements={};let t=null;this._optionItems=(this.host?Array.from(this.host.querySelectorAll("c-option")):[]).map(((e,i)=>{const o={value:e.value,name:e.name||e.innerText,disabled:!!e.disabled};if(e.selected){t=o}e.slot=`option-${i}`;this.options[e.value]=e.cloneNode(true);this._cOptionElements[e.value.toString()]=e.cloneNode(true);return o}));this.hasOptionItems=!!this._optionItems.length;if(t){this._valueChangedHandler(t)}}))}handleChange(t){this.menuVisible=true;this.query=t.target.value;this.changeQuery.emit(this.query);this.changeValue.emit(null)}_select(t,e){t.preventDefault();t.stopPropagation();this.query=e.name;this.value=e;this._valueChangedHandler(e);this.menuVisible=false}componentWillLoad(){a._uniqueId+=1;this._inputId="input_"+(this.hostId||this.label||this.placeholder).replace(/[^a-zA-Z0-9-_]/g,"")}componentDidLoad(){this._getOptionItems();requestAnimationFrame((()=>{this._cInput.createDropdown({type:"autocomplete",items:this._items,options:this.options,itemsPerPage:this.itemsPerPage,parent:this.host,index:this.currentIndex,click:false,id:this._inputId})}))}disconnectedCallback(){this._observer.disconnect()}_renderChevron(){const t={"c-input-menu__chevron":true,"c-input-menu__chevron--active":this.menuVisible};return i("svg",{class:t,viewBox:"0 0 24 24"},i("path",{d:n}))}_renderInputElement(){var t;return i("div",{class:"c-input-menu__input"},i("input",{type:"text",ref:t=>this._inputElement=t,"aria-expanded":this.menuVisible.toString(),"aria-owns":this._inputId+"-items","aria-autocomplete":"list",autocomplete:"off",class:"c-input__input",role:"combobox",value:this.query,name:(t=this.name)!==null&&t!==void 0?t:null,onInput:t=>this.handleChange(t)}))}render(){return i(o,{title:this.query},i("c-input",{ref:t=>this._cInput=t,autofocus:this.autofocus,disabled:this.disabled,"hide-details":this.hideDetails,hint:this.hint,id:this.hostId,"input-id":this._inputId,label:this.label,name:this.name,placeholder:this.placeholder,required:this.required,shadow:this.shadow,valid:this.valid,validate:this.validate,"validate-on-blur":this.validateOnBlur,validation:this.validation,value:this.query,variant:"select",onItemClick:()=>this.items.length&&this._showMenu(false)},i("slot",{name:"pre",slot:"pre"}),i("div",{class:"c-input__content"},this._renderInputElement(),this._renderChevron(),i("slot",{onSlotchange:this._handleSlotChange})),i("slot",{name:"post",slot:"post"})))}static get formAssociated(){return true}get host(){return s(this)}static get watchers(){return{items:["watchHandler"],value:["onValueChange"]}}};a._uniqueId=0;a.style=r;export{a as c_autocomplete};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,c as e,h as i,H as o,g as s}from"./p-9d54e9a4.js";import{g as n}from"./p-dffa1f9f.js";const r="html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-autocomplete-option-background-color:var(--c-autocomplete-option-background-color, var(--c-white));--_c-autocomplete-option-background-hover-color:var(--c-autocomplete-option-background-hover-color, var(--c-primary-100));--_c-autocomplete-active-color:var(--c-autocomplete-active-color, var(--c-primary-600));--_c-autocomplete-inactive-color:var(--c-autocomplete-inactive-color, var(--c-tertiary-600));--_c-autocomplete-background-color:var(--c-autocomplete-background-color, var(--c-transparent));--_c-autocomplete-text-color:var(--c-autocomplete-text-color, var(--c-text-body));--_c-autocomplete-option-text-color:var(--c-autocomplete-option-text-color, var(--c-text-body));--_c-autocomplete-placeholder-color:var(--c-autocomplete-placeholder-color, var(--c-tertiary-500));--c-select-option-background-color:var(\n --_c-autocomplete-option-background-color\n );--c-select-option-background-color-hover:var(\n --_c-autocomplete-option-background-hover-color\n );--c-select-option-text-color:var(--_c-autocomplete-option-text-color);--_c-input-active-color:var(--_c-autocomplete-active-color);--_c-input-inactive-color:var(--_c-autocomplete-inactive-color);--_c-input-background-color:var(--_c-autocomplete-background-color);--_c-input-text-color:var(--_c-autocomplete-text-color);--_c-input-placeholder-color:var(--_c-autocomplete-placeholder-color)}:host{display:block;cursor:text}.c-input-menu__chevron{fill:currentColor;height:22px;width:22px;min-width:22px;transform:rotate(0deg);transition:transform 0.3s ease-in-out}.c-input-menu__chevron--active{transform:rotate(180deg)}.c-input-menu__input{width:100%;display:flex;justify-items:stretch}.c-input-menu__selection{display:none;pointer-events:none}.c-input-menu__selection--show{align-items:center;display:flex;width:100%;color:var(--_c-select-active-color)}.c-input-menu__item-wrapper{position:absolute;width:100%;top:44px;z-index:10;margin-left:calc(var(--_c-input-label-position) * -1)}.c-input-menu__item-wrapper--shadow{top:47px}.c-input-menu__items{position:absolute;background-color:var(--_c-select-option-background-color);min-width:calc(100% + 24px);box-shadow:0 8px 16px 0 rgba(0, 0, 0, 0.2);z-index:10;user-select:none;border-radius:4px;margin:0 -12px;overflow-y:scroll;list-style:none;padding:0}.c-input-menu__items--hidden{display:none}.c-input-menu__items li{cursor:pointer;display:flex;min-height:48px;padding:0 12px;transition:background-color 0.3s;font-size:14px;align-items:center;justify-content:flex-start;color:var(--_c-select-option-text-color)}.c-input-menu__items li.disabled{background-color:var(--c-tertiary-100);filter:grayscale(1) opacity(0.6);cursor:default}.c-input-menu__items li.disabled:hover{background-color:var(--c-tertiary-100)}.c-input-menu__items li.dense{padding:10px 14px}.c-input-menu__items li:hover{background-color:var(--_c-select-option-background-color-hover)}.c-input-menu__items li[aria-selected=true]{background-color:var(--_c-select-option-background-color-hover);box-shadow:inset 0 0 0 1px var(--_c-select-active-color);border-radius:4px;backface-visibility:hidden;transform:translate3d(0, 0, 0)}.c-input-menu__items li.none{color:rgba(0, 0, 0, 0.5)}.c-input-menu__items--empty li{color:var(--c-text-system);cursor:default;gap:8px;pointer-events:none}.c-input-menu__items--empty li svg{fill:var(--c-warning-600);height:18px;width:18px}input{max-height:32px;padding:8px 0;background-color:transparent;border:none;color:var(--c-text-body);flex:1 1 auto;font-family:var(--c-font-family);font-size:16px;line-height:20px;max-width:100%;min-width:0;width:100%;pointer-events:none}input:focus,input:active{outline:none}input::-ms-reveal{display:none}svg{fill:currentColor;height:22px;width:22px}.c-input--disabled{color:var(--c-tertiary-400)}.c-input:focus-within{color:var(--c-primary-600)}.c-input--error{color:var(--c-error-600)}.c-input--error:focus-within{color:var(--c-error-600)}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}";const a=class{constructor(i){t(this,i);this.changeQuery=e(this,"changeQuery",7);this.changeValue=e(this,"changeValue",3);if(i.$hostElement$["s-ei"]){this.internals=i.$hostElement$["s-ei"]}else{this.internals=i.$hostElement$.attachInternals();i.$hostElement$["s-ei"]=this.internals}this._cOptionElements={};this._optionItems=[];this._direction=null;this._observer=new IntersectionObserver(((t,e)=>{t.forEach((t=>{if(!t.isIntersecting){t.target.scrollIntoView({block:this._direction,inline:"nearest"});e.unobserve(t.target)}else{e.unobserve(t.target)}}))}),{threshold:1});this._handleSlotChange=()=>{this._getOptionItems()};this.autofocus=false;this.disabled=false;this.hideDetails=false;this.hint="";this.hostId=undefined;this.shadow=false;this.name=undefined;this.label=undefined;this.query=null;this.value=null;this.dense=undefined;this.required=false;this.valid=true;this.validate=false;this.validateOnBlur=false;this.validation="Required field";this.placeholder="";this.returnValue=undefined;this.items=[];this.itemsPerPage=undefined;this.optionAsSelection=undefined;this.menuVisible=false;this.currentIndex=null;this.hasOptionItems=false;this.options={}}async setValue(t,e){this._select(t,e)}async onHideMenu(){this.menuVisible=false}async setActiveDescendant(t){if(!t){this._inputElement.removeAttribute("aria-activedescendant");return}this._inputElement.setAttribute("aria-activedescendant",t)}async updateQuery(t){this.query=t;this.changeQuery.emit(this.query);this.changeValue.emit(null)}async onItemSelection(t){this.currentIndex=t;const e=this._items[this.currentIndex];this.value=e;this.query=e.name}_setFormValue(t){if(!t)return;const e=this.returnValue?t:t.value;this.internals.setFormValue(e)}_valueChangedHandler(t){function e(e){return e===t}this.currentIndex=this.items.findIndex(e);const i=this.returnValue?t===null||t===void 0?void 0:t.value:t;this._setFormValue(t);this.changeValue.emit(i)}get _items(){return this.hasOptionItems?this._optionItems:this.items}get _itemValues(){return this.items.map((t=>t.value))}get _filteredOptions(){if(!Object.keys(this._cOptionElements).length)return{};return this._itemValues.reduce(((t,e)=>{if(!this._cOptionElements[e])return t;t[e]=this._cOptionElements[e].cloneNode(true);return t}),{})}watchHandler(t){this.currentIndex=!!t.length?0:null;this._optionItems=this._optionItems.filter((t=>this._itemValues.includes(t.value)));requestAnimationFrame((async()=>{await this._dropdownElement.updateDropdown({items:t,options:this._filteredOptions})}))}onValueChange(){if(!this.value)return;requestAnimationFrame((()=>{var t;const e=!((t=this.value)===null||t===void 0?void 0:t.value)?this._items.find((t=>t.value===this.value)):this.value;this._valueChangedHandler(e)}))}handleKeyDown(t){const e=/^[0-9a-zA-Z]+$/;if(t.key.match(e)&&t.key.length===1){this._showMenu(false);if(!this.query){this.updateQuery(t.key)}this._inputElement.focus()}if(t.key==="Tab"){this._dropdownElement.close()}if(t.key==="ArrowDown"){t.preventDefault();this._dropdownElement.open();this._dropdownElement.focusItem(0)}if(t.key==="ArrowUp"){t.preventDefault();this._dropdownElement.open();this._dropdownElement.focusItem(this._items.length-1)}if(t.key===" "){t.preventDefault();this._showMenu()}}_showMenu(t=true){if(this.disabled)return;this._dropdownElement.open(t);if(t){this._dropdownElement.focusDropdown()}}_getOptionItems(){requestAnimationFrame((()=>{this._cOptionElements={};let t=null;this._optionItems=(this.el?Array.from(this.el.querySelectorAll("c-option")):[]).map(((e,i)=>{const o={value:e.value,name:e.name||e.innerText,disabled:!!e.disabled};if(e.selected){t=o}e.slot=`option-${i}`;this.options[e.value]=e.cloneNode(true);this._cOptionElements[e.value.toString()]=e.cloneNode(true);return o}));this.hasOptionItems=!!this._optionItems.length;if(t){this._valueChangedHandler(t)}}))}handleChange(t){this.menuVisible=true;this.query=t.target.value;this.changeQuery.emit(this.query);this.changeValue.emit(null)}_select(t,e){t.preventDefault();t.stopPropagation();this.query=e.name;this.value=e;this._valueChangedHandler(e);this.menuVisible=false}componentWillLoad(){a._uniqueId+=1;this._inputId="input_"+(this.hostId||this.label||this.placeholder).replace(/[^a-zA-Z0-9-_]/g,"")}componentDidLoad(){this._getOptionItems()}disconnectedCallback(){this._observer.disconnect()}_renderChevron(){const t={"c-input-menu__chevron":true,"c-input-menu__chevron--active":this.menuVisible};return i("svg",{class:t,viewBox:"0 0 24 24"},i("path",{d:n}))}_renderInputElement(){var t;return i("div",{class:"c-input-menu__input"},i("input",{type:"text",ref:t=>this._inputElement=t,"aria-expanded":this.menuVisible.toString(),"aria-owns":this._inputId+"-items","aria-autocomplete":"list",autocomplete:"off",class:"c-input__input",role:"combobox",value:this.query,name:(t=this.name)!==null&&t!==void 0?t:null,onInput:t=>this.handleChange(t)}))}render(){return i(o,{title:this.query},i("c-input",{autofocus:this.autofocus,disabled:this.disabled,"hide-details":this.hideDetails,hint:this.hint,id:this.hostId,"input-id":this._inputId,label:this.label,name:this.name,placeholder:this.placeholder,required:this.required,shadow:this.shadow,valid:this.valid,validate:this.validate,"validate-on-blur":this.validateOnBlur,validation:this.validation,value:this.query,variant:"select",onItemClick:()=>this.items.length&&this._showMenu(false)},i("slot",{name:"pre",slot:"pre"}),i("div",{class:"c-input__content"},this._renderInputElement(),this._renderChevron(),i("slot",{onSlotchange:this._handleSlotChange})),i("c-dropdown",{ref:t=>this._dropdownElement=t,slot:"dropdown",items:this._items,options:this._cOptionElements,"items-per-page":this.itemsPerPage,parent:this.el,index:this.currentIndex,"input-id":this._inputId,type:"autocomplete"}),i("slot",{name:"post",slot:"post"})))}static get formAssociated(){return true}get el(){return s(this)}static get watchers(){return{items:["watchHandler"],value:["onValueChange"]}}};a._uniqueId=0;a.style=r;export{a as c_autocomplete};
|
|
2
|
+
//# sourceMappingURL=p-7575c2c3.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cAutocompleteCss","CAutocomplete","this","_cOptionElements","_optionItems","_direction","_observer","IntersectionObserver","entries","observer","forEach","entry","isIntersecting","target","scrollIntoView","block","inline","unobserve","threshold","_handleSlotChange","_getOptionItems","setValue","event","item","_select","onHideMenu","menuVisible","setActiveDescendant","id","_inputElement","removeAttribute","setAttribute","updateQuery","query","changeQuery","emit","changeValue","onItemSelection","index","currentIndex","selectedItem","_items","value","name","_setFormValue","returnValue","internals","setFormValue","_valueChangedHandler","isItem","element","items","findIndex","hasOptionItems","_itemValues","map","_filteredOptions","Object","keys","length","reduce","cloneNode","watchHandler","filter","includes","requestAnimationFrame","async","_dropdownElement","updateDropdown","options","onValueChange","realValue","_a","find","handleKeyDown","ev","alphanumeric","key","match","_showMenu","focus","close","preventDefault","open","focusItem","focusList","disabled","focusDropdown","selection","el","Array","from","querySelectorAll","cAutocompleteItem","innerText","selected","slot","toString","handleChange","stopPropagation","componentWillLoad","_uniqueId","_inputId","hostId","label","placeholder","replace","componentDidLoad","disconnectedCallback","disconnect","_renderChevron","classes","h","class","viewBox","d","mdiChevronDown","_renderInputElement","type","ref","autocomplete","role","onInput","render","Host","title","autofocus","hideDetails","hint","required","shadow","valid","validate","validateOnBlur","validation","variant","onItemClick","onSlotchange","itemsPerPage","parent"],"sources":["src/components/c-autocomplete/c-autocomplete.scss?tag=c-autocomplete&encapsulation=shadow","src/components/c-autocomplete/c-autocomplete.tsx"],"sourcesContent":[":host {\n /**\n * @prop --c-autocomplete-option-background-color: Autocomplete option background color\n * @prop --c-autocomplete-option-background-hover-color: Autocomplete option background hover color\n * @prop --c-autocomplete-active-color: Autocomplete active color\n * @prop --c-autocomplete-inactive-color: Autocomplete inactive color\n * @prop --c-autocomplete-background-color: Autocomplete background color\n * @prop --c-autocomplete-text-color: Autocomplete text color\n * @prop --c-autocomplete-option-text-color: Autocomplete option text color\n * @prop --c-autocomplete-placeholder-color: Autocomplete placeholder color\n */\n --_c-autocomplete-option-background-color: var(--c-autocomplete-option-background-color, var(--c-white));\n --_c-autocomplete-option-background-hover-color: var(--c-autocomplete-option-background-hover-color, var(--c-primary-100));\n --_c-autocomplete-active-color: var(--c-autocomplete-active-color, var(--c-primary-600));\n --_c-autocomplete-inactive-color: var(--c-autocomplete-inactive-color, var(--c-tertiary-600));\n --_c-autocomplete-background-color: var(--c-autocomplete-background-color, var(--c-transparent));\n --_c-autocomplete-text-color: var(--c-autocomplete-text-color, var(--c-text-body));\n --_c-autocomplete-option-text-color: var(--c-autocomplete-option-text-color, var(--c-text-body));\n --_c-autocomplete-placeholder-color: var(--c-autocomplete-placeholder-color, var(--c-tertiary-500));\n\n // c-select options\n --c-select-option-background-color: var(\n --_c-autocomplete-option-background-color\n );\n --c-select-option-background-color-hover: var(\n --_c-autocomplete-option-background-hover-color\n );\n --c-select-option-text-color: var(--_c-autocomplete-option-text-color);\n\n // c-input\n --_c-input-active-color: var(--_c-autocomplete-active-color);\n --_c-input-inactive-color: var(--_c-autocomplete-inactive-color);\n --_c-input-background-color: var(--_c-autocomplete-background-color);\n --_c-input-text-color: var(--_c-autocomplete-text-color);\n --_c-input-placeholder-color: var(--_c-autocomplete-placeholder-color);\n}\n\n@import \"../c-input/c-input-menu\";\n","import {\n AttachInternals,\n Component,\n Element,\n Host,\n Prop,\n State,\n h,\n Listen,\n Event,\n EventEmitter,\n Watch,\n Method,\n} from '@stencil/core';\nimport { mdiChevronDown } from '@mdi/js';\nimport { CAutocompleteItem } from '../../types';\n\n/**\n * @group Form\n * @slot pre - Content added before the input\n * @slot post - Content added after the input\n */\n@Component({\n tag: 'c-autocomplete',\n styleUrl: 'c-autocomplete.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CAutocomplete {\n @Element() el: HTMLCAutocompleteElement;\n\n // eslint-disable-next-line\n @AttachInternals() internals: ElementInternals;\n\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Shadow variant\n */\n @Prop() shadow = false;\n\n /**\n * Input field name\n */\n @Prop() name: string;\n\n /**\n * Element label\n */\n @Prop() label: string;\n\n /**\n * Search string\n */\n @Prop({ mutable: true }) query: string = null;\n\n /**\n * Selected item\n */\n @Prop({ mutable: true }) value: string | number | CAutocompleteItem = null;\n\n /**\n * Dense variant\n */\n @Prop() dense: boolean;\n\n /**\n * Show required validation\n */\n @Prop() required = false;\n\n /**\n * Set the validíty of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Placeholder text\n */\n @Prop() placeholder = '';\n\n /**\n * Return only the item value rather than the whole item object\n */\n @Prop() returnValue: false;\n\n /**\n * Items to be selected\n */\n @Prop() items: CAutocompleteItem[] = [];\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * display the option as selection (works only when c-option elements are used)\n */\n @Prop() optionAsSelection: false;\n\n /**\n * Triggered when text is typed\n */\n @Event() changeQuery: EventEmitter;\n\n /**\n * Triggered when an item is selected\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Sets the value of the autocomplete externally\n */\n @Method()\n async setValue(event, item) {\n this._select(event, item);\n }\n\n /**\n * Hide menu\n * @private\n */\n @Method()\n async onHideMenu() {\n this.menuVisible = false;\n }\n\n /**\n * @private\n */\n @Method()\n async setActiveDescendant(id: string) {\n if (!id) {\n this._inputElement.removeAttribute('aria-activedescendant');\n\n return;\n }\n\n this._inputElement.setAttribute('aria-activedescendant', id);\n }\n\n /**\n * @private\n */\n @Method()\n async updateQuery(query: string) {\n this.query = query;\n this.changeQuery.emit(this.query);\n this.changeValue.emit(null);\n }\n\n /**\n * Select item by index\n */\n @Method()\n async onItemSelection(index: number) {\n this.currentIndex = index;\n\n const selectedItem = this._items[this.currentIndex];\n\n this.value = selectedItem;\n this.query = selectedItem.name;\n }\n\n private _setFormValue(item) {\n if (!item) return;\n\n const value = this.returnValue ? item : (item as CAutocompleteItem).value;\n\n this.internals.setFormValue(value as string);\n }\n\n private _valueChangedHandler(item: string | number | CAutocompleteItem) {\n function isItem(element) {\n return element === item;\n }\n\n this.currentIndex = this.items.findIndex(isItem);\n\n const value = this.returnValue ? (item as CAutocompleteItem)?.value : item;\n\n this._setFormValue(item);\n\n this.changeValue.emit(value);\n }\n\n private _cOptionElements: Record<string, HTMLCOptionElement> = {};\n\n private _optionItems: CAutocompleteItem[] = [];\n\n private _inputId: string;\n\n private static _uniqueId = 0;\n\n private _direction = null;\n\n private _inputElement: HTMLInputElement;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n get _items() {\n return this.hasOptionItems ? this._optionItems : this.items;\n }\n\n @State() menuVisible = false;\n\n @State() currentIndex: number = null;\n\n @State() hasOptionItems = false;\n\n @State() options: Record<string, HTMLCOptionElement> = {};\n\n private get _itemValues() {\n return this.items.map((item) => item.value);\n }\n\n private get _filteredOptions() {\n if (!Object.keys(this._cOptionElements).length) return {};\n\n return this._itemValues.reduce((items, item) => {\n if (!this._cOptionElements[item as string]) return items;\n\n items[item as string] = this._cOptionElements[item as string].cloneNode(\n true,\n ) as HTMLCOptionElement;\n\n return items;\n }, {} as Record<string, HTMLCOptionElement>);\n }\n\n @Watch('items')\n watchHandler(items) {\n this.currentIndex = !!items.length ? 0 : null;\n\n this._optionItems = this._optionItems.filter((item) =>\n this._itemValues.includes(item.value),\n );\n\n requestAnimationFrame(async () => {\n await this._dropdownElement.updateDropdown({\n items: items,\n options: this._filteredOptions,\n });\n });\n }\n\n @Watch('value')\n onValueChange() {\n if (!this.value) return;\n\n requestAnimationFrame(() => {\n const realValue = !(this.value as CAutocompleteItem)?.value\n ? this._items.find((item) => item.value === this.value)\n : this.value;\n\n this._valueChangedHandler(realValue as CAutocompleteItem);\n });\n }\n\n @Listen('keydown', { passive: true })\n handleKeyDown(ev: KeyboardEvent) {\n const alphanumeric = /^[0-9a-zA-Z]+$/;\n\n if (ev.key.match(alphanumeric) && ev.key.length === 1) {\n this._showMenu(false);\n\n if (!this.query) {\n this.updateQuery(ev.key);\n }\n\n this._inputElement.focus();\n }\n\n if (ev.key === 'Tab') {\n this._dropdownElement.close();\n }\n\n if (ev.key === 'ArrowDown') {\n ev.preventDefault();\n\n this._dropdownElement.open();\n this._dropdownElement.focusItem(0);\n }\n\n if (ev.key === 'ArrowUp') {\n ev.preventDefault();\n\n this._dropdownElement.open();\n this._dropdownElement.focusItem(this._items.length - 1);\n }\n\n if (ev.key === ' ') {\n ev.preventDefault();\n\n this._showMenu();\n }\n }\n\n private _showMenu(focusList = true) {\n if (this.disabled) return;\n\n this._dropdownElement.open(focusList);\n\n if (focusList) {\n this._dropdownElement.focusDropdown();\n }\n }\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (!entry.isIntersecting) {\n entry.target.scrollIntoView({\n block: this._direction,\n inline: 'nearest',\n });\n observer.unobserve(entry.target);\n } else {\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n private _getOptionItems() {\n requestAnimationFrame(() => {\n this._cOptionElements = {};\n\n let selection: CAutocompleteItem | null = null;\n\n this._optionItems = (\n this.el ? Array.from(this.el.querySelectorAll('c-option')) : []\n ).map((item, index) => {\n const cAutocompleteItem = {\n value: item.value,\n name: item.name || item.innerText,\n disabled: !!item.disabled,\n } as CAutocompleteItem;\n\n if (item.selected) {\n selection = cAutocompleteItem;\n }\n\n item.slot = `option-${index}`;\n\n this.options[item.value] = item.cloneNode(true) as HTMLCOptionElement;\n\n this._cOptionElements[item.value.toString()] = item.cloneNode(\n true,\n ) as HTMLCOptionElement;\n\n return cAutocompleteItem;\n });\n\n this.hasOptionItems = !!this._optionItems.length;\n\n if (selection) {\n this._valueChangedHandler(selection);\n }\n });\n }\n\n private _handleSlotChange = () => {\n this._getOptionItems();\n };\n\n private handleChange(event) {\n this.menuVisible = true;\n this.query = event.target.value;\n this.changeQuery.emit(this.query);\n this.changeValue.emit(null);\n }\n\n private _select(event, item) {\n event.preventDefault();\n event.stopPropagation();\n this.query = item.name;\n this.value = item;\n this._valueChangedHandler(item);\n this.menuVisible = false;\n }\n\n componentWillLoad() {\n CAutocomplete._uniqueId += 1;\n\n this._inputId =\n 'input_' +\n (this.hostId || this.label || this.placeholder).replace(\n /[^a-zA-Z0-9-_]/g,\n '',\n );\n }\n\n componentDidLoad() {\n this._getOptionItems();\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n private _renderChevron() {\n const classes = {\n 'c-input-menu__chevron': true,\n 'c-input-menu__chevron--active': this.menuVisible,\n };\n\n return (\n <svg class={classes} viewBox=\"0 0 24 24\">\n <path d={mdiChevronDown} />\n </svg>\n );\n }\n\n private _renderInputElement() {\n return (\n <div class=\"c-input-menu__input\">\n <input\n type=\"text\"\n ref={(el) => (this._inputElement = el)}\n aria-expanded={this.menuVisible.toString()}\n aria-owns={this._inputId + '-items'}\n aria-autocomplete=\"list\"\n autocomplete=\"off\"\n class=\"c-input__input\"\n role=\"combobox\"\n value={this.query}\n name={this.name ?? null}\n onInput={(event) => this.handleChange(event)}\n />\n </div>\n );\n }\n\n render() {\n return (\n <Host title={this.query}>\n <c-input\n autofocus={this.autofocus}\n disabled={this.disabled}\n hide-details={this.hideDetails}\n hint={this.hint}\n id={this.hostId}\n input-id={this._inputId}\n label={this.label}\n name={this.name}\n placeholder={this.placeholder}\n required={this.required}\n shadow={this.shadow}\n valid={this.valid}\n validate={this.validate}\n validate-on-blur={this.validateOnBlur}\n validation={this.validation}\n value={this.query}\n variant=\"select\"\n onItemClick={() => this.items.length && this._showMenu(false)}\n >\n <slot name=\"pre\" slot=\"pre\"></slot>\n\n <div class=\"c-input__content\">\n {this._renderInputElement()}\n {this._renderChevron()}\n\n <slot onSlotchange={this._handleSlotChange}></slot>\n </div>\n\n <c-dropdown\n ref={(el) => (this._dropdownElement = el)}\n slot=\"dropdown\"\n items={this._items}\n options={this._cOptionElements}\n items-per-page={this.itemsPerPage}\n parent={this.el}\n index={this.currentIndex}\n input-id={this._inputId}\n type=\"autocomplete\"\n />\n\n <slot name=\"post\" slot=\"post\"></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,OAChB+E,EAAA,WACEc,UAAW5H,KAAK4H,UAChBxC,SAAUpF,KAAKoF,SAAQ,eACTpF,KAAK6H,YACnBC,KAAM9H,KAAK8H,KACXpG,GAAI1B,KAAKqG,OAAM,WACLrG,KAAKoG,SACfE,MAAOtG,KAAKsG,MACZ7D,KAAMzC,KAAKyC,KACX8D,YAAavG,KAAKuG,YAClBwB,SAAU/H,KAAK+H,SACfC,OAAQhI,KAAKgI,OACbC,MAAOjI,KAAKiI,MACZC,SAAUlI,KAAKkI,SAAQ,mBACLlI,KAAKmI,eACvBC,WAAYpI,KAAKoI,WACjB5F,MAAOxC,KAAK+B,MACZsG,QAAQ,SACRC,YAAa,IAAMtI,KAAKiD,MAAMQ,QAAUzD,KAAK6E,UAAU,QAEvDiC,EAAA,QAAMrE,KAAK,MAAMqD,KAAK,QAEtBgB,EAAA,OAAKC,MAAM,oBACR/G,KAAKmH,sBACLnH,KAAK4G,iBAENE,EAAA,QAAMyB,aAAcvI,KAAKiB,qBAG3B6F,EAAA,cACEO,IAAM9B,GAAQvF,KAAKiE,iBAAmBsB,EACtCO,KAAK,WACL7C,MAAOjD,KAAKuC,OACZ4B,QAASnE,KAAKC,iBAAgB,iBACdD,KAAKwI,aACrBC,OAAQzI,KAAKuF,GACbnD,MAAOpC,KAAKqC,aAAY,WACdrC,KAAKoG,SACfgB,KAAK,iBAGPN,EAAA,QAAMrE,KAAK,OAAOqD,KAAK,U,gJA/RhB/F,EAAAoG,UAAY,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as t,c as i,h as e,H as o,g as c}from"./p-9d54e9a4.js";import{d as a,h as s,b as r,t as n}from"./p-dffa1f9f.js";const h='html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-checkbox-background-color-hover:var(--c-checkbox-background-color-hover, rgba(var(--c-primary-rgb), 0.1));--_c-checkbox-color-active:var(--c-checkbox-color-active, var(--_c-checkbox-color));--_c-checkbox-color-disabled:var(--c-checkbox-color-disabled, var(--c-tertiary-500));--_c-checkbox-color:var(--c-checkbox-color, var(--c-primary-600));--_c-checkbox-color-error:var(--c-error-600)}.c-checkbox{position:relative;width:fit-content}.c-checkbox__details{line-height:1;padding:0 12px}.c-checkbox__details.active .c-checkbox__message{opacity:1;transform:translateY(0)}.c-checkbox__message{font-size:12px;opacity:0;transform:translateY(-4px);transition:all 0.2s cubic-bezier(0.25, 0.8, 0.5, 1)}.c-checkbox__message--hint{color:var(--c-tertiary-500)}.c-checkbox__message--error{color:var(--_c-checkbox-color-error)}.c-checkbox__message span{align-items:flex-start;color:currentColor;display:flex;gap:4px;height:16px}.c-checkbox__message svg{fill:currentColor;min-height:16px;min-width:16px;position:relative;top:-2px}.c-checkbox__label-content{padding-top:10px;text-align:left;user-select:none}.c-checkbox__label-content span.required{color:var(--c-error-600)}.c-checkbox--disabled{--_c-checkbox-color:var(--_c-checkbox-color-disabled);--c-error-600:var(--_c-checkbox-color);--_c-checkbox-color-active:var(--_c-checkbox-color-disabled);color:var(--_c-checkbox-color);opacity:0.75}.c-checkbox--disabled .c-checkbox__label{cursor:default}.c-checkbox--error{--_c-checkbox-color:var(--c-error-600);--_c-checkbox-color-active:var(--_c-checkbox-color-error);color:var(--_c-checkbox-color-error)}.c-checkbox input:focus{outline:none}.c-checkbox input:focus+.c-checkbox__label .ripple{outline:2px var(--_c-checkbox-color-active) solid}@supports selector(:focus-visible){.c-checkbox input:focus+.c-checkbox__label .ripple{outline:none}}.c-checkbox input:focus-visible+.c-checkbox__label .ripple{outline:2px var(--_c-checkbox-color-active) solid}.c-checkbox:not(.c-checkbox--disabled) .ripple:hover{background-color:var(--_c-checkbox-background-color-hover)}.c-checkbox .visuallyhidden{border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}.c-checkbox input:checked+.c-checkbox__label .ripple::before{background:var(--_c-checkbox-color-active);border-color:var(--_c-checkbox-color-active)}.c-checkbox input:checked+.c-checkbox__label .path{stroke:#ffffff;fill:#ffffff;stroke-dashoffset:0;stroke-width:13;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.c-checkbox__label{cursor:pointer;display:flex;gap:4px;position:relative;user-select:none}.c-checkbox__label svg{height:14px;left:14px;position:absolute;top:14px;width:14px}.c-checkbox__label--indeterminate .path{stroke-dasharray:0 !important;stroke-dashoffset:0 !important;stroke:transparent}.c-checkbox__label .ripple{border-radius:50%;color:var(--_c-checkbox-color-active);display:grid;height:42px;min-width:42px;overflow:hidden;place-content:center;position:relative;transform:translateZ(0);width:42px}.c-checkbox__label .ripple::before{border-radius:2px;border:2px solid var(--_c-checkbox-color);content:"";display:inline-block;height:18px;left:12px;position:absolute;top:12px;transition:all 0.25s ease-out;vertical-align:middle;width:18px}';const l=class{constructor(o){t(this,o);this.changeValue=i(this,"changeValue",3);if(o.$hostElement$["s-ei"]){this.internals=o.$hostElement$["s-ei"]}else{this.internals=o.$hostElement$.attachInternals();o.$hostElement$["s-ei"]=this.internals}this._validationIcon=e("svg",{height:"16px",width:"16px",viewBox:"0 0 24 24"},e("path",{d:a}));this.checked=false;this.disabled=false;this.hideDetails=false;this.hint="";this.indeterminate=false;this.label="";this.required=false;this.valid=true;this.validation="Required field";this.value=false;this.trueValue=true;this.falseValue=false;this.hostName=undefined;this.messageOptions={show:false,type:"hint",content:""}}onValidationMessageChange(t){this.onValidChange(t.length===0)}onValidChange(t){this._handleValidation(t||this.valid)}handleKeyDown(t){if(["Space"].includes(t.code)){t.preventDefault();this._toggleState(t)}}componentWillLoad(){if(this.value===this.trueValue){this.checked=true}if(this.checked){this.internals.setFormValue(this.value)}}componentDidLoad(){this._handleMessageOptions(this.valid)}_handleMessageOptions(t){requestAnimationFrame((()=>{this.messageOptions=Object.assign(Object.assign({},this.messageOptions),{type:t?"hint":"error",show:true,content:t?e("span",null,this.hint):e("span",null,this._validationIcon," ",this.validation)})}))}_handleValidation(t,i=200){setTimeout((()=>{this._handleMessageOptions(t)}),i)}_toggleState(t){if(this.disabled)return;this._rippleElement.createRipple(t,this._container,true);this.checked=!this.checked;if(typeof this.value==="string"&&typeof this.trueValue==="boolean"){this.changeValue.emit(this.value);this.internals.setFormValue(this.checked?this.value:null);return}this.changeValue.emit(this.checked?this.trueValue:this.falseValue)}_renderMessages(){if(this.hideDetails)return;const t={"c-checkbox__details":true,active:this.messageOptions.show};const i={"c-checkbox__message":true,[`c-checkbox__message--${this.messageOptions.type}`]:true};return e("div",{class:t},e("div",{class:i},this.messageOptions.content))}render(){const t={"c-checkbox":true,"c-checkbox--disabled":this.disabled,"c-checkbox--error":this.messageOptions.type==="error"};const i={"c-checkbox__label":true,"c-checkbox__label--indeterminate":this.indeterminate};const c=!!this.el.childNodes.length;return e(o,null,e("div",{class:t},e("input",Object.assign({class:"visuallyhidden",id:"checkbox"},!!this.hostName?{name:this.hostName}:{},{type:"checkbox","aria-checked":this.checked.toString(),"aria-disabled":this.disabled.toString(),checked:this.checked?true:undefined,disabled:this.disabled,onChange:t=>this._toggleState(t)})),e("label",{class:i,htmlFor:"checkbox"},e("div",{class:"ripple",ref:t=>this._container=t},e("svg",{viewBox:"0 0 100 100"},!this.indeterminate&&this.checked&&e("path",{class:"path",d:"M 12 52 l 24 24 l 47 -47 l -3 -3 l -44 44 l -21 -21 l -3 3"}),this.indeterminate&&e("path",{class:"path",d:"M20 56 h60 v-8 h-60 z"})),e("c-ripple",{ref:t=>this._rippleElement=t})),(!!this.label||c)&&e("div",{class:"c-checkbox__label-content"},!!this.label?this.label:e("slot",null),this.required&&e("span",{class:"required"}," *")))),this._renderMessages())}static get formAssociated(){return true}get el(){return c(this)}static get watchers(){return{validation:["onValidationMessageChange"],valid:["onValidChange"]}}};l.style=h;const p="html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-pagination-button-active-background-color:var(--c-pagination-button-active-background-color, var(--c-primary-600));--_c-pagination-button-active-background-color-hover:var(--c-pagination-button-active-background-color-hover, var(--c-primary-400));--_c-pagination-button-active-text-color:var(--c-pagination-button-active-text-color, var(--c-white));--_c-pagination-button-background-color:var(--c-pagination-button-background-color, var(--c-transparent));--_c-pagination-button-background-color-hover:var(--c-pagination-button-background-color-hover, rgba(var(--c-primary-rgb), 0.1));--_c-pagination-button-text-color:var(--c-pagination-button-text-color, var(--_c-pagination-button-active-background-color));--_c-pagination-menu-text-color:var(--c-pagination-menu-text-color, var(--c-text-system));--_c-pagination-menu-text-color-active:var(--c-pagination-menu-text-color-active, var(--c-primary-600));--_c-pagination-menu-background-color-hover:var(--c-pagination-menu-background-color-hover, var(--c-primary-200));--_c-pagination-menu-outline-color:var(--c-pagination-menu-outline-color, var(--c-primary-600));display:block}:host c-icon-button{--c-icon-button-background-color:var(--_c-pagination-button-active-background-color);--c-icon-button-background-color-hover:var(--_c-pagination-button-active-background-color-hover);--c-icon-button-text-color:var(--_c-pagination-button-active-text-color);--c-icon-button-text-background-color:var(--_c-pagination-button-background-color);--c-icon-button-text-background-color-hover:var(--_c-pagination-button-background-color-hover);--c-icon-button-text-text-color:var(--_c-pagination-button-text-color)}:host span{font-size:14px;text-align:right;white-space:nowrap}:host .range{min-width:132px}:host .visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}:host(.c-pagination) nav{align-items:center;display:flex;flex-wrap:wrap;gap:0 24px;justify-content:center;width:100%}:host(.c-pagination) ul{align-items:center;display:flex;gap:4px;justify-content:center;list-style:none;margin:0;padding:0}:host(.c-pagination) .c-pagination__details{align-items:center;display:flex;flex-wrap:wrap;flex:auto;justify-content:space-between}:host(.c-pagination) .c-pagination__items-per-page{color:var(--c-text-system);font-size:14px;text-align:right;white-space:nowrap;display:flex;align-items:center;gap:4px}:host(.c-pagination) c-menu{--c-menu-text-color:var(--_c-pagination-menu-text-color);--c-menu-text-color-active:var(--_c-pagination-menu-text-color-active);--c-menu-background-color-hover:var(--_c-pagination-menu-background-color-hover);--c-menu-outline-color:var(--_c-pagination-menu-outline-color)}:host(.c-pagination--simple) ul{flex:1;justify-content:flex-end}:host(.c-pagination--small) ul{gap:2px}";const u=class{constructor(e){t(this,e);this.changeValue=i(this,"changeValue",3);this._textContent={itemsPerPageText:"Items per page:",nextPage:"Next page",prevPage:"Previous page"};this._buttons=[];this._increasePageNumber=()=>{if(this._currentPage<this._getTotalPages()){this._currentPage+=1;this._valueChangeHandler()}};this._decreasePageNumber=()=>{if(this._currentPage>1){this._currentPage-=1;this._valueChangeHandler()}};this.value={itemCount:0};this.hideDetails=false;this.simple=false;this.size="default";this._currentPage=undefined;this._itemsPerPage=undefined;this._totalVisible=undefined;this.hideRange=false;this.itemsPerPageOptions=[5,25,50,100];this.tick=""}valueHandler(t,i){if(this._isEqual(t,i))return;requestAnimationFrame((()=>{this._setRange()}))}_isEqual(t,i){const e=Object.keys(t||{});const o=Object.keys(i||{});if(e.length!==o.length){return false}for(const o of e){if(t[o]!==i[o]){return false}}return true}componentWillLoad(){this._setRange()}_getText(t){var i;const e=((i=this.value.textOverrides)===null||i===void 0?void 0:i[t])?this.value.textOverrides:this._textContent;return e[t]}_setRange(){if(!this.value)return;this._currentPage=this.value.currentPage||1;this._itemsPerPage=this.value.itemsPerPage||25;this._totalVisible=this.value.totalVisible||7;this.value.startFrom=this._currentPage*this._itemsPerPage-this._itemsPerPage;this.value.endTo=this._currentPage*this._itemsPerPage-1;this.changeValue.emit(this.value)}_valueChangeHandler(){this.value.currentPage=this._currentPage;this.value.itemsPerPage=this._itemsPerPage;this._setRange()}_renderMenu(){const t=this.itemsPerPageOptions.map((t=>({name:t.toString(),action:()=>{this._itemsPerPage=t;this._currentPage=1;this._valueChangeHandler()}})));const i=t=>{t.stopPropagation()};return e("div",{class:"c-pagination__items-per-page"},this._getText("itemsPerPageText"),e("c-menu",{items:t,onClick:i},e("div",null,e("span",{class:"items-per-page"},this._itemsPerPage))))}_getTotalPages(){return Math.ceil(this.value.itemCount/this._itemsPerPage)}_setPage(t){this._currentPage=t;this._valueChangeHandler()}_getRange(){var t;if(this.hideRange||!this.value.itemCount)return;const i=Math.min(this._currentPage*this._itemsPerPage,this.value.itemCount);const e=this.value.startFrom+1;const o=(t=this.value.textOverrides)===null||t===void 0?void 0:t.pageText;let c;if(o){c=o({start:e,end:i,count:this.value.itemCount})}return o?c:`${e} - ${i} of ${this.value.itemCount} items`}_getArrowLeft(t){return e("li",null,e("c-icon-button",{"aria-disabled":this.value.currentPage<=1?"true":"false","aria-label":`${this._getText("prevPage")}`,disabled:this.value.currentPage<=1,size:t,text:true,onClick:this._decreasePageNumber},e("span",{class:"visuallyhidden"},this._getText("prevPage")),e("c-icon",{path:s})))}_getArrowRight(t){return e("li",null,e("c-icon-button",{"aria-disabled":this.value.currentPage>=this._getTotalPages()?"true":"false","aria-label":`${this._getText("nextPage")}`,disabled:this.value.currentPage>=this._getTotalPages(),size:t,text:true,onClick:this._increasePageNumber},e("span",{class:"visuallyhidden"},this._getText("nextPage")),e("c-icon",{path:r})))}_button(t,i){var o;const c={text:this._currentPage!==t,onClick:()=>this._setPage(t),size:i};if(this._currentPage===t){c["aria-current"]="page"}const a=(o=this.value.textOverrides)===null||o===void 0?void 0:o.pageOfText;let s;if(a){s=a({pageNumber:t,count:this._getTotalPages()})}return e("li",null,e("c-icon-button",Object.assign({},c),e("span",{"aria-label":a?s:`page ${t} of ${this._getTotalPages()}`},t)))}_addButton(t,i){this._buttons.push(this._button(t,i))}_addSeparator(t){this._buttons.push(e("li",null,e("c-icon-button",{"aria-disabled":"true",size:t,tabindex:"-1",role:"separator",disabled:true,text:true},e("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},e("path",{d:n})))))}_addButtons(t,i,e){if(t>1){this._addButton(1,e);this._addSeparator(e)}for(let o=1;o<i;o++){this._addButton(t+o,e)}const o=this._getTotalPages()<=this._totalVisible;if((this._currentPage<this._totalVisible-1||this._currentPage<this._getTotalPages()-this._totalVisible+4)&&!o){this._addSeparator(e)}}_getPageButtons(t){this._buttons=[];let i=0;let e=this._getTotalPages()+1;const o=this._getTotalPages()>this._totalVisible;if(o){if(this._currentPage<this._totalVisible-2){e=this._totalVisible-1}else if(this._currentPage<this._getTotalPages()-this._totalVisible+4){i=Math.ceil(this._currentPage-this._totalVisible/2)+1;e=this._totalVisible-3}else{i=this._getTotalPages()-this._totalVisible+2;e=this._totalVisible-2}}this._addButtons(i,e,t);if(o){this._buttons.push(this._button(this._getTotalPages(),t))}return this._buttons}_renderPaginationButtons(){if(!this.value.itemCount)return"";const t=this.size==="small"?"x-small":"small";return e("ul",null,this._getArrowLeft(t),!this.simple&&this._getPageButtons(t),this._getArrowRight(t))}render(){const t={"c-pagination":true,"c-pagination--small":this.size==="small","c-pagination--simple":this.simple};return e(o,{class:t},e("nav",{role:"navigation","aria-label":"pagination"},!this.hideDetails&&e("div",{class:"c-pagination__details"},this._renderMenu(),e("span",{class:{range:!this.simple}},this._getRange())),this._renderPaginationButtons()))}static get watchers(){return{value:["valueHandler"]}}};u.style=p;export{l as c_checkbox,u as c_pagination};
|
|
2
|
+
//# sourceMappingURL=p-bf307cb4.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cCheckboxCss","CCheckbox","this","_validationIcon","h","height","width","viewBox","d","mdiCloseCircle","show","type","content","onValidationMessageChange","message","onValidChange","length","valid","_handleValidation","handleKeyDown","event","includes","code","preventDefault","_toggleState","componentWillLoad","value","trueValue","checked","internals","setFormValue","componentDidLoad","_handleMessageOptions","requestAnimationFrame","messageOptions","Object","assign","hint","validation","timeout","setTimeout","disabled","_rippleElement","createRipple","_container","changeValue","emit","falseValue","_renderMessages","hideDetails","classes","active","messageClasses","class","render","wrapperClasses","labelClasses","indeterminate","slotHasContent","el","childNodes","Host","id","hostName","name","toString","undefined","onChange","htmlFor","ref","label","required","cPaginationCss","CPagination","_textContent","itemsPerPageText","nextPage","prevPage","_buttons","_increasePageNumber","_currentPage","_getTotalPages","_valueChangeHandler","_decreasePageNumber","itemCount","valueHandler","oldValue","_isEqual","_setRange","options1","options2","keys1","keys","keys2","key","_getText","source","_a","textOverrides","currentPage","_itemsPerPage","itemsPerPage","_totalVisible","totalVisible","startFrom","endTo","_renderMenu","itemsPerPageOptions","map","i","action","onMenuClick","stopPropagation","items","onClick","Math","ceil","_setPage","number","_getRange","hideRange","end","min","start","pageTextOverride","pageText","parsedPageTextOverride","count","_getArrowLeft","size","text","path","mdiChevronLeft","_getArrowRight","mdiChevronRight","_button","params","pageOfTextOverride","pageOfText","parsedPageOfTextOverride","pageNumber","_addButton","push","_addSeparator","tabindex","role","mdiDotsHorizontal","_addButtons","buttonStart","buttonCount","index","allPagesVisible","_getPageButtons","morePagesThanVisible","_renderPaginationButtons","buttonsize","simple","range"],"sources":["src/components/c-checkbox/c-checkbox.scss?tag=c-checkbox&encapsulation=shadow","src/components/c-checkbox/c-checkbox.tsx","src/components/c-pagination/c-pagination.scss?tag=c-pagination&encapsulation=shadow","src/components/c-pagination/c-pagination.tsx"],"sourcesContent":[":host {\n /**\n * @prop --c-checkbox-background-color-hover: Checkbox hover background color\n * @prop --c-checkbox-color-active: Active checkbox color\n * @prop --c-checkbox-color-disabled: Disabled checkbox color\n * @prop --c-checkbox-color: Checkbox color\n */\n --_c-checkbox-background-color-hover: var(--c-checkbox-background-color-hover, rgba(var(--c-primary-rgb), 0.1));\n --_c-checkbox-color-active: var(--c-checkbox-color-active, var(--_c-checkbox-color));\n --_c-checkbox-color-disabled: var(--c-checkbox-color-disabled, var(--c-tertiary-500));\n --_c-checkbox-color: var(--c-checkbox-color, var(--c-primary-600));\n\n // private\n --_c-checkbox-color-error: var(--c-error-600);\n}\n\n.c-checkbox {\n $this: &;\n\n position: relative;\n width: fit-content;\n\n &__details {\n line-height: 1;\n padding: 0 12px;\n\n &.active {\n #{$this} {\n &__message {\n opacity: 1;\n transform: translateY(0);\n }\n }\n }\n }\n\n &__message {\n font-size: 12px;\n opacity: 0;\n transform: translateY(-4px);\n transition: all 0.2s cubic-bezier(0.25, 0.8, 0.5, 1);\n\n &--hint {\n color: var(--c-tertiary-500);\n }\n\n &--error {\n color: var(--_c-checkbox-color-error);\n }\n\n span {\n align-items: flex-start;\n color: currentColor;\n display: flex;\n gap: 4px;\n height: 16px;\n }\n\n svg {\n fill: currentColor;\n min-height: 16px;\n min-width: 16px;\n position: relative;\n top: -2px;\n }\n }\n\n &__label-content {\n padding-top: 10px;\n text-align: left;\n user-select: none;\n\n span.required {\n color: var(--c-error-600);\n }\n }\n\n &--disabled {\n --_c-checkbox-color: var(--_c-checkbox-color-disabled);\n --c-error-600: var(--_c-checkbox-color);\n --_c-checkbox-color-active: var(--_c-checkbox-color-disabled);\n\n color: var(--_c-checkbox-color);\n opacity: 0.75;\n\n .c-checkbox__label {\n cursor: default;\n }\n }\n\n &--error {\n --_c-checkbox-color: var(--c-error-600);\n --_c-checkbox-color-active: var(--_c-checkbox-color-error);\n\n color: var(--_c-checkbox-color-error);\n }\n\n input:focus {\n outline: none;\n }\n\n input:focus + .c-checkbox__label .ripple {\n outline: 2px var(--_c-checkbox-color-active) solid;\n }\n\n @supports selector(:focus-visible) {\n input:focus + .c-checkbox__label .ripple {\n outline: none;\n }\n }\n\n input:focus-visible + .c-checkbox__label .ripple {\n outline: 2px var(--_c-checkbox-color-active) solid;\n }\n\n &:not(.c-checkbox--disabled) {\n .ripple:hover {\n background-color: var(--_c-checkbox-background-color-hover);\n }\n }\n\n .visuallyhidden {\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n }\n}\n\n.c-checkbox input:checked + .c-checkbox__label {\n .ripple::before {\n background: var(--_c-checkbox-color-active);\n border-color: var(--_c-checkbox-color-active);\n }\n\n .path {\n stroke: #ffffff;\n fill: #ffffff;\n stroke-dashoffset: 0;\n stroke-width: 13;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke-miterlimit: 10;\n }\n}\n\n.c-checkbox__label {\n cursor: pointer;\n display: flex;\n gap: 4px;\n position: relative;\n user-select: none;\n\n svg {\n height: 14px;\n left: 14px;\n position: absolute;\n top: 14px;\n width: 14px;\n }\n\n &--indeterminate .path {\n stroke-dasharray: 0 !important;\n stroke-dashoffset: 0 !important;\n stroke: transparent;\n }\n\n .ripple {\n border-radius: 50%;\n color: var(--_c-checkbox-color-active);\n display: grid;\n height: 42px;\n min-width: 42px;\n overflow: hidden;\n place-content: center;\n position: relative;\n transform: translateZ(0);\n width: 42px;\n\n &::before {\n border-radius: 2px;\n border: 2px solid var(--_c-checkbox-color);\n content: \"\";\n display: inline-block;\n height: 18px;\n left: 12px;\n position: absolute;\n top: 12px;\n transition: all 0.25s ease-out;\n vertical-align: middle;\n width: 18px;\n }\n }\n}\n","import {\n Component,\n Host,\n h,\n Listen,\n Prop,\n Event,\n EventEmitter,\n State,\n Watch,\n Element,\n AttachInternals,\n} from '@stencil/core';\nimport { mdiCloseCircle } from '@mdi/js';\n\n/**\n * @group Form\n * @slot Default slot - Default slot for the label\n */\n@Component({\n tag: 'c-checkbox',\n styleUrl: 'c-checkbox.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CCheckbox {\n @Element() el: HTMLCCheckboxElement;\n\n // eslint-disable-next-line @stencil-community/own-props-must-be-private\n @AttachInternals() internals: ElementInternals;\n\n /**\n * If `true`, the checkbox is selected.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * Disable the checkbox\n */\n @Prop() disabled = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Indeterminate state\n */\n @Prop() indeterminate = false;\n\n /**\n * Element label\n */\n @Prop() label = '';\n\n /**\n * Set as required\n */\n @Prop() required = false;\n\n /**\n * Set the validity of the input\n */\n @Prop() valid = true;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * The input value\n * - Only used when the checkbox participates in a native `<form>`\n */\n @Prop() value: string | boolean = false;\n\n /**\n * The value when the checkbox is checked\n */\n @Prop() trueValue: boolean | string = true;\n\n /**\n * The value when the checkbox is unchecked\n */\n @Prop() falseValue: boolean | string = false;\n\n /**\n * Name of the input\n * - Only used when the checkbox participates in a native `<form>`\n */\n @Prop({ attribute: 'name' }) hostName: string;\n\n /**\n * Triggered when element is checked or unchecked\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n @State() messageOptions = {\n show: false,\n type: 'hint',\n content: '',\n };\n\n private _container: HTMLDivElement;\n\n private _rippleElement: HTMLCRippleElement;\n\n private _validationIcon = (\n <svg height=\"16px\" width=\"16px\" viewBox=\"0 0 24 24\">\n <path d={mdiCloseCircle} />\n </svg>\n );\n\n @Watch('validation')\n onValidationMessageChange(message: string) {\n this.onValidChange(message.length === 0);\n }\n\n @Watch('valid')\n onValidChange(valid: boolean) {\n this._handleValidation(valid || this.valid);\n }\n\n @Listen('keydown', { passive: true })\n handleKeyDown(event: KeyboardEvent) {\n if (['Space'].includes(event.code)) {\n event.preventDefault();\n this._toggleState(event);\n }\n }\n\n componentWillLoad() {\n if (this.value === this.trueValue) {\n this.checked = true;\n }\n\n if (this.checked) {\n this.internals.setFormValue(this.value as string);\n }\n }\n\n componentDidLoad() {\n this._handleMessageOptions(this.valid);\n }\n\n private _handleMessageOptions(valid: boolean) {\n requestAnimationFrame(() => {\n this.messageOptions = {\n ...this.messageOptions,\n type: valid ? 'hint' : 'error',\n show: true,\n content: valid ? (\n <span>{this.hint}</span>\n ) : (\n <span>\n {this._validationIcon} {this.validation}\n </span>\n ),\n };\n });\n }\n\n private _handleValidation(valid: boolean, timeout = 200) {\n setTimeout(() => {\n this._handleMessageOptions(valid);\n }, timeout);\n }\n\n private _toggleState(event) {\n if (this.disabled) return;\n\n this._rippleElement.createRipple(event, this._container, true);\n\n this.checked = !this.checked;\n\n if (typeof this.value === 'string' && typeof this.trueValue === 'boolean') {\n this.changeValue.emit(this.value);\n\n this.internals.setFormValue(this.checked ? (this.value as string) : null);\n\n return;\n }\n\n this.changeValue.emit(this.checked ? this.trueValue : this.falseValue);\n }\n\n private _renderMessages() {\n if (this.hideDetails) return;\n\n const classes = {\n 'c-checkbox__details': true,\n active: this.messageOptions.show,\n };\n\n const messageClasses = {\n 'c-checkbox__message': true,\n [`c-checkbox__message--${this.messageOptions.type}`]: true,\n };\n\n return (\n <div class={classes}>\n <div class={messageClasses}>{this.messageOptions.content}</div>\n </div>\n );\n }\n\n render() {\n const wrapperClasses = {\n 'c-checkbox': true,\n 'c-checkbox--disabled': this.disabled,\n 'c-checkbox--error': this.messageOptions.type === 'error',\n };\n\n const labelClasses = {\n 'c-checkbox__label': true,\n 'c-checkbox__label--indeterminate': this.indeterminate,\n };\n\n const slotHasContent = !!this.el.childNodes.length;\n\n return (\n <Host>\n <div class={wrapperClasses}>\n <input\n class=\"visuallyhidden\"\n id=\"checkbox\"\n {...(!!this.hostName ? { name: this.hostName } : {})}\n type=\"checkbox\"\n aria-checked={this.checked.toString()}\n aria-disabled={this.disabled.toString()}\n checked={this.checked ? true : undefined}\n disabled={this.disabled}\n onChange={(event) => this._toggleState(event)}\n />\n\n <label class={labelClasses} htmlFor=\"checkbox\">\n <div\n class=\"ripple\"\n ref={(el) => (this._container = el as HTMLDivElement)}\n >\n <svg viewBox=\"0 0 100 100\">\n {!this.indeterminate && this.checked && (\n <path\n class=\"path\"\n d=\"M 12 52 l 24 24 l 47 -47 l -3 -3 l -44 44 l -21 -21 l -3 3\"\n />\n )}\n {this.indeterminate && (\n <path class=\"path\" d=\"M20 56 h60 v-8 h-60 z\" />\n )}\n </svg>\n\n <c-ripple ref={(el) => (this._rippleElement = el)}></c-ripple>\n </div>\n\n {(!!this.label || slotHasContent) && (\n <div class=\"c-checkbox__label-content\">\n {!!this.label ? this.label : <slot></slot>}\n {this.required && <span class=\"required\"> *</span>}\n </div>\n )}\n </label>\n </div>\n\n {this._renderMessages()}\n </Host>\n );\n }\n}\n",":host {\n /**\n * @prop --c-pagination-button-active-background-color: Active pagination button background color\n * @prop --c-pagination-button-active-background-color-hover: Active pagination button hover background color\n * @prop --c-pagination-button-active-text-color: Active pagination button text color\n * @prop --c-pagination-button-background-color: Pagination button background color\n * @prop --c-pagination-button-background-color-hover: Pagination button hover background color\n * @prop --c-pagination-button-text-color: Pagination button text color\n */\n --_c-pagination-button-active-background-color: var(--c-pagination-button-active-background-color, var(--c-primary-600));\n --_c-pagination-button-active-background-color-hover: var(--c-pagination-button-active-background-color-hover, var(--c-primary-400));\n --_c-pagination-button-active-text-color: var(--c-pagination-button-active-text-color, var(--c-white));\n --_c-pagination-button-background-color: var(--c-pagination-button-background-color, var(--c-transparent));\n --_c-pagination-button-background-color-hover: var(--c-pagination-button-background-color-hover, rgba(var(--c-primary-rgb), 0.1));\n --_c-pagination-button-text-color: var(--c-pagination-button-text-color, var(--_c-pagination-button-active-background-color));\n\n /**\n * @prop --c-pagination-menu-text-color: Pagination menu text color\n * @prop --c-pagination-menu-text-color-active: Active pagination menu text color\n * @prop --c-pagination-menu-background-color-hover: Pagination menu hover background color\n * @prop --c-pagination-menu-outline-color: Pagination menu outline color\n */\n --_c-pagination-menu-text-color: var(--c-pagination-menu-text-color, var(--c-text-system));\n --_c-pagination-menu-text-color-active: var(--c-pagination-menu-text-color-active, var(--c-primary-600));\n --_c-pagination-menu-background-color-hover: var(--c-pagination-menu-background-color-hover, var(--c-primary-200));\n --_c-pagination-menu-outline-color: var(--c-pagination-menu-outline-color, var(--c-primary-600));\n\n c-icon-button {\n --c-icon-button-background-color: var(--_c-pagination-button-active-background-color);\n --c-icon-button-background-color-hover: var(--_c-pagination-button-active-background-color-hover);\n --c-icon-button-text-color: var(--_c-pagination-button-active-text-color);\n --c-icon-button-text-background-color: var(--_c-pagination-button-background-color);\n --c-icon-button-text-background-color-hover: var(--_c-pagination-button-background-color-hover);\n --c-icon-button-text-text-color: var(--_c-pagination-button-text-color);\n }\n\n display: block;\n\n span {\n font-size: 14px;\n text-align: right;\n white-space: nowrap;\n }\n\n .range {\n min-width: 132px;\n }\n\n .visuallyhidden {\n border: 0;\n clip: rect(0 0 0 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n }\n}\n\n:host(.c-pagination) {\n nav {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 0 24px;\n justify-content: center;\n width: 100%;\n }\n\n ul {\n align-items: center;\n display: flex;\n gap: 4px;\n justify-content: center;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n .c-pagination__details {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n flex: auto;\n justify-content: space-between;\n }\n\n .c-pagination__items-per-page {\n color: var(--c-text-system);\n font-size: 14px;\n text-align: right;\n white-space: nowrap;\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n c-menu {\n --c-menu-text-color: var(--_c-pagination-menu-text-color);\n --c-menu-text-color-active: var(--_c-pagination-menu-text-color-active);\n --c-menu-background-color-hover: var(--_c-pagination-menu-background-color-hover);\n --c-menu-outline-color: var(--_c-pagination-menu-outline-color);\n }\n}\n\n:host(.c-pagination--simple) {\n ul {\n flex: 1;\n justify-content: flex-end;\n }\n}\n\n:host(.c-pagination--small) {\n ul {\n gap: 2px;\n }\n}\n","import {\n Component,\n h,\n Host,\n Prop,\n Event,\n EventEmitter,\n State,\n Watch,\n} from '@stencil/core';\nimport { mdiChevronLeft, mdiChevronRight, mdiDotsHorizontal } from '@mdi/js';\nimport { CMenuOption, CPaginationOptions } from '../../types';\n\n/**\n * @group Navigation\n */\n\n@Component({\n tag: 'c-pagination',\n styleUrl: 'c-pagination.scss',\n shadow: true,\n})\nexport class CPagination {\n /**\n * Object containing values that are needed for pagination.\n *\n * Note! startFrom and endTo are assigned automatically to the object based on other values\n */\n @Prop() value: CPaginationOptions = {\n itemCount: 0,\n };\n\n /**\n * Hide details (per page dropdown and the 'x - y of n pages' text)\n */\n @Prop() hideDetails = false;\n\n /**\n * Hide page number buttons\n */\n @Prop() simple = false;\n\n /**\n * Hide details (per page dropdown and the 'x - y of n pages' text)\n */\n @Prop() size: 'default' | 'small' = 'default';\n\n @State() private _currentPage;\n\n @State() private _itemsPerPage;\n\n @State() private _totalVisible;\n\n /**\n * Triggered when values are changed\n */\n @Event({ bubbles: false }) changeValue: EventEmitter<CPaginationOptions>;\n\n /**\n * Hide range indicator\n */\n @Prop() hideRange = false;\n\n /**\n * Items per page options\n */\n @Prop() itemsPerPageOptions: number[] = [5, 25, 50, 100];\n\n @State() tick = '';\n\n @Watch('value')\n valueHandler(value: CPaginationOptions, oldValue: CPaginationOptions) {\n if (this._isEqual(value, oldValue)) return;\n\n requestAnimationFrame(() => {\n this._setRange();\n });\n }\n\n private _isEqual(options1: CPaginationOptions, options2: CPaginationOptions) {\n const keys1 = Object.keys(options1 || {});\n const keys2 = Object.keys(options2 || {});\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n for (const key of keys1) {\n if (options1[key] !== options2[key]) {\n return false;\n }\n }\n\n return true;\n }\n\n componentWillLoad() {\n this._setRange();\n }\n\n private _textContent = {\n itemsPerPageText: 'Items per page:',\n nextPage: 'Next page',\n prevPage: 'Previous page',\n };\n\n private _getText(key: string) {\n const source = this.value.textOverrides?.[key]\n ? this.value.textOverrides\n : this._textContent;\n\n return source[key];\n }\n\n private _setRange() {\n if (!this.value) return;\n\n this._currentPage = this.value.currentPage || 1;\n\n this._itemsPerPage = this.value.itemsPerPage || 25;\n\n this._totalVisible = this.value.totalVisible || 7;\n\n this.value.startFrom =\n this._currentPage * this._itemsPerPage - this._itemsPerPage;\n\n this.value.endTo = this._currentPage * this._itemsPerPage - 1;\n\n this.changeValue.emit(this.value);\n }\n\n private _buttons: HTMLLIElement[] = [];\n\n private _valueChangeHandler() {\n this.value.currentPage = this._currentPage;\n\n this.value.itemsPerPage = this._itemsPerPage;\n\n this._setRange();\n }\n\n private _renderMenu() {\n const itemsPerPageOptions: CMenuOption[] = this.itemsPerPageOptions.map(\n (i) => ({\n name: i.toString(),\n action: () => {\n this._itemsPerPage = i;\n this._currentPage = 1;\n this._valueChangeHandler();\n },\n }),\n );\n\n const onMenuClick = (event) => {\n event.stopPropagation();\n };\n\n return (\n <div class=\"c-pagination__items-per-page\">\n {this._getText('itemsPerPageText')}\n\n <c-menu items={itemsPerPageOptions} onClick={onMenuClick}>\n <div>\n <span class=\"items-per-page\">{this._itemsPerPage}</span>\n </div>\n </c-menu>\n </div>\n );\n }\n\n private _getTotalPages() {\n return Math.ceil(this.value.itemCount / this._itemsPerPage);\n }\n\n private _increasePageNumber = () => {\n if (this._currentPage < this._getTotalPages()) {\n this._currentPage += 1;\n this._valueChangeHandler();\n }\n };\n\n private _decreasePageNumber = () => {\n if (this._currentPage > 1) {\n this._currentPage -= 1;\n this._valueChangeHandler();\n }\n };\n\n private _setPage(number) {\n this._currentPage = number;\n this._valueChangeHandler();\n }\n\n private _getRange() {\n if (this.hideRange || !this.value.itemCount) return;\n\n const end = Math.min(\n this._currentPage * this._itemsPerPage,\n this.value.itemCount,\n );\n const start = this.value.startFrom + 1;\n\n const pageTextOverride = this.value.textOverrides?.pageText;\n\n let parsedPageTextOverride;\n\n if (pageTextOverride) {\n parsedPageTextOverride = pageTextOverride({\n start: start,\n end: end,\n count: this.value.itemCount,\n });\n }\n\n return pageTextOverride\n ? parsedPageTextOverride\n : `${start} - ${end} of ${this.value.itemCount} items`;\n }\n\n private _getArrowLeft(size) {\n return (\n <li>\n <c-icon-button\n aria-disabled={this.value.currentPage <= 1 ? 'true' : 'false'}\n aria-label={`${this._getText('prevPage')}`}\n disabled={this.value.currentPage <= 1}\n size={size}\n text\n onClick={this._decreasePageNumber}\n >\n <span class=\"visuallyhidden\">{this._getText('prevPage')}</span>\n\n <c-icon path={mdiChevronLeft}></c-icon>\n </c-icon-button>\n </li>\n );\n }\n\n private _getArrowRight(size) {\n return (\n <li>\n <c-icon-button\n aria-disabled={\n this.value.currentPage >= this._getTotalPages() ? 'true' : 'false'\n }\n aria-label={`${this._getText('nextPage')}`}\n disabled={this.value.currentPage >= this._getTotalPages()}\n size={size}\n text\n onClick={this._increasePageNumber}\n >\n <span class=\"visuallyhidden\">{this._getText('nextPage')}</span>\n\n <c-icon path={mdiChevronRight}></c-icon>\n </c-icon-button>\n </li>\n );\n }\n\n private _button(number, size) {\n const params = {\n text: this._currentPage !== number,\n onClick: () => this._setPage(number),\n size,\n };\n\n if (this._currentPage === number) {\n params['aria-current'] = 'page';\n }\n\n const pageOfTextOverride = this.value.textOverrides?.pageOfText;\n\n let parsedPageOfTextOverride;\n\n if (pageOfTextOverride) {\n parsedPageOfTextOverride = pageOfTextOverride({\n pageNumber: number,\n count: this._getTotalPages(),\n });\n }\n\n return (\n <li>\n <c-icon-button {...params}>\n <span\n aria-label={\n pageOfTextOverride\n ? parsedPageOfTextOverride\n : `page ${number} of ${this._getTotalPages()}`\n }\n >\n {number}\n </span>\n </c-icon-button>\n </li>\n );\n }\n\n private _addButton(number, size) {\n this._buttons.push(this._button(number, size));\n }\n\n private _addSeparator(size) {\n this._buttons.push(\n <li>\n <c-icon-button\n aria-disabled=\"true\"\n size={size}\n tabindex=\"-1\"\n role=\"separator\"\n disabled\n text\n >\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\">\n <path d={mdiDotsHorizontal} />\n </svg>\n </c-icon-button>\n </li>,\n );\n }\n\n private _addButtons(buttonStart, buttonCount, size) {\n if (buttonStart > 1) {\n this._addButton(1, size);\n this._addSeparator(size);\n }\n\n for (let index = 1; index < buttonCount; index++) {\n this._addButton(buttonStart + index, size);\n }\n\n const allPagesVisible = this._getTotalPages() <= this._totalVisible;\n\n if (\n (this._currentPage < this._totalVisible - 1 ||\n this._currentPage < this._getTotalPages() - this._totalVisible + 4) &&\n !allPagesVisible\n ) {\n this._addSeparator(size);\n }\n }\n\n private _getPageButtons(size) {\n this._buttons = [];\n let buttonStart = 0;\n let buttonCount = this._getTotalPages() + 1;\n const morePagesThanVisible = this._getTotalPages() > this._totalVisible;\n\n if (morePagesThanVisible) {\n if (this._currentPage < this._totalVisible - 2) {\n buttonCount = this._totalVisible - 1;\n } else if (\n this._currentPage <\n this._getTotalPages() - this._totalVisible + 4\n ) {\n buttonStart = Math.ceil(this._currentPage - this._totalVisible / 2) + 1;\n buttonCount = this._totalVisible - 3;\n } else {\n buttonStart = this._getTotalPages() - this._totalVisible + 2;\n buttonCount = this._totalVisible - 2;\n }\n }\n\n this._addButtons(buttonStart, buttonCount, size);\n\n if (morePagesThanVisible) {\n this._buttons.push(this._button(this._getTotalPages(), size));\n }\n\n return this._buttons;\n }\n\n private _renderPaginationButtons() {\n if (!this.value.itemCount) return '';\n\n const buttonsize = this.size === 'small' ? 'x-small' : 'small';\n\n return (\n <ul>\n {this._getArrowLeft(buttonsize)}\n {!this.simple && this._getPageButtons(buttonsize)}\n {this._getArrowRight(buttonsize)}\n </ul>\n );\n }\n\n render() {\n const classes = {\n 'c-pagination': true,\n 'c-pagination--small': this.size === 'small',\n 'c-pagination--simple': this.simple,\n };\n\n return (\n <Host class={classes}>\n <nav role=\"navigation\" aria-label=\"pagination\">\n {!this.hideDetails && (\n <div class=\"c-pagination__details\">\n {this._renderMenu()}\n <span class={{ range: !this.simple }}>{this._getRange()}</span>\n </div>\n )}\n {this._renderPaginationButtons()}\n </nav>\n </Host>\n );\n }\n}\n"],"mappings":"yHAAA,MAAMA,EAAe,02G,MCyBRC,EAAS,M,kOAwFZC,KAAAC,gBACNC,EAAA,OAAKC,OAAO,OAAOC,MAAM,OAAOC,QAAQ,aACtCH,EAAA,QAAMI,EAAGC,K,aAjFsB,M,cAKhB,M,iBAKG,M,UAKP,G,mBAKS,M,WAKR,G,cAKG,M,WAKH,K,gBAKK,iB,WAMa,M,eAKI,K,gBAKC,M,4CAab,CACxBC,KAAM,MACNC,KAAM,OACNC,QAAS,G,CAcX,yBAAAC,CAA0BC,GACxBZ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AKC,KAAKlH,KAAK8E,aAAe9E,KAAKoG,cAAgB,GAAK,EACtE+C,EAAcnJ,KAAKoG,cAAgB,C,KAC9B,CACL8C,EAAclJ,KAAK+E,iBAAmB/E,KAAKoG,cAAgB,EAC3D+C,EAAcnJ,KAAKoG,cAAgB,C,EAIvCpG,KAAKiJ,YAAYC,EAAaC,EAAapB,GAE3C,GAAIwB,EAAsB,CACxBvJ,KAAK4E,SAASgE,KAAK5I,KAAKqI,QAAQrI,KAAK+E,iBAAkBgD,G,CAGzD,OAAO/H,KAAK4E,Q,CAGN,wBAAA4E,GACN,IAAKxJ,KAAKwB,MAAM0D,UAAW,MAAO,GAElC,MAAMuE,EAAazJ,KAAK+H,OAAS,QAAU,UAAY,QAEvD,OACE7H,EAAA,UACGF,KAAK8H,cAAc2B,IAClBzJ,KAAK0J,QAAU1J,KAAKsJ,gBAAgBG,GACrCzJ,KAAKmI,eAAesB,G,CAK3B,MAAArG,GACE,MAAMJ,EAAU,CACd,eAAgB,KAChB,sBAAuBhD,KAAK+H,OAAS,QACrC,uBAAwB/H,KAAK0J,QAG/B,OACExJ,EAACyD,EAAI,CAACR,MAAOH,GACX9C,EAAA,OAAK6I,KAAK,aAAY,aAAY,eAC9B/I,KAAK+C,aACL7C,EAAA,OAAKiD,MAAM,yBACRnD,KAAKwG,cACNtG,EAAA,QAAMiD,MAAO,CAAEwG,OAAQ3J,KAAK0J,SAAW1J,KAAKqH,cAG/CrH,KAAKwJ,4B"}
|
|
@@ -120,7 +120,7 @@ const CAutocomplete = class {
|
|
|
120
120
|
this.currentIndex = !!items.length ? 0 : null;
|
|
121
121
|
this._optionItems = this._optionItems.filter((item) => this._itemValues.includes(item.value));
|
|
122
122
|
requestAnimationFrame(async () => {
|
|
123
|
-
await this.
|
|
123
|
+
await this._dropdownElement.updateDropdown({
|
|
124
124
|
items: items,
|
|
125
125
|
options: this._filteredOptions,
|
|
126
126
|
});
|
|
@@ -141,19 +141,23 @@ const CAutocomplete = class {
|
|
|
141
141
|
const alphanumeric = /^[0-9a-zA-Z]+$/;
|
|
142
142
|
if (ev.key.match(alphanumeric) && ev.key.length === 1) {
|
|
143
143
|
this._showMenu(false);
|
|
144
|
+
if (!this.query) {
|
|
145
|
+
this.updateQuery(ev.key);
|
|
146
|
+
}
|
|
147
|
+
this._inputElement.focus();
|
|
144
148
|
}
|
|
145
149
|
if (ev.key === 'Tab') {
|
|
146
|
-
this.
|
|
150
|
+
this._dropdownElement.close();
|
|
147
151
|
}
|
|
148
152
|
if (ev.key === 'ArrowDown') {
|
|
149
153
|
ev.preventDefault();
|
|
150
|
-
this.
|
|
151
|
-
this.
|
|
154
|
+
this._dropdownElement.open();
|
|
155
|
+
this._dropdownElement.focusItem(0);
|
|
152
156
|
}
|
|
153
157
|
if (ev.key === 'ArrowUp') {
|
|
154
158
|
ev.preventDefault();
|
|
155
|
-
this.
|
|
156
|
-
this.
|
|
159
|
+
this._dropdownElement.open();
|
|
160
|
+
this._dropdownElement.focusItem(this._items.length - 1);
|
|
157
161
|
}
|
|
158
162
|
if (ev.key === ' ') {
|
|
159
163
|
ev.preventDefault();
|
|
@@ -163,16 +167,16 @@ const CAutocomplete = class {
|
|
|
163
167
|
_showMenu(focusList = true) {
|
|
164
168
|
if (this.disabled)
|
|
165
169
|
return;
|
|
166
|
-
this.
|
|
170
|
+
this._dropdownElement.open(focusList);
|
|
167
171
|
if (focusList) {
|
|
168
|
-
this.
|
|
172
|
+
this._dropdownElement.focusDropdown();
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
_getOptionItems() {
|
|
172
176
|
requestAnimationFrame(() => {
|
|
173
177
|
this._cOptionElements = {};
|
|
174
178
|
let selection = null;
|
|
175
|
-
this._optionItems = (this.
|
|
179
|
+
this._optionItems = (this.el ? Array.from(this.el.querySelectorAll('c-option')) : []).map((item, index) => {
|
|
176
180
|
const cAutocompleteItem = {
|
|
177
181
|
value: item.value,
|
|
178
182
|
name: item.name || item.innerText,
|
|
@@ -214,18 +218,6 @@ const CAutocomplete = class {
|
|
|
214
218
|
}
|
|
215
219
|
componentDidLoad() {
|
|
216
220
|
this._getOptionItems();
|
|
217
|
-
requestAnimationFrame(() => {
|
|
218
|
-
this._cInput.createDropdown({
|
|
219
|
-
type: 'autocomplete',
|
|
220
|
-
items: this._items,
|
|
221
|
-
options: this.options,
|
|
222
|
-
itemsPerPage: this.itemsPerPage,
|
|
223
|
-
parent: this.host,
|
|
224
|
-
index: this.currentIndex,
|
|
225
|
-
click: false,
|
|
226
|
-
id: this._inputId,
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
221
|
}
|
|
230
222
|
disconnectedCallback() {
|
|
231
223
|
this._observer.disconnect();
|
|
@@ -242,10 +234,10 @@ const CAutocomplete = class {
|
|
|
242
234
|
return (h("div", { class: "c-input-menu__input" }, h("input", { type: "text", ref: (el) => (this._inputElement = el), "aria-expanded": this.menuVisible.toString(), "aria-owns": this._inputId + '-items', "aria-autocomplete": "list", autocomplete: "off", class: "c-input__input", role: "combobox", value: this.query, name: (_a = this.name) !== null && _a !== void 0 ? _a : null, onInput: (event) => this.handleChange(event) })));
|
|
243
235
|
}
|
|
244
236
|
render() {
|
|
245
|
-
return (h(Host, { title: this.query }, h("c-input", {
|
|
237
|
+
return (h(Host, { title: this.query }, h("c-input", { autofocus: this.autofocus, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, label: this.label, name: this.name, placeholder: this.placeholder, required: this.required, shadow: this.shadow, valid: this.valid, validate: this.validate, "validate-on-blur": this.validateOnBlur, validation: this.validation, value: this.query, variant: "select", onItemClick: () => this.items.length && this._showMenu(false) }, h("slot", { name: "pre", slot: "pre" }), h("div", { class: "c-input__content" }, this._renderInputElement(), this._renderChevron(), h("slot", { onSlotchange: this._handleSlotChange })), h("c-dropdown", { ref: (el) => (this._dropdownElement = el), slot: "dropdown", items: this._items, options: this._cOptionElements, "items-per-page": this.itemsPerPage, parent: this.el, index: this.currentIndex, "input-id": this._inputId, type: "autocomplete" }), h("slot", { name: "post", slot: "post" }))));
|
|
246
238
|
}
|
|
247
239
|
static get formAssociated() { return true; }
|
|
248
|
-
get
|
|
240
|
+
get el() { return getElement(this); }
|
|
249
241
|
static get watchers() { return {
|
|
250
242
|
"items": ["watchHandler"],
|
|
251
243
|
"value": ["onValueChange"]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"c-autocomplete.entry.js","mappings":";;;AAAA,MAAM,gBAAgB,GAAG,0nIAA0nI;;MC4BtoI,aAAa;;;;;;;;;;;;IAqMhB,qBAAgB,GAAuC,EAAE,CAAC;IAE1D,iBAAY,GAAwB,EAAE,CAAC;IAMvC,eAAU,GAAG,IAAI,CAAC;IA4GlB,cAAS,GAAG,IAAI,oBAAoB,CAC1C,CAAC,OAAO,EAAE,QAAQ;MAChB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK;QACpB,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;UACzB,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC;YAC1B,KAAK,EAAE,IAAI,CAAC,UAAU;YACtB,MAAM,EAAE,SAAS;WAClB,CAAC,CAAC;UACH,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAClC;aAAM;UACL,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAClC;OACF,CAAC,CAAC;KACJ,EACD,EAAE,SAAS,EAAE,CAAC,EAAE,CACjB,CAAC;IAwCM,sBAAiB,GAAG;MAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;KACxB,CAAC;qBAzWkB,KAAK;oBAKN,KAAK;uBAKF,KAAK;gBAKZ,EAAE;;kBAUA,KAAK;;;iBAemB,IAAI;iBAKyB,IAAI;;oBAUvD,KAAK;iBAKR,IAAI;oBAKD,KAAK;0BAKC,KAAK;sBAKT,gBAAgB;uBAKf,EAAE;;iBAUa,EAAE;;;uBAoHhB,KAAK;wBAEI,IAAI;0BAEV,KA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AAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ,kBACT,IAAI,CAAC,WAAW,EAC9B,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,EAAE,EAAE,IAAI,CAAC,MAAM,cACL,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ,sBACL,IAAI,CAAC,cAAc,EACrC,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAC,QAAQ,EAChB,WAAW,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAE7D,YAAM,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,KAAK,GAAQ,EAEnC,WAAK,KAAK,EAAC,kBAAkB,IAC1B,IAAI,CAAC,mBAAmB,EAAE,EAC1B,IAAI,CAAC,cAAc,EAAE,EAEtB,YAAM,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAS,CAC/C,EAEN,YAAM,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAQ,CAC7B,CACL,EACP;GACH;;;;;;;;AA/Rc,uBAAS,GAAG,CAAH,CAAK;;;;;","names":[],"sources":["src/components/c-autocomplete/c-autocomplete.scss?tag=c-autocomplete&encapsulation=shadow","src/components/c-autocomplete/c-autocomplete.tsx"],"sourcesContent":[":host {\n /**\n * @prop --c-autocomplete-option-background-color: Autocomplete option background color\n * @prop --c-autocomplete-option-background-hover-color: Autocomplete option background hover color\n * @prop --c-autocomplete-active-color: Autocomplete active color\n * @prop --c-autocomplete-inactive-color: Autocomplete inactive color\n * @prop --c-autocomplete-background-color: Autocomplete background color\n * @prop --c-autocomplete-text-color: Autocomplete text color\n * @prop --c-autocomplete-option-text-color: Autocomplete option text color\n * @prop --c-autocomplete-placeholder-color: Autocomplete placeholder color\n */\n --_c-autocomplete-option-background-color: var(--c-autocomplete-option-background-color, var(--c-white));\n --_c-autocomplete-option-background-hover-color: var(--c-autocomplete-option-background-hover-color, var(--c-primary-100));\n --_c-autocomplete-active-color: var(--c-autocomplete-active-color, var(--c-primary-600));\n --_c-autocomplete-inactive-color: var(--c-autocomplete-inactive-color, var(--c-tertiary-600));\n --_c-autocomplete-background-color: var(--c-autocomplete-background-color, var(--c-transparent));\n --_c-autocomplete-text-color: var(--c-autocomplete-text-color, var(--c-text-body));\n --_c-autocomplete-option-text-color: var(--c-autocomplete-option-text-color, var(--c-text-body));\n --_c-autocomplete-placeholder-color: var(--c-autocomplete-placeholder-color, var(--c-tertiary-500));\n\n // c-select options\n --c-select-option-background-color: var(\n --_c-autocomplete-option-background-color\n );\n --c-select-option-background-color-hover: var(\n --_c-autocomplete-option-background-hover-color\n );\n --c-select-option-text-color: var(--_c-autocomplete-option-text-color);\n\n // c-input\n --_c-input-active-color: var(--_c-autocomplete-active-color);\n --_c-input-inactive-color: var(--_c-autocomplete-inactive-color);\n --_c-input-background-color: var(--_c-autocomplete-background-color);\n --_c-input-text-color: var(--_c-autocomplete-text-color);\n --_c-input-placeholder-color: var(--_c-autocomplete-placeholder-color);\n}\n\n@import \"../c-input/c-input-menu\";\n","import {\n AttachInternals,\n Component,\n Element,\n Host,\n Prop,\n State,\n h,\n Listen,\n Event,\n EventEmitter,\n Watch,\n Method,\n} from '@stencil/core';\nimport { mdiChevronDown } from '@mdi/js';\nimport { CAutocompleteItem } from '../../types';\n\n/**\n * @group Form\n * @slot pre - Content added before the input\n * @slot post - Content added after the input\n */\n@Component({\n tag: 'c-autocomplete',\n styleUrl: 'c-autocomplete.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CAutocomplete {\n @Element() host: HTMLCAutocompleteElement;\n\n // eslint-disable-next-line\n @AttachInternals() internals: ElementInternals;\n\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Shadow variant\n */\n @Prop() shadow = false;\n\n /**\n * Input field name\n */\n @Prop() name: string;\n\n /**\n * Element label\n */\n @Prop() label: string;\n\n /**\n * Search string\n */\n @Prop({ mutable: true }) query: string = null;\n\n /**\n * Selected item\n */\n @Prop({ mutable: true }) value: string | number | CAutocompleteItem = null;\n\n /**\n * Dense variant\n */\n @Prop() dense: boolean;\n\n /**\n * Show required validation\n */\n @Prop() required = false;\n\n /**\n * Set the validíty of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Placeholder text\n */\n @Prop() placeholder = '';\n\n /**\n * Return only the item value rather than the whole item object\n */\n @Prop() returnValue: false;\n\n /**\n * Items to be selected\n */\n @Prop() items: CAutocompleteItem[] = [];\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * display the option as selection (works only when c-option elements are used)\n */\n @Prop() optionAsSelection: false;\n\n /**\n * Triggered when text is typed\n */\n @Event() changeQuery: EventEmitter;\n\n /**\n * Triggered when an item is selected\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Sets the value of the autocomplete externally\n */\n @Method()\n async setValue(event, item) {\n this._select(event, item);\n }\n\n /**\n * Hide menu\n * @private\n */\n @Method()\n async onHideMenu() {\n this.menuVisible = false;\n }\n\n /**\n * @private\n */\n @Method()\n async setActiveDescendant(id: string) {\n if (!id) {\n this._inputElement.removeAttribute('aria-activedescendant');\n\n return;\n }\n\n this._inputElement.setAttribute('aria-activedescendant', id);\n }\n\n /**\n * @private\n */\n @Method()\n async updateQuery(query: string) {\n this.query = query;\n this.changeQuery.emit(this.query);\n this.changeValue.emit(null);\n }\n\n /**\n * Select item by index\n */\n @Method()\n async onItemSelection(index: number) {\n this.currentIndex = index;\n\n const selectedItem = this._items[this.currentIndex];\n\n this.value = selectedItem;\n this.query = selectedItem.name;\n }\n\n private _setFormValue(item) {\n if (!item) return;\n\n const value = this.returnValue ? item : (item as CAutocompleteItem).value;\n\n this.internals.setFormValue(value as string);\n }\n\n private _valueChangedHandler(item: string | number | CAutocompleteItem) {\n function isItem(element) {\n return element === item;\n }\n\n this.currentIndex = this.items.findIndex(isItem);\n\n const value = this.returnValue ? (item as CAutocompleteItem)?.value : item;\n\n this._setFormValue(item);\n\n this.changeValue.emit(value);\n }\n\n private _cOptionElements: Record<string, HTMLCOptionElement> = {};\n\n private _optionItems: CAutocompleteItem[] = [];\n\n private _inputId: string;\n\n private static _uniqueId = 0;\n\n private _direction = null;\n\n private _cInput: HTMLCInputElement;\n\n private _inputElement: HTMLInputElement;\n\n get _items() {\n return this.hasOptionItems ? this._optionItems : this.items;\n }\n\n @State() menuVisible = false;\n\n @State() currentIndex: number = null;\n\n @State() hasOptionItems = false;\n\n @State() options: Record<string, HTMLCOptionElement> = {};\n\n private get _itemValues() {\n return this.items.map((item) => item.value);\n }\n\n private get _filteredOptions() {\n if (!Object.keys(this._cOptionElements).length) return {};\n\n return this._itemValues.reduce((items, item) => {\n if (!this._cOptionElements[item as string]) return items;\n\n items[item as string] = this._cOptionElements[item as string].cloneNode(\n true,\n ) as HTMLCOptionElement;\n\n return items;\n }, {} as Record<string, HTMLCOptionElement>);\n }\n\n @Watch('items')\n watchHandler(items) {\n this.currentIndex = !!items.length ? 0 : null;\n\n this._optionItems = this._optionItems.filter((item) =>\n this._itemValues.includes(item.value),\n );\n\n requestAnimationFrame(async () => {\n await this._cInput.updateDropdown({\n items: items,\n options: this._filteredOptions,\n });\n });\n }\n\n @Watch('value')\n onValueChange() {\n if (!this.value) return;\n\n requestAnimationFrame(() => {\n const realValue = !(this.value as CAutocompleteItem)?.value\n ? this._items.find((item) => item.value === this.value)\n : this.value;\n\n this._valueChangedHandler(realValue as CAutocompleteItem);\n });\n }\n\n @Listen('keydown', { passive: true })\n handleKeyDown(ev: KeyboardEvent) {\n const alphanumeric = /^[0-9a-zA-Z]+$/;\n\n if (ev.key.match(alphanumeric) && ev.key.length === 1) {\n this._showMenu(false);\n }\n\n if (ev.key === 'Tab') {\n this._cInput.closeDropdown();\n }\n\n if (ev.key === 'ArrowDown') {\n ev.preventDefault();\n\n this._cInput.openDropdown();\n this._cInput.focusItem('first');\n }\n\n if (ev.key === 'ArrowUp') {\n ev.preventDefault();\n\n this._cInput.openDropdown();\n this._cInput.focusItem('last');\n }\n\n if (ev.key === ' ') {\n ev.preventDefault();\n\n this._showMenu();\n }\n }\n\n private _showMenu(focusList = true) {\n if (this.disabled) return;\n\n this._cInput.openDropdown(focusList);\n\n if (focusList) {\n this._cInput.focusDropdown();\n }\n }\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (!entry.isIntersecting) {\n entry.target.scrollIntoView({\n block: this._direction,\n inline: 'nearest',\n });\n observer.unobserve(entry.target);\n } else {\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n private _getOptionItems() {\n requestAnimationFrame(() => {\n this._cOptionElements = {};\n\n let selection: CAutocompleteItem | null = null;\n\n this._optionItems = (\n this.host ? Array.from(this.host.querySelectorAll('c-option')) : []\n ).map((item, index) => {\n const cAutocompleteItem = {\n value: item.value,\n name: item.name || item.innerText,\n disabled: !!item.disabled,\n } as CAutocompleteItem;\n\n if (item.selected) {\n selection = cAutocompleteItem;\n }\n\n item.slot = `option-${index}`;\n\n this.options[item.value] = item.cloneNode(true) as HTMLCOptionElement;\n\n this._cOptionElements[item.value.toString()] = item.cloneNode(\n true,\n ) as HTMLCOptionElement;\n\n return cAutocompleteItem;\n });\n\n this.hasOptionItems = !!this._optionItems.length;\n\n if (selection) {\n this._valueChangedHandler(selection);\n }\n });\n }\n\n private _handleSlotChange = () => {\n this._getOptionItems();\n };\n\n private handleChange(event) {\n this.menuVisible = true;\n this.query = event.target.value;\n this.changeQuery.emit(this.query);\n this.changeValue.emit(null);\n }\n\n private _select(event, item) {\n event.preventDefault();\n event.stopPropagation();\n this.query = item.name;\n this.value = item;\n this._valueChangedHandler(item);\n this.menuVisible = false;\n }\n\n componentWillLoad() {\n CAutocomplete._uniqueId += 1;\n\n this._inputId =\n 'input_' +\n (this.hostId || this.label || this.placeholder).replace(\n /[^a-zA-Z0-9-_]/g,\n '',\n );\n }\n\n componentDidLoad() {\n this._getOptionItems();\n\n requestAnimationFrame(() => {\n this._cInput.createDropdown({\n type: 'autocomplete',\n items: this._items,\n options: this.options,\n itemsPerPage: this.itemsPerPage,\n parent: this.host,\n index: this.currentIndex,\n click: false,\n id: this._inputId,\n });\n });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n private _renderChevron() {\n const classes = {\n 'c-input-menu__chevron': true,\n 'c-input-menu__chevron--active': this.menuVisible,\n };\n\n return (\n <svg class={classes} viewBox=\"0 0 24 24\">\n <path d={mdiChevronDown} />\n </svg>\n );\n }\n\n private _renderInputElement() {\n return (\n <div class=\"c-input-menu__input\">\n <input\n type=\"text\"\n ref={(el) => (this._inputElement = el)}\n aria-expanded={this.menuVisible.toString()}\n aria-owns={this._inputId + '-items'}\n aria-autocomplete=\"list\"\n autocomplete=\"off\"\n class=\"c-input__input\"\n role=\"combobox\"\n value={this.query}\n name={this.name ?? null}\n onInput={(event) => this.handleChange(event)}\n />\n </div>\n );\n }\n\n render() {\n return (\n <Host title={this.query}>\n <c-input\n ref={(el) => (this._cInput = el)}\n autofocus={this.autofocus}\n disabled={this.disabled}\n hide-details={this.hideDetails}\n hint={this.hint}\n id={this.hostId}\n input-id={this._inputId}\n label={this.label}\n name={this.name}\n placeholder={this.placeholder}\n required={this.required}\n shadow={this.shadow}\n valid={this.valid}\n validate={this.validate}\n validate-on-blur={this.validateOnBlur}\n validation={this.validation}\n value={this.query}\n variant=\"select\"\n onItemClick={() => this.items.length && this._showMenu(false)}\n >\n <slot name=\"pre\" slot=\"pre\"></slot>\n\n <div class=\"c-input__content\">\n {this._renderInputElement()}\n {this._renderChevron()}\n\n <slot onSlotchange={this._handleSlotChange}></slot>\n </div>\n\n <slot name=\"post\" slot=\"post\"></slot>\n </c-input>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"c-autocomplete.entry.js","mappings":";;;AAAA,MAAM,gBAAgB,GAAG,0nIAA0nI;;MC4BtoI,aAAa;;;;;;;;;;;;IAqMhB,qBAAgB,GAAuC,EAAE,CAAC;IAE1D,iBAAY,GAAwB,EAAE,CAAC;IAMvC,eAAU,GAAG,IAAI,CAAC;IAkHlB,cAAS,GAAG,IAAI,oBAAoB,CAC1C,CAAC,OAAO,EAAE,QAAQ;MAChB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK;QACpB,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;UACzB,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC;YAC1B,KAAK,EAAE,IAAI,CAAC,UAAU;YACtB,MAAM,EAAE,SAAS;WAClB,CAAC,CAAC;UACH,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAClC;aAAM;UACL,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAClC;OACF,CAAC,CAAC;KACJ,EACD,EAAE,SAAS,EAAE,CAAC,EAAE,CACjB,CAAC;IAwCM,sBAAiB,GAAG;MAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;KACxB,CAAC;qBA/WkB,KAAK;oBAKN,KAAK;uBAK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M,GAAQ,CAC7B,CACL,EACP;GACH;;;;;;;;AAnSc,uBAAS,GAAG,CAAH,CAAK;;;;;","names":[],"sources":["src/components/c-autocomplete/c-autocomplete.scss?tag=c-autocomplete&encapsulation=shadow","src/components/c-autocomplete/c-autocomplete.tsx"],"sourcesContent":[":host {\n /**\n * @prop --c-autocomplete-option-background-color: Autocomplete option background color\n * @prop --c-autocomplete-option-background-hover-color: Autocomplete option background hover color\n * @prop --c-autocomplete-active-color: Autocomplete active color\n * @prop --c-autocomplete-inactive-color: Autocomplete inactive color\n * @prop --c-autocomplete-background-color: Autocomplete background color\n * @prop --c-autocomplete-text-color: Autocomplete text color\n * @prop --c-autocomplete-option-text-color: Autocomplete option text color\n * @prop --c-autocomplete-placeholder-color: Autocomplete placeholder color\n */\n --_c-autocomplete-option-background-color: var(--c-autocomplete-option-background-color, var(--c-white));\n --_c-autocomplete-option-background-hover-color: var(--c-autocomplete-option-background-hover-color, var(--c-primary-100));\n --_c-autocomplete-active-color: var(--c-autocomplete-active-color, var(--c-primary-600));\n --_c-autocomplete-inactive-color: var(--c-autocomplete-inactive-color, var(--c-tertiary-600));\n --_c-autocomplete-background-color: var(--c-autocomplete-background-color, var(--c-transparent));\n --_c-autocomplete-text-color: var(--c-autocomplete-text-color, var(--c-text-body));\n --_c-autocomplete-option-text-color: var(--c-autocomplete-option-text-color, var(--c-text-body));\n --_c-autocomplete-placeholder-color: var(--c-autocomplete-placeholder-color, var(--c-tertiary-500));\n\n // c-select options\n --c-select-option-background-color: var(\n --_c-autocomplete-option-background-color\n );\n --c-select-option-background-color-hover: var(\n --_c-autocomplete-option-background-hover-color\n );\n --c-select-option-text-color: var(--_c-autocomplete-option-text-color);\n\n // c-input\n --_c-input-active-color: var(--_c-autocomplete-active-color);\n --_c-input-inactive-color: var(--_c-autocomplete-inactive-color);\n --_c-input-background-color: var(--_c-autocomplete-background-color);\n --_c-input-text-color: var(--_c-autocomplete-text-color);\n --_c-input-placeholder-color: var(--_c-autocomplete-placeholder-color);\n}\n\n@import \"../c-input/c-input-menu\";\n","import {\n AttachInternals,\n Component,\n Element,\n Host,\n Prop,\n State,\n h,\n Listen,\n Event,\n EventEmitter,\n Watch,\n Method,\n} from '@stencil/core';\nimport { mdiChevronDown } from '@mdi/js';\nimport { CAutocompleteItem } from '../../types';\n\n/**\n * @group Form\n * @slot pre - Content added before the input\n * @slot post - Content added after the input\n */\n@Component({\n tag: 'c-autocomplete',\n styleUrl: 'c-autocomplete.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CAutocomplete {\n @Element() el: HTMLCAutocompleteElement;\n\n // eslint-disable-next-line\n @AttachInternals() internals: ElementInternals;\n\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Shadow variant\n */\n @Prop() shadow = false;\n\n /**\n * Input field name\n */\n @Prop() name: string;\n\n /**\n * Element label\n */\n @Prop() label: string;\n\n /**\n * Search string\n */\n @Prop({ mutable: true }) query: string = null;\n\n /**\n * Selected item\n */\n @Prop({ mutable: true }) value: string | number | CAutocompleteItem = null;\n\n /**\n * Dense variant\n */\n @Prop() dense: boolean;\n\n /**\n * Show required validation\n */\n @Prop() required = false;\n\n /**\n * Set the validíty of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Placeholder text\n */\n @Prop() placeholder = '';\n\n /**\n * Return only the item value rather than the whole item object\n */\n @Prop() returnValue: false;\n\n /**\n * Items to be selected\n */\n @Prop() items: CAutocompleteItem[] = [];\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * display the option as selection (works only when c-option elements are used)\n */\n @Prop() optionAsSelection: false;\n\n /**\n * Triggered when text is typed\n */\n @Event() changeQuery: EventEmitter;\n\n /**\n * Triggered when an item is selected\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Sets the value of the autocomplete externally\n */\n @Method()\n async setValue(event, item) {\n this._select(event, item);\n }\n\n /**\n * Hide menu\n * @private\n */\n @Method()\n async onHideMenu() {\n this.menuVisible = false;\n }\n\n /**\n * @private\n */\n @Method()\n async setActiveDescendant(id: string) {\n if (!id) {\n this._inputElement.removeAttribute('aria-activedescendant');\n\n return;\n }\n\n this._inputElement.setAttribute('aria-activedescendant', id);\n }\n\n /**\n * @private\n */\n @Method()\n async updateQuery(query: string) {\n this.query = query;\n this.changeQuery.emit(this.query);\n this.changeValue.emit(null);\n }\n\n /**\n * Select item by index\n */\n @Method()\n async onItemSelection(index: number) {\n this.currentIndex = index;\n\n const selectedItem = this._items[this.currentIndex];\n\n this.value = selectedItem;\n this.query = selectedItem.name;\n }\n\n private _setFormValue(item) {\n if (!item) return;\n\n const value = this.returnValue ? item : (item as CAutocompleteItem).value;\n\n this.internals.setFormValue(value as string);\n }\n\n private _valueChangedHandler(item: string | number | CAutocompleteItem) {\n function isItem(element) {\n return element === item;\n }\n\n this.currentIndex = this.items.findIndex(isItem);\n\n const value = this.returnValue ? (item as CAutocompleteItem)?.value : item;\n\n this._setFormValue(item);\n\n this.changeValue.emit(value);\n }\n\n private _cOptionElements: Record<string, HTMLCOptionElement> = {};\n\n private _optionItems: CAutocompleteItem[] = [];\n\n private _inputId: string;\n\n private static _uniqueId = 0;\n\n private _direction = null;\n\n private _inputElement: HTMLInputElement;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n get _items() {\n return this.hasOptionItems ? this._optionItems : this.items;\n }\n\n @State() menuVisible = false;\n\n @State() currentIndex: number = null;\n\n @State() hasOptionItems = false;\n\n @State() options: Record<string, HTMLCOptionElement> = {};\n\n private get _itemValues() {\n return this.items.map((item) => item.value);\n }\n\n private get _filteredOptions() {\n if (!Object.keys(this._cOptionElements).length) return {};\n\n return this._itemValues.reduce((items, item) => {\n if (!this._cOptionElements[item as string]) return items;\n\n items[item as string] = this._cOptionElements[item as string].cloneNode(\n true,\n ) as HTMLCOptionElement;\n\n return items;\n }, {} as Record<string, HTMLCOptionElement>);\n }\n\n @Watch('items')\n watchHandler(items) {\n this.currentIndex = !!items.length ? 0 : null;\n\n this._optionItems = this._optionItems.filter((item) =>\n this._itemValues.includes(item.value),\n );\n\n requestAnimationFrame(async () => {\n await this._dropdownElement.updateDropdown({\n items: items,\n options: this._filteredOptions,\n });\n });\n }\n\n @Watch('value')\n onValueChange() {\n if (!this.value) return;\n\n requestAnimationFrame(() => {\n const realValue = !(this.value as CAutocompleteItem)?.value\n ? this._items.find((item) => item.value === this.value)\n : this.value;\n\n this._valueChangedHandler(realValue as CAutocompleteItem);\n });\n }\n\n @Listen('keydown', { passive: true })\n handleKeyDown(ev: KeyboardEvent) {\n const alphanumeric = /^[0-9a-zA-Z]+$/;\n\n if (ev.key.match(alphanumeric) && ev.key.length === 1) {\n this._showMenu(false);\n\n if (!this.query) {\n this.updateQuery(ev.key);\n }\n\n this._inputElement.focus();\n }\n\n if (ev.key === 'Tab') {\n this._dropdownElement.close();\n }\n\n if (ev.key === 'ArrowDown') {\n ev.preventDefault();\n\n this._dropdownElement.open();\n this._dropdownElement.focusItem(0);\n }\n\n if (ev.key === 'ArrowUp') {\n ev.preventDefault();\n\n this._dropdownElement.open();\n this._dropdownElement.focusItem(this._items.length - 1);\n }\n\n if (ev.key === ' ') {\n ev.preventDefault();\n\n this._showMenu();\n }\n }\n\n private _showMenu(focusList = true) {\n if (this.disabled) return;\n\n this._dropdownElement.open(focusList);\n\n if (focusList) {\n this._dropdownElement.focusDropdown();\n }\n }\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (!entry.isIntersecting) {\n entry.target.scrollIntoView({\n block: this._direction,\n inline: 'nearest',\n });\n observer.unobserve(entry.target);\n } else {\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n private _getOptionItems() {\n requestAnimationFrame(() => {\n this._cOptionElements = {};\n\n let selection: CAutocompleteItem | null = null;\n\n this._optionItems = (\n this.el ? Array.from(this.el.querySelectorAll('c-option')) : []\n ).map((item, index) => {\n const cAutocompleteItem = {\n value: item.value,\n name: item.name || item.innerText,\n disabled: !!item.disabled,\n } as CAutocompleteItem;\n\n if (item.selected) {\n selection = cAutocompleteItem;\n }\n\n item.slot = `option-${index}`;\n\n this.options[item.value] = item.cloneNode(true) as HTMLCOptionElement;\n\n this._cOptionElements[item.value.toString()] = item.cloneNode(\n true,\n ) as HTMLCOptionElement;\n\n return cAutocompleteItem;\n });\n\n this.hasOptionItems = !!this._optionItems.length;\n\n if (selection) {\n this._valueChangedHandler(selection);\n }\n });\n }\n\n private _handleSlotChange = () => {\n this._getOptionItems();\n };\n\n private handleChange(event) {\n this.menuVisible = true;\n this.query = event.target.value;\n this.changeQuery.emit(this.query);\n this.changeValue.emit(null);\n }\n\n private _select(event, item) {\n event.preventDefault();\n event.stopPropagation();\n this.query = item.name;\n this.value = item;\n this._valueChangedHandler(item);\n this.menuVisible = false;\n }\n\n componentWillLoad() {\n CAutocomplete._uniqueId += 1;\n\n this._inputId =\n 'input_' +\n (this.hostId || this.label || this.placeholder).replace(\n /[^a-zA-Z0-9-_]/g,\n '',\n );\n }\n\n componentDidLoad() {\n this._getOptionItems();\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n private _renderChevron() {\n const classes = {\n 'c-input-menu__chevron': true,\n 'c-input-menu__chevron--active': this.menuVisible,\n };\n\n return (\n <svg class={classes} viewBox=\"0 0 24 24\">\n <path d={mdiChevronDown} />\n </svg>\n );\n }\n\n private _renderInputElement() {\n return (\n <div class=\"c-input-menu__input\">\n <input\n type=\"text\"\n ref={(el) => (this._inputElement = el)}\n aria-expanded={this.menuVisible.toString()}\n aria-owns={this._inputId + '-items'}\n aria-autocomplete=\"list\"\n autocomplete=\"off\"\n class=\"c-input__input\"\n role=\"combobox\"\n value={this.query}\n name={this.name ?? null}\n onInput={(event) => this.handleChange(event)}\n />\n </div>\n );\n }\n\n render() {\n return (\n <Host title={this.query}>\n <c-input\n autofocus={this.autofocus}\n disabled={this.disabled}\n hide-details={this.hideDetails}\n hint={this.hint}\n id={this.hostId}\n input-id={this._inputId}\n label={this.label}\n name={this.name}\n placeholder={this.placeholder}\n required={this.required}\n shadow={this.shadow}\n valid={this.valid}\n validate={this.validate}\n validate-on-blur={this.validateOnBlur}\n validation={this.validation}\n value={this.query}\n variant=\"select\"\n onItemClick={() => this.items.length && this._showMenu(false)}\n >\n <slot name=\"pre\" slot=\"pre\"></slot>\n\n <div class=\"c-input__content\">\n {this._renderInputElement()}\n {this._renderChevron()}\n\n <slot onSlotchange={this._handleSlotChange}></slot>\n </div>\n\n <c-dropdown\n ref={(el) => (this._dropdownElement = el)}\n slot=\"dropdown\"\n items={this._items}\n options={this._cOptionElements}\n items-per-page={this.itemsPerPage}\n parent={this.el}\n index={this.currentIndex}\n input-id={this._inputId}\n type=\"autocomplete\"\n />\n\n <slot name=\"post\" slot=\"post\"></slot>\n </c-input>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -74,7 +74,6 @@ const CCheckbox = class {
|
|
|
74
74
|
this.checked = !this.checked;
|
|
75
75
|
if (typeof this.value === 'string' && typeof this.trueValue === 'boolean') {
|
|
76
76
|
this.changeValue.emit(this.value);
|
|
77
|
-
console.log('🐿️', this.checked, this.value);
|
|
78
77
|
this.internals.setFormValue(this.checked ? this.value : null);
|
|
79
78
|
return;
|
|
80
79
|
}
|