@lazhus/kg-ui 0.9.4 → 0.9.6

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.
@@ -2454,16 +2454,12 @@
2454
2454
  },
2455
2455
  {
2456
2456
  "kind": "method",
2457
- "name": "updated",
2457
+ "name": "willUpdate",
2458
2458
  "parameters": [
2459
2459
  {
2460
2460
  "name": "changedProperties"
2461
2461
  }
2462
- ],
2463
- "inheritedFrom": {
2464
- "name": "FormAssociated",
2465
- "module": "src/mixins/FormAssociated.js"
2466
- }
2462
+ ]
2467
2463
  },
2468
2464
  {
2469
2465
  "kind": "method",
@@ -2598,6 +2594,19 @@
2598
2594
  "module": "src/mixins/FormAssociated.js"
2599
2595
  }
2600
2596
  },
2597
+ {
2598
+ "kind": "method",
2599
+ "name": "updated",
2600
+ "parameters": [
2601
+ {
2602
+ "name": "changedProperties"
2603
+ }
2604
+ ],
2605
+ "inheritedFrom": {
2606
+ "name": "FormAssociated",
2607
+ "module": "src/mixins/FormAssociated.js"
2608
+ }
2609
+ },
2601
2610
  {
2602
2611
  "kind": "method",
2603
2612
  "name": "formResetCallback",
@@ -1,4 +1,4 @@
1
- var e,i=Object.defineProperty;import{LitElement as r,css as t,html as s}from"lit";import{F as a}from"../chunks/FormAssociated-Cx5D8YQA.js";class l extends(a(r)){static get properties(){return{...super.properties,label:{type:String},placeholder:{type:String},accept:{type:String},multiple:{type:Boolean},hideChips:{type:Boolean,attribute:"hide-chips"},files:{type:Array,state:!0},_previews:{state:!0}}}constructor(){super(),this.placeholder="Dosya seçin...",this.accept="*",this.multiple=!1,this.hideChips=!1,this.files=[],this._previews=/* @__PURE__ */new Map}disconnectedCallback(){super.disconnectedCallback(),this._revokePreviews()}_updateFormValue(){if(this.files.length>0){const e=new FormData;this.files.forEach(i=>e.append(this.name,i)),this.internals.setFormValue(e)}else this.internals.setFormValue(null)}updated(e){e.has("files")&&(this._updatePreviews(),this._updateFormValue()),super.updated(e)}_revokePreviews(){this._previews.forEach(e=>URL.revokeObjectURL(e)),this._previews.clear()}_updatePreviews(){this._revokePreviews();const e=/* @__PURE__ */new Map;this.files.forEach(i=>{i.type.startsWith("image/")&&e.set(i,URL.createObjectURL(i))}),this._previews=e,this.requestUpdate()}_handleFileChange(e){const i=Array.from(e.target.files);this._addFiles(i),e.target.value=""}_addFiles(e){this.disabled||0===e.length||(this.files=this.multiple?e:[e[0]],this._emitChange())}_removeFile(e){this.files=this.files.filter((i,r)=>r!==e),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("change",{detail:{files:this.files},bubbles:!0,composed:!0}))}_triggerUpload(){this.disabled||this.shadowRoot.querySelector("input").click()}_onDragOver(e){e.preventDefault(),this.disabled||this.shadowRoot.querySelector(".upload-wrapper").classList.add("active")}_onDragLeave(){this.shadowRoot.querySelector(".upload-wrapper").classList.remove("active")}_onDrop(e){if(e.preventDefault(),this._onDragLeave(),this.disabled)return;const i=Array.from(e.dataTransfer.files);this._addFiles(i)}render(){const e=this.files.length>0,i=e?this.multiple?`${this.files.length} Dosya Seçildi`:this.files[0].name:this.placeholder;return s`
1
+ var e,i=Object.defineProperty;import{LitElement as r,css as t,html as s}from"lit";import{F as a}from"../chunks/FormAssociated-Cx5D8YQA.js";class l extends(a(r)){static get properties(){return{...super.properties,label:{type:String},placeholder:{type:String},accept:{type:String},multiple:{type:Boolean},hideChips:{type:Boolean,attribute:"hide-chips"},files:{type:Array,state:!0},_previews:{state:!0}}}constructor(){super(),this.placeholder="Dosya seçin...",this.accept="*",this.multiple=!1,this.hideChips=!1,this.files=[],this._previews=/* @__PURE__ */new Map}disconnectedCallback(){super.disconnectedCallback(),this._revokePreviews()}_updateFormValue(){if(this.files.length>0){const e=new FormData;this.files.forEach(i=>e.append(this.name,i)),this.internals.setFormValue(e)}else this.internals.setFormValue(null)}willUpdate(e){e.has("files")&&(this._updatePreviews(),this._updateFormValue())}_revokePreviews(){this._previews.forEach(e=>URL.revokeObjectURL(e)),this._previews.clear()}_updatePreviews(){this._revokePreviews();const e=/* @__PURE__ */new Map;this.files.forEach(i=>{i&&i.type&&i.type.startsWith("image/")&&e.set(i,URL.createObjectURL(i))}),this._previews=e}_handleFileChange(e){const i=Array.from(e.target.files);this._addFiles(i),e.target.value=""}_addFiles(e){this.disabled||0===e.length||(this.files=this.multiple?e:[e[0]],this._emitChange())}_removeFile(e){this.files=this.files.filter((i,r)=>r!==e),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("change",{detail:{files:this.files},bubbles:!0,composed:!0}))}_triggerUpload(){this.disabled||this.shadowRoot.querySelector("input").click()}_onDragOver(e){e.preventDefault(),this.disabled||this.shadowRoot.querySelector(".upload-wrapper").classList.add("active")}_onDragLeave(){this.shadowRoot.querySelector(".upload-wrapper").classList.remove("active")}_onDrop(e){if(e.preventDefault(),this._onDragLeave(),this.disabled)return;const i=Array.from(e.dataTransfer.files);this._addFiles(i)}render(){const e=this.files.length>0,i=e?this.multiple?`${this.files.length} Dosya Seçildi`:this.files[0].name:this.placeholder;return s`
2
2
  <div class="container">
3
3
  ${this.label?s`<label class="label">${this.label}</label>`:""}
4
4
 
@@ -1 +1 @@
1
- import e,{useState as t,useRef as r,useMemo as n,useEffect as a}from"react";import{createPortal as o}from"react-dom";import{o as c}from"../chunks/create-component-jQ1kjF1Z.js";import{kgdatagrid as s}from"../components/kg-datagrid.js";"undefined"==typeof customElements||customElements.get("kg-datagrid")||customElements.define("kg-datagrid",s);const l=c({tagName:"kg-datagrid",elementClass:s,react:e,events:{onSelectionChange:"selection-change",onPageChange:"page-change",onPageSizeChange:"page-size-change",onSort:"sort"}}),i=({columns:c,...s})=>{const[i,m]=t(/* @__PURE__ */new Map),d=r(null),g=r(/* @__PURE__ */new WeakMap),u=n(()=>c?c.map(t=>t.render?{...t,render:r=>{const n=t.render(r);if(!e.isValidElement(n))return n;let a=g.current.get(r);a||(a=/* @__PURE__ */new Map,g.current.set(r,a));let o=a.get(t.field);return o||(o=document.createElement("div"),o.className="kg-react-cell-portal",o.style.display="contents",o.dataset.reactCellId=Math.random().toString(36).substr(2,9),a.set(t.field,o)),o._reactContent=n,o}}:t):[],[c]);return a(()=>{const e=d.current;if(!e)return;const t=e.shadowRoot||e,r=()=>{const e=t.querySelectorAll(".kg-react-cell-portal"),r=/* @__PURE__ */new Map;e.forEach(e=>{e._reactContent&&r.set(e,e._reactContent)}),m(e=>{if(e.size!==r.size)return r;for(const[t,n]of r)if(e.get(t)!==n)return r;return e})},n=new MutationObserver(()=>{r()});return n.observe(t,{childList:!0,subtree:!0,attributes:!1,characterData:!1}),r(),()=>n.disconnect()},[u,s.data]),e.createElement(e.Fragment,null,e.createElement(l,{ref:d,columns:u,...s}),Array.from(i.entries()).map(([e,t])=>o(t,e,e.dataset.reactCellId)))};export{i as KgDataGrid};
1
+ import e,{useState as t,useRef as r,useMemo as n,useEffect as a}from"react";import{createPortal as o}from"react-dom";import{o as c}from"../chunks/create-component-jQ1kjF1Z.js";import{kgdatagrid as s}from"../components/kg-datagrid.js";"undefined"==typeof customElements||customElements.get("kg-datagrid")||customElements.define("kg-datagrid",s);const l=c({tagName:"kg-datagrid",elementClass:s,react:e,events:{onSelectionChange:"selection-change",onPageChange:"page-change",onPageSizeChange:"page-size-change",onSort:"sort"}}),d=({columns:c,...s})=>{const[d,i]=t(/* @__PURE__ */new Map),m=r(null),u=r(/* @__PURE__ */new WeakMap),g=r(/* @__PURE__ */new WeakMap),p=n(()=>c?c.map(t=>{const r={...t};return t.render&&(r.render=r=>{const n=t.render(r);if(!e.isValidElement(n))return n;let a=u.current.get(r);a||(a=/* @__PURE__ */new Map,u.current.set(r,a));let o=a.get(t.field);return o||(o=document.createElement("div"),o.className="kg-react-cell-portal",o.style.display="contents",o.dataset.reactCellId=Math.random().toString(36).substr(2,9),a.set(t.field,o)),o._reactContent=n,o}),t.headerRender&&(r.headerRender=r=>{const n=t.headerRender(r);if(!e.isValidElement(n))return n;let a=g.current.get(t);return a||(a=document.createElement("div"),a.className="kg-react-cell-portal",a.style.display="contents",a.dataset.reactCellId="h-"+Math.random().toString(36).substr(2,9),g.current.set(t,a)),a._reactContent=n,a}),r}):[],[c]);return a(()=>{const e=m.current;if(!e)return;const t=e.shadowRoot||e,r=()=>{const e=t.querySelectorAll(".kg-react-cell-portal"),r=/* @__PURE__ */new Map;e.forEach(e=>{e._reactContent&&r.set(e,e._reactContent)}),i(e=>{if(e.size!==r.size)return r;for(const[t,n]of r)if(e.get(t)!==n)return r;return e})},n=new MutationObserver(()=>{r()});return n.observe(t,{childList:!0,subtree:!0,attributes:!1,characterData:!1}),r(),()=>n.disconnect()},[p,s.data]),e.createElement(e.Fragment,null,e.createElement(l,{ref:m,columns:p,...s}),Array.from(d.entries()).map(([e,t])=>o(t,e,e.dataset.reactCellId)))};export{d as KgDataGrid};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazhus/kg-ui",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",