@paperless/core 0.1.0-alpha.358 → 0.1.0-alpha.360
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/CHANGELOG.md +22 -0
- package/dist/build/{p-6d796b74.entry.js → p-5aabd2c2.entry.js} +2 -2
- package/dist/{paperless/p-6d796b74.entry.js.map → build/p-5aabd2c2.entry.js.map} +1 -1
- package/dist/build/{p-70edb46e.entry.js → p-72c479f9.entry.js} +2 -2
- package/dist/build/{p-049cac21.entry.js → p-f98027f1.entry.js} +2 -2
- package/dist/build/paperless.esm.js +1 -1
- package/dist/cjs/p-button_3.cjs.entry.js +2 -2
- package/dist/cjs/p-dropdown-menu-container.cjs.entry.js +1 -1
- package/dist/cjs/p-select.cjs.entry.js +1 -1
- package/dist/cjs/p-select.cjs.entry.js.map +1 -1
- package/dist/collection/components/atoms/button/button.component.css +1 -1
- package/dist/collection/components/atoms/dropdown-menu-container/dropdown-menu-container.component.css +1 -1
- package/dist/collection/components/atoms/helper/helper.component.css +1 -1
- package/dist/collection/components/atoms/icon/icon.component.css +1 -1
- package/dist/collection/components/atoms/loader/loader.component.css +1 -1
- package/dist/collection/components/atoms/tooltip/tooltip.component.css +1 -1
- package/dist/collection/components/molecules/dropdown/dropdown.component.css +1 -1
- package/dist/collection/components/molecules/input-group/input-group.component.css +1 -1
- package/dist/collection/components/molecules/select/select.component.js +1 -1
- package/dist/collection/components/molecules/select/select.component.js.map +1 -1
- package/dist/components/button.component.js +1 -1
- package/dist/components/dropdown-menu-container.component.js +1 -1
- package/dist/components/icon.component.js +1 -1
- package/dist/components/p-select.js +1 -1
- package/dist/components/p-select.js.map +1 -1
- package/dist/esm/p-button_3.entry.js +2 -2
- package/dist/esm/p-dropdown-menu-container.entry.js +1 -1
- package/dist/esm/p-select.entry.js +1 -1
- package/dist/esm/p-select.entry.js.map +1 -1
- package/dist/index.html +1 -1
- package/dist/paperless/{p-6d796b74.entry.js → p-5aabd2c2.entry.js} +2 -2
- package/dist/{build/p-6d796b74.entry.js.map → paperless/p-5aabd2c2.entry.js.map} +1 -1
- package/dist/paperless/{p-70edb46e.entry.js → p-72c479f9.entry.js} +2 -2
- package/dist/paperless/{p-049cac21.entry.js → p-f98027f1.entry.js} +2 -2
- package/dist/paperless/paperless.esm.js +1 -1
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/hydrate/index.js +9 -9
- package/package.json +1 -1
- /package/dist/build/{p-70edb46e.entry.js.map → p-72c479f9.entry.js.map} +0 -0
- /package/dist/build/{p-049cac21.entry.js.map → p-f98027f1.entry.js.map} +0 -0
- /package/dist/paperless/{p-70edb46e.entry.js.map → p-72c479f9.entry.js.map} +0 -0
- /package/dist/paperless/{p-049cac21.entry.js.map → p-f98027f1.entry.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.1.0-alpha.360](https://github.com/ionic-team/stencil-component-starter/compare/v0.1.0-alpha.359...v0.1.0-alpha.360) (2023-02-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **Molecules/Select:** add nullish coalescing ([e339c27](https://github.com/ionic-team/stencil-component-starter/commit/e339c278bb241ecddc516b3d2206b8fb3094bbae))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [0.1.0-alpha.359](https://github.com/ionic-team/stencil-component-starter/compare/v0.1.0-alpha.358...v0.1.0-alpha.359) (2023-02-22)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **Molecules/Select:** Make sure we check if value is not `null` ([cff7fa7](https://github.com/ionic-team/stencil-component-starter/commit/cff7fa7ae0f27290b45bc1981b4ec1cdd72b46bb))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [0.1.0-alpha.358](https://github.com/ionic-team/stencil-component-starter/compare/v0.1.0-alpha.357...v0.1.0-alpha.358) (2023-02-22)
|
|
7
29
|
|
|
8
30
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,c as e,h as r,H as a,g as i}from"./p-69d43b9d.js";import{c as s}from"./p-8a6728d5.js";const o=".visible{visibility:visible!important}.static{position:static!important}.absolute{position:absolute!important}.ml-2{margin-left:.5rem!important}.inline{display:inline!important}.flex{display:flex!important}.h-6{height:1.5rem!important}.w-full{width:100%!important}.-rotate-0{--tw-rotate:-0deg!important}.-rotate-0,.-rotate-135{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-135{--tw-rotate:-135deg!important}.-rotate-180{--tw-rotate:-180deg!important}.-rotate-180,.-rotate-225{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-225{--tw-rotate:-225deg!important}.-rotate-25{--tw-rotate:-25deg!important}.-rotate-25,.-rotate-270{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-270{--tw-rotate:-270deg!important}.-rotate-315{--tw-rotate:-315deg!important}.-rotate-315,.-rotate-45{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-45{--tw-rotate:-45deg!important}.-rotate-90{--tw-rotate:-90deg!important}.-rotate-90,.rotate-0{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-0{--tw-rotate:0deg!important}.rotate-135{--tw-rotate:135deg!important}.rotate-135,.rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-180{--tw-rotate:180deg!important}.rotate-225{--tw-rotate:225deg!important}.rotate-225,.rotate-25{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-25{--tw-rotate:25deg!important}.rotate-270{--tw-rotate:270deg!important}.rotate-270,.rotate-315{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-315{--tw-rotate:315deg!important}.rotate-45{--tw-rotate:45deg!important}.rotate-45,.rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-90{--tw-rotate:90deg!important}.scale-x-flip{--tw-scale-x:-1!important}.scale-x-flip,.scale-y-flip{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.scale-y-flip{--tw-scale-y:-1!important}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.cursor-pointer{cursor:pointer!important}.items-end{align-items:flex-end!important}.justify-center{justify-content:center!important}.justify-between{justify-content:space-between!important}.rounded{border-radius:.25rem!important}.rounded-bl-none{border-bottom-left-radius:0!important}.rounded-br-none{border-bottom-right-radius:0!important}.rounded-tl-none{border-top-left-radius:0!important}.rounded-tr-none{border-top-right-radius:0!important}.border-l-0{border-left-width:0!important}.border-r-0{border-right-width:0!important}.pl-0{padding-left:0!important}.pr-0{padding-right:0!important}.text-2xl{font-size:1.5rem!important;line-height:2rem!important}.text-3xl{font-size:1.875rem!important;line-height:2.25rem!important}.text-4xl{font-size:2.25rem!important;line-height:2.5rem!important}.text-5xl{font-size:3rem!important}.text-5xl,.text-6xl{line-height:1!important}.text-6xl{font-size:3.75rem!important}.text-base{font-size:1rem!important;line-height:1.5rem!important}.text-lg{font-size:1.125rem!important;line-height:1.75rem!important}.text-sm{font-size:.875rem!important;line-height:1.25rem!important}.text-xl{font-size:1.25rem!important;line-height:1.75rem!important}.text-xs{font-size:.75rem!important;line-height:1rem!important}.text-xxs{font-size:.6875rem!important}.text-negative{color:rgb(185 30 40/var(--tw-text-opacity))!important}.text-negative,.text-negative-light{--tw-text-opacity:1!important}.text-negative-light{color:rgb(255 204 211/var(--tw-text-opacity))!important}.blur{--tw-blur:blur(8px)!important}.blur,.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}*{box-sizing:border-box}:host{display:flex;flex-direction:column}:host input.read-only{text-overflow:ellipsis}.-rotate-0,.-rotate-135,.-rotate-180,.-rotate-225,.-rotate-25,.-rotate-270,.-rotate-315,.-rotate-45,.-rotate-90,.rotate-0,.rotate-135,.rotate-180,.rotate-225,.rotate-25,.rotate-270,.rotate-315,.rotate-45,.rotate-90,.scale-x-flip,.scale-y-flip{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.hover\\:text-negative:hover{--tw-text-opacity:1!important;color:rgb(185 30 40/var(--tw-text-opacity))!important}";const n=class{constructor(r){t(this,r);this.queryChange=e(this,"queryChange",7);this.valueChange=e(this,"valueChange",7);this.dropdownShown=e(this,"dropdownShown",7);this._isAutoCompleting=false;this.items=undefined;this.icon=undefined;this.query=undefined;this.placeholder=undefined;this.autocompletePlaceholder=undefined;this.value=undefined;this.displayKey="text";this.valueKey="value";this.identifierKey=undefined;this.queryKey=undefined;this.autoSelectFirst=true;this.showChevron=true;this.maxDisplayedItems=10;this.enableAutocomplete=true;this.asyncFilter=false;this.loading=false;this.size="medium";this.prefix=undefined;this.label=undefined;this.helper=undefined;this.error=undefined;this.disabled=false;this._showDropdown=false;this._selectedItem=null}get _items(){var t;if(!this.items||this.loading){return[]}let e=typeof this.items==="string"?JSON.parse(this.items):this.items;if(typeof(e===null||e===void 0?void 0:e[0])==="string"){this.displayKey="text";this.valueKey="value";e=e.map((t=>({value:t,text:t})))}if(this._isAutoCompleting&&((t=this.query)===null||t===void 0?void 0:t.length)&&!this.asyncFilter){e=e.filter((t=>{if(this.queryKey){return this._checkvalue(this.queryKey,t)}return this._checkvalue(this._identifierKey,t)||this._checkvalue(this.displayKey,t)}))}return e===null||e===void 0?void 0:e.slice(0,this.maxDisplayedItems)}get _displayValue(){var t;if(this._isAutoCompleting){return this.query}return(t=this._selectedItem)===null||t===void 0?void 0:t[this.displayKey]}get _placeholder(){var t;return this._isAutoCompleting&&((t=this.autocompletePlaceholder)===null||t===void 0?void 0:t.length)?this.autocompletePlaceholder:this.placeholder}get _identifierKey(){var t;return(t=this.identifierKey)!==null&&t!==void 0?t:this.valueKey}componentDidLoad(){var t;if(this.value){this._valueChange(this.value);return}if(this.autoSelectFirst){this._selectedItem=(t=this._items)===null||t===void 0?void 0:t[0]}}render(){return r(a,{class:"p-select"},r("p-dropdown",{disableTriggerClick:true,calculateWidth:true,insideClick:true,show:this._showDropdown&&(!!this._items.length||this.loading)},r("p-input-group",{slot:"trigger",icon:this.icon,size:this.size,prefix:this.prefix,label:this.label,helper:this.helper,error:this.error,disabled:this.disabled,focused:this._showDropdown},r("input",{slot:"input",type:"text",placeholder:this._placeholder,value:this._displayValue,class:`p-input cursor-pointer ${!this._isAutoCompleting&&"read-only"}`,onFocus:()=>this._onFocus(),onMouseDown:t=>this._onMouseDown(t),onClick:()=>this._onClick(),onInput:t=>this._onChange(t),ref:t=>this._inputRef=t}),this.showChevron&&r("p-icon",{variant:"chevron",slot:"suffix"})),r("div",{slot:"items"},this.loading?this._getLoadingItems():this._getItems())))}documentClickHandler({target:t}){if(!this._showDropdown||s(t,this._el)){return}this._showDropdown=false;this._isAutoCompleting=false}_valueChange(t){this._preselectItem(t)}itemChanges(){this._preselectItem()}_showDropdownChanges(){this.dropdownShown.emit({value:this._showDropdown,query:this.query})}_preselectItem(t){var e;t=t===undefined?null:t;t=!t?this.value:t;t=this.valueKey==="false"||!this.valueKey||!((e=this.valueKey)===null||e===void 0?void 0:e.length)?t[this._identifierKey]:t;const r=JSON.stringify(t);if(this._selectedItem&&JSON.stringify(this._selectedItem[this._identifierKey])===r){return}const a=this._items.find((t=>JSON.stringify(t===null||t===void 0?void 0:t[this._identifierKey])===r));this._selectedItem=a}_selectValue(t){var e;this._selectedItem=t;const r=!!((e=this.valueKey)===null||e===void 0?void 0:e.length)&&this.valueKey!=="false"?t[this.valueKey]:t;this.value=r;this.valueChange.emit(this.value);this._onBlur(true)}_onFocus(){if(!this.enableAutocomplete){this._inputRef.blur();if(!this._showDropdown){this._showDropdown=true}return}this._isAutoCompleting=true;this._showDropdown=true}_onMouseDown(t){if(this.enableAutocomplete){return}t.preventDefault()}_onClick(){if(this.enableAutocomplete){return}this._showDropdown=!this._showDropdown}_onBlur(t=false){if(!this.enableAutocomplete&&!t){return}this._isAutoCompleting=false;this._showDropdown=false}_onChange(t){if(!this._isAutoCompleting){return}this.query=t.target.value;this.queryChange.emit(this.query)}_checkvalue(t,e){var r,a,i;return((a=(r=e===null||e===void 0?void 0:e[t])===null||r===void 0?void 0:r.toString())===null||a===void 0?void 0:a.toLowerCase().indexOf((i=this.query)===null||i===void 0?void 0:i.toLowerCase()))>=0}_getItems(){return this._items.map((t=>{var e;return r("p-dropdown-menu-item",{onClick:()=>this._selectValue(t),active:t[this._identifierKey]===((e=this._selectedItem)===null||e===void 0?void 0:e[this._identifierKey])},t[this.displayKey])}))}_getLoadingItems(){return[0,0,0].map((()=>r("p-dropdown-menu-item",{enableHover:false},r("p-loader",{variant:"ghost",class:"h-6 w-full rounded"}))))}get _el(){return i(this)}static get watchers(){return{value:["_valueChange"],items:["itemChanges"],_showDropdown:["_showDropdownChanges"]}}};n.style=o;export{n as p_select};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,c as e,h as r,H as a,g as i}from"./p-69d43b9d.js";import{c as s}from"./p-8a6728d5.js";const o=".visible{visibility:visible!important}.static{position:static!important}.absolute{position:absolute!important}.ml-2{margin-left:.5rem!important}.inline{display:inline!important}.flex{display:flex!important}.h-6{height:1.5rem!important}.w-full{width:100%!important}.-rotate-0{--tw-rotate:-0deg!important}.-rotate-0,.-rotate-135{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-135{--tw-rotate:-135deg!important}.-rotate-180{--tw-rotate:-180deg!important}.-rotate-180,.-rotate-225{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-225{--tw-rotate:-225deg!important}.-rotate-25{--tw-rotate:-25deg!important}.-rotate-25,.-rotate-270{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-270{--tw-rotate:-270deg!important}.-rotate-315{--tw-rotate:-315deg!important}.-rotate-315,.-rotate-45{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.-rotate-45{--tw-rotate:-45deg!important}.-rotate-90{--tw-rotate:-90deg!important}.-rotate-90,.rotate-0{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-0{--tw-rotate:0deg!important}.rotate-135{--tw-rotate:135deg!important}.rotate-135,.rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-180{--tw-rotate:180deg!important}.rotate-225{--tw-rotate:225deg!important}.rotate-225,.rotate-25{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-25{--tw-rotate:25deg!important}.rotate-270{--tw-rotate:270deg!important}.rotate-270,.rotate-315{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-315{--tw-rotate:315deg!important}.rotate-45{--tw-rotate:45deg!important}.rotate-45,.rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.rotate-90{--tw-rotate:90deg!important}.scale-x-flip{--tw-scale-x:-1!important}.scale-x-flip,.scale-y-flip{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.scale-y-flip{--tw-scale-y:-1!important}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.cursor-pointer{cursor:pointer!important}.items-end{align-items:flex-end!important}.justify-center{justify-content:center!important}.justify-between{justify-content:space-between!important}.rounded{border-radius:.25rem!important}.rounded-bl-none{border-bottom-left-radius:0!important}.rounded-br-none{border-bottom-right-radius:0!important}.rounded-tl-none{border-top-left-radius:0!important}.rounded-tr-none{border-top-right-radius:0!important}.border-l-0{border-left-width:0!important}.border-r-0{border-right-width:0!important}.pl-0{padding-left:0!important}.pr-0{padding-right:0!important}.text-2xl{font-size:1.5rem!important;line-height:2rem!important}.text-3xl{font-size:1.875rem!important;line-height:2.25rem!important}.text-4xl{font-size:2.25rem!important;line-height:2.5rem!important}.text-5xl{font-size:3rem!important}.text-5xl,.text-6xl{line-height:1!important}.text-6xl{font-size:3.75rem!important}.text-base{font-size:1rem!important;line-height:1.5rem!important}.text-lg{font-size:1.125rem!important;line-height:1.75rem!important}.text-sm{font-size:.875rem!important;line-height:1.25rem!important}.text-xl{font-size:1.25rem!important;line-height:1.75rem!important}.text-xs{font-size:.75rem!important;line-height:1rem!important}.text-xxs{font-size:.6875rem!important}.text-negative{color:rgb(185 30 40/var(--tw-text-opacity))!important}.text-negative,.text-negative-light{--tw-text-opacity:1!important}.text-negative-light{color:rgb(255 204 211/var(--tw-text-opacity))!important}.blur{--tw-blur:blur(8px)!important}.blur,.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)!important}*{box-sizing:border-box}:host{display:flex;flex-direction:column}:host input.read-only{text-overflow:ellipsis}.-rotate-0,.-rotate-135,.-rotate-180,.-rotate-225,.-rotate-25,.-rotate-270,.-rotate-315,.-rotate-45,.-rotate-90,.rotate-0,.rotate-135,.rotate-180,.rotate-225,.rotate-25,.rotate-270,.rotate-315,.rotate-45,.rotate-90,.scale-x-flip,.scale-y-flip{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))!important}.hover\\:text-negative:hover{--tw-text-opacity:1!important;color:rgb(185 30 40/var(--tw-text-opacity))!important}";const n=class{constructor(r){t(this,r);this.queryChange=e(this,"queryChange",7);this.valueChange=e(this,"valueChange",7);this.dropdownShown=e(this,"dropdownShown",7);this._isAutoCompleting=false;this.items=undefined;this.icon=undefined;this.query=undefined;this.placeholder=undefined;this.autocompletePlaceholder=undefined;this.value=undefined;this.displayKey="text";this.valueKey="value";this.identifierKey=undefined;this.queryKey=undefined;this.autoSelectFirst=true;this.showChevron=true;this.maxDisplayedItems=10;this.enableAutocomplete=true;this.asyncFilter=false;this.loading=false;this.size="medium";this.prefix=undefined;this.label=undefined;this.helper=undefined;this.error=undefined;this.disabled=false;this._showDropdown=false;this._selectedItem=null}get _items(){var t;if(!this.items||this.loading){return[]}let e=typeof this.items==="string"?JSON.parse(this.items):this.items;if(typeof(e===null||e===void 0?void 0:e[0])==="string"){this.displayKey="text";this.valueKey="value";e=e.map((t=>({value:t,text:t})))}if(this._isAutoCompleting&&((t=this.query)===null||t===void 0?void 0:t.length)&&!this.asyncFilter){e=e.filter((t=>{if(this.queryKey){return this._checkvalue(this.queryKey,t)}return this._checkvalue(this._identifierKey,t)||this._checkvalue(this.displayKey,t)}))}return e===null||e===void 0?void 0:e.slice(0,this.maxDisplayedItems)}get _displayValue(){var t;if(this._isAutoCompleting){return this.query}return(t=this._selectedItem)===null||t===void 0?void 0:t[this.displayKey]}get _placeholder(){var t;return this._isAutoCompleting&&((t=this.autocompletePlaceholder)===null||t===void 0?void 0:t.length)?this.autocompletePlaceholder:this.placeholder}get _identifierKey(){var t;return(t=this.identifierKey)!==null&&t!==void 0?t:this.valueKey}componentDidLoad(){var t;if(this.value){this._valueChange(this.value);return}if(this.autoSelectFirst){this._selectedItem=(t=this._items)===null||t===void 0?void 0:t[0]}}render(){return r(a,{class:"p-select"},r("p-dropdown",{disableTriggerClick:true,calculateWidth:true,insideClick:true,show:this._showDropdown&&(!!this._items.length||this.loading)},r("p-input-group",{slot:"trigger",icon:this.icon,size:this.size,prefix:this.prefix,label:this.label,helper:this.helper,error:this.error,disabled:this.disabled,focused:this._showDropdown},r("input",{slot:"input",type:"text",placeholder:this._placeholder,value:this._displayValue,class:`p-input cursor-pointer ${!this._isAutoCompleting&&"read-only"}`,onFocus:()=>this._onFocus(),onMouseDown:t=>this._onMouseDown(t),onClick:()=>this._onClick(),onInput:t=>this._onChange(t),ref:t=>this._inputRef=t}),this.showChevron&&r("p-icon",{variant:"chevron",slot:"suffix"})),r("div",{slot:"items"},this.loading?this._getLoadingItems():this._getItems())))}documentClickHandler({target:t}){if(!this._showDropdown||s(t,this._el)){return}this._showDropdown=false;this._isAutoCompleting=false}_valueChange(t){this._preselectItem(t)}itemChanges(){this._preselectItem()}_showDropdownChanges(){this.dropdownShown.emit({value:this._showDropdown,query:this.query})}_preselectItem(t){var e;t=t===undefined?null:t;t=!t?this.value:t;t=this.valueKey==="false"||!this.valueKey||!((e=this.valueKey)===null||e===void 0?void 0:e.length)?t===null||t===void 0?void 0:t[this._identifierKey]:t;const r=JSON.stringify(t);if(this._selectedItem&&JSON.stringify(this._selectedItem[this._identifierKey])===r){return}const a=this._items.find((t=>JSON.stringify(t===null||t===void 0?void 0:t[this._identifierKey])===r));this._selectedItem=a}_selectValue(t){var e;this._selectedItem=t;const r=!!((e=this.valueKey)===null||e===void 0?void 0:e.length)&&this.valueKey!=="false"?t[this.valueKey]:t;this.value=r;this.valueChange.emit(this.value);this._onBlur(true)}_onFocus(){if(!this.enableAutocomplete){this._inputRef.blur();if(!this._showDropdown){this._showDropdown=true}return}this._isAutoCompleting=true;this._showDropdown=true}_onMouseDown(t){if(this.enableAutocomplete){return}t.preventDefault()}_onClick(){if(this.enableAutocomplete){return}this._showDropdown=!this._showDropdown}_onBlur(t=false){if(!this.enableAutocomplete&&!t){return}this._isAutoCompleting=false;this._showDropdown=false}_onChange(t){if(!this._isAutoCompleting){return}this.query=t.target.value;this.queryChange.emit(this.query)}_checkvalue(t,e){var r,a,i;return((a=(r=e===null||e===void 0?void 0:e[t])===null||r===void 0?void 0:r.toString())===null||a===void 0?void 0:a.toLowerCase().indexOf((i=this.query)===null||i===void 0?void 0:i.toLowerCase()))>=0}_getItems(){return this._items.map((t=>{var e;return r("p-dropdown-menu-item",{onClick:()=>this._selectValue(t),active:t[this._identifierKey]===((e=this._selectedItem)===null||e===void 0?void 0:e[this._identifierKey])},t[this.displayKey])}))}_getLoadingItems(){return[0,0,0].map((()=>r("p-dropdown-menu-item",{enableHover:false},r("p-loader",{variant:"ghost",class:"h-6 w-full rounded"}))))}get _el(){return i(this)}static get watchers(){return{value:["_valueChange"],items:["itemChanges"],_showDropdown:["_showDropdownChanges"]}}};n.style=o;export{n as p_select};
|
|
2
|
+
//# sourceMappingURL=p-5aabd2c2.entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["selectComponentCss","Select","this","_isAutoCompleting","_items","items","loading","JSON","parse","displayKey","valueKey","map","str","value","text","_a","query","length","asyncFilter","filter","item","queryKey","_checkvalue","_identifierKey","slice","maxDisplayedItems","_displayValue","_selectedItem","_placeholder","autocompletePlaceholder","placeholder","identifierKey","componentDidLoad","_valueChange","autoSelectFirst","render","h","Host","class","disableTriggerClick","calculateWidth","insideClick","show","_showDropdown","slot","icon","size","prefix","label","helper","error","disabled","focused","type","onFocus","_onFocus","onMouseDown","ev","_onMouseDown","onClick","_onClick","onInput","_onChange","ref","_inputRef","showChevron","variant","_getLoadingItems","_getItems","documentClickHandler","target","childOf","_el","_preselectItem","itemChanges","_showDropdownChanges","dropdownShown","emit","undefined","parsedValue","stringify","find","i","_selectValue","valueChange","_onBlur","enableAutocomplete","blur","preventDefault","force","queryChange","key","_b","toString","toLowerCase","indexOf","_c","active","enableHover"],"sources":["./src/components/molecules/select/select.component.scss?tag=p-select","./src/components/molecules/select/select.component.tsx"],"sourcesContent":[":host {\n @apply flex flex-col;\n\n input.read-only {\n @apply text-ellipsis;\n }\n}\n","import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Listen,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport { childOf } from '../../../utils';\nimport { IconVariant } from '../../atoms/icon/icon.component';\n\n@Component({\n tag: 'p-select',\n styleUrl: 'select.component.scss',\n shadow: false,\n})\nexport class Select {\n /**\n * The items to show in the dropdown\n */\n @Prop() items: string | any[];\n\n /**\n * Icon of the select box\n */\n @Prop() icon: IconVariant;\n\n /**\n * The current query\n */\n @Prop() query: string;\n\n /**\n * The placeholder of the input\n */\n @Prop() placeholder: string;\n\n /**\n * The placeholder of the input when auto completing\n */\n @Prop() autocompletePlaceholder: string;\n\n /**\n * The current value\n */\n @Prop() value: any;\n\n /**\n * The key of the object to display\n */\n @Prop() displayKey: string = 'text';\n\n /**\n * The key of the object to return\n */\n @Prop() valueKey: string = 'value';\n\n /**\n * The key to identify an object\n */\n @Prop() identifierKey: string;\n\n /**\n * The key of the object to display\n */\n @Prop() queryKey?: string;\n\n /**\n * Wether to automatically select the first item\n */\n @Prop() autoSelectFirst: boolean = true;\n\n /**\n * Wether to show the chevron or not\n */\n @Prop() showChevron: boolean = true;\n\n /**\n * The maximum amount of items to display\n */\n @Prop() maxDisplayedItems: number = 10;\n\n /**\n * Wether to enable autocomplete\n */\n @Prop() enableAutocomplete: boolean = true;\n\n /**\n * Wether the input uses async filtering\n */\n @Prop() asyncFilter: boolean = false;\n\n /**\n * Wether to show loading items\n */\n @Prop() loading: boolean = false;\n\n /**\n * Event when the query of the autocomplete changes\n */\n @Event() queryChange: EventEmitter<string>;\n\n /**\n * Event when the value changes\n */\n @Event() valueChange: EventEmitter<any>;\n\n /**\n * Event when the dropdown shows\n */\n @Event() dropdownShown: EventEmitter<any>;\n\n /**\n * The size of the input group used by the select\n */\n @Prop() size: 'small' | 'medium' = 'medium';\n\n /**\n * The prefix of the input group used by the select\n */\n @Prop() prefix: string;\n\n /**\n * The label of the input group used by the select\n */\n @Prop() label: string;\n\n /**\n * The helper of the input group used by the select\n */\n @Prop() helper: string;\n\n /**\n * The helper of the input group used by the select\n */\n @Prop({ reflect: true }) error: string;\n\n /**\n * Wether the input group is disabled used by the select\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * The host element\n */\n @Element() private _el: HTMLElement;\n\n @State() private _showDropdown: any = false;\n @State() private _selectedItem: any = null;\n\n private _isAutoCompleting: boolean = false;\n\n private _inputRef: HTMLInputElement;\n\n get _items() {\n if (!this.items || this.loading) {\n return [];\n }\n\n let items =\n typeof this.items === 'string'\n ? JSON.parse(this.items)\n : this.items;\n\n if (typeof items?.[0] === 'string') {\n this.displayKey = 'text';\n this.valueKey = 'value';\n\n items = items.map((str) => ({\n value: str,\n text: str,\n }));\n }\n\n if (this._isAutoCompleting && this.query?.length && !this.asyncFilter) {\n items = items.filter((item) => {\n if (this.queryKey) {\n return this._checkvalue(this.queryKey, item);\n }\n\n return (\n this._checkvalue(this._identifierKey, item) ||\n this._checkvalue(this.displayKey, item)\n );\n });\n }\n\n return items?.slice(0, this.maxDisplayedItems);\n }\n\n get _displayValue() {\n if (this._isAutoCompleting) {\n return this.query;\n }\n\n return this._selectedItem?.[this.displayKey];\n }\n\n get _placeholder() {\n return this._isAutoCompleting && this.autocompletePlaceholder?.length\n ? this.autocompletePlaceholder\n : this.placeholder;\n }\n\n get _identifierKey() {\n return this.identifierKey ?? this.valueKey;\n }\n\n componentDidLoad() {\n if (this.value) {\n this._valueChange(this.value);\n return;\n }\n\n if (this.autoSelectFirst) {\n this._selectedItem = this._items?.[0];\n }\n }\n\n render() {\n return (\n <Host class=\"p-select\">\n <p-dropdown\n disableTriggerClick={true}\n calculateWidth={true}\n insideClick={true}\n show={\n this._showDropdown &&\n (!!this._items.length || this.loading)\n }\n >\n <p-input-group\n slot=\"trigger\"\n icon={this.icon}\n size={this.size}\n prefix={this.prefix}\n label={this.label}\n helper={this.helper}\n error={this.error}\n disabled={this.disabled}\n focused={this._showDropdown}\n >\n <input\n slot=\"input\"\n type=\"text\"\n placeholder={this._placeholder}\n value={this._displayValue}\n class={`p-input cursor-pointer ${\n !this._isAutoCompleting && 'read-only'\n }`}\n onFocus={() => this._onFocus()}\n onMouseDown={(ev) => this._onMouseDown(ev)}\n onClick={() => this._onClick()}\n onInput={(ev) => this._onChange(ev)}\n ref={(ref) => (this._inputRef = ref)}\n />\n\n {this.showChevron && (\n <p-icon variant=\"chevron\" slot=\"suffix\" />\n )}\n </p-input-group>\n <div slot=\"items\">\n {this.loading\n ? this._getLoadingItems()\n : this._getItems()}\n </div>\n </p-dropdown>\n </Host>\n );\n }\n\n @Listen('click', { target: 'document', capture: true })\n protected documentClickHandler({ target }) {\n if (!this._showDropdown || childOf(target, this._el)) {\n return;\n }\n\n this._showDropdown = false;\n this._isAutoCompleting = false;\n }\n\n @Watch('value')\n private _valueChange(value: any) {\n this._preselectItem(value);\n }\n\n @Watch('items')\n public itemChanges() {\n this._preselectItem();\n }\n\n @Watch('_showDropdown')\n public _showDropdownChanges() {\n this.dropdownShown.emit({\n value: this._showDropdown,\n query: this.query,\n });\n }\n\n private _preselectItem(value?: any) {\n value = value === undefined ? null : value;\n value = !value ? this.value : value;\n value =\n this.valueKey === 'false' ||\n !this.valueKey ||\n !this.valueKey?.length\n ? value[this._identifierKey]\n : value;\n const parsedValue = JSON.stringify(value);\n\n if (\n this._selectedItem &&\n JSON.stringify(this._selectedItem[this._identifierKey]) ===\n parsedValue\n ) {\n return;\n }\n\n const item = this._items.find(\n (i) => JSON.stringify(i?.[this._identifierKey]) === parsedValue\n );\n\n this._selectedItem = item;\n }\n\n private _selectValue(item) {\n this._selectedItem = item;\n const value =\n !!this.valueKey?.length && this.valueKey !== 'false'\n ? item[this.valueKey]\n : item;\n\n this.value = value;\n this.valueChange.emit(this.value);\n\n this._onBlur(true);\n }\n\n private _onFocus() {\n if (!this.enableAutocomplete) {\n this._inputRef.blur();\n if (!this._showDropdown) {\n this._showDropdown = true;\n }\n return;\n }\n\n this._isAutoCompleting = true;\n\n this._showDropdown = true;\n }\n\n private _onMouseDown(ev) {\n if (this.enableAutocomplete) {\n return;\n }\n\n ev.preventDefault();\n }\n\n private _onClick() {\n if (this.enableAutocomplete) {\n return;\n }\n\n this._showDropdown = !this._showDropdown;\n }\n\n private _onBlur(force = false) {\n if (!this.enableAutocomplete && !force) {\n return;\n }\n\n this._isAutoCompleting = false;\n this._showDropdown = false;\n }\n\n private _onChange(ev) {\n if (!this._isAutoCompleting) {\n return;\n }\n\n this.query = ev.target.value;\n this.queryChange.emit(this.query);\n }\n\n private _checkvalue(key, item) {\n return (\n item?.[key]\n ?.toString()\n ?.toLowerCase()\n .indexOf(this.query?.toLowerCase()) >= 0\n );\n }\n\n private _getItems() {\n return this._items.map((item) => (\n <p-dropdown-menu-item\n onClick={() => this._selectValue(item)}\n active={\n item[this._identifierKey] ===\n this._selectedItem?.[this._identifierKey]\n }\n >\n {item[this.displayKey]}\n </p-dropdown-menu-item>\n ));\n }\n\n private _getLoadingItems() {\n return [0, 0, 0].map(() => (\n <p-dropdown-menu-item enableHover={false}>\n <p-loader variant=\"ghost\" class=\"h-6 w-full rounded\" />\n </p-dropdown-menu-item>\n ));\n }\n}\n"],"mappings":"oGAAA,MAAMA,EAAqB,2yL,MCoBdC,EAAM,M,wJAsIPC,KAAAC,kBAA6B,M,qKApGR,O,cAKF,Q,0EAeQ,K,iBAKJ,K,uBAKK,G,wBAKE,K,iBAKP,M,aAKJ,M,UAoBQ,S,oGAyBU,M,mBAOP,M,mBACA,I,CAMlCC,a,MACA,IAAKF,KAAKG,OAASH,KAAKI,QAAS,CAC7B,MAAO,E,CAGX,IAAID,SACOH,KAAKG,QAAU,SAChBE,KAAKC,MAAMN,KAAKG,OAChBH,KAAKG,MAEf,UAAWA,IAAK,MAALA,SAAK,SAALA,EAAQ,MAAO,SAAU,CAChCH,KAAKO,WAAa,OAClBP,KAAKQ,SAAW,QAEhBL,EAAQA,EAAMM,KAAKC,IAAG,CAClBC,MAAOD,EACPE,KAAMF,K,CAId,GAAIV,KAAKC,qBAAqBY,EAAAb,KAAKc,SAAK,MAAAD,SAAA,SAAAA,EAAEE,UAAWf,KAAKgB,YAAa,CACnEb,EAAQA,EAAMc,QAAQC,IAClB,GAAIlB,KAAKmB,SAAU,CACf,OAAOnB,KAAKoB,YAAYpB,KAAKmB,SAAUD,E,CAG3C,OACIlB,KAAKoB,YAAYpB,KAAKqB,eAAgBH,IACtClB,KAAKoB,YAAYpB,KAAKO,WAAYW,EAAK,G,CAKnD,OAAOf,IAAK,MAALA,SAAK,SAALA,EAAOmB,MAAM,EAAGtB,KAAKuB,kB,CAG5BC,oB,MACA,GAAIxB,KAAKC,kBAAmB,CACxB,OAAOD,KAAKc,K,CAGhB,OAAOD,EAAAb,KAAKyB,iBAAa,MAAAZ,SAAA,SAAAA,EAAGb,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gB,I,CAGjBe,aAAaD,GACjB,GAAIvD,KAAKoF,mBAAoB,CACzB,M,CAGJ7B,EAAG+B,gB,CAGC5B,WACJ,GAAI1D,KAAKoF,mBAAoB,CACzB,M,CAGJpF,KAAKyC,eAAiBzC,KAAKyC,a,CAGvB0C,QAAQI,EAAQ,OACpB,IAAKvF,KAAKoF,qBAAuBG,EAAO,CACpC,M,CAGJvF,KAAKC,kBAAoB,MACzBD,KAAKyC,cAAgB,K,CAGjBmB,UAAUL,GACd,IAAKvD,KAAKC,kBAAmB,CACzB,M,CAGJD,KAAKc,MAAQyC,EAAGa,OAAOzD,MACvBX,KAAKwF,YAAYb,KAAK3E,KAAKc,M,CAGvBM,YAAYqE,EAAKvE,G,UACrB,QACIwE,GAAA7E,EAAAK,IAAI,MAAJA,SAAI,SAAJA,EAAOuE,MAAI,MAAA5E,SAAA,SAAAA,EACL8E,cAAU,MAAAD,SAAA,SAAAA,EACVE,cACDC,SAAQC,EAAA9F,KAAKc,SAAK,MAAAgF,SAAA,SAAAA,EAAEF,iBAAkB,C,CAI3C1B,YACJ,OAAOlE,KAAKE,OAAOO,KAAKS,I,MAAS,OAC7BgB,EAAA,wBACIuB,QAAS,IAAMzD,KAAKiF,aAAa/D,GACjC6E,OACI7E,EAAKlB,KAAKqB,oBACVR,EAAAb,KAAKyB,iBAAa,MAAAZ,SAAA,SAAAA,EAAGb,KAAKqB,kBAG7BH,EAAKlB,KAAKO,YACQ,G,CAIvB0D,mBACJ,MAAO,CAAC,EAAG,EAAG,GAAGxD,KAAI,IACjByB,EAAA,wBAAsB8D,YAAa,OAC/B9D,EAAA,YAAU8B,QAAQ,QAAQ5B,MAAM,yB"}
|
|
1
|
+
{"version":3,"names":["selectComponentCss","Select","this","_isAutoCompleting","_items","items","loading","JSON","parse","displayKey","valueKey","map","str","value","text","_a","query","length","asyncFilter","filter","item","queryKey","_checkvalue","_identifierKey","slice","maxDisplayedItems","_displayValue","_selectedItem","_placeholder","autocompletePlaceholder","placeholder","identifierKey","componentDidLoad","_valueChange","autoSelectFirst","render","h","Host","class","disableTriggerClick","calculateWidth","insideClick","show","_showDropdown","slot","icon","size","prefix","label","helper","error","disabled","focused","type","onFocus","_onFocus","onMouseDown","ev","_onMouseDown","onClick","_onClick","onInput","_onChange","ref","_inputRef","showChevron","variant","_getLoadingItems","_getItems","documentClickHandler","target","childOf","_el","_preselectItem","itemChanges","_showDropdownChanges","dropdownShown","emit","undefined","parsedValue","stringify","find","i","_selectValue","valueChange","_onBlur","enableAutocomplete","blur","preventDefault","force","queryChange","key","_b","toString","toLowerCase","indexOf","_c","active","enableHover"],"sources":["./src/components/molecules/select/select.component.scss?tag=p-select","./src/components/molecules/select/select.component.tsx"],"sourcesContent":[":host {\n @apply flex flex-col;\n\n input.read-only {\n @apply text-ellipsis;\n }\n}\n","import {\n Component,\n Element,\n Event,\n EventEmitter,\n h,\n Host,\n Listen,\n Prop,\n State,\n Watch,\n} from '@stencil/core';\nimport { childOf } from '../../../utils';\nimport { IconVariant } from '../../atoms/icon/icon.component';\n\n@Component({\n tag: 'p-select',\n styleUrl: 'select.component.scss',\n shadow: false,\n})\nexport class Select {\n /**\n * The items to show in the dropdown\n */\n @Prop() items: string | any[];\n\n /**\n * Icon of the select box\n */\n @Prop() icon: IconVariant;\n\n /**\n * The current query\n */\n @Prop() query: string;\n\n /**\n * The placeholder of the input\n */\n @Prop() placeholder: string;\n\n /**\n * The placeholder of the input when auto completing\n */\n @Prop() autocompletePlaceholder: string;\n\n /**\n * The current value\n */\n @Prop() value: any;\n\n /**\n * The key of the object to display\n */\n @Prop() displayKey: string = 'text';\n\n /**\n * The key of the object to return\n */\n @Prop() valueKey: string = 'value';\n\n /**\n * The key to identify an object\n */\n @Prop() identifierKey: string;\n\n /**\n * The key of the object to display\n */\n @Prop() queryKey?: string;\n\n /**\n * Wether to automatically select the first item\n */\n @Prop() autoSelectFirst: boolean = true;\n\n /**\n * Wether to show the chevron or not\n */\n @Prop() showChevron: boolean = true;\n\n /**\n * The maximum amount of items to display\n */\n @Prop() maxDisplayedItems: number = 10;\n\n /**\n * Wether to enable autocomplete\n */\n @Prop() enableAutocomplete: boolean = true;\n\n /**\n * Wether the input uses async filtering\n */\n @Prop() asyncFilter: boolean = false;\n\n /**\n * Wether to show loading items\n */\n @Prop() loading: boolean = false;\n\n /**\n * Event when the query of the autocomplete changes\n */\n @Event() queryChange: EventEmitter<string>;\n\n /**\n * Event when the value changes\n */\n @Event() valueChange: EventEmitter<any>;\n\n /**\n * Event when the dropdown shows\n */\n @Event() dropdownShown: EventEmitter<any>;\n\n /**\n * The size of the input group used by the select\n */\n @Prop() size: 'small' | 'medium' = 'medium';\n\n /**\n * The prefix of the input group used by the select\n */\n @Prop() prefix: string;\n\n /**\n * The label of the input group used by the select\n */\n @Prop() label: string;\n\n /**\n * The helper of the input group used by the select\n */\n @Prop() helper: string;\n\n /**\n * The helper of the input group used by the select\n */\n @Prop({ reflect: true }) error: string;\n\n /**\n * Wether the input group is disabled used by the select\n */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /**\n * The host element\n */\n @Element() private _el: HTMLElement;\n\n @State() private _showDropdown: any = false;\n @State() private _selectedItem: any = null;\n\n private _isAutoCompleting: boolean = false;\n\n private _inputRef: HTMLInputElement;\n\n get _items() {\n if (!this.items || this.loading) {\n return [];\n }\n\n let items =\n typeof this.items === 'string'\n ? JSON.parse(this.items)\n : this.items;\n\n if (typeof items?.[0] === 'string') {\n this.displayKey = 'text';\n this.valueKey = 'value';\n\n items = items.map((str) => ({\n value: str,\n text: str,\n }));\n }\n\n if (this._isAutoCompleting && this.query?.length && !this.asyncFilter) {\n items = items.filter((item) => {\n if (this.queryKey) {\n return this._checkvalue(this.queryKey, item);\n }\n\n return (\n this._checkvalue(this._identifierKey, item) ||\n this._checkvalue(this.displayKey, item)\n );\n });\n }\n\n return items?.slice(0, this.maxDisplayedItems);\n }\n\n get _displayValue() {\n if (this._isAutoCompleting) {\n return this.query;\n }\n\n return this._selectedItem?.[this.displayKey];\n }\n\n get _placeholder() {\n return this._isAutoCompleting && this.autocompletePlaceholder?.length\n ? this.autocompletePlaceholder\n : this.placeholder;\n }\n\n get _identifierKey() {\n return this.identifierKey ?? this.valueKey;\n }\n\n componentDidLoad() {\n if (this.value) {\n this._valueChange(this.value);\n return;\n }\n\n if (this.autoSelectFirst) {\n this._selectedItem = this._items?.[0];\n }\n }\n\n render() {\n return (\n <Host class=\"p-select\">\n <p-dropdown\n disableTriggerClick={true}\n calculateWidth={true}\n insideClick={true}\n show={\n this._showDropdown &&\n (!!this._items.length || this.loading)\n }\n >\n <p-input-group\n slot=\"trigger\"\n icon={this.icon}\n size={this.size}\n prefix={this.prefix}\n label={this.label}\n helper={this.helper}\n error={this.error}\n disabled={this.disabled}\n focused={this._showDropdown}\n >\n <input\n slot=\"input\"\n type=\"text\"\n placeholder={this._placeholder}\n value={this._displayValue}\n class={`p-input cursor-pointer ${\n !this._isAutoCompleting && 'read-only'\n }`}\n onFocus={() => this._onFocus()}\n onMouseDown={(ev) => this._onMouseDown(ev)}\n onClick={() => this._onClick()}\n onInput={(ev) => this._onChange(ev)}\n ref={(ref) => (this._inputRef = ref)}\n />\n\n {this.showChevron && (\n <p-icon variant=\"chevron\" slot=\"suffix\" />\n )}\n </p-input-group>\n <div slot=\"items\">\n {this.loading\n ? this._getLoadingItems()\n : this._getItems()}\n </div>\n </p-dropdown>\n </Host>\n );\n }\n\n @Listen('click', { target: 'document', capture: true })\n protected documentClickHandler({ target }) {\n if (!this._showDropdown || childOf(target, this._el)) {\n return;\n }\n\n this._showDropdown = false;\n this._isAutoCompleting = false;\n }\n\n @Watch('value')\n private _valueChange(value: any) {\n this._preselectItem(value);\n }\n\n @Watch('items')\n public itemChanges() {\n this._preselectItem();\n }\n\n @Watch('_showDropdown')\n public _showDropdownChanges() {\n this.dropdownShown.emit({\n value: this._showDropdown,\n query: this.query,\n });\n }\n\n private _preselectItem(value?: any) {\n value = value === undefined ? null : value;\n value = !value ? this.value : value;\n\n value =\n this.valueKey === 'false' ||\n !this.valueKey ||\n !this.valueKey?.length\n ? value?.[this._identifierKey]\n : value;\n const parsedValue = JSON.stringify(value);\n\n if (\n this._selectedItem &&\n JSON.stringify(this._selectedItem[this._identifierKey]) ===\n parsedValue\n ) {\n return;\n }\n\n const item = this._items.find(\n (i) => JSON.stringify(i?.[this._identifierKey]) === parsedValue\n );\n\n this._selectedItem = item;\n }\n\n private _selectValue(item) {\n this._selectedItem = item;\n const value =\n !!this.valueKey?.length && this.valueKey !== 'false'\n ? item[this.valueKey]\n : item;\n\n this.value = value;\n this.valueChange.emit(this.value);\n\n this._onBlur(true);\n }\n\n private _onFocus() {\n if (!this.enableAutocomplete) {\n this._inputRef.blur();\n if (!this._showDropdown) {\n this._showDropdown = true;\n }\n return;\n }\n\n this._isAutoCompleting = true;\n\n this._showDropdown = true;\n }\n\n private _onMouseDown(ev) {\n if (this.enableAutocomplete) {\n return;\n }\n\n ev.preventDefault();\n }\n\n private _onClick() {\n if (this.enableAutocomplete) {\n return;\n }\n\n this._showDropdown = !this._showDropdown;\n }\n\n private _onBlur(force = false) {\n if (!this.enableAutocomplete && !force) {\n return;\n }\n\n this._isAutoCompleting = false;\n this._showDropdown = false;\n }\n\n private _onChange(ev) {\n if (!this._isAutoCompleting) {\n return;\n }\n\n this.query = ev.target.value;\n this.queryChange.emit(this.query);\n }\n\n private _checkvalue(key, item) {\n return (\n item?.[key]\n ?.toString()\n ?.toLowerCase()\n .indexOf(this.query?.toLowerCase()) >= 0\n );\n }\n\n private _getItems() {\n return this._items.map((item) => (\n <p-dropdown-menu-item\n onClick={() => this._selectValue(item)}\n active={\n item[this._identifierKey] ===\n this._selectedItem?.[this._identifierKey]\n }\n >\n {item[this.displayKey]}\n </p-dropdown-menu-item>\n ));\n }\n\n private _getLoadingItems() {\n return [0, 0, 0].map(() => (\n <p-dropdown-menu-item enableHover={false}>\n <p-loader variant=\"ghost\" class=\"h-6 w-full rounded\" />\n </p-dropdown-menu-item>\n ));\n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