@kodaris/krubble-components 1.0.4 → 1.0.5

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.
@@ -130,7 +130,7 @@
130
130
  {
131
131
  "kind": "variable",
132
132
  "name": "KRButton",
133
- "default": "class KRButton extends i$1 { constructor() { super(...arguments); /** * The button variant style */ this.variant = 'primary'; /** * The button size */ this.size = 'medium'; /** * Whether the button is disabled */ this.disabled = false; } render() { const sizeClass = this.size !== 'medium' ? this.size : ''; return b ` <button part=\"button\" class=\"${this.variant} ${sizeClass}\" ?disabled=${this.disabled} > <slot></slot> </button> `; } }",
133
+ "default": "class KRButton extends i$1 { constructor() { super(...arguments); /** * The button variant (shape) */ this.variant = 'flat'; /** * The button color */ this.color = 'primary'; /** * The button size */ this.size = 'medium'; /** * Whether the button is disabled */ this.disabled = false; this._state = 'idle'; this._stateText = ''; this._handleKeydown = (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); this.click(); } }; } connectedCallback() { super.connectedCallback(); this.setAttribute('role', 'button'); this.setAttribute('tabindex', '0'); this.addEventListener('keydown', this._handleKeydown); } disconnectedCallback() { super.disconnectedCallback(); this.removeEventListener('keydown', this._handleKeydown); } /** * Shows a loading spinner and disables the button. */ showLoading() { this._clearStateTimeout(); this._state = 'loading'; this._stateText = ''; } /** * Shows a success state with optional custom text. * @param text - Text to display (default: \"Saved\") * @param duration - Duration in ms before auto-reset (default: 2000) */ showSuccess(text = 'Success', duration = 2000) { this._clearStateTimeout(); this._state = 'success'; this._stateText = text; this._stateTimeout = window.setTimeout(() => this.reset(), duration); } /** * Shows an error state with optional custom text. * @param text - Text to display (default: \"Error\") * @param duration - Duration in ms before auto-reset (default: 2000) */ showError(text = 'Error', duration = 2000) { this._clearStateTimeout(); this._state = 'error'; this._stateText = text; this._stateTimeout = window.setTimeout(() => this.reset(), duration); } /** * Resets the button to its idle state. */ reset() { this._clearStateTimeout(); this._state = 'idle'; this._stateText = ''; } _clearStateTimeout() { if (this._stateTimeout) { clearTimeout(this._stateTimeout); this._stateTimeout = undefined; } } updated(changedProperties) { // Reflect state classes to host this.classList.toggle('kr-button--loading', this._state === 'loading'); this.classList.toggle('kr-button--success', this._state === 'success'); this.classList.toggle('kr-button--error', this._state === 'error'); this.classList.toggle(`kr-button--${this.variant}`, true); this.classList.toggle(`kr-button--${this.color}`, true); this.classList.toggle('kr-button--small', this.size === 'small'); this.classList.toggle('kr-button--large', this.size === 'large'); } render() { return b ` <slot></slot> ${this._state !== 'idle' ? b `<span class=\"state-overlay\"> ${this._state === 'loading' ? b `<span class=\"spinner\"></span>` : this._stateText} </span>` : ''} `; } }",
134
134
  "description": "A customizable button component."
135
135
  },
