@lazhus/kg-ui 0.8.9 → 0.9.1

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/README.md CHANGED
@@ -10,6 +10,7 @@ Modern, lightweight UI component library built with LitElement.
10
10
  - 📱 **Responsive** - Mobile-first design
11
11
  - ⚡ **Lightweight** - Built with LitElement
12
12
  - 🎯 **TypeScript Ready** - Full type support (Global & React/JSX)
13
+ - 📊 **Powerful DataGrid** - Server-side pagination, sorting, and custom rendering
13
14
  - ♿ **Accessible** - ARIA compliant components
14
15
 
15
16
  ## 📦 Installation
@@ -5346,7 +5346,7 @@
5346
5346
  "kind": "field",
5347
5347
  "name": "styles",
5348
5348
  "static": true,
5349
- "default": "css` :host { display: inline-block; vertical-align: middle; cursor: pointer; user-select: none; font-family: inherit; } :host([disabled]) { cursor: not-allowed; opacity: 0.5; } .kg-switch-wrapper { display: flex; align-items: center; gap: 0.75rem; } .kg-switch-track { position: relative; width: 44px; height: 24px; background: var(--kg-border); border-radius: 24px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); } .kg-switch-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: white; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); } /* Checked State */ :host([checked]) .kg-switch-track { background: var(--switch-active-color, var(--kg-primary)); } :host([checked]) .kg-switch-thumb { transform: translateX(20px); .label { font-size: 0.95rem; font-weight: 500; color: var(--kg-text); } .error-text { position: absolute; top: 100%; left: 2px; color: #DB2828; font-size: 0.75rem; margin-top: 4px; font-weight: 500; animation: fadeIn 0.2s ease-in; white-space: nowrap; } .error .kg-switch-track { box-shadow: 0 0 0 2px rgba(219, 40, 40, 0.2); } @keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } } `"
5349
+ "default": "css` :host { display: inline-block; vertical-align: middle; cursor: pointer; user-select: none; font-family: inherit; } :host([disabled]) { cursor: not-allowed; opacity: 0.5; } .kg-switch-wrapper { display: flex; align-items: center; gap: 0.75rem; } .kg-switch-track { position: relative; width: 44px; height: 24px; background: var(--kg-border); border-radius: 24px; transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); } .kg-switch-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: white; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transform: translateX(0); will-change: transform; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.2s ease, background-color 0.3s ease; } /* Micro-animation: stretch effect on click */ .kg-switch-wrapper:active .kg-switch-thumb { width: 26px; } /* Checked State */ :host([checked]) .kg-switch-track { background: var(--switch-active-color, var(--kg-primary)); } :host([checked]) .kg-switch-thumb { transform: translateX(20px); } :host([checked]) .kg-switch-wrapper:active .kg-switch-thumb { transform: translateX(14px); /* Adjust position when stretched */ } .label { font-size: 0.95rem; font-weight: 500; color: var(--kg-text); transition: color 0.3s ease; } .error-text { position: absolute; top: 100%; left: 2px; color: #DB2828; font-size: 0.75rem; margin-top: 4px; font-weight: 500; animation: fadeIn 0.2s ease-in; white-space: nowrap; } .error .kg-switch-track { box-shadow: 0 0 0 2px rgba(219, 40, 40, 0.2); } @keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } } `"
5350
5350
  },
5351
5351
  {
5352
5352
  "kind": "method",
@@ -5414,6 +5414,30 @@
5414
5414
  },
5415
5415
  "default": "'primary'"
5416
5416
  },
