@kodaris/krubble-components 1.0.7 → 1.0.8
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 +14 -14
- package/dist/krubble.bundled.js +2 -2
- package/dist/krubble.bundled.js.map +1 -1
- package/dist/krubble.bundled.min.js +2 -2
- package/dist/krubble.bundled.min.js.map +1 -1
- package/dist/krubble.umd.js +2 -2
- package/dist/krubble.umd.js.map +1 -1
- package/dist/krubble.umd.min.js +2 -2
- package/dist/krubble.umd.min.js.map +1 -1
- package/dist/tabs/tabs.js +2 -2
- package/package.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -928,44 +928,44 @@
|
|
|
928
928
|
},
|
|
929
929
|
{
|
|
930
930
|
"kind": "javascript-module",
|
|
931
|
-
"path": "dist/
|
|
931
|
+
"path": "dist/code-demo/code-demo.js",
|
|
932
932
|
"declarations": [
|
|
933
933
|
{
|
|
934
934
|
"kind": "variable",
|
|
935
|
-
"name": "
|
|
936
|
-
"default": "class
|
|
937
|
-
"description": "
|
|
935
|
+
"name": "KRCodeDemo",
|
|
936
|
+
"default": "class KRCodeDemo extends LitElement { constructor() { super(...arguments); this.language = 'html'; this.code = ''; this.activeTab = 'preview'; this.copied = false; } setTab(tab) { this.activeTab = tab; } getHighlightedCode() { if (!this.code) return ''; if (window.Prism && window.Prism.languages[this.language]) { return window.Prism.highlight(this.code, window.Prism.languages[this.language], this.language); } // Fallback: escape HTML and return plain text return this.escapeHtml(this.code); } escapeHtml(text) { const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } async copyCode() { if (!this.code) return; try { await navigator.clipboard.writeText(this.code); this.copied = true; setTimeout(() => { this.copied = false; }, 2000); } catch (err) { console.error('Failed to copy code:', err); } } render() { return html ` <div class=\"tabs\"> <button class=${classMap({ tab: true, 'tab--active': this.activeTab === 'preview' })} @click=${() => this.setTab('preview')} > Preview </button> <button class=${classMap({ tab: true, 'tab--active': this.activeTab === 'code' })} @click=${() => this.setTab('code')} > Code </button> </div> <div class=${classMap({ panel: true, 'panel--active': this.activeTab === 'preview', preview: true })}> <slot name=\"preview\"></slot> </div> <div class=${classMap({ panel: true, 'panel--active': this.activeTab === 'code', 'code-container': true })}> <button class=${classMap({ 'copy-btn': true, 'copy-btn--copied': this.copied })} @click=${this.copyCode} > ${this.copied ? 'Copied!' : 'Copy'} </button> <pre class=\"code\"><code>${unsafeHTML(this.getHighlightedCode())}</code></pre> </div> `; } }",
|
|
937
|
+
"description": "Code demo component with Preview/Code tabs and syntax highlighting.\n\nUsage:\n```html\n<kr-code-demo language=\"html\">\n <div slot=\"preview\">\n <kr-button>Click me</kr-button>\n </div>\n <script slot=\"code\" type=\"text/plain\">\n <kr-button>Click me</kr-button>\n </script>\n</kr-code-demo>\n```\n\nRequires Prism.js to be loaded globally for syntax highlighting."
|
|
938
938
|
}
|
|
939
939
|
],
|
|
940
940
|
"exports": [
|
|
941
941
|
{
|
|
942
942
|
"kind": "js",
|
|
943
|
-
"name": "
|
|
943
|
+
"name": "KRCodeDemo",
|
|
944
944
|
"declaration": {
|
|
945
|
-
"name": "
|
|
946
|
-
"module": "dist/
|
|
945
|
+
"name": "KRCodeDemo",
|
|
946
|
+
"module": "dist/code-demo/code-demo.js"
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
949
|
]
|
|
950
950
|
},
|
|
951
951
|
{
|
|
952
952
|
"kind": "javascript-module",
|
|
953
|
-
"path": "dist/
|
|
953
|
+
"path": "dist/button/button.js",
|
|
954
954
|
"declarations": [
|
|
955
955
|
{
|
|
956
956
|
"kind": "variable",
|
|
957
|
-
"name": "
|
|
958
|
-
"default": "class
|
|
959
|
-
"description": "
|
|
957
|
+
"name": "KRButton",
|
|
958
|
+
"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>` : ''} `; } }",
|
|
959
|
+
"description": "A customizable button component."
|
|
960
960
|
}
|
|
961
961
|
],
|
|
962
962
|
"exports": [
|
|
963
963
|
{
|
|
964
964
|
"kind": "js",
|
|
965
|
-
"name": "
|
|
965
|
+
"name": "KRButton",
|
|
966
966
|
"declaration": {
|
|
967
|
-
"name": "
|
|
968
|
-
"module": "dist/
|
|
967
|
+
"name": "KRButton",
|
|
968
|
+
"module": "dist/button/button.js"
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
]
|
package/dist/krubble.bundled.js
CHANGED
|
@@ -1812,7 +1812,7 @@ KRTabGroup.styles = [
|
|
|
1812
1812
|
padding: 12px 16px;
|
|
1813
1813
|
font-family: inherit;
|
|
1814
1814
|
font-size: 14px;
|
|
1815
|
-
font-weight:
|
|
1815
|
+
font-weight: 400;
|
|
1816
1816
|
color: var(--kr-text-muted);
|
|
1817
1817
|
background: none;
|
|
1818
1818
|
border: none;
|
|
@@ -1847,7 +1847,7 @@ KRTabGroup.styles = [
|
|
|
1847
1847
|
}
|
|
1848
1848
|
|
|
1849
1849
|
:host([size="small"]) .label {
|
|
1850
|
-
padding: 8px
|
|
1850
|
+
padding: 8px 16px;
|
|
1851
1851
|
font-size: 13px;
|
|
1852
1852
|
gap: 6px;
|
|
1853
1853
|
}
|