136
136
  {
@@ -373,27 +373,27 @@
373
373
  {
374
374
  "kind": "variable",
375
375
  "name": "kt",
376
- "default": "class extends nt{constructor(){super(...arguments),this.type=\"info\",this.dismissible=!1,this.visible=!0}_handleDismiss(){this.visible=!1,this.dispatchEvent(new CustomEvent(\"dismiss\",{bubbles:!0,composed:!0}))}render(){const t={info:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clip-rule=\"evenodd\"/></svg>`,success:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clip-rule=\"evenodd\"/></svg>`,warning:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"/></svg>`,error:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clip-rule=\"evenodd\"/></svg>`};return V` <div class=${$t({alert:!0,[\"alert--\"+this.type]:!0,\"alert--hidden\":!this.visible})} role=\"alert\" > ${t[this.type]} <div class=\"content\"> ${this.header?V`<h4 class=\"header\">${this.header}</h4>`:q} <div class=\"message\"> <slot></slot> </div> </div> ${this.dismissible?V` <button class=\"dismiss\" type=\"button\" aria-label=\"Dismiss alert\" @click=${this._handleDismiss} > <svg viewBox=\"0 0 20 20\" fill=\"currentColor\" width=\"16\" height=\"16\"> <path fill-rule=\"evenodd\" d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\" clip-rule=\"evenodd\"/> </svg> </button> `:q} </div> `}}"
376
+ "default": "class extends nt{constructor(){super(...arguments),this.type=\"info\",this.dismissible=!1,this.visible=!0}_handleDismiss(){this.visible=!1,this.dispatchEvent(new CustomEvent(\"dismiss\",{bubbles:!0,composed:!0}))}render(){const t={info:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clip-rule=\"evenodd\"/></svg>`,success:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clip-rule=\"evenodd\"/></svg>`,warning:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clip-rule=\"evenodd\"/></svg>`,error:V`<svg class=\"icon\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clip-rule=\"evenodd\"/></svg>`};return V` <div class=${xt({alert:!0,[\"alert--\"+this.type]:!0,\"alert--hidden\":!this.visible})} role=\"alert\" > ${t[this.type]} <div class=\"content\"> ${this.header?V`<h4 class=\"header\">${this.header}</h4>`:q} <div class=\"message\"> <slot></slot> </div> </div> ${this.dismissible?V` <button class=\"dismiss\" type=\"button\" aria-label=\"Dismiss alert\" @click=${this._handleDismiss} > <svg viewBox=\"0 0 20 20\" fill=\"currentColor\" width=\"16\" height=\"16\"> <path fill-rule=\"evenodd\" d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\" clip-rule=\"evenodd\"/> </svg> </button> `:q} </div> `}}"
377
377
  },
378
378
  {
379
379
  "kind": "variable",
380
380
  "name": "At",
381
- "default": "class extends nt{constructor(){super(...arguments),this.variant=\"primary\",this.size=\"medium\",this.disabled=!1}render(){const t=\"medium\"!==this.size?this.size:\"\";return V` <button part=\"button\" class=\"${this.variant} ${t}\" ?disabled=${this.disabled} > <slot></slot> </button> `}}"
381
+ "default": "class extends nt{constructor(){super(...arguments),this.variant=\"flat\",this.color=\"primary\",this.size=\"medium\",this.disabled=!1,this._state=\"idle\",this._stateText=\"\",this._handleKeydown=t=>{\"Enter\"!==t.key&&\" \"!==t.key||(t.preventDefault(),this.click())}}connectedCallback(){super.connectedCallback(),this.setAttribute(\"role\",\"button\"),this.setAttribute(\"tabindex\",\"0\"),this.addEventListener(\"keydown\",this._handleKeydown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(\"keydown\",this._handleKeydown)}showLoading(){this._clearStateTimeout(),this._state=\"loading\",this._stateText=\"\"}showSuccess(t=\"Success\",e=2e3){this._clearStateTimeout(),this._state=\"success\",this._stateText=t,this._stateTimeout=window.setTimeout(()=>this.reset(),e)}showError(t=\"Error\",e=2e3){this._clearStateTimeout(),this._state=\"error\",this._stateText=t,this._stateTimeout=window.setTimeout(()=>this.reset(),e)}reset(){this._clearStateTimeout(),this._state=\"idle\",this._stateText=\"\"}_clearStateTimeout(){this._stateTimeout&&(clearTimeout(this._stateTimeout),this._stateTimeout=void 0)}updated(t){this.classList.toggle(\"kr-button--loading\",\"loading\"===this._state),this.classList.toggle(\"kr-button--success\",\"success\"===this._state),this.classList.toggle(\"kr-button--error\",\"error\"===this._state),this.classList.toggle(`kr-button--${this.variant}`,!0),this.classList.toggle(`kr-button--${this.color}`,!0),this.classList.toggle(\"kr-button--small\",\"small\"===this.size),this.classList.toggle(\"kr-button--large\",\"large\"===this.size)}render(){return V` <slot></slot> ${\"idle\"!==this._state?V`<span class=\"state-overlay\"> ${\"loading\"===this._state?V`<span class=\"spinner\"></span>`:this._stateText} </span>`:\"\"} `}}"
382
382
  },
