@kodaris/krubble-components 1.0.3 → 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.
- package/custom-elements.json +174 -66
- package/dist/button/button.d.ts +34 -3
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.js +193 -38
- package/dist/button/button.js.map +1 -1
- package/dist/krubble.bundled.js +244 -49
- package/dist/krubble.bundled.js.map +1 -1
- package/dist/krubble.bundled.min.js +165 -78
- package/dist/krubble.bundled.min.js.map +1 -1
- package/dist/krubble.umd.js +244 -49
- package/dist/krubble.umd.js.map +1 -1
- package/dist/krubble.umd.min.js +166 -79
- package/dist/krubble.umd.min.js.map +1 -1
- package/dist/snackbar/snackbar.d.ts +16 -6
- package/dist/snackbar/snackbar.d.ts.map +1 -1
- package/dist/snackbar/snackbar.js +52 -12
- package/dist/snackbar/snackbar.js.map +1 -1
- package/package.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -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
|
|
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
|
{
|
|
@@ -358,49 +358,49 @@
|
|
|
358
358
|
"declarations": [
|
|
359
359
|
{
|
|
360
360
|
"kind": "variable",
|
|
361
|
-
"name": "
|
|
361
|
+
"name": "t",
|
|
362
362
|
"default": "globalThis"
|
|
363
363
|
},
|
|
364
364
|
{
|
|
365
365
|
"kind": "variable",
|
|
366
|
-
"name": "
|
|
366
|
+
"name": "e"
|
|
367
367
|
},
|
|
368
368
|
{
|
|
369
369
|
"kind": "variable",
|
|
370
|
-
"name": "
|
|
371
|
-
"default": "class extends
|
|
370
|
+
"name": "ft",
|
|
371
|
+
"default": "class extends nt{constructor(){super(...arguments),this.header=\"\",this.expanded=!1}toggle(){this.expanded=!this.expanded}render(){return V` <div class=\"header\" @click=${this.toggle}> <span class=\"header__title\">${this.header}</span> <svg class=\"header__icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"> <path d=\"M6 9l6 6 6-6\"/> </svg> </div> <div class=\"content\"> <div class=\"content__inner\"> <div class=\"content__body\"> <slot></slot> </div> </div> </div> `}}"
|
|
372
372
|
},
|
|
373
373
|
{
|
|
374
374
|
"kind": "variable",
|
|
375
|
-
"name": "
|
|
376
|
-
"default": "class extends
|
|
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=${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
|
-
"name": "
|
|
381
|
-
"default": "class extends
|
|
380
|
+
"name": "At",
|
|
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
|
-
"name": "
|
|
386
|
-
"default": "class extends
|
|
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=${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": "
|
|
391
|
-
"default": "class extends
|
|
390
|
+
"name": "Ot",
|
|
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": "
|
|
396
|
+
"name": "Rt",
|
|
397
397
|
"members": [
|
|
398
398
|
{
|
|
399
399
|
"kind": "method",
|
|
400
400
|
"name": "setDialogElement",
|
|
401
401
|
"parameters": [
|
|
402
402
|
{
|
|
403
|
-
"name": "
|
|
403
|
+
"name": "t"
|
|
404
404
|
}
|
|
405
405
|
]
|
|
406
406
|
},
|
|
@@ -409,7 +409,7 @@
|
|
|
409
409
|
"name": "close",
|
|
410
410
|
"parameters": [
|
|
411
411
|
{
|
|
412
|
-
"name": "
|
|
412
|
+
"name": "t"
|
|
413
413
|
}
|
|
414
414
|
]
|
|
415
415
|
},
|
|
@@ -436,39 +436,39 @@
|
|
|
436
436
|
{
|
|
437
437
|
"kind": "field",
|
|
438
438
|
"name": "promise",
|
|
439
|
-
"default": "new Promise(
|
|
439
|
+
"default": "new Promise(t=>{this.resolvePromise=t})"
|
|
440
440
|
}
|
|
441
441
|
]
|
|
442
442
|
},
|
|
443
443
|
{
|
|
444
444
|
"kind": "variable",
|
|
445
|
-
"name": "
|
|
446
|
-
"default": "class extends
|
|
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 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": "
|
|
450
|
+
"name": "jt"
|
|
451
451
|
},
|
|
452
452
|
{
|
|
453
453
|
"kind": "variable",
|
|
454
|
-
"name": "
|
|
455
|
-
"default": "class extends
|
|
454
|
+
"name": "Bt",
|
|
455
|
+
"default": "class extends nt{constructor(){super(),this.label=\"\",this.name=\"\",this.value=\"\",this.placeholder=\"\",this.type=\"text\",this.required=!1,this.disabled=!1,this.readonly=!1,this.autocomplete=\"\",this.hint=\"\",this._touched=!1,this._dirty=!1,this._internals=this.attachInternals()}get form(){return this._internals.form}get validity(){return this._internals.validity}get validationMessage(){return this._internals.validationMessage}get willValidate(){return this._internals.willValidate}checkValidity(){return this._internals.checkValidity()}reportValidity(){return this._internals.reportValidity()}formResetCallback(){this.value=\"\",this._touched=!1,this._dirty=!1,this._internals.setFormValue(\"\"),this._internals.setValidity({})}formStateRestoreCallback(t){this.value=t}_handleInput(t){this.value=t.target.value,this._dirty=!0,this._internals.setFormValue(this.value),this._internals.setValidity(this._input.validity,this._input.validationMessage,this._input)}_handleChange(t){this.value=t.target.value,this._internals.setFormValue(this.value)}_handleBlur(){this._touched=!0,this._internals.setValidity(this._input.validity,this._input.validationMessage,this._input)}render(){let t=\"\";return this._touched&&this._input&&!this._input.validity.valid&&(t=this._input.validationMessage),V` <div class=\"wrapper\"> ${this.label?V` <label for=\"input\"> ${this.label} ${this.required?V`<span class=\"required\" aria-hidden=\"true\">*</span>`:\"\"} </label> `:\"\"} <input id=\"input\" type=${this.type} name=${this.name} .value=${Dt(this.value)} placeholder=${this.placeholder} ?required=${this.required} ?disabled=${this.disabled} ?readonly=${this.readonly} minlength=${this.minlength??\"\"} maxlength=${this.maxlength??\"\"} pattern=${this.pattern??\"\"} autocomplete=${this.autocomplete} @input=${this._handleInput} @change=${this._handleChange} @blur=${this._handleBlur} /> ${t?V`<div class=\"validation-message\">${t}</div>`:this.hint?V`<div class=\"hint\">${this.hint}</div>`:\"\"} </div> `}focus(){this._input?.focus()}blur(){this._input?.blur()}select(){this._input?.select()}}"
|
|
456
456
|
}
|
|
457
457
|
],
|
|
458
458
|
"exports": [
|
|
459
459
|
{
|
|
460
460
|
"kind": "custom-element-definition",
|
|
461
|
-
"name": "
|
|
461
|
+
"name": "t",
|
|
462
462
|
"declaration": {
|
|
463
|
-
"name": "
|
|
463
|
+
"name": "e",
|
|
464
464
|
"module": "dist/krubble.bundled.min.js"
|
|
465
465
|
}
|
|
466
466
|
},
|
|
467
467
|
{
|
|
468
468
|
"kind": "custom-element-definition",
|
|
469
|
-
"name": "
|
|
469
|
+
"name": "t",
|
|
470
470
|
"declaration": {
|
|
471
|
-
"name": "
|
|
471
|
+
"name": "e",
|
|
472
472
|
"module": "dist/krubble.bundled.min.js"
|
|
473
473
|
}
|
|
474
474
|
},
|
|
@@ -476,7 +476,7 @@
|
|
|
476
476
|
"kind": "js",
|
|
477
477
|
"name": "DialogRef",
|
|
478
478
|
"declaration": {
|
|
479
|
-
"name": "
|
|
479
|
+
"name": "Rt",
|
|
480
480
|
"module": "dist/krubble.bundled.min.js"
|
|
481
481
|
}
|
|
482
482
|
},
|
|
@@ -484,7 +484,7 @@
|
|
|
484
484
|
"kind": "js",
|
|
485
485
|
"name": "KRAccordion",
|
|
486
486
|
"declaration": {
|
|
487
|
-
"name": "
|
|
487
|
+
"name": "ft",
|
|
488
488
|
"module": "dist/krubble.bundled.min.js"
|
|
489
489
|
}
|
|
490
490
|
},
|
|
@@ -492,7 +492,7 @@
|
|
|
492
492
|
"kind": "js",
|
|
493
493
|
"name": "KRAlert",
|
|
494
494
|
"declaration": {
|
|
495
|
-
"name": "
|
|
495
|
+
"name": "kt",
|
|
496
496
|
"module": "dist/krubble.bundled.min.js"
|
|
497
497
|
}
|
|
498
498
|
},
|
|
@@ -500,7 +500,7 @@
|
|
|
500
500
|
"kind": "js",
|
|
501
501
|
"name": "KRButton",
|
|
502
502
|
"declaration": {
|
|
503
|
-
"name": "
|
|
503
|
+
"name": "At",
|
|
504
504
|
"module": "dist/krubble.bundled.min.js"
|
|
505
505
|
}
|
|
506
506
|
},
|
|
@@ -508,7 +508,7 @@
|
|
|
508
508
|
"kind": "js",
|
|
509
509
|
"name": "KRCodeDemo",
|
|
510
510
|
"declaration": {
|
|
511
|
-
"name": "
|
|
511
|
+
"name": "Pt",
|
|
512
512
|
"module": "dist/krubble.bundled.min.js"
|
|
513
513
|
}
|
|
514
514
|
},
|
|
@@ -516,7 +516,7 @@
|
|
|
516
516
|
"kind": "js",
|
|
517
517
|
"name": "KRContextMenu",
|
|
518
518
|
"declaration": {
|
|
519
|
-
"name": "
|
|
519
|
+
"name": "Ot",
|
|
520
520
|
"module": "dist/krubble.bundled.min.js"
|
|
521
521
|
}
|
|
522
522
|
},
|
|
@@ -524,7 +524,7 @@
|
|
|
524
524
|
"kind": "js",
|
|
525
525
|
"name": "KRDialog",
|
|
526
526
|
"declaration": {
|
|
527
|
-
"name": "
|
|
527
|
+
"name": "zt",
|
|
528
528
|
"module": "dist/krubble.bundled.min.js"
|
|
529
529
|
}
|
|
530
530
|
},
|
|
@@ -532,7 +532,7 @@
|
|
|
532
532
|
"kind": "js",
|
|
533
533
|
"name": "KRSnackbar",
|
|
534
534
|
"declaration": {
|
|
535
|
-
"name": "
|
|
535
|
+
"name": "jt",
|
|
536
536
|
"module": "dist/krubble.bundled.min.js"
|
|
537
537
|
}
|
|
538
538
|
},
|
|
@@ -540,7 +540,7 @@
|
|
|
540
540
|
"kind": "js",
|
|
541
541
|
"name": "KRTextField",
|
|
542
542
|
"declaration": {
|
|
543
|
-
"name": "
|
|
543
|
+
"name": "Bt",
|
|
544
544
|
"module": "dist/krubble.bundled.min.js"
|
|
545
545
|
}
|
|
546
546
|
}
|
|
@@ -641,28 +641,28 @@
|
|
|
641
641
|
"declarations": [
|
|
642
642
|
{
|
|
643
643
|
"kind": "variable",
|
|
644
|
-
"name": "
|
|
644
|
+
"name": "e",
|
|
645
645
|
"default": "globalThis"
|
|
646
646
|
},
|
|
647
647
|
{
|
|
648
648
|
"kind": "variable",
|
|
649
|
-
"name": "
|
|
649
|
+
"name": "t"
|
|
650
650
|
}
|
|
651
651
|
],
|
|
652
652
|
"exports": [
|
|
653
653
|
{
|
|
654
654
|
"kind": "custom-element-definition",
|
|
655
|
-
"name": "
|
|
655
|
+
"name": "t",
|
|
656
656
|
"declaration": {
|
|
657
|
-
"name": "
|
|
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": "
|
|
663
|
+
"name": "t",
|
|
664
664
|
"declaration": {
|
|
665
|
-
"name": "
|
|
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
|
|
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": "'
|
|
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
|
|
1229
|
-
"attribute": "
|
|
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": "'
|
|
1350
|
+
"text": "'flat' | 'outline'"
|
|
1263
1351
|
},
|
|
1264
|
-
"default": "'
|
|
1265
|
-
"description": "The button variant
|
|
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": {
|
|
@@ -1820,23 +1917,15 @@
|
|
|
1820
1917
|
}
|
|
1821
1918
|
},
|
|
1822
1919
|
"parameters": [
|
|
1823
|
-
{
|
|
1824
|
-
"name": "message",
|
|
1825
|
-
"type": {
|
|
1826
|
-
"text": "string"
|
|
1827
|
-
},
|
|
1828
|
-
"description": "The message to display"
|
|
1829
|
-
},
|
|
1830
1920
|
{
|
|
1831
1921
|
"name": "options",
|
|
1832
|
-
"optional": true,
|
|
1833
1922
|
"type": {
|
|
1834
1923
|
"text": "KRSnackbarOptions"
|
|
1835
1924
|
},
|
|
1836
|
-
"description": "
|
|
1925
|
+
"description": "Configuration including message, optional title, type, and duration"
|
|
1837
1926
|
}
|
|
1838
1927
|
],
|
|
1839
|
-
"description": "Show a snackbar with the given
|
|
1928
|
+
"description": "Show a snackbar with the given options."
|
|
1840
1929
|
},
|
|
1841
1930
|
{
|
|
1842
1931
|
"kind": "field",
|
|
@@ -1857,6 +1946,16 @@
|
|
|
1857
1946
|
"description": "The snackbar type/severity. Controls the color scheme and icon.",
|
|
1858
1947
|
"attribute": "type"
|
|
1859
1948
|
},
|
|
1949
|
+
{
|
|
1950
|
+
"kind": "field",
|
|
1951
|
+
"name": "title",
|
|
1952
|
+
"type": {
|
|
1953
|
+
"text": "string"
|
|
1954
|
+
},
|
|
1955
|
+
"default": "''",
|
|
1956
|
+
"description": "Optional title to display above the message.",
|
|
1957
|
+
"attribute": "title"
|
|
1958
|
+
},
|
|
1860
1959
|
{
|
|
1861
1960
|
"kind": "field",
|
|
1862
1961
|
"name": "message",
|
|
@@ -1907,6 +2006,15 @@
|
|
|
1907
2006
|
"description": "The snackbar type/severity. Controls the color scheme and icon.",
|
|
1908
2007
|
"fieldName": "type"
|
|
1909
2008
|
},
|
|
2009
|
+
{
|
|
2010
|
+
"name": "title",
|
|
2011
|
+
"type": {
|
|
2012
|
+
"text": "string"
|
|
2013
|
+
},
|
|
2014
|
+
"default": "''",
|
|
2015
|
+
"description": "Optional title to display above the message.",
|
|
2016
|
+
"fieldName": "title"
|
|
2017
|
+
},
|
|
1910
2018
|
{
|
|
1911
2019
|
"name": "message",
|
|
1912
2020
|
"type": {
|
package/dist/button/button.d.ts
CHANGED
|
@@ -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
|
|
11
|
+
* The button variant (shape)
|
|
13
12
|
*/
|
|
14
|
-
variant: '
|
|
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
|
|
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"}
|