@lazhus/kg-ui 0.8.7 → 0.8.8
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/custom-elements.json
CHANGED
|
@@ -4399,7 +4399,7 @@
|
|
|
4399
4399
|
"kind": "field",
|
|
4400
4400
|
"name": "styles",
|
|
4401
4401
|
"static": true,
|
|
4402
|
-
"default": "css` :host { display: inline-block; width: 100%; position: relative; font-family: inherit; user-select: none; } .kg-select-container { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; position: relative; } .select-label { font-size: 0.875rem; font-weight: 600; color: var(--kg-text); opacity: 0.8; margin-left: 2px; } * { box-sizing: border-box; } .select-trigger { display: flex; align-items: center; justify-content: space-between; height: var(--kg-form-height); padding: 0 1rem; background: var(--kg-surface); border: 1px solid var(--kg-border); border-radius: var(--kg-radius-md, 8px); cursor: pointer; transition: all 0.2s ease; gap: 8px; flex-wrap: nowrap; overflow: hidden; } .select-trigger:hover { border-color: var(--kg-primary); } .select-trigger.open { border-color: var(--kg-primary); box-shadow: 0 0 0 2px rgba(65, 171, 52, 0.2); } .select-trigger.disabled { opacity: 0.5; cursor: not-allowed; background: var(--kg-bg-secondary); } .placeholder { color: var(--kg-text-muted); opacity: 0.6; } .selected-text { color: var(--kg-text); flex: 1; } .tags-container { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; } .tag { background: var(--kg-primary); color: white; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; display: flex; align-items: center; gap: 4px; } .tag-remove { cursor: pointer; opacity: 0.8; } .tag-remove:hover { opacity: 1; } .chevron { transition: transform 0.2s ease; color: var(--kg-text-muted); flex-shrink: 0; } .open .chevron { transform: rotate(180deg); } /* Dropdown */ .select-dropdown { position: absolute; top: calc(100% + 5px); left: 0; width: 100%; background: var(--kg-surface); border: 1px solid var(--kg-border); border-radius: var(--kg-radius-md, 8px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); z-index: 1000; max-height: 300px; overflow-y: auto; display: none; animation: slideDown 0.2s ease-out; } .select-dropdown.visible { display: block; } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .search-container { padding: 8px; border-bottom: 1px solid var(--kg-border); position: sticky; top: 0; background: var(--kg-surface); z-index: 10; } .search-input { width: 100%; padding: 6px 10px; border: 1px solid var(--kg-border); border-radius: 4px; outline: none; font-family: inherit; font-size: 0.9rem; } .search-input:focus { border-color: var(--kg-primary); } .option-item { padding: 10px 16px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; transition: background 0.15s; color: var(--kg-text); } .option-item:hover { background: var(--kg-bg-secondary, rgba(0, 0, 0, 0.04)); } .option-item.selected { background: rgba(var(--kg-primary-rgb, 19, 103, 255), 0.08); color: var(--kg-primary); font-weight: 600; } .no-results { padding: 16px; text-align: center; color: var(--kg-text-muted); font-size: 0.9rem; } .check-icon { width: 16px; height: 16px; } .select-trigger.error { border-color: #DB2828 !important; background-color: rgba(219, 40, 40, 0.02) !important; } .error-text { position: absolute; top: 100%; left: 2px; color: #DB2828; font-size: 0.75rem; margin-top: 2px; font-weight: 500; animation: fadeIn 0.2s ease-in; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } } `"
|
|
4402
|
+
"default": "css` :host { display: inline-block; width: 100%; position: relative; font-family: inherit; user-select: none; } .kg-select-container { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; position: relative; } .select-label { font-size: 0.875rem; font-weight: 600; color: var(--kg-text); opacity: 0.8; margin-left: 2px; } * { box-sizing: border-box; } .select-trigger { display: flex; align-items: center; justify-content: space-between; height: var(--kg-form-height); padding: 0 1rem; background: var(--kg-surface); border: 1px solid var(--kg-border); border-radius: var(--kg-radius-md, 8px); cursor: pointer; transition: all 0.2s ease; gap: 8px; flex-wrap: nowrap; overflow: hidden; } .select-trigger:hover { border-color: var(--kg-primary); } .select-trigger.open { border-color: var(--kg-primary); box-shadow: 0 0 0 2px rgba(65, 171, 52, 0.2); } .select-trigger.disabled { opacity: 0.5; cursor: not-allowed; background: var(--kg-bg-secondary); } .placeholder { color: var(--kg-text-muted); opacity: 0.6; } .selected-text { color: var(--kg-text); flex: 1; } .tags-container { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; } .tag { background: var(--kg-primary); color: white; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; display: flex; align-items: center; gap: 4px; } .tag-remove { cursor: pointer; opacity: 0.8; } .tag-remove:hover { opacity: 1; } .chevron { transition: transform 0.2s ease; color: var(--kg-text-muted); flex-shrink: 0; } .open .chevron { transform: rotate(180deg); } .clear-button { display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--kg-text-muted); opacity: 0.6; transition: all 0.2s; flex-shrink: 0; padding: 4px; border-radius: 50%; } .clear-button:hover { opacity: 1; background: var(--kg-bg-secondary, rgba(0, 0, 0, 0.04)); color: var(--kg-primary); } /* Dropdown */ .select-dropdown { position: absolute; top: calc(100% + 5px); left: 0; width: 100%; background: var(--kg-surface); border: 1px solid var(--kg-border); border-radius: var(--kg-radius-md, 8px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); z-index: 1000; max-height: 300px; overflow-y: auto; display: none; animation: slideDown 0.2s ease-out; } .select-dropdown.visible { display: block; } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .search-container { padding: 8px; border-bottom: 1px solid var(--kg-border); position: sticky; top: 0; background: var(--kg-surface); z-index: 10; } .search-input { width: 100%; padding: 6px 10px; border: 1px solid var(--kg-border); border-radius: 4px; outline: none; font-family: inherit; font-size: 0.9rem; } .search-input:focus { border-color: var(--kg-primary); } .option-item { padding: 10px 16px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; transition: background 0.15s; color: var(--kg-text); } .option-item:hover { background: var(--kg-bg-secondary, rgba(0, 0, 0, 0.04)); } .option-item.selected { background: rgba(var(--kg-primary-rgb, 19, 103, 255), 0.08); color: var(--kg-primary); font-weight: 600; } .no-results { padding: 16px; text-align: center; color: var(--kg-text-muted); font-size: 0.9rem; } .check-icon { width: 16px; height: 16px; } .select-trigger.error { border-color: #DB2828 !important; background-color: rgba(219, 40, 40, 0.02) !important; } .error-text { position: absolute; top: 100%; left: 2px; color: #DB2828; font-size: 0.75rem; margin-top: 2px; font-weight: 500; animation: fadeIn 0.2s ease-in; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } } `"
|
|
4403
4403
|
},
|
|
4404
4404
|
{
|
|
4405
4405
|
"kind": "method",
|
|
@@ -4447,6 +4447,15 @@
|
|
|
4447
4447
|
"kind": "method",
|
|
4448
4448
|
"name": "_dispatchChange"
|
|
4449
4449
|
},
|
|
4450
|
+
{
|
|
4451
|
+
"kind": "method",
|
|
4452
|
+
"name": "_clearValue",
|
|
4453
|
+
"parameters": [
|
|
4454
|
+
{
|
|
4455
|
+
"name": "e"
|
|
4456
|
+
}
|
|
4457
|
+
]
|
|
4458
|
+
},
|
|
4450
4459
|
{
|
|
4451
4460
|
"kind": "method",
|
|
4452
4461
|
"name": "_handleSearch",
|
|
@@ -4516,6 +4525,14 @@
|
|
|
4516
4525
|
},
|
|
4517
4526
|
"default": "false"
|
|
4518
4527
|
},
|
|
4528
|
+
{
|
|
4529
|
+
"kind": "field",
|
|
4530
|
+
"name": "clearable",
|
|
4531
|
+
"type": {
|
|
4532
|
+
"text": "boolean"
|
|
4533
|
+
},
|
|
4534
|
+
"default": "false"
|
|
4535
|
+
},
|
|
4519
4536
|
{
|
|
4520
4537
|
"kind": "field",
|
|
4521
4538
|
"name": "_open",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e,t=Object.defineProperty;import{LitElement as r,css as i,html as s}from"lit";import"lit/directives/class-map.js";import{F as
|
|
1
|
+
var e,t=Object.defineProperty;import{LitElement as r,css as i,html as s}from"lit";import"lit/directives/class-map.js";import{F as a}from"../chunks/FormAssociated-Cx5D8YQA.js";class o extends(a(r)){static get properties(){return{...super.properties,options:{type:Array},value:{type:Object},placeholder:{type:String},label:{type:String},multiple:{type:Boolean},searchable:{type:Boolean},clearable:{type:Boolean},_open:{type:Boolean,state:!0},_searchQuery:{type:String,state:!0}}}constructor(){super(),this.options=[],this.value=null,this.placeholder="Seçiniz...",this.multiple=!1,this.searchable=!1,this.clearable=!1,this._open=!1,this._searchQuery="",this._handleOutsideClick=this._handleOutsideClick.bind(this)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleOutsideClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleOutsideClick)}_updateFormValue(){if(this.multiple&&Array.isArray(this.value)){const e=new FormData;this.value.forEach(t=>e.append(this.name,t)),this.internals.setFormValue(e)}else this.internals.setFormValue(this.value)}_handleOutsideClick(e){this._open&&(e.composedPath().includes(this)||this._closeDropdown())}_toggleDropdown(e){this.disabled||(this._open=!this._open,this._open&&(this._searchQuery="",setTimeout(()=>{const e=this.shadowRoot.querySelector(".search-input");e&&e.focus()},100)))}_closeDropdown(){this._open=!1}_selectOption(e,t){if(t.stopPropagation(),this.multiple){let t=Array.isArray(this.value)?[...this.value]:[];const r=t.indexOf(e.value);r>-1?t.splice(r,1):t.push(e.value),this.value=t}else this.value=e.value,this._closeDropdown();this._dispatchChange()}_dispatchChange(){this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))}_clearValue(e){e.stopPropagation(),this.value=this.multiple?[]:null,this._dispatchChange(),this._open&&this._closeDropdown()}_handleSearch(e){this._searchQuery=e.target.value.toLowerCase()}_removeTag(e,t){t.stopPropagation();let r=[...this.value];const i=r.indexOf(e);i>-1&&(r.splice(i,1),this.value=r,this._dispatchChange())}render(){const e=e=>this.multiple&&Array.isArray(this.value)?this.value.includes(e):this.value===e,t=(()=>{if(!this.value)return null;if(this.multiple&&Array.isArray(this.value))return this.options.filter(e=>this.value.includes(e.value));const e=this.options.find(e=>e.value===this.value);return e?e.label:null})(),r=(this.options||[]).filter(e=>e.label.toLowerCase().includes(this._searchQuery||""));return s`
|
|
2
2
|
<div class="kg-select-container">
|
|
3
3
|
${this.label?s`<label class="select-label">${this.label}</label>`:""}
|
|
4
4
|
|
|
@@ -26,9 +26,19 @@ var e,t=Object.defineProperty;import{LitElement as r,css as i,html as s}from"lit
|
|
|
26
26
|
<span class="selected-text">${t}</span>
|
|
27
27
|
`}
|
|
28
28
|
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
<span style="display: flex; align-items: center; gap: 8px;">
|
|
30
|
+
${this.clearable&&!this.disabled&&(Array.isArray(this.value)?this.value.length>0:null!==this.value)?s`
|
|
31
|
+
<div class="clear-button" @click="${this._clearValue}" title="Temizle">
|
|
32
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
33
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
34
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
35
|
+
</svg>
|
|
36
|
+
</div>
|
|
37
|
+
`:""}
|
|
38
|
+
<svg class="chevron" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
39
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
40
|
+
</svg>
|
|
41
|
+
</span>
|
|
32
42
|
</div>
|
|
33
43
|
|
|
34
44
|
<div class="select-dropdown ${this._open?"visible":""}">
|
|
@@ -63,7 +73,7 @@ var e,t=Object.defineProperty;import{LitElement as r,css as i,html as s}from"lit
|
|
|
63
73
|
</div>
|
|
64
74
|
${this.errorText?s`<div class="error-text">${this.errorText}</div>`:""}
|
|
65
75
|
</div>
|
|
66
|
-
`}}((e,r,i)=>{r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[r]=i})(
|
|
76
|
+
`}}((e,r,i)=>{r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[r]=i})(o,"symbol"!=typeof(e="styles")?e+"":e,i`
|
|
67
77
|
:host {
|
|
68
78
|
display: inline-block;
|
|
69
79
|
width: 100%;
|
|
@@ -170,6 +180,25 @@ var e,t=Object.defineProperty;import{LitElement as r,css as i,html as s}from"lit
|
|
|
170
180
|
transform: rotate(180deg);
|
|
171
181
|
}
|
|
172
182
|
|
|
183
|
+
.clear-button {
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
color: var(--kg-text-muted);
|
|
189
|
+
opacity: 0.6;
|
|
190
|
+
transition: all 0.2s;
|
|
191
|
+
flex-shrink: 0;
|
|
192
|
+
padding: 4px;
|
|
193
|
+
border-radius: 50%;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.clear-button:hover {
|
|
197
|
+
opacity: 1;
|
|
198
|
+
background: var(--kg-bg-secondary, rgba(0, 0, 0, 0.04));
|
|
199
|
+
color: var(--kg-primary);
|
|
200
|
+
}
|
|
201
|
+
|
|
173
202
|
/* Dropdown */
|
|
174
203
|
.select-dropdown {
|
|
175
204
|
position: absolute;
|
|
@@ -271,4 +300,4 @@ var e,t=Object.defineProperty;import{LitElement as r,css as i,html as s}from"lit
|
|
|
271
300
|
from { opacity: 0; transform: translateY(-4px); }
|
|
272
301
|
to { opacity: 1; transform: translateY(0); }
|
|
273
302
|
}
|
|
274
|
-
`),"undefined"==typeof customElements||customElements.get("kg-select")||customElements.define("kg-select",
|
|
303
|
+
`),"undefined"==typeof customElements||customElements.get("kg-select")||customElements.define("kg-select",o);export{o as kgselect};
|
package/package.json
CHANGED
|
@@ -21,6 +21,8 @@ export class kgselect extends LitElement {
|
|
|
21
21
|
/** */
|
|
22
22
|
searchable: boolean;
|
|
23
23
|
/** */
|
|
24
|
+
clearable: boolean;
|
|
25
|
+
/** */
|
|
24
26
|
form: any;
|
|
25
27
|
/** */
|
|
26
28
|
type: string;
|
|
@@ -43,6 +45,7 @@ declare global {
|
|
|
43
45
|
placeholder?: string;
|
|
44
46
|
multiple?: boolean;
|
|
45
47
|
searchable?: boolean;
|
|
48
|
+
clearable?: boolean;
|
|
46
49
|
form?: any;
|
|
47
50
|
type?: string;
|
|
48
51
|
onChange?: (e: any) => void;
|