383
383
  {
384
384
  "kind": "variable",
385
385
  "name": "Pt",
386
- "default": "class extends nt{constructor(){super(...arguments),this.language=\"html\",this.code=\"\",this.activeTab=\"preview\",this.copied=!1}setTab(t){this.activeTab=t}getHighlightedCode(){return this.code?window.Prism&&window.Prism.languages[this.language]?window.Prism.highlight(this.code,window.Prism.languages[this.language],this.language):this.escapeHtml(this.code):\"\"}escapeHtml(t){const e=document.createElement(\"div\");return e.textContent=t,e.innerHTML}async copyCode(){if(this.code)try{await navigator.clipboard.writeText(this.code),this.copied=!0,setTimeout(()=>{this.copied=!1},2e3)}catch(t){console.error(\"Failed to copy code:\",t)}}render(){return V` <div class=\"tabs\"> <button class=${$t({tab:!0,\"tab--active\":\"preview\"===this.activeTab})} @click=${()=>this.setTab(\"preview\")} > Preview </button> <button class=${$t({tab:!0,\"tab--active\":\"code\"===this.activeTab})} @click=${()=>this.setTab(\"code\")} > Code </button> </div> <div class=${$t({panel:!0,\"panel--active\":\"preview\"===this.activeTab,preview:!0})}> <slot name=\"preview\"></slot> </div> <div class=${$t({panel:!0,\"panel--active\":\"code\"===this.activeTab,\"code-container\":!0})}> <button class=${$t({\"copy-btn\":!0,\"copy-btn--copied\":this.copied})} @click=${this.copyCode} > ${this.copied?\"Copied!\":\"Copy\"} </button> <pre class=\"code\"><code>${St(this.getHighlightedCode())}</code></pre> </div> `}}"
386
+ "default": "class extends nt{constructor(){super(...arguments),this.language=\"html\",this.code=\"\",this.activeTab=\"preview\",this.copied=!1}setTab(t){this.activeTab=t}getHighlightedCode(){return this.code?window.Prism&&window.Prism.languages[this.language]?window.Prism.highlight(this.code,window.Prism.languages[this.language],this.language):this.escapeHtml(this.code):\"\"}escapeHtml(t){const e=document.createElement(\"div\");return e.textContent=t,e.innerHTML}async copyCode(){if(this.code)try{await navigator.clipboard.writeText(this.code),this.copied=!0,setTimeout(()=>{this.copied=!1},2e3)}catch(t){console.error(\"Failed to copy code:\",t)}}render(){return V` <div class=\"tabs\"> <button class=${xt({tab:!0,\"tab--active\":\"preview\"===this.activeTab})} @click=${()=>this.setTab(\"preview\")} > Preview </button> <button class=${xt({tab:!0,\"tab--active\":\"code\"===this.activeTab})} @click=${()=>this.setTab(\"code\")} > Code </button> </div> <div class=${xt({panel:!0,\"panel--active\":\"preview\"===this.activeTab,preview:!0})}> <slot name=\"preview\"></slot> </div> <div class=${xt({panel:!0,\"panel--active\":\"code\"===this.activeTab,\"code-container\":!0})}> <button class=${xt({\"copy-btn\":!0,\"copy-btn--copied\":this.copied})} @click=${this.copyCode} > ${this.copied?\"Copied!\":\"Copy\"} </button> <pre class=\"code\"><code>${St(this.getHighlightedCode())}</code></pre> </div> `}}"
387
387
  },
388
388
  {
389
389
  "kind": "variable",
390
- "name": "Mt",
390
+ "name": "Ot",
391
391
  "default": "class extends nt{constructor(){super(...arguments),this.items=[],this.resolvePromise=null,this.boundHandleOutsideClick=this.handleOutsideClick.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this)}static async open(t){const e=document.querySelector(\"kr-context-menu\");e&&e.remove();const i=document.createElement(\"kr-context-menu\");return document.body.appendChild(i),i.show(t)}async show(t){this.items=t.items,this.style.left=`${t.x}px`,this.style.top=`${t.y}px`,await this.updateComplete;const e=this.getBoundingClientRect();return e.right>window.innerWidth&&(this.style.left=t.x-e.width+\"px\"),e.bottom>window.innerHeight&&(this.style.top=t.y-e.height+\"px\"),requestAnimationFrame(()=>{document.addEventListener(\"click\",this.boundHandleOutsideClick),document.addEventListener(\"contextmenu\",this.boundHandleOutsideClick),document.addEventListener(\"keydown\",this.boundHandleKeyDown)}),new Promise(t=>{this.resolvePromise=t})}handleOutsideClick(t){this.contains(t.target)||this.close(null)}handleKeyDown(t){\"Escape\"===t.key&&this.close(null)}handleItemClick(t){t.disabled||t.divider||this.close(t)}close(t){document.removeEventListener(\"click\",this.boundHandleOutsideClick),document.removeEventListener(\"contextmenu\",this.boundHandleOutsideClick),document.removeEventListener(\"keydown\",this.boundHandleKeyDown),this.resolvePromise&&(this.resolvePromise(t),this.resolvePromise=null),this.remove()}render(){return V` <div class=\"menu\"> ${this.items.map(t=>t.divider?V`<div class=\"menu__divider\"></div>`:V` <button class=\"menu__item\" ?disabled=${t.disabled} @click=${()=>this.handleItemClick(t)} > ${t.icon?V`<span class=\"menu__item-icon\">${t.icon}</span>`:null} ${t.label} </button> `)} </div> `}}"
392
392
  },