5417
+ {
5418
+ "kind": "field",
5419
+ "name": "label",
5420
+ "type": {
5421
+ "text": "string"
5422
+ },
5423
+ "default": "''"
5424
+ },
5425
+ {
5426
+ "kind": "field",
5427
+ "name": "leftLabel",
5428
+ "type": {
5429
+ "text": "string"
5430
+ },
5431
+ "default": "''"
5432
+ },
5433
+ {
5434
+ "kind": "field",
5435
+ "name": "rightLabel",
5436
+ "type": {
5437
+ "text": "string"
5438
+ },
5439
+ "default": "''"
5440
+ },
5417
5441
  {
5418
5442
  "kind": "field",
5419
5443
  "name": "value",
@@ -1,14 +1,15 @@
1
- var e,t=Object.defineProperty;import{LitElement as r,css as s,html as i}from"lit";import"lit/directives/class-map.js";import{F as a}from"../chunks/FormAssociated-Cx5D8YQA.js";class c extends(a(r)){static get properties(){return{...super.properties,checked:{type:Boolean,reflect:!0},label:{type:String},color:{type:String}}}constructor(){super(),this.checked=!1,this.color="primary",this.value="on"}formResetCallback(){this.checked=this.hasAttribute("checked"),this._updateFormValue()}formStateRestoreCallback(e){"checked"===e?this.checked=!0:"unchecked"===e&&(this.checked=!1),this._updateFormValue()}updated(e){e.has("checked")&&this._updateFormValue(),super.updated(e)}_updateFormValue(){const e=this.checked?this.value||"on":null;this.internals.setFormValue(e,this.checked?"checked":"unchecked")}_toggle(){this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.checked},bubbles:!0,composed:!0})))}render(){const e=(r=this.color)&&"primary"!==r?r.startsWith("#")||r.startsWith("rgb")||r.startsWith("hsl")?r:{secondary:"var(--kg-secondary)",tertiary:"var(--kg-tertiary)",error:"#e74c3c",red:"#e74c3c",green:"#2ecc71",blue:"#3498db",orange:"#f39c12",purple:"#9b59b6"}[r]||`var(--kg-${r}, ${r})`:"var(--kg-primary)",t=this.checked?`--switch-active-color: ${e};`:"";var r;return i`
1
+ var e,t=Object.defineProperty;import{LitElement as r,css as s,html as i}from"lit";import"lit/directives/class-map.js";import{F as a}from"../chunks/FormAssociated-Cx5D8YQA.js";class c extends(a(r)){static get properties(){return{...super.properties,checked:{type:Boolean,reflect:!0},label:{type:String},leftLabel:{type:String},rightLabel:{type:String},color:{type:String}}}constructor(){super(),this.checked=!1,this.color="primary",this.label="",this.leftLabel="",this.rightLabel="",this.value="on"}formResetCallback(){this.checked=this.hasAttribute("checked"),this._updateFormValue()}formStateRestoreCallback(e){"checked"===e?this.checked=!0:"unchecked"===e&&(this.checked=!1),this._updateFormValue()}updated(e){e.has("checked")&&this._updateFormValue(),super.updated(e)}_updateFormValue(){const e=this.checked?this.value||"on":null;this.internals.setFormValue(e,this.checked?"checked":"unchecked")}_toggle(){this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.checked},bubbles:!0,composed:!0})))}render(){const e=(r=this.color)&&"primary"!==r?r.startsWith("#")||r.startsWith("rgb")||r.startsWith("hsl")?r:{secondary:"var(--kg-secondary)",tertiary:"var(--kg-tertiary)",error:"#e74c3c",red:"#e74c3c",green:"#2ecc71",blue:"#3498db",orange:"#f39c12",purple:"#9b59b6"}[r]||`var(--kg-${r}, ${r})`:"var(--kg-primary)",t=this.checked?`--switch-active-color: ${e};`:"";var r;return i`
2
2
  <div style="position: relative; display: inline-block;">
3
3
  <div
4
4
  class="kg-switch-wrapper ${this.errorText?"error":""}"
5
5
  style="${t}"
6
6
  @click="${this._toggle}"
7
7
  >
8
+ ${this.leftLabel?i`<span class="label left-label">${this.leftLabel}</span>`:""}
8
9
  <div class="kg-switch-track">
9
10
  <div class="kg-switch-thumb"></div>
10
11
  </div>
11
- ${this.label?i`<span class="label">${this.label}</span>`:""}
12
+ ${this.rightLabel||this.label?i`<span class="label right-label">${this.rightLabel||this.label}</span>`:""}
12
13
  </div>
13
14
  ${this.errorText?i`<div class="error-text">${this.errorText}</div>`:""}
14
15
  </div>
@@ -38,7 +39,7 @@ var e,t=Object.defineProperty;import{LitElement as r,css as s,html as i}from"lit
38
39
  height: 24px;
39
40
  background: var(--kg-border);
40
41
  border-radius: 24px;
41
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
42
+ transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
42
43
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
43
44
  }
44
45
 
@@ -51,7 +52,16 @@ var e,t=Object.defineProperty;import{LitElement as r,css as s,html as i}from"lit
51
52
  background: white;
52
53
  border-radius: 50%;
53
54
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
54
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
55
+ transform: translateX(0);
56
+ will-change: transform;
57
+ transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
58
+ width 0.2s ease,
59
+ background-color 0.3s ease;
60
+ }
61
+
62
+ /* Micro-animation: stretch effect on click */
63
+ .kg-switch-wrapper:active .kg-switch-thumb {
64
+ width: 26px;
55
65
  }
56
66
 
57
67
  /* Checked State */
@@ -61,10 +71,17 @@ var e,t=Object.defineProperty;import{LitElement as r,css as s,html as i}from"lit
61
71
 
62
72
  :host([checked]) .kg-switch-thumb {
63
73
  transform: translateX(20px);
74
+ }
75
+
76
+ :host([checked]) .kg-switch-wrapper:active .kg-switch-thumb {
77
+ transform: translateX(14px); /* Adjust position when stretched */
78
+ }
79
+
64
80
  .label {
65
81
  font-size: 0.95rem;
66
82
  font-weight: 500;
67
83
  color: var(--kg-text);
84
+ transition: color 0.3s ease;
68
85
  }
69
86
 
70
87
  .error-text {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazhus/kg-ui",
3
- "version": "0.8.9",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -17,6 +17,12 @@ export class kgswitch extends LitElement {
17
17
  /** */
18
18
  color: string;
19
19
  /** */
20
+ label: string;
21
+ /** */
22
+ leftLabel: string;
23
+ /** */
24
+ rightLabel: string;
25
+ /** */
20
26
  form: any;
21
27
  /** */
22
28
  type: string;
@@ -37,6 +43,9 @@ declare global {
37
43
  errorText?: string;
38
44
  checked?: boolean;
39
45
  color?: string;
46
+ label?: string;
47
+ leftLabel?: string;
48
+ rightLabel?: string;
40
49
  form?: any;
41
50
  type?: string;
42
51
  onChange?: (e: any) => void;
package/types/index.d.ts CHANGED
@@ -429,6 +429,9 @@ declare global {
429
429
  errorText?: string;
430
430
  checked?: boolean;
431
431
  color?: string;
432
+ label?: string;
433
+ leftLabel?: string;
434
+ rightLabel?: string;
432
435
  form?: any;
433
436
  type?: string;
434
437
  onChange?: (e: any) => void;