@lazhus/kg-ui 0.8.9 → 0.9.0
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 +1 -0
- package/custom-elements.json +25 -1
- package/dist/components/kg-switch.js +5 -2
- package/package.json +1 -1
- package/types/components/kg-switch.d.ts +9 -0
- package/types/index.d.ts +3 -0
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
|
package/custom-elements.json
CHANGED
|
@@ -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: 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); } } `"
|
|
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>
|
|
@@ -61,6 +62,8 @@ var e,t=Object.defineProperty;import{LitElement as r,css as s,html as i}from"lit
|
|
|
61
62
|
|
|
62
63
|
:host([checked]) .kg-switch-thumb {
|
|
63
64
|
transform: translateX(20px);
|
|
65
|
+
}
|
|
66
|
+
|
|
64
67
|
.label {
|
|
65
68
|
font-size: 0.95rem;
|
|
66
69
|
font-weight: 500;
|
package/package.json
CHANGED
|
@@ -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