393
393
  {
394
394
  "kind": "class",
395
395
  "description": "",
396
- "name": "Tt",
396
+ "name": "Rt",
397
397
  "members": [
398
398
  {
399
399
  "kind": "method",
@@ -443,11 +443,11 @@
443
443
  {
444
444
  "kind": "variable",
445
445
  "name": "zt",
446
- "default": "class extends nt{constructor(){super(...arguments),this.contentElement=null,this.dialogRef=null,this.boundHandleKeyDown=this.handleKeyDown.bind(this)}static open(t,e){const i=document.querySelector(\"kr-dialog\");i&&i.remove();const o=new Tt,s=document.createElement(\"kr-dialog\");o.setDialogElement(s),s.dialogRef=o;const r=new t;return r.dialogRef=o,e?.data&&(r.data=e.data),s.contentElement=r,document.body.appendChild(s),document.addEventListener(\"keydown\",s.boundHandleKeyDown),o}handleKeyDown(t){\"Escape\"===t.key&&this.dialogRef?.close(void 0)}handleBackdropClick(t){t.target.classList.contains(\"backdrop\")&&this.dialogRef?.close(void 0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(\"keydown\",this.boundHandleKeyDown)}render(){return V` <div class=\"backdrop\" @click=${this.handleBackdropClick}></div> <div class=\"dialog\"> ${this.contentElement} </div> `}}"
446
+ "default": "class extends nt{constructor(){super(...arguments),this.contentElement=null,this.dialogRef=null,this.boundHandleKeyDown=this.handleKeyDown.bind(this)}static open(t,e){const i=document.querySelector(\"kr-dialog\");i&&i.remove();const o=new Rt,s=document.createElement(\"kr-dialog\");o.setDialogElement(s),s.dialogRef=o;const r=new t;return r.dialogRef=o,e?.data&&(r.data=e.data),s.contentElement=r,document.body.appendChild(s),document.addEventListener(\"keydown\",s.boundHandleKeyDown),o}handleKeyDown(t){\"Escape\"===t.key&&this.dialogRef?.close(void 0)}handleBackdropClick(t){t.target.classList.contains(\"backdrop\")&&this.dialogRef?.close(void 0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(\"keydown\",this.boundHandleKeyDown)}render(){return V` <div class=\"backdrop\" @click=${this.handleBackdropClick}></div> <div class=\"dialog\"> ${this.contentElement} </div> `}}"
447
447
  },
448
448
  {
449
449
  "kind": "variable",
450
- "name": "Lt"
450
+ "name": "jt"
451
451
  },
452
452
  {
453
453
  "kind": "variable",
@@ -476,7 +476,7 @@
476
476
  "kind": "js",
477
477
  "name": "DialogRef",
478
478
  "declaration": {
479
- "name": "Tt",
479
+ "name": "Rt",
480
480
  "module": "dist/krubble.bundled.min.js"
481
481
  }
482
482
  },
@@ -516,7 +516,7 @@
516
516
  "kind": "js",
517
517
  "name": "KRContextMenu",
518
518
  "declaration": {
519
- "name": "Mt",
519
+ "name": "Ot",
520
520
  "module": "dist/krubble.bundled.min.js"
521
521
  }
522
522
  },
@@ -532,7 +532,7 @@
532
532
  "kind": "js",
533
533
  "name": "KRSnackbar",
534
534
  "declaration": {
535
- "name": "Lt",
535
+ "name": "jt",
536
536
  "module": "dist/krubble.bundled.min.js"
537
537
  }
538
538
  },
@@ -641,28 +641,28 @@
641
641
  "declarations": [
642
642
  {
643
643
  "kind": "variable",
644
- "name": "t",
644
+ "name": "e",
645
645
  "default": "globalThis"
646
646
  },
647
647
  {
648
648
  "kind": "variable",
649
- "name": "e"
649
+ "name": "t"
650
650
  }
651
651
  ],
652
652
  "exports": [
653
653
  {
654
654
  "kind": "custom-element-definition",
655
- "name": "e",
655
+ "name": "t",
656
656
  "declaration": {
657
- "name": "t",
657
+ "name": "e",
658
658
  "module": "dist/krubble.umd.min.js"
659
659
  }
660
660
  },
661
661
  {
662
662
  "kind": "custom-element-definition",
663
- "name": "e",
663
+ "name": "t",
664
664
  "declaration": {
665
- "name": "t",
665
+ "name": "e",
666
666
  "module": "dist/krubble.umd.min.js"
667
667
  }
668
668
  }
@@ -942,7 +942,7 @@
942
942
  {
943
943
  "kind": "variable",
944
944
  "name": "KRButton",
945
- "default": "class KRButton extends LitElement { constructor() { super(...arguments); /** * The button variant style */ this.variant = 'primary'; /** * The button size */ this.size = 'medium'; /** * Whether the button is disabled */ this.disabled = false; } render() { const sizeClass = this.size !== 'medium' ? this.size : ''; return html ` <button part=\"button\" class=\"${this.variant} ${sizeClass}\" ?disabled=${this.disabled} > <slot></slot> </button> `; } }",
945
+ "default": "class KRButton extends LitElement { constructor() { super(...arguments); /** * The button variant (shape) */ this.variant = 'flat'; /** * The button color */ this.color = 'primary'; /** * The button size */ this.size = 'medium'; /** * Whether the button is disabled */ this.disabled = false; this._state = 'idle'; this._stateText = ''; this._handleKeydown = (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); this.click(); } }; } connectedCallback() { super.connectedCallback(); this.setAttribute('role', 'button'); this.setAttribute('tabindex', '0'); this.addEventListener('keydown', this._handleKeydown); } disconnectedCallback() { super.disconnectedCallback(); this.removeEventListener('keydown', this._handleKeydown); } /** * Shows a loading spinner and disables the button. */ showLoading() { this._clearStateTimeout(); this._state = 'loading'; this._stateText = ''; } /** * Shows a success state with optional custom text. * @param text - Text to display (default: \"Saved\") * @param duration - Duration in ms before auto-reset (default: 2000) */ showSuccess(text = 'Success', duration = 2000) { this._clearStateTimeout(); this._state = 'success'; this._stateText = text; this._stateTimeout = window.setTimeout(() => this.reset(), duration); } /** * Shows an error state with optional custom text. * @param text - Text to display (default: \"Error\") * @param duration - Duration in ms before auto-reset (default: 2000) */ showError(text = 'Error', duration = 2000) { this._clearStateTimeout(); this._state = 'error'; this._stateText = text; this._stateTimeout = window.setTimeout(() => this.reset(), duration); } /** * Resets the button to its idle state. */ reset() { this._clearStateTimeout(); this._state = 'idle'; this._stateText = ''; } _clearStateTimeout() { if (this._stateTimeout) { clearTimeout(this._stateTimeout); this._stateTimeout = undefined; } } updated(changedProperties) { // Reflect state classes to host this.classList.toggle('kr-button--loading', this._state === 'loading'); this.classList.toggle('kr-button--success', this._state === 'success'); this.classList.toggle('kr-button--error', this._state === 'error'); this.classList.toggle(`kr-button--${this.variant}`, true); this.classList.toggle(`kr-button--${this.color}`, true); this.classList.toggle('kr-button--small', this.size === 'small'); this.classList.toggle('kr-button--large', this.size === 'large'); } render() { return html ` <slot></slot> ${this._state !== 'idle' ? html `<span class=\"state-overlay\"> ${this._state === 'loading' ? html `<span class=\"spinner\"></span>` : this._stateText} </span>` : ''} `; } }",
946
946
  "description": "A customizable button component."
947
947
  }
948
948
  ],
@@ -1205,12 +1205,6 @@
1205
1205
  "kind": "class",
1206
1206
  "description": "A customizable button component.",
1207
1207
  "name": "KRButton",
1208
- "cssParts": [
1209
- {
1210
- "description": "The button element",
1211
- "name": "button"
1212
- }
1213
- ],
1214
1208
  "slots": [
1215
1209
  {
1216
1210
  "description": "The button content",
@@ -1222,11 +1216,23 @@
1222
1216
  "kind": "field",
1223
1217
  "name": "variant",
1224
1218
  "type": {
1225
- "text": "'primary' | 'secondary' | 'outline'"
1219
+ "text": "'flat' | 'outline'"
1220
+ },
1221
+ "default": "'flat'",
1222
+ "description": "The button variant (shape)",
1223
+ "attribute": "variant",
1224
+ "reflects": true
1225
+ },
1226
+ {
1227
+ "kind": "field",
1228
+ "name": "color",
1229
+ "type": {
1230
+ "text": "'primary' | 'secondary'"
1226
1231
  },
1227
1232
  "default": "'primary'",
1228
- "description": "The button variant style",
1229
- "attribute": "variant"
1233
+ "description": "The button color",
1234
+ "attribute": "color",
1235
+ "reflects": true
1230
1236
  },
1231
1237
  {
1232
1238
  "kind": "field",
@@ -1236,7 +1242,8 @@
1236
1242
  },
1237
1243
  "default": "'medium'",
1238
1244
  "description": "The button size",
1239
- "attribute": "size"
1245
+ "attribute": "size",
1246
+ "reflects": true
1240
1247
  },
1241
1248
  {
1242
1249
  "kind": "field",
@@ -1246,7 +1253,88 @@
1246
1253
  },
1247
1254
  "default": "false",
1248
1255
  "description": "Whether the button is disabled",
1249
- "attribute": "disabled"
1256
+ "attribute": "disabled",
1257
+ "reflects": true
1258
+ },
1259
+ {
1260
+ "kind": "field",
1261
+ "name": "_state",
1262
+ "type": {
1263
+ "text": "'idle' | 'loading' | 'success' | 'error'"
1264
+ },
1265
+ "privacy": "private",
1266
+ "default": "'idle'"
1267
+ },
1268
+ {
1269
+ "kind": "field",
1270
+ "name": "_stateText",
1271
+ "type": {
1272
+ "text": "string"
1273
+ },
1274
+ "privacy": "private",
1275
+ "default": "''"
1276
+ },
1277
+ {
1278
+ "kind": "field",
1279
+ "name": "_stateTimeout",
1280
+ "type": {
1281
+ "text": "number | undefined"
1282
+ },
1283
+ "privacy": "private"
1284
+ },
1285
+ {
1286
+ "kind": "field",
1287
+ "name": "_handleKeydown",
1288
+ "privacy": "private"
1289
+ },
1290
+ {
1291
+ "kind": "method",
1292
+ "name": "showLoading",
1293
+ "description": "Shows a loading spinner and disables the button."
1294
+ },
1295
+ {
1296
+ "kind": "method",
1297
+ "name": "showSuccess",
1298
+ "parameters": [
1299
+ {
1300
+ "name": "text",
1301
+ "default": "'Success'",
1302
+ "description": "Text to display (default: \"Saved\")"
1303
+ },
1304
+ {
1305
+ "name": "duration",
1306
+ "default": "2000",
1307
+ "description": "Duration in ms before auto-reset (default: 2000)"
1308
+ }
1309
+ ],
1310
+ "description": "Shows a success state with optional custom text."
1311
+ },
1312
+ {
1313
+ "kind": "method",
1314
+ "name": "showError",
1315
+ "parameters": [
1316
+ {
1317
+ "name": "text",
1318
+ "default": "'Error'",
1319
+ "description": "Text to display (default: \"Error\")"
1320
+ },
1321
+ {
1322
+ "name": "duration",
1323
+ "default": "2000",
1324
+ "description": "Duration in ms before auto-reset (default: 2000)"
1325
+ }
1326
+ ],
1327
+ "description": "Shows an error state with optional custom text."
1328
+ },
1329
+ {
1330
+ "kind": "method",
1331
+ "name": "reset",
1332
+ "description": "Resets the button to its idle state."
1333
+ },
1334
+ {
1335
+ "kind": "method",
1336
+ "name": "_clearStateTimeout",
1337
+ "privacy": "private"
1250
1338
  }
