@logosphere-ui/core 0.0.0-alpha.24 → 0.0.0-alpha.25
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/AGENTS.md +1118 -0
- package/dist/AGENTS.md +1118 -0
- package/dist/atoms/Badge/badge.d.ts +1 -1
- package/dist/atoms/FormField/formfield.d.ts +3 -0
- package/dist/badge-CGgnn_UN.js +72 -0
- package/dist/badge-DXBwR32c.cjs +13 -0
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/button-BBf5JAD-.js +58 -0
- package/dist/button-BryTzF74.cjs +10 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/{calendar-WZ_GQvnn.js → calendar-BiJlAmA6.js} +1 -1
- package/dist/{calendar-LMn1ZF3N.cjs → calendar-D5W-t26J.cjs} +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/{card-KiNHfEi2.cjs → card-C8G9YXhU.cjs} +1 -1
- package/dist/{card-CNoTUaJC.js → card-RWV7CumH.js} +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/chatbot-BfzuCerB.cjs +183 -0
- package/dist/{chatbot-Cn3Cvz8h.js → chatbot-CDtwNwGX.js} +146 -84
- package/dist/chatbot.cjs +1 -1
- package/dist/chatbot.js +1 -1
- package/dist/{combobox-D5X75iH0.cjs → combobox-BrANDiaM.cjs} +1 -1
- package/dist/{combobox-CtvjEL24.js → combobox-D5QdM3ue.js} +3 -3
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/{datepicker-CwDDA6np.cjs → datepicker-CxKs90IQ.cjs} +1 -1
- package/dist/{datepicker-SwKsdw3S.js → datepicker-DZsZdSCv.js} +3 -3
- package/dist/datepicker.cjs +1 -1
- package/dist/datepicker.js +1 -1
- package/dist/{drawer-DVINJB4a.js → drawer-D_qOdapq.js} +2 -2
- package/dist/drawer-s1BLy2Xe.cjs +25 -0
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.js +1 -1
- package/dist/{formfield-CNh4mBSs.js → formfield-BZOK4Pkz.js} +23 -16
- package/dist/formfield-HIqosWPz.cjs +33 -0
- package/dist/formfield.cjs +1 -1
- package/dist/formfield.js +1 -1
- package/dist/index.cjs +119 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +358 -41
- package/dist/index.umd.js +381 -173
- package/dist/{input-DcSyXsp9.js → input-CG6RsUJs.js} +2 -2
- package/dist/{input-C6OHJuya.cjs → input-DgGaco-Y.cjs} +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/left-menu.cjs +1 -1
- package/dist/left-menu.js +1 -1
- package/dist/{leftmenu-BSb9rGg4.cjs → leftmenu-BSVpwbyD.cjs} +1 -1
- package/dist/{leftmenu-vMqGQhcS.js → leftmenu-DJE2N5kl.js} +7 -7
- package/dist/molecules/Textarea/text-area.d.ts +5 -1
- package/dist/molecules/TimePicker/index.d.ts +2 -0
- package/dist/molecules/TimePicker/timepicker.d.ts +62 -0
- package/dist/organisms/Chatbot/chatbot.d.ts +7 -0
- package/dist/organisms/Toast/index.d.ts +2 -0
- package/dist/organisms/Toast/toast-container.d.ts +42 -0
- package/dist/organisms/Toast/toast.d.ts +48 -0
- package/dist/styles/main.css +89 -83
- package/dist/text-area-Bz62kq2S.cjs +51 -0
- package/dist/text-area-CG0gBXni.js +235 -0
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/toast-container-Br8TDkFh.js +274 -0
- package/dist/toast-container-DsEbVrT7.cjs +64 -0
- package/dist/toast.cjs +1 -0
- package/dist/toast.js +6 -0
- package/dist/{tree-menu-BbX8GK_z.js → tree-menu-B39KDvKV.js} +2 -2
- package/dist/tree-menu-BZEOD4_f.cjs +47 -0
- package/dist/tree-menu.cjs +1 -1
- package/dist/tree-menu.js +1 -1
- package/dist/ui-icon-BRl1UmIf.cjs +22 -0
- package/dist/ui-icon-CFvsDv0z.js +66 -0
- package/package.json +21 -11
- package/dist/badge-7IIatiRv.cjs +0 -13
- package/dist/badge-B2chRYGd.js +0 -72
- package/dist/button-BqOMevro.js +0 -58
- package/dist/button-CDRccsk9.cjs +0 -10
- package/dist/chatbot-DjFe2_HE.cjs +0 -161
- package/dist/drawer-BvcPd5nz.cjs +0 -25
- package/dist/formfield-BFOIEicR.cjs +0 -33
- package/dist/text-area-CZDdxbrN.cjs +0 -46
- package/dist/text-area-Dec_k4rs.js +0 -205
- package/dist/tree-menu-B1iwfHyd.cjs +0 -47
- package/dist/ui-icon-Bys4HYSQ.js +0 -57
- package/dist/ui-icon-DWh1MhBa.cjs +0 -22
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("lit"),s=require("lit/decorators.js"),y=require("lit/directives/unsafe-html.js");require("./combobox-D5X75iH0.cjs");require("./button-CDRccsk9.cjs");require("./input-C6OHJuya.cjs");require("./ui-icon-DWh1MhBa.cjs");const w=":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;inset:0;background-color:#0003;z-index:var(--z-index-modal-backdrop)}.chatbot__launcher{position:fixed;z-index:var(--z-index-modal);display:flex;align-items:center;gap:var(--spacing-4);padding-left:var(--spacing-4);padding-right:var(--spacing-4);height:66px;color:#fff;border-radius:var(--radius-xl);cursor:pointer;box-shadow:var(--shadow-base);background-color:var(--color-body-bg);overflow:hidden;transition:box-shadow var(--transition-speed-fast) var(--transition-timing)}.chatbot__launcher:hover{box-shadow:var(--shadow-md)}.chatbot__launcher--draggable{cursor:move}.chatbot__launcher--hidden{visibility:hidden;width:72px;height:66px;justify-content:center;padding:0}.chatbot__launcher-icon{width:40px;height:34px;flex-shrink:0}.chatbot__launcher-text{display:flex;flex-direction:column}.chatbot__launcher-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;white-space:nowrap;color:var(--color-body-text)}.chatbot__launcher-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;white-space:nowrap;color:var(--color-tertiary)}.chatbot__window{position:fixed;z-index:var(--z-index-modal);display:flex;flex-direction:column;box-shadow:var(--shadow-xl);border-radius:var(--radius-md);overflow:hidden;background-color:var(--color-body-bg)}.chatbot__window--hidden{display:none}.chatbot__window--fullscreen{inset:80px 50px;width:auto;height:auto}.chatbot__resize-top{position:absolute;top:0;left:0;right:0;height:8px;cursor:ns-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-top:hover{background-color:#0000000d}.chatbot__resize-side{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-side:hover{background-color:#0000000d}.chatbot__resize-side--left{left:0}.chatbot__resize-side--right{right:0}.chatbot__resize-corner{position:absolute;top:0;width:16px;height:16px;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-corner:hover{background-color:#0000001a}.chatbot__resize-corner--nwse{left:0;cursor:nwse-resize}.chatbot__resize-corner--nesw{right:0;cursor:nesw-resize}.chatbot__header{height:74px;display:flex;align-items:center;justify-content:space-between;padding-left:var(--spacing-5);padding-right:var(--spacing-4);gap:var(--spacing-4);flex-shrink:0;background-color:var(--color-body-bg);border-bottom:1px solid var(--color-border)}.chatbot__header-info{display:flex;align-items:center;gap:var(--spacing-4)}.chatbot__header-logo{width:50px;height:41px}.chatbot__header-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;color:var(--color-body-text)}.chatbot__header-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;color:var(--color-tertiary)}.chatbot__header-actions{display:flex;align-items:center;gap:var(--spacing-2)}.chatbot__body{flex:1;display:flex;flex-direction:column;background-color:var(--color-body-bg);position:relative;overflow:hidden}.chatbot__product{padding:var(--spacing-3);padding-bottom:0;flex-shrink:0;margin:0 var(--spacing-3)}.chatbot__messages{flex:1;display:flex;flex-direction:column;gap:var(--spacing-3);margin-top:var(--spacing-4);padding:var(--spacing-4);overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}.chatbot__messages::-webkit-scrollbar{display:none}.chatbot__message{display:flex}.chatbot__message--user{justify-content:flex-end}.chatbot__message--assistant,.chatbot__message--system{justify-content:flex-start}.chatbot__bubble{position:relative;color:var(--color-body-text);max-width:85%;border-radius:var(--radius-md);padding:var(--spacing-4);font-size:var(--font-size-sm);line-height:20px;font-weight:var(--font-weight-medium)}.chatbot__bubble--user{background-color:var(--color-primary);color:#fff;border-bottom-right-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.chatbot__bubble--user a{color:#ffffffe6}.chatbot__bubble--assistant,.chatbot__bubble--system{background-color:var(--color-tertiary-bg);border-bottom-left-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-right-radius:var(--radius-xl)}.chatbot__message-content p{margin:0}.chatbot__message-content ol{list-style-type:decimal;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content ul{list-style-type:disc;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content li>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.chatbot__message-content li{padding-left:var(--spacing-1)}.chatbot__message-content a{color:var(--color-primary);text-decoration:underline;transition:color var(--transition-speed-fast) var(--transition-timing)}.chatbot__message-content a:hover{color:var(--color-primary-hover)}.chatbot__feedback{display:flex;align-items:center;gap:var(--spacing-2);padding-top:var(--spacing-2)}.chatbot__typing-wrapper{display:flex;justify-content:flex-start}.chatbot__typing{background-color:var(--color-tertiary-bg);padding:var(--spacing-3);border-radius:var(--radius-xl);border-bottom-left-radius:0;display:inline-flex;align-items:center;gap:2px}.chatbot__typing-dot{display:inline-block;width:6px;height:6px;background-color:var(--color-gray-300);border-radius:var(--radius-full);animation:chatbot-typing 1.4s infinite ease-in-out both;margin:0 2px}.chatbot__typing-dot:nth-child(1){animation-delay:-.32s}.chatbot__typing-dot:nth-child(2){animation-delay:-.16s}@keyframes chatbot-typing{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chatbot__input-area{padding:var(--spacing-4);padding-top:var(--spacing-2);padding-bottom:var(--spacing-1);background-color:var(--color-body-bg)}.chatbot__input-wrapper{position:relative;display:flex;align-items:center;gap:var(--spacing-2);background-color:var(--color-tertiary-bg);border-radius:var(--radius-md);padding:var(--spacing-2);border:1px solid transparent;transition:background-color var(--transition-speed-fast) var(--transition-timing),border-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__input-wrapper:focus-within{background-color:var(--color-body-bg);border-color:var(--color-border)}.chatbot__input{flex:1;background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-body-text)}.chatbot__input::placeholder{color:var(--color-tertiary)}.chatbot__input:disabled{opacity:.5;cursor:not-allowed}.chatbot__footer{display:flex;align-items:center;justify-content:center;padding-bottom:var(--spacing-2)}.chatbot__footer-text{margin:0;padding:0;color:var(--color-secondary);font-size:var(--font-size-xs);font-family:var(--font-family-base)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";var x=Object.defineProperty,C=Object.getOwnPropertyDescriptor,r=(l,t,e,a)=>{for(var o=a>1?void 0:a?C(t,e):t,i=l.length-1,h;i>=0;i--)(h=l[i])&&(o=(a?h(t,e,o):h(o))||o);return a&&o&&x(t,e,o),o};exports.LogosphereChatBot=class extends n.LitElement{constructor(){super(...arguments),this.returnUri="",this.questionPrompt="",this.minimizedIconOnly=!1,this.draggable=!1,this.resizable=!1,this.products=[],this.openInitially=!1,this.showFeedbackButtons=!1,this.open=!1,this.fullscreen=!1,this.messages=[],this.isLoading=!1,this.inputText="",this.selectedProductId="",this.windowWidth=440,this.windowHeight=Math.min(700,window.innerHeight-40),this.position={right:20,bottom:20},this.isDragging=!1,this.screenWidth=window.innerWidth,this.dragStartPos={x:0,y:0},this.initialPosition={right:0,bottom:0},this.isResizing=!1,this.resizeDirection="horizontal",this.resizeStartWidth=0,this.resizeStartHeight=0,this.onWindowResize=()=>{this.screenWidth=window.innerWidth;const t=window.innerHeight-40;this.windowHeight>t&&(this.windowHeight=t)},this.onToggle=()=>{this.open=!this.open,this.scrollToBottom()},this.onClose=()=>{this.open=!1,this.fullscreen=!1},this.onToggleFullscreen=()=>{this.fullscreen=!this.fullscreen},this.onMouseMove=t=>{if(this.isDragging){const e=this.dragStartPos.x-t.clientX,a=this.dragStartPos.y-t.clientY,i=this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(),h=i?.width||72,g=i?.height||66;this.position={right:Math.max(0,Math.min(window.innerWidth-h,this.initialPosition.right+e)),bottom:Math.max(0,Math.min(window.innerHeight-g,this.initialPosition.bottom+a))}}else if(this.isResizing){const e=this.dragStartPos.x-t.clientX,a=this.dragStartPos.y-t.clientY;if(this.resizeDirection==="horizontal"||this.resizeDirection==="both"){const o=this.position.right<this.screenWidth/2;this.windowWidth=Math.max(300,this.resizeStartWidth+(o?e:-e))}(this.resizeDirection==="vertical"||this.resizeDirection==="both")&&(this.windowHeight=Math.max(400,this.resizeStartHeight+a))}},this.onMouseUp=t=>{this.isDragging?(this.isDragging=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),Math.hypot(t.clientX-this.dragStartPos.x,t.clientY-this.dragStartPos.y)<5&&this.onToggle()):this.isResizing&&(this.isResizing=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp))},this.handleKeyDown=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendMessage())},this.onInput=t=>{const e=t.target;this.inputText=e?e.value:t.detail},this.onCopyMessage=t=>{navigator.clipboard.writeText(t)}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onWindowResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}async firstUpdated(){this.selectedProductId=this._resolveInitialProduct(),this.open=this.openInitially,this.open&&await this.initConversation()}updated(t){t.has("products")&&this.handleProductUpdate(),t.has("messages")&&this.scrollToBottom(),t.has("open")&&this.open&&!this.conversationId&&this.initConversation()}_resolveInitialProduct(){if(!this.products.length)return"";const t=this.products.find(e=>e.selected);return t?t.id:this.products.length===1?this.products[0].id:""}handleProductUpdate(){if(!this.products.length)return;const t=this.products.find(a=>a.selected),e=this.products.some(a=>a.id===this.selectedProductId);t&&t.id!==this.selectedProductId?(this.selectedProductId=t.id,this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()):e||(this.selectedProductId=this._resolveInitialProduct(),this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()),requestAnimationFrame(()=>this.updateComboboxItems())}updateComboboxItems(){const t=this.productEl;if(!t||this.products?.length<=1)return;const e=this.products.map(o=>({value:o.id,label:o.name}));if(t.items=e,(t.selectedItems?.()||[])[0]?.value!==this.selectedProductId){const o=e.find(i=>i.value===this.selectedProductId);t.setSelected&&t.setSelected(o?[o]:[])}}async onProductChange(t){const e=t.detail?.selected?.[0]?.value;e&&e!==this.selectedProductId&&(this.selectedProductId=e)}onMouseDown(t){this.draggable&&(t.preventDefault(),this.isDragging=!0,this.dragStartPos={x:t.clientX,y:t.clientY},this.initialPosition={...this.position},window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}startResize(t,e){this.resizable&&(t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.resizeDirection=e,this.dragStartPos={x:t.clientX,y:t.clientY},this.resizeStartWidth=this.windowWidth,this.resizeStartHeight=this.windowHeight,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}async ensureToken(t=!1){const e="logosphere_chatbot_token";if(t&&(this.assertionToken=void 0,localStorage.removeItem(e)),!t){const i=localStorage.getItem(e);if(i){this.assertionToken=i;return}}const o=await(await fetch(`${this.returnUri}/api/chat/start`)).json();if(!o.Success||!o.Data?.Token)throw new Error("Token alınamadı");this.assertionToken=o.Data.Token,localStorage.setItem(e,this.assertionToken)}async postChat(t){await this.ensureToken();const e=`${this.returnUri}/api/chat/completions`,a=()=>fetch(e,{method:"POST",headers:{"Content-Type":"application/json",client_assertion:this.assertionToken,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},body:JSON.stringify(t)});let o=await a();if(o.status===401&&(await this.ensureToken(!0),o=await a()),!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async initConversation(){if(!this.isLoading){this.isLoading=!0;try{await this.ensureToken();const t=await this.postChat({ChatCompletionType:"NewConversation",Context:this.selectedProductId,QuestionPrompt:this.questionPrompt});this.conversationId=t.Data.ConversationId;const e=t.Data.Choices?.[0]?.Message?.Content;e&&this.addMessage(e,"assistant")}catch{this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.","system")}finally{this.isLoading=!1}}}async sendMessage(){const t=this.inputText.trim();if(!(!t||!this.conversationId||this.isLoading)){if(!this.selectedProductId){this.addMessage("Lütfen önce bir ürün seçiniz.","system");return}this.addMessage(t,"user"),this.inputText="",this.isLoading=!0;try{const a=(await this.postChat({ChatCompletionType:"ConversationUpdate",Content:t,Context:this.selectedProductId,ConversationId:this.conversationId,QuestionPrompt:this.questionPrompt})).Data?.Choices?.[0]?.Message?.Content;this.addMessage(a||"Cevap alınamadı.","assistant")}catch{this.addMessage("Bağlantı hatası.","system")}finally{this.isLoading=!1}}}addMessage(t,e){this.messages=[...this.messages,{content:t,role:e,timestamp:Date.now()}]}scrollToBottom(){setTimeout(()=>{this.chatContainer&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)},0)}formatContent(t){if(!t)return"";const a=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").split(`
|
|
2
|
-
`);let o="";const i=[];let h=!1;const g=()=>{h&&(o+="</li>",h=!1)},f=d=>{for(;i.length>0&&i[i.length-1].indent>=d;)g(),o+=`</${i.pop().type}>`,i.length>0&&(h=!0)},b=()=>f(-1);for(const d of a){const p=d.match(/^(\s*)\d+\.\s+(.*)/),m=d.match(/^(\s*)[-*]\s+(.*)/);if(p||m){const c=(p?p[1]:m[1]).length,u=p?"ol":"ul",_=p?p[2]:m[2];if(i.length===0)o+=`<${u}>`,i.push({type:u,indent:c});else{const v=i[i.length-1];c>v.indent?(o+=`<${u}>`,i.push({type:u,indent:c})):c===v.indent?g():(f(c+1),i.length>0&&i[i.length-1].indent===c?g():(b(),o+=`<${u}>`,i.push({type:u,indent:c})))}o+=`<li>${_}`,h=!0}else d.trim()===""?i.length===0&&(o+="<br>"):(b(),o+=`<p>${d}</p>`)}return b(),o.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>')}render(){const t=this.position.right<this.screenWidth/2;return n.html`
|
|
3
|
-
<div class="chatbot">
|
|
4
|
-
${this.renderOverlay()}
|
|
5
|
-
${this.renderLauncher()}
|
|
6
|
-
${this.renderWindow(t)}
|
|
7
|
-
</div>
|
|
8
|
-
`}renderOverlay(){return this.open||this.fullscreen?n.html`<div class="chatbot__overlay" @click=${this.onToggle}></div>`:""}renderLauncher(){const t=["chatbot__launcher",this.draggable?"chatbot__launcher--draggable":"",this.open?"chatbot__launcher--hidden":""].filter(Boolean).join(" ");return n.html`
|
|
9
|
-
<div
|
|
10
|
-
class="${t}"
|
|
11
|
-
style="right: ${this.position.right}px; bottom: ${this.position.bottom}px;"
|
|
12
|
-
@mousedown=${this.onMouseDown}
|
|
13
|
-
@click=${this.draggable?null:this.onToggle}
|
|
14
|
-
aria-expanded=${this.open?"true":"false"}
|
|
15
|
-
>
|
|
16
|
-
<img class="chatbot__launcher-icon" src="${exports.LogosphereChatBot.ICONS.launcher}" alt="chatbot" />
|
|
17
|
-
${!this.open&&!this.minimizedIconOnly?n.html`
|
|
18
|
-
<div class="chatbot__launcher-text">
|
|
19
|
-
<p class="chatbot__launcher-title">Logo</p>
|
|
20
|
-
<p class="chatbot__launcher-subtitle">Dijital Danışman</p>
|
|
21
|
-
</div>
|
|
22
|
-
`:""}
|
|
23
|
-
</div>
|
|
24
|
-
`}renderWindow(t){const e=["chatbot__window",this.open?"":"chatbot__window--hidden",this.fullscreen?"chatbot__window--fullscreen":""].filter(Boolean).join(" "),a=this.fullscreen?"":`bottom: 20px; height: ${this.windowHeight}px; width: ${this.windowWidth}px; ${t?"right: 20px;":"left: 20px;"}`;return n.html`
|
|
25
|
-
<div class="${e}" style="${a}">
|
|
26
|
-
${this.renderResizeHandles(t)}
|
|
27
|
-
${this.renderHeader()}
|
|
28
|
-
<div class="chatbot__body">
|
|
29
|
-
${this.renderProductSelector()}
|
|
30
|
-
${this.renderChatArea()}
|
|
31
|
-
${this.renderInputArea()}
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
`}renderResizeHandles(t){return this.fullscreen||!this.resizable?"":n.html`
|
|
35
|
-
<div class="chatbot__resize-top"
|
|
36
|
-
@mousedown=${e=>this.startResize(e,"vertical")}></div>
|
|
37
|
-
<div class="chatbot__resize-side ${t?"chatbot__resize-side--left":"chatbot__resize-side--right"}"
|
|
38
|
-
@mousedown=${e=>this.startResize(e,"horizontal")}></div>
|
|
39
|
-
<div class="chatbot__resize-corner ${t?"chatbot__resize-corner--nwse":"chatbot__resize-corner--nesw"}"
|
|
40
|
-
@mousedown=${e=>this.startResize(e,"both")}></div>
|
|
41
|
-
`}renderHeader(){return n.html`
|
|
42
|
-
<div class="chatbot__header">
|
|
43
|
-
<div class="chatbot__header-info">
|
|
44
|
-
<img class="chatbot__header-logo" alt="logo" src="${exports.LogosphereChatBot.ICONS.launcher}" />
|
|
45
|
-
<div>
|
|
46
|
-
<p class="chatbot__header-title">Logo</p>
|
|
47
|
-
<p class="chatbot__header-subtitle">Dijital Danışman</p>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
<div class="chatbot__header-actions">
|
|
51
|
-
<logosphere-button
|
|
52
|
-
iconOnly="true"
|
|
53
|
-
size="sm"
|
|
54
|
-
variant="text"
|
|
55
|
-
theme="--color-light-rgb"
|
|
56
|
-
title=${this.fullscreen?"Küçült":"Tam Ekran"}
|
|
57
|
-
@click=${this.onToggleFullscreen}
|
|
58
|
-
>
|
|
59
|
-
<ui-icon name="${this.fullscreen?"uil-compress-alt":"uil-expand-alt"}" size="16"></ui-icon>
|
|
60
|
-
</logosphere-button>
|
|
61
|
-
<logosphere-button
|
|
62
|
-
iconOnly="true"
|
|
63
|
-
size="sm"
|
|
64
|
-
variant="text"
|
|
65
|
-
theme="--color-light"
|
|
66
|
-
title="Kapat"
|
|
67
|
-
@click=${this.onClose}
|
|
68
|
-
>
|
|
69
|
-
<ui-icon name="uil-times" size="16"></ui-icon>
|
|
70
|
-
</logosphere-button>
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
`}renderProductSelector(){return n.html`
|
|
74
|
-
<div class="chatbot__product-selector">
|
|
75
|
-
${this.products.length>1?n.html`
|
|
76
|
-
<logosphere-combobox
|
|
77
|
-
id="product"
|
|
78
|
-
.items=${this.products.map(t=>({value:t.id,label:t.name}))}
|
|
79
|
-
optionValue="value"
|
|
80
|
-
optionLabel="label"
|
|
81
|
-
placeholder="Ürün seçiniz"
|
|
82
|
-
@selected=${this.onProductChange}
|
|
83
|
-
></logosphere-combobox>
|
|
84
|
-
`:n.html`
|
|
85
|
-
<input
|
|
86
|
-
id="product"
|
|
87
|
-
class="chatbot__product-input"
|
|
88
|
-
placeholder="Ürün seçiniz"
|
|
89
|
-
.value=${this.products.length===1?this.products[0].name:""}
|
|
90
|
-
readOnly="true"
|
|
91
|
-
>
|
|
92
|
-
`}
|
|
93
|
-
</div>
|
|
94
|
-
`}renderChatArea(){return n.html`
|
|
95
|
-
<div id="chat-container" class="chatbot__messages">
|
|
96
|
-
${this.messages.map(t=>this.renderMessage(t))}
|
|
97
|
-
${this.isLoading?this.renderTypingIndicator():""}
|
|
98
|
-
</div>
|
|
99
|
-
`}renderMessage(t){const e=["chatbot__bubble",`chatbot__bubble--${t.role}`].join(" ");return n.html`
|
|
100
|
-
<div class="chatbot__message chatbot__message--${t.role}">
|
|
101
|
-
<div class="${e}">
|
|
102
|
-
<div class="chatbot__message-content">
|
|
103
|
-
${y.unsafeHTML(this.formatContent(t.content))}
|
|
104
|
-
</div>
|
|
105
|
-
${this.showFeedbackButtons&&t.role==="assistant"?this.renderFeedbackButtons(t):""}
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
`}renderFeedbackButtons(t){return n.html`
|
|
109
|
-
<div class="chatbot__feedback">
|
|
110
|
-
<logosphere-button
|
|
111
|
-
@click=${()=>this.onCopyMessage(t.content)}
|
|
112
|
-
title="Kopyala"
|
|
113
|
-
iconOnly="true"
|
|
114
|
-
size="sm"
|
|
115
|
-
theme="--color-light-rgb"
|
|
116
|
-
>
|
|
117
|
-
<ui-icon name="uil-copy" size="14"></ui-icon>
|
|
118
|
-
</logosphere-button>
|
|
119
|
-
<logosphere-button title="Like" iconOnly="true" size="sm" theme="--color-light-rgb">
|
|
120
|
-
<ui-icon name="uil-thumbs-up" size="14"></ui-icon>
|
|
121
|
-
</logosphere-button>
|
|
122
|
-
<logosphere-button title="Dislike" iconOnly="true" size="sm" theme="--color-light-rgb">
|
|
123
|
-
<ui-icon name="uil-thumbs-down" size="14"></ui-icon>
|
|
124
|
-
</logosphere-button>
|
|
125
|
-
</div>
|
|
126
|
-
`}renderTypingIndicator(){return n.html`
|
|
127
|
-
<div class="chatbot__typing-wrapper">
|
|
128
|
-
<div class="chatbot__typing">
|
|
129
|
-
<span class="chatbot__typing-dot"></span>
|
|
130
|
-
<span class="chatbot__typing-dot"></span>
|
|
131
|
-
<span class="chatbot__typing-dot"></span>
|
|
132
|
-
</div>
|
|
133
|
-
</div>
|
|
134
|
-
`}renderInputArea(){return n.html`
|
|
135
|
-
<div class="chatbot__input-area">
|
|
136
|
-
<div class="chatbot__input-wrapper">
|
|
137
|
-
<input
|
|
138
|
-
class="chatbot__input"
|
|
139
|
-
placeholder=${this.selectedProductId?"Bir şeyler yazın...":"Lütfen ürün seçiniz..."}
|
|
140
|
-
.value=${this.inputText}
|
|
141
|
-
@input=${this.onInput}
|
|
142
|
-
@keydown=${this.handleKeyDown}
|
|
143
|
-
?disabled=${!this.selectedProductId}
|
|
144
|
-
/>
|
|
145
|
-
<logosphere-button
|
|
146
|
-
iconOnly="true"
|
|
147
|
-
size="sm"
|
|
148
|
-
variant="text"
|
|
149
|
-
theme="--color-light"
|
|
150
|
-
title="Gönder"
|
|
151
|
-
@click=${this.sendMessage}
|
|
152
|
-
?disabled=${!this.selectedProductId||!this.inputText.trim()}
|
|
153
|
-
>
|
|
154
|
-
<ui-icon name="uil-arrow-circle-right" size="20"></ui-icon>
|
|
155
|
-
</logosphere-button>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
<div class="chatbot__footer">
|
|
159
|
-
<p class="chatbot__footer-text">İçerik Yapay Zeka ile Üretilmiştir</p>
|
|
160
|
-
</div>
|
|
161
|
-
`}};exports.LogosphereChatBot.styles=[n.css`${n.unsafeCSS(w)}`];exports.LogosphereChatBot.ICONS={launcher:"data:image/svg+xml,%3Csvg%20width%3D%2251%22%20height%3D%2242%22%20viewBox%3D%220%200%2051%2042%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M38.457%200C40.0338%200%2041.542%200.293293%2042.9302%200.8283L49.15%206.07675C50.2611%207.93912%2050.8994%2010.1162%2050.8994%2012.4424V23.084C50.8994%2024.4858%2050.6676%2025.8334%2050.2402%2027.0907L43.1534%2034.6096C41.7043%2035.2006%2040.1187%2035.5264%2038.457%2035.5264H30.7605L38.5805%2027.2296C40.814%2027.1643%2042.6045%2025.3332%2042.6045%2023.084V12.4424C42.6045%2010.1518%2040.7476%208.29492%2038.457%208.29492H12.4424C10.1518%208.29492%208.29492%2010.1518%208.29492%2012.4424V23.084C8.29492%2025.3746%2010.1518%2027.2314%2012.4424%2027.2314H33.5078L20.4487%2041.0866C17.7992%2042.5379%2014.3381%2040.2741%2014.7842%2036.7803C14.8402%2036.3421%2014.9629%2035.9194%2015.1416%2035.5264H12.4424C10.9217%2035.5264%209.46472%2035.2536%208.11774%2034.7542L0.610679%2026.945C0.214298%2025.7295%200%2024.4318%200%2023.084V12.4424C0%2010.8011%200.317794%209.23402%200.895207%207.79935L7.12424%201.19058C8.73679%200.427072%2010.5397%200%2012.4424%200H38.457ZM23.1357%2017.7881C23.1357%2015.4815%2021.2656%2013.6113%2018.959%2013.6113C16.6525%2013.6114%2014.7822%2015.4815%2014.7822%2017.7881C14.7824%2020.0945%2016.6526%2021.9638%2018.959%2021.9639C21.2655%2021.9639%2023.1356%2020.0945%2023.1357%2017.7881ZM36.2344%2017.7881C36.2344%2015.4815%2034.3642%2013.6113%2032.0576%2013.6113C29.7511%2013.6114%2027.8809%2015.4815%2027.8809%2017.7881C27.881%2020.0945%2029.7512%2021.9638%2032.0576%2021.9639C34.3641%2021.9639%2036.2342%2020.0945%2036.2344%2017.7881Z%22%20fill%3D%22url(%23paint0_linear_97_4585)%22%2F%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22paint0_linear_97_4585%22%20x1%3D%2231.662%22%20y1%3D%224.88016%22%20x2%3D%2214.4119%22%20y2%3D%2237.9167%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20stop-color%3D%22%23F22727%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23CA0D0D%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E"};r([s.property({type:String,attribute:"return-uri"})],exports.LogosphereChatBot.prototype,"returnUri",2);r([s.property({type:String,attribute:"question-prompt"})],exports.LogosphereChatBot.prototype,"questionPrompt",2);r([s.property({type:Boolean,attribute:"minimized-icon-only"})],exports.LogosphereChatBot.prototype,"minimizedIconOnly",2);r([s.property({type:Boolean,attribute:"draggable"})],exports.LogosphereChatBot.prototype,"draggable",2);r([s.property({type:Boolean,attribute:"resizable"})],exports.LogosphereChatBot.prototype,"resizable",2);r([s.property({type:Array,hasChanged:(l,t)=>l===t?!1:!t||!l||l.length!==t.length?!0:JSON.stringify(l)!==JSON.stringify(t)}),s.property({type:Array})],exports.LogosphereChatBot.prototype,"products",2);r([s.property({type:Boolean,attribute:"open-initially"})],exports.LogosphereChatBot.prototype,"openInitially",2);r([s.property({type:Boolean,attribute:"show-feedback-buttons"})],exports.LogosphereChatBot.prototype,"showFeedbackButtons",2);r([s.state()],exports.LogosphereChatBot.prototype,"open",2);r([s.state()],exports.LogosphereChatBot.prototype,"fullscreen",2);r([s.state()],exports.LogosphereChatBot.prototype,"messages",2);r([s.state()],exports.LogosphereChatBot.prototype,"conversationId",2);r([s.state()],exports.LogosphereChatBot.prototype,"assertionToken",2);r([s.state()],exports.LogosphereChatBot.prototype,"isLoading",2);r([s.state()],exports.LogosphereChatBot.prototype,"inputText",2);r([s.state()],exports.LogosphereChatBot.prototype,"selectedProductId",2);r([s.state()],exports.LogosphereChatBot.prototype,"windowWidth",2);r([s.state()],exports.LogosphereChatBot.prototype,"windowHeight",2);r([s.state()],exports.LogosphereChatBot.prototype,"position",2);r([s.state()],exports.LogosphereChatBot.prototype,"isDragging",2);r([s.state()],exports.LogosphereChatBot.prototype,"screenWidth",2);r([s.query("#chat-container")],exports.LogosphereChatBot.prototype,"chatContainer",2);r([s.query("#product")],exports.LogosphereChatBot.prototype,"productEl",2);exports.LogosphereChatBot=r([s.customElement("logosphere-chatbot")],exports.LogosphereChatBot);
|
package/dist/drawer-BvcPd5nz.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("lit"),i=require("lit/decorators.js");require("./ui-icon-DWh1MhBa.cjs");const p=":host{display:block}.drawer{position:relative;font-family:var(--font-family-base)}.drawer__trigger{display:inline-flex}.drawer__panel{position:fixed;top:0;bottom:0;width:var(--drawer-width, 360px);max-width:min(100vw,var(--drawer-width, 360px));background:var(--color-body-bg);border-left:1px solid var(--color-border);box-shadow:var(--shadow-lg);z-index:var(--z-index-modal);display:flex;flex-direction:column;pointer-events:none;opacity:0;transition:transform var(--transition-speed-slow) var(--transition-timing),opacity var(--transition-speed-slow) linear}.drawer__panel--right{right:0;transform:translate(100%)}.drawer__panel--left{left:0;transform:translate(-100%);border-left:none;border-right:1px solid var(--color-border)}.drawer__panel--open{transform:translate(0);pointer-events:auto;opacity:1}.drawer__header{padding:var(--spacing-3) var(--spacing-4);border-bottom:1px solid var(--color-border);display:flex;align-items:center;justify-content:space-between;gap:var(--spacing-2)}.drawer__title{margin:0;font-size:var(--font-size-base);font-weight:var(--font-weight-semibold);color:var(--color-body-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.drawer__close{width:28px;height:28px;border:1px solid var(--color-border);border-radius:var(--radius-sm);background:var(--color-body-bg);display:inline-flex;align-items:center;justify-content:center;color:var(--color-body-text);cursor:pointer}.drawer__close:hover{background:var(--color-tertiary-bg)}.drawer__body{flex:1;overflow:auto;padding:var(--spacing-4)}";var c=Object.defineProperty,h=Object.getOwnPropertyDescriptor,s=(d,e,r,t)=>{for(var o=t>1?void 0:t?h(e,r):e,a=d.length-1,n;a>=0;a--)(n=d[a])&&(o=(t?n(e,r,o):n(o))||o);return t&&o&&c(e,r,o),o};exports.Drawer=class extends l.LitElement{constructor(){super(...arguments),this.open=!1,this.title="",this.position="right",this.width=360,this.closeOnEsc=!0,this.containerSelector="",this._frameStyle="",this._onKeyDown=e=>{!this.open||!this.closeOnEsc||(e.key==="Escape"||e.key==="Esc")&&this._setOpen(!1)},this._onTriggerClick=()=>this._setOpen(!0),this._onCloseClick=()=>this._setOpen(!1),this._syncFrame=()=>{const e=this._resolveContainer().getBoundingClientRect(),r=Math.max(0,e.top),t=Math.max(0,window.innerHeight-e.bottom),o=Math.max(0,e.left),a=Math.max(0,window.innerWidth-e.right),n=Math.max(0,e.width);this._frameStyle=this.position==="right"?`top:${r}px;bottom:${t}px;right:${a}px;max-width:${n}px;`:`top:${r}px;bottom:${t}px;left:${o}px;max-width:${n}px;`}}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this._onKeyDown,!0),window.addEventListener("resize",this._syncFrame),window.addEventListener("scroll",this._syncFrame,!0),this.updateComplete.then(()=>this._syncFrame())}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this._onKeyDown,!0),window.removeEventListener("resize",this._syncFrame),window.removeEventListener("scroll",this._syncFrame,!0)}updated(e){(e.has("open")||e.has("position")||e.has("width")||e.has("containerSelector"))&&this._syncFrame()}openDrawer(){this._setOpen(!0)}closeDrawer(){this._setOpen(!1)}_setOpen(e){this.open!==e&&(this.open=e,this.dispatchEvent(new CustomEvent(e?"drawer-open":"drawer-close",{bubbles:!0,composed:!0})))}_resolveContainer(){if(this.containerSelector){const e=this.getRootNode();if("querySelector"in e){const t=e.querySelector(this.containerSelector);if(t)return t}const r=document.querySelector(this.containerSelector);if(r)return r}return this.parentElement??this}render(){return l.html`
|
|
2
|
-
<div class="drawer">
|
|
3
|
-
<div class="drawer__trigger" @click=${this._onTriggerClick}>
|
|
4
|
-
<slot name="trigger"></slot>
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
<aside
|
|
8
|
-
class="drawer__panel drawer__panel--${this.position} ${this.open?"drawer__panel--open":""}"
|
|
9
|
-
style=${`--drawer-width:${this.width}px;${this._frameStyle}`}
|
|
10
|
-
role="dialog"
|
|
11
|
-
aria-modal="false"
|
|
12
|
-
aria-hidden=${this.open?"false":"true"}
|
|
13
|
-
>
|
|
14
|
-
<div class="drawer__header">
|
|
15
|
-
<h3 class="drawer__title">${this.title}</h3>
|
|
16
|
-
<button class="drawer__close" type="button" aria-label="Close drawer" @click=${this._onCloseClick}>
|
|
17
|
-
<ui-icon name="uil-times" size="16"></ui-icon>
|
|
18
|
-
</button>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="drawer__body">
|
|
21
|
-
<slot></slot>
|
|
22
|
-
</div>
|
|
23
|
-
</aside>
|
|
24
|
-
</div>
|
|
25
|
-
`}};exports.Drawer.styles=[l.css`${l.unsafeCSS(p)}`];s([i.property({type:Boolean,reflect:!0})],exports.Drawer.prototype,"open",2);s([i.property({type:String})],exports.Drawer.prototype,"title",2);s([i.property({type:String})],exports.Drawer.prototype,"position",2);s([i.property({type:Number})],exports.Drawer.prototype,"width",2);s([i.property({type:Boolean})],exports.Drawer.prototype,"closeOnEsc",2);s([i.property({type:String})],exports.Drawer.prototype,"containerSelector",2);exports.Drawer=s([i.customElement("logosphere-drawer")],exports.Drawer);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("lit"),t=require("lit/decorators.js"),f=":host{display:block}.formfield{position:relative;font-family:var(--font-family-base)}.formfield__label{display:block;font-size:var(--font-size-sm);font-weight:var(--font-weight-medium);color:var(--color-body-text);margin-bottom:var(--spacing-2)}.formfield__required{color:var(--color-danger);margin-left:var(--spacing-1)}.formfield__container{position:relative;display:flex;align-items:center;box-sizing:border-box;border-radius:var(--radius-base);border:1px solid var(--color-border);padding:0 var(--spacing-2) 0 var(--spacing-3);background-color:var(--color-body-bg);cursor:text;transition:border-color var(--transition-speed-base) var(--transition-timing),background-color var(--transition-speed-base) var(--transition-timing)}.formfield__container--cursor-text{cursor:text}.formfield__container--cursor-pointer{cursor:pointer}.formfield__container--cursor-default{cursor:default}.formfield__container--default{min-height:32px}.formfield__container--large{min-height:40px}.formfield__container--focused{border-color:var(--color-secondary-hover);background-color:var(--color-body-bg)}.formfield__container--hovered:not(.formfield__container--focused):not(.formfield__container--error):not(.formfield__container--disabled){background-color:var(--color-tertiary-bg)}.formfield__container--error{border-color:var(--color-danger);background-color:var(--color-danger-bg-subtle)}.formfield__container--disabled{background-color:var(--color-tertiary-bg);opacity:.4;cursor:not-allowed}.formfield__container--subtle:not(.formfield__container--focused):not(.formfield__container--error){border-color:transparent}.formfield__input-area{flex:1;min-width:0;display:flex;align-items:center}.formfield__prefix,.formfield__clear,.formfield__suffix{display:flex;align-items:center;flex-shrink:0;align-self:stretch}.formfield__prefix{margin-right:var(--spacing-2)}.formfield__clear,.formfield__suffix{margin-left:var(--spacing-2)}.formfield__container--has-prefix .formfield__prefix{border-right:1px solid var(--color-border);padding-right:var(--spacing-2)}.formfield__container--has-suffix .formfield__suffix{border-left:1px solid var(--color-border);padding-left:var(--spacing-2)}.formfield__prefix:empty,.formfield__clear:empty,.formfield__suffix:empty{display:none}.formfield__helper{font-size:var(--font-size-sm);color:var(--color-tertiary);margin-top:var(--spacing-1)}.formfield__error{font-size:var(--font-size-sm);color:var(--color-danger);margin-top:var(--spacing-1)}::slotted(input),::slotted(textarea){width:100%;border:none;outline:none;background:transparent;font-size:14px;line-height:1.5}::slotted(input:disabled),::slotted(textarea:disabled){cursor:not-allowed}";var c=Object.defineProperty,h=Object.getOwnPropertyDescriptor,o=(n,e,r,l)=>{for(var i=l>1?void 0:l?h(e,r):e,a=n.length-1,d;a>=0;a--)(d=n[a])&&(i=(l?d(e,r,i):d(i))||i);return l&&i&&c(e,r,i),i};exports.FormField=class extends s.LitElement{constructor(){super(...arguments),this.label="",this.helper="",this.error="",this.placeholder="",this.size="default",this.variant="default",this.cursor="text",this.required=!1,this.disabled=!1,this.readonly=!1,this._focused=!1,this._hovered=!1,this._hasPrefix=!1,this._hasSuffix=!1,this.handleSlotFocus=e=>{const r=e.target;["INPUT","TEXTAREA","SELECT"].includes(r.tagName)&&(this._focused=!0,this.dispatchEvent(new CustomEvent("field-focus",{bubbles:!0,composed:!0,detail:{originalEvent:e}})))},this.handleSlotBlur=e=>{const r=e.target;["INPUT","TEXTAREA","SELECT"].includes(r.tagName)&&(this._focused=!1,this.dispatchEvent(new CustomEvent("field-blur",{bubbles:!0,composed:!0,detail:{originalEvent:e}})))},this.handleMouseEnter=()=>{this._hovered=!0},this.handleMouseLeave=()=>{this._hovered=!1},this.handleContainerClick=e=>{const r=e.target;if(["INPUT","TEXTAREA","SELECT","BUTTON"].includes(r.tagName))return;this.shadowRoot?.querySelector("slot:not([name])")?.assignedElements({flatten:!0}).find(a=>["INPUT","TEXTAREA","SELECT"].includes(a.tagName))?.focus()},this.handlePrefixSlotChange=e=>{const r=e.target;this._hasPrefix=r.assignedElements({flatten:!0}).length>0},this.handleSuffixSlotChange=e=>{const r=e.target;this._hasSuffix=r.assignedElements({flatten:!0}).length>0}}connectedCallback(){super.connectedCallback(),this.addEventListener("focus",this.handleSlotFocus,!0),this.addEventListener("blur",this.handleSlotBlur,!0)}firstUpdated(){const e=this.shadowRoot?.querySelector('slot[name="prefix"]'),r=this.shadowRoot?.querySelector('slot[name="suffix"]');e&&(this._hasPrefix=e.assignedElements({flatten:!0}).length>0),r&&(this._hasSuffix=r.assignedElements({flatten:!0}).length>0)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("focus",this.handleSlotFocus,!0),this.removeEventListener("blur",this.handleSlotBlur,!0)}render(){const e=!!this.error,r=!e&&!!this.helper,l=["formfield__container",`formfield__container--${this.size}`,`formfield__container--cursor-${this.cursor}`,this._hasPrefix?"formfield__container--has-prefix":"",this._hasSuffix?"formfield__container--has-suffix":"",e?"formfield__container--error":"",this._focused?"formfield__container--focused":"",this._hovered?"formfield__container--hovered":"",this.disabled?"formfield__container--disabled":"",this.variant==="subtle"?"formfield__container--subtle":""].filter(Boolean).join(" ");return s.html`
|
|
2
|
-
<div class="formfield">
|
|
3
|
-
${this.label?s.html`
|
|
4
|
-
<label class="formfield__label">
|
|
5
|
-
${this.label}
|
|
6
|
-
${this.required?s.html`<span class="formfield__required">*</span>`:""}
|
|
7
|
-
</label>
|
|
8
|
-
`:""}
|
|
9
|
-
|
|
10
|
-
<div
|
|
11
|
-
class="${l}"
|
|
12
|
-
@mouseenter=${this.handleMouseEnter}
|
|
13
|
-
@mouseleave=${this.handleMouseLeave}
|
|
14
|
-
@click=${this.handleContainerClick}
|
|
15
|
-
>
|
|
16
|
-
<div class="formfield__prefix">
|
|
17
|
-
<slot name="prefix" @slotchange=${this.handlePrefixSlotChange}></slot>
|
|
18
|
-
</div>
|
|
19
|
-
<div class="formfield__input-area">
|
|
20
|
-
<slot></slot>
|
|
21
|
-
</div>
|
|
22
|
-
<div class="formfield__clear">
|
|
23
|
-
<slot name="clear"></slot>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="formfield__suffix">
|
|
26
|
-
<slot name="suffix" @slotchange=${this.handleSuffixSlotChange}></slot>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
${r?s.html`<div class="formfield__helper">${this.helper}</div>`:""}
|
|
31
|
-
${e?s.html`<div class="formfield__error">${this.error}</div>`:""}
|
|
32
|
-
</div>
|
|
33
|
-
`}};exports.FormField.styles=[s.css`${s.unsafeCSS(f)}`];o([t.property({type:String})],exports.FormField.prototype,"label",2);o([t.property({type:String})],exports.FormField.prototype,"helper",2);o([t.property({type:String})],exports.FormField.prototype,"error",2);o([t.property({type:String})],exports.FormField.prototype,"placeholder",2);o([t.property({type:String})],exports.FormField.prototype,"size",2);o([t.property({type:String})],exports.FormField.prototype,"variant",2);o([t.property({type:String})],exports.FormField.prototype,"cursor",2);o([t.property({type:Boolean})],exports.FormField.prototype,"required",2);o([t.property({type:Boolean})],exports.FormField.prototype,"disabled",2);o([t.property({type:Boolean})],exports.FormField.prototype,"readonly",2);o([t.state()],exports.FormField.prototype,"_focused",2);o([t.state()],exports.FormField.prototype,"_hovered",2);o([t.state()],exports.FormField.prototype,"_hasPrefix",2);o([t.state()],exports.FormField.prototype,"_hasSuffix",2);exports.FormField=o([t.customElement("logosphere-formfield")],exports.FormField);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("lit"),t=require("lit/decorators.js"),p=require("lit/directives/live.js");require("./formfield-BFOIEicR.cjs");require("./ui-icon-DWh1MhBa.cjs");const u=".textarea__field{width:100%;background:transparent;border:none;outline:none;font-size:var(--font-size-sm);font-family:var(--font-family-base);color:var(--color-body-text);box-sizing:border-box;line-height:1.5}.textarea__field::placeholder{color:var(--color-tertiary)}.textarea__field:disabled{cursor:not-allowed}.textarea__field--resize-none{resize:none}.textarea__field--resize-vertical{resize:vertical}.textarea__field--resize-horizontal{resize:horizontal}.textarea__field--resize-both{resize:both}.textarea__field--auto-resize{resize:none;overflow:hidden}.textarea__clear-btn{border:none;background:transparent;color:var(--color-gray-400);cursor:pointer;padding:0;display:inline-flex;align-items:flex-start;align-self:flex-start;margin-top:var(--spacing-1);outline:none;flex-shrink:0;transition:color var(--transition-speed-fast) var(--transition-timing)}.textarea__clear-btn:hover{color:var(--color-gray-600)}";var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,r=(l,e,a,o)=>{for(var s=o>1?void 0:o?y(e,a):e,n=l.length-1,h;n>=0;n--)(h=l[n])&&(s=(o?h(e,a,s):h(s))||s);return o&&s&&d(e,a,s),s};exports.TextArea=class extends i.LitElement{constructor(){super(...arguments),this.value="",this.placeholder="",this.name="",this.autocomplete="",this.rows=3,this.wrap="soft",this.resize="vertical",this.autoResize=!1,this.size="default",this.variant="default",this.label="",this.helper="",this.error="",this.required=!1,this.disabled=!1,this.readonly=!1,this._internalError="",this.handleInput=e=>{const a=e.target;this.value=a.value,this.autoResize&&this.adjustHeight(),this._internalError&&(this._internalError="",this._textareaElement.setCustomValidity("")),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{value:this.value,originalEvent:e}}))},this.handleChange=e=>{const a=e.target;this.value=a.value,a.checkValidity()||(this._internalError=a.validationMessage),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{value:this.value,originalEvent:e}}))},this.handleKeyDown=e=>{this.dispatchEvent(new CustomEvent("keydown",{bubbles:!0,composed:!0,detail:{key:e.key,originalEvent:e}}))},this.handleKeyUp=e=>{this.dispatchEvent(new CustomEvent("keyup",{bubbles:!0,composed:!0,detail:{key:e.key,originalEvent:e}}))},this.handleClear=()=>{this.value="",this._textareaElement&&(this._textareaElement.value="",this.autoResize&&this.adjustHeight()),this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{value:"",originalEvent:null}}))}}get textareaElement(){return this._textareaElement}focus(){this._textareaElement?.focus()}blur(){this._textareaElement?.blur()}select(){this._textareaElement?.select()}setSelectionRange(e,a,o){this._textareaElement?.setSelectionRange(e,a,o)}checkValidity(){return this._textareaElement?.checkValidity()??!0}reportValidity(){return this._textareaElement?.reportValidity()??!0}setCustomValidity(e){this._textareaElement?.setCustomValidity(e),this._internalError=e,this.requestUpdate()}adjustHeight(){!this.autoResize||!this._textareaElement||(this._textareaElement.style.height="auto",this._textareaElement.style.height=`${this._textareaElement.scrollHeight}px`)}updated(e){super.updated(e),e.has("value")&&this.autoResize&&this.adjustHeight()}getResizeClass(){return this.autoResize?"textarea__field--auto-resize":{none:"textarea__field--resize-none",vertical:"textarea__field--resize-vertical",horizontal:"textarea__field--resize-horizontal",both:"textarea__field--resize-both"}[this.resize]}render(){const e=this.error||this._internalError,a=!!this.value&&!this.disabled&&!this.readonly,o=`textarea__field ${this.getResizeClass()}`;return i.html`
|
|
2
|
-
<logosphere-formfield
|
|
3
|
-
.label=${this.label}
|
|
4
|
-
.helper=${this.helper}
|
|
5
|
-
.error=${e}
|
|
6
|
-
.required=${this.required}
|
|
7
|
-
.disabled=${this.disabled}
|
|
8
|
-
.readonly=${this.readonly}
|
|
9
|
-
.placeholder=${this.placeholder}
|
|
10
|
-
.size=${this.size}
|
|
11
|
-
.variant=${this.variant}
|
|
12
|
-
>
|
|
13
|
-
<slot name="prefix" slot="prefix"></slot>
|
|
14
|
-
<textarea
|
|
15
|
-
class="${o}"
|
|
16
|
-
.value=${p.live(this.value)}
|
|
17
|
-
placeholder=${this.placeholder||i.nothing}
|
|
18
|
-
name=${this.name||i.nothing}
|
|
19
|
-
autocomplete=${this.autocomplete||i.nothing}
|
|
20
|
-
?required=${this.required}
|
|
21
|
-
?disabled=${this.disabled}
|
|
22
|
-
?readonly=${this.readonly}
|
|
23
|
-
minlength=${this.minlength??i.nothing}
|
|
24
|
-
maxlength=${this.maxlength??i.nothing}
|
|
25
|
-
rows=${this.rows}
|
|
26
|
-
cols=${this.cols??i.nothing}
|
|
27
|
-
wrap=${this.wrap}
|
|
28
|
-
@input=${this.handleInput}
|
|
29
|
-
@change=${this.handleChange}
|
|
30
|
-
@keydown=${this.handleKeyDown}
|
|
31
|
-
@keyup=${this.handleKeyUp}
|
|
32
|
-
></textarea>
|
|
33
|
-
${a?i.html`
|
|
34
|
-
<button
|
|
35
|
-
type="button"
|
|
36
|
-
slot="clear"
|
|
37
|
-
class="textarea__clear-btn"
|
|
38
|
-
@click=${this.handleClear}
|
|
39
|
-
tabindex="-1"
|
|
40
|
-
>
|
|
41
|
-
<ui-icon name="uil-times" size="14"></ui-icon>
|
|
42
|
-
</button>
|
|
43
|
-
`:i.nothing}
|
|
44
|
-
<slot name="suffix" slot="suffix"></slot>
|
|
45
|
-
</logosphere-formfield>
|
|
46
|
-
`}};exports.TextArea.styles=[i.css`${i.unsafeCSS(u)}`];r([t.query("textarea")],exports.TextArea.prototype,"_textareaElement",2);r([t.property({type:String})],exports.TextArea.prototype,"value",2);r([t.property({type:String})],exports.TextArea.prototype,"placeholder",2);r([t.property({type:String})],exports.TextArea.prototype,"name",2);r([t.property({type:String})],exports.TextArea.prototype,"autocomplete",2);r([t.property({type:Number})],exports.TextArea.prototype,"minlength",2);r([t.property({type:Number})],exports.TextArea.prototype,"maxlength",2);r([t.property({type:Number})],exports.TextArea.prototype,"rows",2);r([t.property({type:Number})],exports.TextArea.prototype,"cols",2);r([t.property({type:String})],exports.TextArea.prototype,"wrap",2);r([t.property({type:String})],exports.TextArea.prototype,"resize",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"autoResize",2);r([t.property({type:String})],exports.TextArea.prototype,"size",2);r([t.property({type:String})],exports.TextArea.prototype,"variant",2);r([t.property({type:String})],exports.TextArea.prototype,"label",2);r([t.property({type:String})],exports.TextArea.prototype,"helper",2);r([t.property({type:String})],exports.TextArea.prototype,"error",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"required",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"disabled",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"readonly",2);r([t.state()],exports.TextArea.prototype,"_internalError",2);exports.TextArea=r([t.customElement("logosphere-textarea")],exports.TextArea);
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { unsafeCSS as d, css as c, LitElement as y, nothing as l, html as u } from "lit";
|
|
2
|
-
import { query as m, property as i, state as f, customElement as _ } from "lit/decorators.js";
|
|
3
|
-
import { live as v } from "lit/directives/live.js";
|
|
4
|
-
import "./formfield-CNh4mBSs.js";
|
|
5
|
-
import "./ui-icon-Bys4HYSQ.js";
|
|
6
|
-
const x = ".textarea__field{width:100%;background:transparent;border:none;outline:none;font-size:var(--font-size-sm);font-family:var(--font-family-base);color:var(--color-body-text);box-sizing:border-box;line-height:1.5}.textarea__field::placeholder{color:var(--color-tertiary)}.textarea__field:disabled{cursor:not-allowed}.textarea__field--resize-none{resize:none}.textarea__field--resize-vertical{resize:vertical}.textarea__field--resize-horizontal{resize:horizontal}.textarea__field--resize-both{resize:both}.textarea__field--auto-resize{resize:none;overflow:hidden}.textarea__clear-btn{border:none;background:transparent;color:var(--color-gray-400);cursor:pointer;padding:0;display:inline-flex;align-items:flex-start;align-self:flex-start;margin-top:var(--spacing-1);outline:none;flex-shrink:0;transition:color var(--transition-speed-fast) var(--transition-timing)}.textarea__clear-btn:hover{color:var(--color-gray-600)}";
|
|
7
|
-
var b = Object.defineProperty, g = Object.getOwnPropertyDescriptor, r = (e, a, s, n) => {
|
|
8
|
-
for (var o = n > 1 ? void 0 : n ? g(a, s) : a, h = e.length - 1, p; h >= 0; h--)
|
|
9
|
-
(p = e[h]) && (o = (n ? p(a, s, o) : p(o)) || o);
|
|
10
|
-
return n && o && b(a, s, o), o;
|
|
11
|
-
};
|
|
12
|
-
let t = class extends y {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments), this.value = "", this.placeholder = "", this.name = "", this.autocomplete = "", this.rows = 3, this.wrap = "soft", this.resize = "vertical", this.autoResize = !1, this.size = "default", this.variant = "default", this.label = "", this.helper = "", this.error = "", this.required = !1, this.disabled = !1, this.readonly = !1, this._internalError = "", this.handleInput = (e) => {
|
|
15
|
-
const a = e.target;
|
|
16
|
-
this.value = a.value, this.autoResize && this.adjustHeight(), this._internalError && (this._internalError = "", this._textareaElement.setCustomValidity("")), this.dispatchEvent(new CustomEvent("input", {
|
|
17
|
-
bubbles: !0,
|
|
18
|
-
composed: !0,
|
|
19
|
-
detail: { value: this.value, originalEvent: e }
|
|
20
|
-
}));
|
|
21
|
-
}, this.handleChange = (e) => {
|
|
22
|
-
const a = e.target;
|
|
23
|
-
this.value = a.value, a.checkValidity() || (this._internalError = a.validationMessage), this.dispatchEvent(new CustomEvent("change", {
|
|
24
|
-
bubbles: !0,
|
|
25
|
-
composed: !0,
|
|
26
|
-
detail: { value: this.value, originalEvent: e }
|
|
27
|
-
}));
|
|
28
|
-
}, this.handleKeyDown = (e) => {
|
|
29
|
-
this.dispatchEvent(new CustomEvent("keydown", {
|
|
30
|
-
bubbles: !0,
|
|
31
|
-
composed: !0,
|
|
32
|
-
detail: { key: e.key, originalEvent: e }
|
|
33
|
-
}));
|
|
34
|
-
}, this.handleKeyUp = (e) => {
|
|
35
|
-
this.dispatchEvent(new CustomEvent("keyup", {
|
|
36
|
-
bubbles: !0,
|
|
37
|
-
composed: !0,
|
|
38
|
-
detail: { key: e.key, originalEvent: e }
|
|
39
|
-
}));
|
|
40
|
-
}, this.handleClear = () => {
|
|
41
|
-
this.value = "", this._textareaElement && (this._textareaElement.value = "", this.autoResize && this.adjustHeight()), this.dispatchEvent(new CustomEvent("clear", { bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("input", {
|
|
42
|
-
bubbles: !0,
|
|
43
|
-
composed: !0,
|
|
44
|
-
detail: { value: "", originalEvent: null }
|
|
45
|
-
}));
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
get textareaElement() {
|
|
49
|
-
return this._textareaElement;
|
|
50
|
-
}
|
|
51
|
-
focus() {
|
|
52
|
-
this._textareaElement?.focus();
|
|
53
|
-
}
|
|
54
|
-
blur() {
|
|
55
|
-
this._textareaElement?.blur();
|
|
56
|
-
}
|
|
57
|
-
select() {
|
|
58
|
-
this._textareaElement?.select();
|
|
59
|
-
}
|
|
60
|
-
setSelectionRange(e, a, s) {
|
|
61
|
-
this._textareaElement?.setSelectionRange(e, a, s);
|
|
62
|
-
}
|
|
63
|
-
checkValidity() {
|
|
64
|
-
return this._textareaElement?.checkValidity() ?? !0;
|
|
65
|
-
}
|
|
66
|
-
reportValidity() {
|
|
67
|
-
return this._textareaElement?.reportValidity() ?? !0;
|
|
68
|
-
}
|
|
69
|
-
setCustomValidity(e) {
|
|
70
|
-
this._textareaElement?.setCustomValidity(e), this._internalError = e, this.requestUpdate();
|
|
71
|
-
}
|
|
72
|
-
adjustHeight() {
|
|
73
|
-
!this.autoResize || !this._textareaElement || (this._textareaElement.style.height = "auto", this._textareaElement.style.height = `${this._textareaElement.scrollHeight}px`);
|
|
74
|
-
}
|
|
75
|
-
updated(e) {
|
|
76
|
-
super.updated(e), e.has("value") && this.autoResize && this.adjustHeight();
|
|
77
|
-
}
|
|
78
|
-
getResizeClass() {
|
|
79
|
-
return this.autoResize ? "textarea__field--auto-resize" : {
|
|
80
|
-
none: "textarea__field--resize-none",
|
|
81
|
-
vertical: "textarea__field--resize-vertical",
|
|
82
|
-
horizontal: "textarea__field--resize-horizontal",
|
|
83
|
-
both: "textarea__field--resize-both"
|
|
84
|
-
}[this.resize];
|
|
85
|
-
}
|
|
86
|
-
render() {
|
|
87
|
-
const e = this.error || this._internalError, a = !!this.value && !this.disabled && !this.readonly, s = `textarea__field ${this.getResizeClass()}`;
|
|
88
|
-
return u`
|
|
89
|
-
<logosphere-formfield
|
|
90
|
-
.label=${this.label}
|
|
91
|
-
.helper=${this.helper}
|
|
92
|
-
.error=${e}
|
|
93
|
-
.required=${this.required}
|
|
94
|
-
.disabled=${this.disabled}
|
|
95
|
-
.readonly=${this.readonly}
|
|
96
|
-
.placeholder=${this.placeholder}
|
|
97
|
-
.size=${this.size}
|
|
98
|
-
.variant=${this.variant}
|
|
99
|
-
>
|
|
100
|
-
<slot name="prefix" slot="prefix"></slot>
|
|
101
|
-
<textarea
|
|
102
|
-
class="${s}"
|
|
103
|
-
.value=${v(this.value)}
|
|
104
|
-
placeholder=${this.placeholder || l}
|
|
105
|
-
name=${this.name || l}
|
|
106
|
-
autocomplete=${this.autocomplete || l}
|
|
107
|
-
?required=${this.required}
|
|
108
|
-
?disabled=${this.disabled}
|
|
109
|
-
?readonly=${this.readonly}
|
|
110
|
-
minlength=${this.minlength ?? l}
|
|
111
|
-
maxlength=${this.maxlength ?? l}
|
|
112
|
-
rows=${this.rows}
|
|
113
|
-
cols=${this.cols ?? l}
|
|
114
|
-
wrap=${this.wrap}
|
|
115
|
-
@input=${this.handleInput}
|
|
116
|
-
@change=${this.handleChange}
|
|
117
|
-
@keydown=${this.handleKeyDown}
|
|
118
|
-
@keyup=${this.handleKeyUp}
|
|
119
|
-
></textarea>
|
|
120
|
-
${a ? u`
|
|
121
|
-
<button
|
|
122
|
-
type="button"
|
|
123
|
-
slot="clear"
|
|
124
|
-
class="textarea__clear-btn"
|
|
125
|
-
@click=${this.handleClear}
|
|
126
|
-
tabindex="-1"
|
|
127
|
-
>
|
|
128
|
-
<ui-icon name="uil-times" size="14"></ui-icon>
|
|
129
|
-
</button>
|
|
130
|
-
` : l}
|
|
131
|
-
<slot name="suffix" slot="suffix"></slot>
|
|
132
|
-
</logosphere-formfield>
|
|
133
|
-
`;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
t.styles = [c`${d(x)}`];
|
|
137
|
-
r([
|
|
138
|
-
m("textarea")
|
|
139
|
-
], t.prototype, "_textareaElement", 2);
|
|
140
|
-
r([
|
|
141
|
-
i({ type: String })
|
|
142
|
-
], t.prototype, "value", 2);
|
|
143
|
-
r([
|
|
144
|
-
i({ type: String })
|
|
145
|
-
], t.prototype, "placeholder", 2);
|
|
146
|
-
r([
|
|
147
|
-
i({ type: String })
|
|
148
|
-
], t.prototype, "name", 2);
|
|
149
|
-
r([
|
|
150
|
-
i({ type: String })
|
|
151
|
-
], t.prototype, "autocomplete", 2);
|
|
152
|
-
r([
|
|
153
|
-
i({ type: Number })
|
|
154
|
-
], t.prototype, "minlength", 2);
|
|
155
|
-
r([
|
|
156
|
-
i({ type: Number })
|
|
157
|
-
], t.prototype, "maxlength", 2);
|
|
158
|
-
r([
|
|
159
|
-
i({ type: Number })
|
|
160
|
-
], t.prototype, "rows", 2);
|
|
161
|
-
r([
|
|
162
|
-
i({ type: Number })
|
|
163
|
-
], t.prototype, "cols", 2);
|
|
164
|
-
r([
|
|
165
|
-
i({ type: String })
|
|
166
|
-
], t.prototype, "wrap", 2);
|
|
167
|
-
r([
|
|
168
|
-
i({ type: String })
|
|
169
|
-
], t.prototype, "resize", 2);
|
|
170
|
-
r([
|
|
171
|
-
i({ type: Boolean })
|
|
172
|
-
], t.prototype, "autoResize", 2);
|
|
173
|
-
r([
|
|
174
|
-
i({ type: String })
|
|
175
|
-
], t.prototype, "size", 2);
|
|
176
|
-
r([
|
|
177
|
-
i({ type: String })
|
|
178
|
-
], t.prototype, "variant", 2);
|
|
179
|
-
r([
|
|
180
|
-
i({ type: String })
|
|
181
|
-
], t.prototype, "label", 2);
|
|
182
|
-
r([
|
|
183
|
-
i({ type: String })
|
|
184
|
-
], t.prototype, "helper", 2);
|
|
185
|
-
r([
|
|
186
|
-
i({ type: String })
|
|
187
|
-
], t.prototype, "error", 2);
|
|
188
|
-
r([
|
|
189
|
-
i({ type: Boolean })
|
|
190
|
-
], t.prototype, "required", 2);
|
|
191
|
-
r([
|
|
192
|
-
i({ type: Boolean })
|
|
193
|
-
], t.prototype, "disabled", 2);
|
|
194
|
-
r([
|
|
195
|
-
i({ type: Boolean })
|
|
196
|
-
], t.prototype, "readonly", 2);
|
|
197
|
-
r([
|
|
198
|
-
f()
|
|
199
|
-
], t.prototype, "_internalError", 2);
|
|
200
|
-
t = r([
|
|
201
|
-
_("logosphere-textarea")
|
|
202
|
-
], t);
|
|
203
|
-
export {
|
|
204
|
-
t as T
|
|
205
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("lit"),s=require("lit/decorators.js"),d=require("lit/directives/unsafe-html.js");require("./ui-icon-DWh1MhBa.cjs");const h=".tree{width:100%;font-family:var(--font-family-base)}.tree__list,.tree__children{list-style:none;margin:0;padding:0}.tree__item{margin:0;padding:0}.tree__row{display:flex;align-items:center;gap:var(--spacing-1);padding:var(--spacing-2) var(--spacing-3);padding-left:calc(var(--spacing-3) + (var(--tree-level, 0) * 14px));border-radius:var(--radius-sm);color:var(--color-body-text);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.tree--icons .tree__row{justify-content:center;padding:0;width:44px;height:44px;min-height:44px;margin:0 auto}.tree__row:hover{background-color:var(--color-tertiary-bg)}.tree__row:focus-visible{outline:2px solid var(--color-secondary);outline-offset:1px}.tree__row--disabled{opacity:.5;cursor:not-allowed}.tree__row--active .tree__label,.tree__row--active .tree__icon{color:var(--color-primary)}.tree:not(.tree--icons) .tree__row--active{background-color:var(--color-tertiary-bg)}.tree__icon{width:20px;min-width:20px;display:inline-flex;align-items:center;justify-content:center;color:inherit}.tree--icons .tree__icon{width:20px;min-width:20px;height:20px}.tree--icons .tree__row--active{background-color:var(--color-primary)}.tree--icons .tree__row--active .tree__icon{color:#fff}.tree--icons .tree__row--active:hover{background-color:var(--color-primary-hover)}.tree__chevron-btn{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border:none;background:transparent;color:var(--color-tertiary);cursor:pointer;padding:0;flex-shrink:0}.tree__chevron-btn--right{margin-left:auto}.tree__chevron{transform:rotate(-90deg);transition:transform var(--transition-speed-fast) var(--transition-timing)}.tree__chevron--open{transform:rotate(0)}.tree__chevron-spacer{width:20px;height:20px;flex-shrink:0}.tree__label{display:inline-flex;align-items:center;font-size:var(--font-size-sm);color:inherit}";var p=Object.defineProperty,_=Object.getOwnPropertyDescriptor,a=(c,e,t,n)=>{for(var i=n>1?void 0:n?_(e,t):e,l=c.length-1,o;l>=0;l--)(o=c[l])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&p(e,t,i),i};exports.TreeMenu=class extends r.LitElement{constructor(){super(...arguments),this.items=[],this.expandedIds=[],this.expandOnLabelClick=!0,this.chevronPosition="left",this.showLabels=!0,this.iconSize=16,this._expandedSet=new Set}willUpdate(e){e.has("expandedIds")&&(this._expandedSet=new Set(this.expandedIds??[]))}_isExpanded(e){return this._expandedSet.has(e)}_emitToggle(e,t){this.dispatchEvent(new CustomEvent("toggle",{detail:{item:e,expanded:t},bubbles:!0,composed:!0}))}_emitItemClick(e){this.dispatchEvent(new CustomEvent("item-click",{detail:{item:e},bubbles:!0,composed:!0}))}_emitNodeClick(e,t){this.dispatchEvent(new CustomEvent("node-click",{detail:{item:e,hasChildren:t},bubbles:!0,composed:!0}))}_setExpanded(e,t){t?this._expandedSet.add(e.id):this._expandedSet.delete(e.id),this.expandedIds=Array.from(this._expandedSet),this._emitToggle(e,t)}_toggle(e,t){t.stopPropagation(),!(e.disabled||!e.children?.length)&&this._setExpanded(e,!this._isExpanded(e.id))}_handleItemClick(e,t){if(t.stopPropagation(),e.disabled)return;const n=!!e.children?.length;if(this._emitNodeClick(e,n),n&&this.expandOnLabelClick){this._setExpanded(e,!this._isExpanded(e.id));return}n||(e.onClick?.(e),this._emitItemClick(e))}_handleRowKeydown(e,t){t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this._handleItemClick(e,t))}_renderIcon(e){return e.iconName?r.html`
|
|
2
|
-
<span class="tree__icon">
|
|
3
|
-
<ui-icon name=${e.iconName} .size=${this.iconSize}></ui-icon>
|
|
4
|
-
</span>
|
|
5
|
-
`:e.iconHtml?r.html`<span class="tree__icon">${d.unsafeHTML(e.iconHtml)}</span>`:r.nothing}_renderChevron(e,t){const n=!!e.children?.length;return this.showLabels?n?r.html`
|
|
6
|
-
<button
|
|
7
|
-
type="button"
|
|
8
|
-
class="tree__chevron-btn ${this.chevronPosition==="right"?"tree__chevron-btn--right":""}"
|
|
9
|
-
aria-label=${t?"Collapse":"Expand"}
|
|
10
|
-
@click=${i=>this._toggle(e,i)}
|
|
11
|
-
>
|
|
12
|
-
<ui-icon
|
|
13
|
-
class="tree__chevron ${t?"tree__chevron--open":""}"
|
|
14
|
-
name="uil-angle-down"
|
|
15
|
-
size="20"
|
|
16
|
-
></ui-icon>
|
|
17
|
-
</button>
|
|
18
|
-
`:r.html`<span class="tree__chevron-spacer"></span>`:r.nothing}_renderNode(e,t){const n=!!e.children?.length,i=n?this._isExpanded(e.id):!1,l=this.showLabels?`--tree-level:${t};`:"--tree-level:0;";return r.html`
|
|
19
|
-
<li class="tree__item">
|
|
20
|
-
<div
|
|
21
|
-
class="tree__row ${e.disabled?"tree__row--disabled":""} ${e.active?"tree__row--active":""}"
|
|
22
|
-
style=${l}
|
|
23
|
-
role="button"
|
|
24
|
-
tabindex=${e.disabled?-1:0}
|
|
25
|
-
@click=${o=>this._handleItemClick(e,o)}
|
|
26
|
-
@keydown=${o=>this._handleRowKeydown(e,o)}
|
|
27
|
-
title=${this.showLabels?"":e.label}
|
|
28
|
-
>
|
|
29
|
-
${this.chevronPosition==="left"?this._renderChevron(e,i):r.nothing}
|
|
30
|
-
${this._renderIcon(e)}
|
|
31
|
-
${this.showLabels?r.html`<span class="tree__label">${e.label}</span>`:r.nothing}
|
|
32
|
-
${this.chevronPosition==="right"?this._renderChevron(e,i):r.nothing}
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
${this.showLabels&&n&&i?r.html`
|
|
36
|
-
<ul class="tree__children">
|
|
37
|
-
${e.children.map(o=>this._renderNode(o,t+1))}
|
|
38
|
-
</ul>
|
|
39
|
-
`:r.nothing}
|
|
40
|
-
</li>
|
|
41
|
-
`}render(){return r.html`
|
|
42
|
-
<nav class="tree ${this.showLabels?"":"tree--icons"}" aria-label="Tree Menu">
|
|
43
|
-
<ul class="tree__list">
|
|
44
|
-
${this.items.map(e=>this._renderNode(e,0))}
|
|
45
|
-
</ul>
|
|
46
|
-
</nav>
|
|
47
|
-
`}};exports.TreeMenu.styles=[r.css`${r.unsafeCSS(h)}`];a([s.property({attribute:!1})],exports.TreeMenu.prototype,"items",2);a([s.property({type:Array})],exports.TreeMenu.prototype,"expandedIds",2);a([s.property({type:Boolean})],exports.TreeMenu.prototype,"expandOnLabelClick",2);a([s.property({type:String})],exports.TreeMenu.prototype,"chevronPosition",2);a([s.property({type:Boolean})],exports.TreeMenu.prototype,"showLabels",2);a([s.property({type:Number})],exports.TreeMenu.prototype,"iconSize",2);a([s.state()],exports.TreeMenu.prototype,"_expandedSet",2);exports.TreeMenu=a([s.customElement("logosphere-tree-menu")],exports.TreeMenu);
|