@paperless/core 2.12.10 → 2.12.12
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 +19 -0
- package/dist/build/{p-a089eb53.js → p-3deda660.js} +1 -1
- package/dist/build/p-7cb05993.entry.js +2 -0
- package/dist/{paperless/p-6fc32bea.entry.js.map → build/p-7cb05993.entry.js.map} +1 -1
- package/dist/build/p-select.entry.esm.js.map +1 -1
- package/dist/build/paperless.esm.js +1 -1
- package/dist/cjs/p-select.cjs.entry.js +3 -3
- package/dist/cjs/p-select.cjs.entry.js.map +1 -1
- package/dist/cjs/p-select.entry.cjs.js.map +1 -1
- package/dist/collection/components/molecules/select/select.component.css +1 -1
- package/dist/collection/components/molecules/select/select.component.js +2 -2
- package/dist/collection/components/molecules/select/select.component.js.map +1 -1
- package/dist/components/p-select.js +3 -3
- package/dist/components/p-select.js.map +1 -1
- package/dist/esm/p-select.entry.js +3 -3
- package/dist/esm/p-select.entry.js.map +1 -1
- package/dist/index.html +1 -1
- package/dist/paperless/p-7cb05993.entry.js +2 -0
- package/dist/{build/p-6fc32bea.entry.js.map → paperless/p-7cb05993.entry.js.map} +1 -1
- package/dist/paperless/p-select.entry.esm.js.map +1 -1
- package/dist/paperless/paperless.esm.js +1 -1
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/package.json +1 -1
- package/dist/build/p-6fc32bea.entry.js +0 -2
- package/dist/paperless/p-6fc32bea.entry.js +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,g as i,h as s}from"./p-Dpmiv2da.js";import{a as r}from"./p-BFSNj6hu.js";import{c as a}from"./p-CBWjHURv.js";import{c as o}from"./p-CT54OXR2.js";import{T as n}from"./p-C1iNEsnH.js";import"./p-ChV9xqsO.js";import"./p-BIwGgs9f.js";const h="*{box-sizing:border-box}:host{--tw-translate-y:0px!important;--tw-translate-x:0px!important}.pointer-events-none{pointer-events:none!important}.pointer-events-auto{pointer-events:auto!important}.static{position:static!important}.absolute{position:absolute!important}.relative{position:relative!important}.sticky{position:sticky!important}.top-0{top:0!important}.z-10{z-index:10!important}.mb-3{margin-bottom:.75rem!important}.block{display:block!important}.flex{display:flex!important}.hidden{display:none!important}.h-6{height:1.5rem!important}.h-8{height:2rem!important}.h-\\[1\\.625rem\\]{height:1.625rem!important}.h-full{height:100%!important}.w-6{width:1.5rem!important}.w-full{width:100%!important}.min-w-0{min-width:0!important}.flex-1{flex:1 1 0%!important}.cursor-pointer{cursor:pointer!important}.items-center{align-items:center!important}.justify-center{justify-content:center!important}.gap-1{gap:.25rem!important}.gap-2{gap:.5rem!important}.overflow-hidden{overflow:hidden!important}.text-ellipsis{text-overflow:ellipsis!important}.whitespace-nowrap{white-space:nowrap!important}.rounded{border-radius:.25rem!important}.rounded-lg{border-radius:.5rem!important}.bg-indigo-100{--tw-bg-opacity:1!important;background-color:rgb(227 236 254/var(--tw-bg-opacity,1))!important}.p-2{padding:.5rem!important}.px-2{padding-left:.5rem!important;padding-right:.5rem!important}.text-center{text-align:center!important}.text-start{text-align:start!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-xs{font-size:.75rem!important;line-height:1rem!important}.font-semibold{font-weight:600!important}.text-indigo-500{--tw-text-opacity:1!important;color:rgb(142 179 251/var(--tw-text-opacity,1))!important}.text-indigo-600{--tw-text-opacity:1!important;color:rgb(82 138 250/var(--tw-text-opacity,1))!important}.text-negative-red-700{--tw-text-opacity:1!important;color:rgb(147 16 16/var(--tw-text-opacity,1))!important}.text-storm-100{--tw-text-opacity:1!important;color:rgb(209 210 212/var(--tw-text-opacity,1))!important}.text-storm-300{--tw-text-opacity:1!important;color:rgb(116 120 127/var(--tw-text-opacity,1))!important}.text-storm-400{--tw-text-opacity:1!important;color:rgb(70 75 84/var(--tw-text-opacity,1))!important}.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}.group\\/button:hover .group-hover\\/button\\:text-negative-red-800{--tw-text-opacity:1!important;color:rgb(141 16 16/var(--tw-text-opacity,1))!important}.group\\/item:hover .group-hover\\/item\\:text-indigo-800{--tw-text-opacity:1!important;color:rgb(27 88 210/var(--tw-text-opacity,1))!important}.dark\\:bg-white\\/15:where(:host([data-theme=dark]),:host([data-theme=dark]) *){background-color:hsla(0,0%,100%,.15)!important}.dark\\:text-negative-red-alternative:where(:host([data-theme=dark]),:host([data-theme=dark]) *){--tw-text-opacity:1!important;color:rgb(255 92 92/var(--tw-text-opacity,1))!important}.dark\\:text-white:where(:host([data-theme=dark]),:host([data-theme=dark]) *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}.dark\\:text-white\\/15:where(:host([data-theme=dark]),:host([data-theme=dark]) *){color:hsla(0,0%,100%,.15)!important}.group\\/item:hover .dark\\:group-hover\\/item\\:text-white:where(:host([data-theme=dark]),:host([data-theme=dark]) *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}.dark\\:bg-white\\/15:where([data-theme=dark],[data-theme=dark] *){background-color:hsla(0,0%,100%,.15)!important}.dark\\:text-negative-red-alternative:where([data-theme=dark],[data-theme=dark] *){--tw-text-opacity:1!important;color:rgb(255 92 92/var(--tw-text-opacity,1))!important}.dark\\:text-white:where([data-theme=dark],[data-theme=dark] *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}.dark\\:text-white\\/15:where([data-theme=dark],[data-theme=dark] *){color:hsla(0,0%,100%,.15)!important}.group\\/item:hover .dark\\:group-hover\\/item\\:text-white:where([data-theme=dark],[data-theme=dark] *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}";const l=a(["flex items-center gap-2","flex-1 min-w-0 h-full","pointer-events-none overflow-hidden"]);const p=a(["item group/item","pointer-events-auto cursor-pointer","flex h-[1.625rem] items-center gap-2","h-[1.625rem] px-2","text-sm font-semibold whitespace-nowrap","rounded-lg","bg-indigo-100","dark:bg-white/15"]);const m=a("block w-full overflow-hidden text-start",{variants:{variant:{placeholder:"text-storm-400 dark:text-white",default:null},enableTextWrap:{true:false,false:"text-ellipsis whitespace-nowrap"},error:{true:"text-negative-red-700 dark:text-negative-red-alternative group-hover/button:text-negative-red-800",false:null}}});const c=class{constructor(i){t(this,i);this.queryChange=e(this,"queryChange",3);this.valueChange=e(this,"valueChange",3);this.selectAllChange=e(this,"selectAllChange",3);this.dropdownShown=e(this,"dropdownShown",3);this.add=e(this,"add",3);if(i.$hostElement$["s-ei"]){this._internals=i.$hostElement$["s-ei"]}else{this._internals=i.$hostElement$.attachInternals();i.$hostElement$["s-ei"]=this._internals}}items;multi;strategy="absolute";icon;query;placeholder;autocompletePlaceholder="Search...";value;displayKey="text";dropdownDisplayKey;selectionDisplayKey;valueKey;avatarKey;iconKey="icon";iconClassKey="iconClass";showIconOnSelectedItem;classKey="class";applyClassOnSelectedItem;applyClassOnSelectedItemInMenu;avatarLettersKey;identifierKey;queryKey;autoSelectFirst=true;showChevron=true;maxDisplayedItems=10;enableAutocomplete=true;enableTextWrap=false;asyncFilter=false;loading=false;enableSelectAll=false;selectAllText="Select all";selectAllIcon;queryChange;valueChange;selectAllChange;dropdownShown;size="base";prefix;label;helper;required=true;showOptional=true;error;disabled=false;showAddItem=false;addItemText="Add item";add;emptyStateText="No items available";get _el(){return i(this)}_showDropdown=false;_selectedItem=null;_allSelected=false;_amountHidden=0;_internals;_inputRef;autocompleteInputRef;_multiContainerRef;_resizeObserver;_resizeDebounceTimer;_checkSelectedItemsTimeout;get _items(){return this._getParsedItems()}get _displayValue(){const t=s("div",{class:m({variant:"placeholder"})},this.placeholder);if(!this._selectedItem){return t}if(this.multi){if(this._selectedItem?.length===0){return t}return s("div",{class:l(),ref:t=>this._multiContainerRef=t},this._selectedItem.map((t=>s("div",{class:p(),onClick:()=>this._selectValue(t)},t[this.selectionDisplayKey??this.displayKey],s("p-icon",{class:"text-xs text-indigo-500 group-hover/item:text-indigo-800 dark:text-white/15 dark:group-hover/item:text-white",variant:"negative"})))),s("div",{class:"extra pointer-events-none hidden text-sm text-storm-100"},"+",this._amountHidden))}return this._getDisplay(this._selectedItem,true)}get _identifierKey(){return this.identifierKey??this.valueKey??"value"}formResetCallback(){this._selectValue(null)}componentDidLoad(){if(!this.valueKey&&!this.identifierKey){throw new Error("You must provide a valueKey or identifierKey")}if(this.multi){this._setMultiContainerMaxWidth();this._resizeObserver=new ResizeObserver((()=>{if(this._resizeDebounceTimer){clearTimeout(this._resizeDebounceTimer);this._resizeDebounceTimer=null}this._resizeDebounceTimer=setTimeout((()=>{this._setMultiContainerMaxWidth();this._setCheckSelectedItemsTimeout()}),200)}));this._resizeObserver.observe(this._el)}if(this.value){this._valueChange();return}this.itemChanges()}componentDidRender(){if(this.multi){this._setMultiContainerMaxWidth()}}disconnectedCallback(){if(this.multi){this._resizeObserver.disconnect()}}render(){let t=this.icon;if(this._selectedItem&&!this.avatarKey&&!!this.iconKey&&this._selectedItem?.[this.iconKey]&&!this.showIconOnSelectedItem){t=this._selectedItem[this.iconKey]}if(this.avatarKey&&this._selectedItem?.[this.avatarKey]||this.avatarLettersKey&&this._selectedItem?.[this.avatarLettersKey]){t=null}if(this.error?.length){t="warning"}return s(n,{key:"9439487b74e09bb8808ff811a2c733e222210448"},s("p-field-container",{key:"dd6a355d244590e5fb0063ae8a44df9758cb7716",variant:"write",prefix:this.prefix,label:this.label,helper:this.helper,required:this.required,showOptional:this.showOptional,error:this.error,forceShowTooltip:!!this.error?.length&&!this._showDropdown},s("p-dropdown",{key:"236da5b3db7ff74fc175e79e91bfc35d7aad2eeb",applyFullWidth:true,applyMaxWidth:false,slot:"content",insideClick:true,manual:true,scrollable:this.enableAutocomplete?"large":true,"disable-trigger-click":this.disabled,show:this._showDropdown,onIsOpen:t=>this._onDropdownOpen(t),strategy:this.strategy},s("p-button",{key:"d688d0ff91ea09d413c5c53d7416b6bf65e9c13a",slot:"trigger",class:"w-full",variant:"secondary",size:this.size,chevron:this.showChevron?this._showDropdown?"up":"down":false,active:this._showDropdown,error:!!this.error?.length,icon:t,iconClass:this.applyClassOnSelectedItem&&this._selectedItem?.[this.iconClassKey],onClick:t=>this._onClick(t)},s("div",{key:"20ba382b0663009f96335c0139935156e9161411",class:"relative min-w-0 flex-1",ref:t=>this._inputRef=t},this._displayValue)),this.loading?this._getLoadingItems():this._getItems(),this.showAddItem&&this._getAddItem())))}documentClickHandler(t){if(!this._showDropdown||r(t,this._el)){return}this._showDropdown=false}_valueChange(){setTimeout((()=>{this._preselectItem();this._setCheckSelectedItemsTimeout()}))}itemChanges(){setTimeout((()=>this._preselectItem()))}_showDropdownChanges(){this.dropdownShown.emit({value:this._showDropdown,query:this.query})}multiChanges(){if(this._selectedItem&&!Array.isArray(this._selectedItem)){this._selectedItem=[]}}_preselectItem(){let t=typeof this.value==="string"&&this.multi?JSON.parse(this.value):this.value;if(this.multi){if(!Array.isArray(t)){this.value=[];this.valueChange.emit(this.value);return}this.value=t;if(!t.length){this._selectedItem=[];return}this._selectedItem=!!this.valueKey&&this.valueKey!=="false"?this._items.filter((e=>t.includes(e?.[this.valueKey]))):[...t];return}if(!this._selectedItem&&!t&&this.autoSelectFirst){t=this._items[0]}const e=typeof t==="object"&&t!==null?t[this._identifierKey]:t;const i=typeof e==="string"||typeof e==="number"?e:JSON.stringify(e);const s=this._selectedItem?this._selectedItem?.[this._identifierKey]:null;const r=typeof s==="string"||typeof s==="number"?s:JSON.stringify(s);if(this._selectedItem&&r===i){return}if(!this._items?.length&&t){this._selectValue(t,false);return}const a=this._getParsedItems(false);const o=a.find((t=>{const e=t?.[this._identifierKey];const s=typeof e==="string"||typeof e==="number"?e:JSON.stringify(e);return s===i}));this._selectValue(!!o?o:t,false)}_selectValue(t,e=true){let i=!!this.valueKey&&this.valueKey!=="false"&&t!==null?t?.[this.valueKey]:t;if(this.multi){if(!this._selectedItem||!Array.isArray(this._selectedItem)){this._selectedItem=[]}if(!this.value||!Array.isArray(this.value)){this.value=[]}const e=[...this._selectedItem];const s=[...this.value];const r=e.findIndex((e=>e[this._identifierKey]===t[this._identifierKey]));if(r===-1){e.push(t);s.push(i)}else{e.splice(r,1);s.splice(r,1)}this._selectedItem=e;this.value=s;this.valueChange.emit(s);return}this._selectedItem=t;this.value=i;this.valueChange.emit(i);this._onBlur(e)}_onClick(t){const e=t?.composedPath();for(const t of e){if(t.nodeName.toLowerCase()==="p-button"){break}if(t.classList?.contains("item")){return}}this._showDropdown=!this._showDropdown}_onBlur(t=false){if(this.enableAutocomplete&&!t){return}this._showDropdown=false}_onAutoComplete(t){if(!this.enableAutocomplete){return}this._showDropdown=true;this.query=t.detail;this.queryChange.emit(t.detail)}_checkvalue(t,e){return e?.[t]?.toString()?.toLowerCase().indexOf(this.query?.toLowerCase())>=0}_getItems(){let t=this._items.map((t=>{const e=this.multi&&!!this._selectedItem&&Array.isArray(this._selectedItem)?this._selectedItem.findIndex((e=>e[this._identifierKey]===t[this._identifierKey]))>=0:t[this._identifierKey]===this._selectedItem?.[this._identifierKey];return s("p-dropdown-menu-item",{enableTextWrap:this.enableTextWrap,useContainer:false,onClick:()=>this._selectValue(t),active:e,checkbox:this.multi?true:false,slot:"items"},this._getDisplay(t,false,e))}));if(!this._items.length){t=[s("p",{class:"w-full p-2 text-center text-sm text-storm-400",slot:"items"},this.emptyStateText)]}if(this.enableSelectAll&&this._items.length){t.unshift(s("p-dropdown-menu-item",{slot:"items",useContainer:false,checkbox:true,onClick:()=>this._selectAllChange(),active:this._allSelected},this.selectAllIcon?.length?s("span",{class:"flex items-center gap-2"},s("div",{class:"flex w-6 justify-center text-lg"},s("p-icon",{variant:this.selectAllIcon}))," ",this.selectAllText):this.selectAllText))}if(this.enableAutocomplete){t.unshift(this._getAutoCompleteItem())}return t}_getAddItem(){return s("p-dropdown-menu-item",{onClick:()=>this.add.emit(),useContainer:false,slot:"items"},s("span",{class:"flex items-center gap-1 font-semibold text-indigo-600"},this.addItemText,s("p-icon",{variant:"plus"})))}_getLoadingItems(){const t=[0,0,0].map((()=>s("p-dropdown-menu-item",{enableHover:false,slot:"items"},s("p-loader",{variant:"ghost",class:"h-6 w-full rounded"}))));if(this.enableAutocomplete){t.unshift(this._getAutoCompleteItem())}return t}_getAutoCompleteItem(){return s("div",{class:"sticky top-0 z-10 mb-3 h-8",slot:"items"},s("p-field",{class:"block",placeholder:this.autocompletePlaceholder,onValueChange:t=>this._onAutoComplete(t),onInputRefChange:t=>this.autocompleteInputRef=t.detail,value:this.query}))}_setMultiContainerMaxWidth(){if(!this._inputRef||!this._multiContainerRef){return}const t=this._inputRef.clientWidth-16;this._multiContainerRef.style.maxWidth=`${t>=16?t:16}px`}_setCheckSelectedItemsTimeout(){if(this._checkSelectedItemsTimeout){clearTimeout(this._checkSelectedItemsTimeout)}this._checkSelectedItemsTimeout=setTimeout((()=>this._checkSelectedItems()),50)}_checkSelectedItems(){if(!this._multiContainerRef){return}const t=this._multiContainerRef.getBoundingClientRect();const e=this._multiContainerRef.querySelectorAll(".item");let i=0;for(const s of e){s.classList.remove("hidden");s.classList.add("flex");const e=s.getBoundingClientRect();if(e.right>t.right){s.classList.remove("flex");s.classList.add("hidden");i++;continue}}this._amountHidden=i;const s=this._multiContainerRef.querySelector(".extra");if(!s){return}if(!s.classList.contains("hidden")){s.classList.add("hidden")}if(i>0){s.classList.remove("hidden")}}_onDropdownOpen(t){if(!t.detail||!this.autocompleteInputRef){return}setTimeout((()=>this.autocompleteInputRef.focus()),100)}_selectAllChange(){this._allSelected=!this._allSelected;this.selectAllChange.emit(this._allSelected)}_getDisplay(t,e=false,i=false){let r=s("div",{class:m({variant:"default",error:!!this.error?.length,enableTextWrap:this.enableTextWrap&&!e})},t[e?this.selectionDisplayKey??this.displayKey:this.displayKey]);if(this.avatarKey){r=s("span",{class:"flex items-center gap-2"},s("p-avatar",{size:"sm",src:t[this.avatarKey],letters:t[this.avatarLettersKey]}),s("div",{class:m({variant:"default",error:!!this.error?.length,enableTextWrap:this.enableTextWrap&&!e})},t[this.dropdownDisplayKey??this.displayKey]))}if(this.iconKey&&(!e||this.showIconOnSelectedItem)){r=s("span",{class:"flex items-center gap-2"},s("p-icon",{class:o("text-storm-300",(!e||!!this.applyClassOnSelectedItem)&&(!i||!!this.applyClassOnSelectedItemInMenu)?t?.[this.iconClassKey]??"":""),variant:t[this.iconKey]}),s("div",{class:m({variant:"default",error:!!this.error?.length,enableTextWrap:this.enableTextWrap&&!e})},t[this.dropdownDisplayKey??this.displayKey]))}if((!e||!!this.applyClassOnSelectedItem)&&(!i||!!this.applyClassOnSelectedItemInMenu)&&!!t?.[this.classKey]?.length){return s("div",{class:t[this.classKey]},r)}return r}_getParsedItems(t=true){if(!this.items||this.loading){return[]}let e=typeof this.items==="string"?JSON.parse(this.items):this.items;if(typeof e?.[0]==="string"){this.displayKey="text";this.valueKey="value";e=e.map((t=>({value:t,text:t})))}if(this.query?.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)}))}if(!t){return e}return e?.slice(0,this.maxDisplayedItems)}static get formAssociated(){return true}static get watchers(){return{value:["_valueChange"],items:["itemChanges"],_showDropdown:["_showDropdownChanges"],multi:["multiChanges"]}}};c.style=h;export{c as p_select};
|
|
2
|
-
//# sourceMappingURL=p-6fc32bea.entry.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,g as i,h as s}from"./p-Dpmiv2da.js";import{a as r}from"./p-BFSNj6hu.js";import{c as a}from"./p-CBWjHURv.js";import{c as o}from"./p-CT54OXR2.js";import{T as n}from"./p-C1iNEsnH.js";import"./p-ChV9xqsO.js";import"./p-BIwGgs9f.js";const h="*{box-sizing:border-box}:host{--tw-translate-y:0px!important;--tw-translate-x:0px!important}.pointer-events-none{pointer-events:none!important}.pointer-events-auto{pointer-events:auto!important}.static{position:static!important}.absolute{position:absolute!important}.relative{position:relative!important}.sticky{position:sticky!important}.top-0{top:0!important}.z-10{z-index:10!important}.mb-3{margin-bottom:.75rem!important}.block{display:block!important}.flex{display:flex!important}.hidden{display:none!important}.h-6{height:1.5rem!important}.h-8{height:2rem!important}.h-\\[1\\.625rem\\]{height:1.625rem!important}.h-full{height:100%!important}.w-6{width:1.5rem!important}.w-full{width:100%!important}.min-w-0{min-width:0!important}.flex-1{flex:1 1 0%!important}.cursor-pointer{cursor:pointer!important}.items-center{align-items:center!important}.justify-center{justify-content:center!important}.gap-1{gap:.25rem!important}.gap-2{gap:.5rem!important}.overflow-hidden{overflow:hidden!important}.text-ellipsis{text-overflow:ellipsis!important}.whitespace-nowrap{white-space:nowrap!important}.rounded{border-radius:.25rem!important}.rounded-lg{border-radius:.5rem!important}.bg-indigo-100{--tw-bg-opacity:1!important;background-color:rgb(227 236 254/var(--tw-bg-opacity,1))!important}.p-2{padding:.5rem!important}.px-2{padding-left:.5rem!important;padding-right:.5rem!important}.text-center{text-align:center!important}.text-start{text-align:start!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-xs{font-size:.75rem!important;line-height:1rem!important}.font-semibold{font-weight:600!important}.text-indigo-500{--tw-text-opacity:1!important;color:rgb(142 179 251/var(--tw-text-opacity,1))!important}.text-indigo-600{--tw-text-opacity:1!important;color:rgb(82 138 250/var(--tw-text-opacity,1))!important}.text-negative-red-700{--tw-text-opacity:1!important;color:rgb(147 16 16/var(--tw-text-opacity,1))!important}.text-storm-100{--tw-text-opacity:1!important;color:rgb(209 210 212/var(--tw-text-opacity,1))!important}.text-storm-300{--tw-text-opacity:1!important;color:rgb(116 120 127/var(--tw-text-opacity,1))!important}.text-storm-400{--tw-text-opacity:1!important;color:rgb(70 75 84/var(--tw-text-opacity,1))!important}.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}.group\\/button:hover .group-hover\\/button\\:text-negative-red-800{--tw-text-opacity:1!important;color:rgb(141 16 16/var(--tw-text-opacity,1))!important}.group\\/item:hover .group-hover\\/item\\:text-indigo-800{--tw-text-opacity:1!important;color:rgb(27 88 210/var(--tw-text-opacity,1))!important}.dark\\:bg-white\\/15:where(:host([data-theme=dark]),:host([data-theme=dark]) *){background-color:hsla(0,0%,100%,.15)!important}.dark\\:text-negative-red-alternative:where(:host([data-theme=dark]),:host([data-theme=dark]) *){--tw-text-opacity:1!important;color:rgb(255 92 92/var(--tw-text-opacity,1))!important}.dark\\:text-white:where(:host([data-theme=dark]),:host([data-theme=dark]) *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}.dark\\:text-white\\/15:where(:host([data-theme=dark]),:host([data-theme=dark]) *){color:hsla(0,0%,100%,.15)!important}.group\\/item:hover .dark\\:group-hover\\/item\\:text-white:where(:host([data-theme=dark]),:host([data-theme=dark]) *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}.dark\\:bg-white\\/15:where([data-theme=dark],[data-theme=dark] *){background-color:hsla(0,0%,100%,.15)!important}.dark\\:text-negative-red-alternative:where([data-theme=dark],[data-theme=dark] *){--tw-text-opacity:1!important;color:rgb(255 92 92/var(--tw-text-opacity,1))!important}.dark\\:text-white:where([data-theme=dark],[data-theme=dark] *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}.dark\\:text-white\\/15:where([data-theme=dark],[data-theme=dark] *){color:hsla(0,0%,100%,.15)!important}.group\\/item:hover .dark\\:group-hover\\/item\\:text-white:where([data-theme=dark],[data-theme=dark] *){--tw-text-opacity:1!important;color:rgb(255 255 255/var(--tw-text-opacity,1))!important}";const l=a(["flex items-center gap-2","flex-1 min-w-0 h-full","pointer-events-none overflow-hidden"]);const p=a(["item group/item","pointer-events-auto cursor-pointer","flex h-[1.625rem] items-center gap-2","h-[1.625rem] px-2","text-sm font-semibold whitespace-nowrap","rounded-lg","bg-indigo-100","dark:bg-white/15"]);const m=a("block w-full overflow-hidden text-start",{variants:{variant:{placeholder:"text-storm-400 dark:text-white",default:null},enableTextWrap:{true:false,false:"text-ellipsis whitespace-nowrap"},error:{true:"text-negative-red-700 dark:text-negative-red-alternative group-hover/button:text-negative-red-800",false:null}}});const c=class{constructor(i){t(this,i);this.queryChange=e(this,"queryChange",3);this.valueChange=e(this,"valueChange",3);this.selectAllChange=e(this,"selectAllChange",3);this.dropdownShown=e(this,"dropdownShown",3);this.add=e(this,"add",3);if(i.$hostElement$["s-ei"]){this._internals=i.$hostElement$["s-ei"]}else{this._internals=i.$hostElement$.attachInternals();i.$hostElement$["s-ei"]=this._internals}}items;multi;strategy="absolute";icon;query;placeholder;autocompletePlaceholder="Search...";value;displayKey="text";dropdownDisplayKey;selectionDisplayKey;valueKey;avatarKey;iconKey="icon";iconClassKey="iconClass";showIconOnSelectedItem;classKey="class";applyClassOnSelectedItem;applyClassOnSelectedItemInMenu;avatarLettersKey;identifierKey;queryKey;autoSelectFirst=true;showChevron=true;maxDisplayedItems=10;enableAutocomplete=true;enableTextWrap=false;asyncFilter=false;loading=false;enableSelectAll=false;selectAllText="Select all";selectAllIcon;queryChange;valueChange;selectAllChange;dropdownShown;size="base";prefix;label;helper;required=true;showOptional=true;error;disabled=false;showAddItem=false;addItemText="Add item";add;emptyStateText="No items available";get _el(){return i(this)}_showDropdown=false;_selectedItem=null;_allSelected=false;_amountHidden=0;_internals;_inputRef;autocompleteInputRef;_multiContainerRef;_resizeObserver;_resizeDebounceTimer;_checkSelectedItemsTimeout;get _items(){return this._getParsedItems()}get _displayValue(){const t=s("div",{class:m({variant:"placeholder"})},this.placeholder);if(!this._selectedItem){return t}if(this.multi){if(this._selectedItem?.length===0){return t}return s("div",{class:l(),ref:t=>this._multiContainerRef=t},this._selectedItem.map((t=>s("div",{class:p(),onClick:()=>this._selectValue(t)},t[this.selectionDisplayKey??this.displayKey],s("p-icon",{class:"text-xs text-indigo-500 group-hover/item:text-indigo-800 dark:text-white/15 dark:group-hover/item:text-white",variant:"negative"})))),s("div",{class:"extra pointer-events-none hidden text-sm text-storm-100"},"+",this._amountHidden))}return this._getDisplay(this._selectedItem,true)}get _identifierKey(){return this.identifierKey??this.valueKey??"value"}formResetCallback(){this._selectValue(null)}componentDidLoad(){if(!this.valueKey&&!this.identifierKey){throw new Error("You must provide a valueKey or identifierKey")}if(this.multi){this._setMultiContainerMaxWidth();this._resizeObserver=new ResizeObserver((()=>{if(this._resizeDebounceTimer){clearTimeout(this._resizeDebounceTimer);this._resizeDebounceTimer=null}this._resizeDebounceTimer=setTimeout((()=>{this._setMultiContainerMaxWidth();this._setCheckSelectedItemsTimeout()}),200)}));this._resizeObserver.observe(this._el)}if(this.value){this._valueChange();return}this.itemChanges()}componentDidRender(){if(this.multi){this._setMultiContainerMaxWidth()}}disconnectedCallback(){if(this.multi){this._resizeObserver.disconnect()}}render(){let t=this.icon;if(this._selectedItem&&!this.avatarKey&&!!this.iconKey&&this._selectedItem?.[this.iconKey]&&!this.showIconOnSelectedItem){t=this._selectedItem[this.iconKey]}if(this.avatarKey&&this._selectedItem?.[this.avatarKey]||this.avatarLettersKey&&this._selectedItem?.[this.avatarLettersKey]){t=null}if(this.error?.length){t="warning"}return s(n,{key:"9439487b74e09bb8808ff811a2c733e222210448"},s("p-field-container",{key:"dd6a355d244590e5fb0063ae8a44df9758cb7716",variant:"write",prefix:this.prefix,label:this.label,helper:this.helper,required:this.required,showOptional:this.showOptional,error:this.error,forceShowTooltip:!!this.error?.length&&!this._showDropdown},s("p-dropdown",{key:"236da5b3db7ff74fc175e79e91bfc35d7aad2eeb",applyFullWidth:true,applyMaxWidth:false,slot:"content",insideClick:true,manual:true,scrollable:this.enableAutocomplete?"large":true,"disable-trigger-click":this.disabled,show:this._showDropdown,onIsOpen:t=>this._onDropdownOpen(t),strategy:this.strategy},s("p-button",{key:"d688d0ff91ea09d413c5c53d7416b6bf65e9c13a",slot:"trigger",class:"w-full",variant:"secondary",size:this.size,chevron:this.showChevron?this._showDropdown?"up":"down":false,active:this._showDropdown,error:!!this.error?.length,icon:t,iconClass:this.applyClassOnSelectedItem&&this._selectedItem?.[this.iconClassKey],onClick:t=>this._onClick(t)},s("div",{key:"20ba382b0663009f96335c0139935156e9161411",class:"relative min-w-0 flex-1",ref:t=>this._inputRef=t},this._displayValue)),this.loading?this._getLoadingItems():this._getItems(),this.showAddItem&&this._getAddItem())))}documentClickHandler(t){if(!this._showDropdown||r(t,this._el)){return}this._showDropdown=false}_valueChange(){setTimeout((()=>{this._preselectItem();this._setCheckSelectedItemsTimeout()}))}itemChanges(){setTimeout((()=>this._preselectItem()))}_showDropdownChanges(){this.dropdownShown.emit({value:this._showDropdown,query:this.query})}multiChanges(){if(this._selectedItem&&!Array.isArray(this._selectedItem)){this._selectedItem=[]}}_preselectItem(){let t=typeof this.value==="string"&&this.multi?JSON.parse(this.value):this.value;if(this.multi){if(!Array.isArray(t)){this.value=[];this.valueChange.emit(this.value);return}this.value=t;if(!t.length){this._selectedItem=[];return}this._selectedItem=!!this.valueKey&&this.valueKey!=="false"?this._items.filter((e=>t.includes(e?.[this.valueKey]))):[...t];return}if(!this._selectedItem&&!t&&this.autoSelectFirst){t=this._items[0]}const e=typeof t==="object"&&t!==null?t[this._identifierKey]:t;const i=typeof e==="string"||typeof e==="number"?e:JSON.stringify(e);const s=this._selectedItem?this._selectedItem?.[this._identifierKey]:null;const r=typeof s==="string"||typeof s==="number"?s:JSON.stringify(s);if(this._selectedItem&&r===i){return}if(!this._items?.length&&t){this._selectValue(t,false);return}const a=this._getParsedItems(false);const o=a.find((t=>{const e=t?.[this._identifierKey];const s=typeof e==="string"||typeof e==="number"?e:JSON.stringify(e);return s===i}));this._selectValue(!!o?o:t,false)}_selectValue(t,e=true){let i=!!this.valueKey&&this.valueKey!=="false"&&t!==null?t?.[this.valueKey]:t;if(this.multi){if(!this._selectedItem||!Array.isArray(this._selectedItem)){this._selectedItem=[]}if(!this.value||!Array.isArray(this.value)){this.value=[]}const e=[...this._selectedItem];const s=[...this.value];const r=e.findIndex((e=>e[this._identifierKey]===t[this._identifierKey]));if(r===-1){e.push(t);s.push(i)}else{e.splice(r,1);s.splice(r,1)}this._selectedItem=e;this.value=s;this.valueChange.emit(s);return}this._selectedItem=t;this.value=i;this.valueChange.emit(i);this._onBlur(e)}_onClick(t){const e=t?.composedPath();for(const t of e){if(t.nodeName.toLowerCase()==="p-button"){break}if(t.classList?.contains("item")){return}}this._showDropdown=!this._showDropdown}_onBlur(t=false){if(this.enableAutocomplete&&!t){return}this._showDropdown=false}_onAutoComplete(t){if(!this.enableAutocomplete){return}this._showDropdown=true;this.query=t.detail;this.queryChange.emit(t.detail)}_checkvalue(t,e){return e?.[t]?.toString()?.toLowerCase().indexOf(this.query?.toLowerCase())>=0}_getItems(){let t=this._items.map((t=>{const e=this.multi&&!!this._selectedItem&&Array.isArray(this._selectedItem)?this._selectedItem.findIndex((e=>e[this._identifierKey]===t[this._identifierKey]))>=0:t[this._identifierKey]===this._selectedItem?.[this._identifierKey];return s("p-dropdown-menu-item",{enableTextWrap:this.enableTextWrap,useContainer:false,onClick:()=>this._selectValue(t),active:e,checkbox:this.multi?true:false,slot:"items"},this._getDisplay(t,false,e))}));if(!this._items.length){t=[s("p",{class:"w-full p-2 text-center text-sm text-storm-400",slot:"items"},this.emptyStateText)]}if(this.enableSelectAll&&this._items.length){t.unshift(s("p-dropdown-menu-item",{slot:"items",useContainer:false,checkbox:true,onClick:()=>this._selectAllChange(),active:this._allSelected},this.selectAllIcon?.length?s("span",{class:"flex items-center gap-2"},s("div",{class:"flex w-6 justify-center text-lg"},s("p-icon",{variant:this.selectAllIcon}))," ",this.selectAllText):this.selectAllText))}if(this.enableAutocomplete){t.unshift(this._getAutoCompleteItem())}return t}_getAddItem(){return s("p-dropdown-menu-item",{onClick:()=>this.add.emit(),useContainer:false,slot:"items"},s("span",{class:"flex items-center gap-1 font-semibold text-indigo-600"},this.addItemText,s("p-icon",{variant:"plus"})))}_getLoadingItems(){const t=[0,0,0].map((()=>s("p-dropdown-menu-item",{enableHover:false,slot:"items"},s("p-loader",{variant:"ghost",class:"h-6 w-full rounded"}))));if(this.enableAutocomplete){t.unshift(this._getAutoCompleteItem())}return t}_getAutoCompleteItem(){return s("div",{class:"sticky top-0 z-10 mb-3 h-8",slot:"items"},s("p-field",{class:"block",placeholder:this.autocompletePlaceholder,onValueChange:t=>this._onAutoComplete(t),onInputRefChange:t=>this.autocompleteInputRef=t.detail,value:this.query}))}_setMultiContainerMaxWidth(){if(!this._inputRef||!this._multiContainerRef){return}const t=this._inputRef.clientWidth-16;this._multiContainerRef.style.maxWidth=`${t>=16?t:16}px`}_setCheckSelectedItemsTimeout(){if(this._checkSelectedItemsTimeout){clearTimeout(this._checkSelectedItemsTimeout)}this._checkSelectedItemsTimeout=setTimeout((()=>this._checkSelectedItems()),50)}_checkSelectedItems(){if(!this._multiContainerRef){return}const t=this._multiContainerRef.getBoundingClientRect();const e=this._multiContainerRef.querySelectorAll(".item");let i=0;for(const s of e){s.classList.remove("hidden");s.classList.add("flex");const e=s.getBoundingClientRect();if(e.right>t.right){s.classList.remove("flex");s.classList.add("hidden");i++;continue}}this._amountHidden=i;const s=this._multiContainerRef.querySelector(".extra");if(!s){return}if(!s.classList.contains("hidden")){s.classList.add("hidden")}if(i>0){s.classList.remove("hidden")}}_onDropdownOpen(t){if(!t.detail||!this.autocompleteInputRef){return}setTimeout((()=>this.autocompleteInputRef.focus()),100)}_selectAllChange(){this._allSelected=!this._allSelected;this.selectAllChange.emit(this._allSelected)}_getDisplay(t,e=false,i=false){let r=s("div",{class:m({variant:"default",error:!!this.error?.length,enableTextWrap:this.enableTextWrap&&!e})},t[e?this.selectionDisplayKey??this.displayKey:this.displayKey]);if(this.avatarKey){r=s("span",{class:"flex items-center gap-2"},s("p-avatar",{size:"sm",src:t[this.avatarKey],letters:t[this.avatarLettersKey]}),s("div",{class:m({variant:"default",error:!!this.error?.length,enableTextWrap:this.enableTextWrap&&!e})},t[this.dropdownDisplayKey??this.displayKey]))}if(this.iconKey&&(!e||this.showIconOnSelectedItem)){r=s("span",{class:"flex items-center gap-2"},s("p-icon",{class:o("text-storm-300",(!e||!!this.applyClassOnSelectedItem)&&(!i||!!this.applyClassOnSelectedItemInMenu)?t?.[this.iconClassKey]??"":""),variant:t[this.iconKey]}),s("div",{class:m({variant:"default",error:!!this.error?.length,enableTextWrap:this.enableTextWrap&&!e})},t[this.dropdownDisplayKey??this.displayKey]))}if((!e||!!this.applyClassOnSelectedItem)&&(!i||!!this.applyClassOnSelectedItemInMenu)&&!!t?.[this.classKey]?.length){return s("div",{class:t[this.classKey]},r)}return r}_getParsedItems(t=true){if(!this.items||this.loading){return[]}let e=typeof this.items==="string"?JSON.parse(this.items):this.items;if(typeof e?.[0]==="string"){this.displayKey="text";this.valueKey="value";e=e.map((t=>({value:t,text:t})))}if(this.query?.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)}))}if(!t){return e}return e?.slice(0,this.maxDisplayedItems)}static get formAssociated(){return true}static get watchers(){return{value:["_valueChange"],items:["itemChanges"],_showDropdown:["_showDropdownChanges"],multi:["multiChanges"]}}};c.style=h;export{c as p_select};
|
|
2
|
-
//# sourceMappingURL=p-6fc32bea.entry.js.map
|