1251
1339
  ],
1252
1340
  "events": [
@@ -1259,12 +1347,21 @@
1259
1347
  {
1260
1348
  "name": "variant",
1261
1349
  "type": {
1262
- "text": "'primary' | 'secondary' | 'outline'"
1350
+ "text": "'flat' | 'outline'"
1263
1351
  },
1264
- "default": "'primary'",
1265
- "description": "The button variant style",
1352
+ "default": "'flat'",
1353
+ "description": "The button variant (shape)",
1266
1354
  "fieldName": "variant"
1267
1355
  },
1356
+ {
1357
+ "name": "color",
1358
+ "type": {
1359
+ "text": "'primary' | 'secondary'"
1360
+ },
1361
+ "default": "'primary'",
1362
+ "description": "The button color",
1363
+ "fieldName": "color"
1364
+ },
1268
1365
  {
1269
1366
  "name": "size",
1270
1367
  "type": {
@@ -3,15 +3,18 @@ import { LitElement } from 'lit';
3
3
  * A customizable button component.
4
4
  *
5
5
  * @slot - The button content
6
- * @csspart button - The button element
7
6
  * @fires click - Fired when the button is clicked
8
7
  */
9
8
  export declare class KRButton extends LitElement {
10
9
  static styles: import("lit").CSSResult;
11
10
  /**
12
- * The button variant style
11
+ * The button variant (shape)
13
12
  */
14
- variant: 'primary' | 'secondary' | 'outline';
13
+ variant: 'flat' | 'outline';
14
+ /**
15
+ * The button color
16
+ */
17
+ color: 'primary' | 'secondary';
15
18
  /**
16
19
  * The button size
17
20
  */
@@ -20,6 +23,34 @@ export declare class KRButton extends LitElement {
20
23
  * Whether the button is disabled
21
24
  */
22
25
  disabled: boolean;
26
+ private _state;
27
+ private _stateText;
28
+ private _stateTimeout?;
29
+ connectedCallback(): void;
30
+ disconnectedCallback(): void;
31
+ private _handleKeydown;
32
+ /**
33
+ * Shows a loading spinner and disables the button.
34
+ */
35
+ showLoading(): void;
36
+ /**
37
+ * Shows a success state with optional custom text.
38
+ * @param text - Text to display (default: "Saved")
39
+ * @param duration - Duration in ms before auto-reset (default: 2000)
40
+ */
41
+ showSuccess(text?: string, duration?: number): void;
42
+ /**
43
+ * Shows an error state with optional custom text.
44
+ * @param text - Text to display (default: "Error")
45
+ * @param duration - Duration in ms before auto-reset (default: 2000)
46
+ */
47
+ showError(text?: string, duration?: number): void;
48
+ /**
49
+ * Resets the button to its idle state.
50
+ */
51
+ reset(): void;
52
+ private _clearStateTimeout;
53
+ protected updated(changedProperties: Map<string, unknown>): void;
23
54
  render(): import("lit-html").TemplateResult<1>;
24
55
  }
25
56
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C;;;;;;GAMG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,OAAgB,MAAM,0BA0EpB;IAEF;;OAEG;IAEH,OAAO,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAa;IAEzD;;OAEG;IAEH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAY;IAE9C;;OAEG;IAEH,QAAQ,UAAS;IAER,MAAM;CAahB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C;;;;;GAKG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,OAAgB,MAAM,0BAiJpB;IAEF;;OAEG;IAEH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAU;IAErC;;OAEG;IAEH,KAAK,EAAE,SAAS,GAAG,WAAW,CAAa;IAE3C;;OAEG;IAEH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAY;IAE9C;;OAEG;IAEH,QAAQ,UAAS;IAGjB,OAAO,CAAC,MAAM,CAAoD;IAGlE,OAAO,CAAC,UAAU,CAAM;IAExB,OAAO,CAAC,aAAa,CAAC,CAAS;IAE/B,iBAAiB;IAOjB,oBAAoB;IAKpB,OAAO,CAAC,cAAc,CAKpB;IAEF;;OAEG;IACH,WAAW;IAMX;;;;OAIG;IACH,WAAW,CAAC,IAAI,SAAY,EAAE,QAAQ,SAAO;IAO7C;;;;OAIG;IACH,SAAS,CAAC,IAAI,SAAU,EAAE,QAAQ,SAAO;IAOzC;;OAEG;IACH,KAAK;IAML,OAAO,CAAC,kBAAkB;cAOP,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAWzD,MAAM;CAYhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}