@kodaris/krubble-components 1.0.22 → 1.0.23
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/package.json +5 -1
package/custom-elements.json
CHANGED
|
@@ -1075,44 +1075,44 @@
|
|
|
1075
1075
|
},
|
|
1076
1076
|
{
|
|
1077
1077
|
"kind": "javascript-module",
|
|
1078
|
-
"path": "dist/
|
|
1078
|
+
"path": "dist/code-demo/code-demo.js",
|
|
1079
1079
|
"declarations": [
|
|
1080
1080
|
{
|
|
1081
1081
|
"kind": "variable",
|
|
1082
|
-
"name": "
|
|
1083
|
-
"default": "class
|
|
1084
|
-
"description": "
|
|
1082
|
+
"name": "KRCodeDemo",
|
|
1083
|
+
"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> `; } }",
|
|
1084
|
+
"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."
|
|
1085
1085
|
}
|
|
1086
1086
|
],
|
|
1087
1087
|
"exports": [
|
|
1088
1088
|
{
|
|
1089
1089
|
"kind": "js",
|
|
1090
|
-
"name": "
|
|
1090
|
+
"name": "KRCodeDemo",
|
|
1091
1091
|
"declaration": {
|
|
1092
|
-
"name": "
|
|
1093
|
-
"module": "dist/
|
|
1092
|
+
"name": "KRCodeDemo",
|
|
1093
|
+
"module": "dist/code-demo/code-demo.js"
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
]
|
|
1097
1097
|
},
|
|
1098
1098
|
{
|
|
1099
1099
|
"kind": "javascript-module",
|
|
1100
|
-
"path": "dist/
|
|
1100
|
+
"path": "dist/context-menu/context-menu.js",
|
|
1101
1101
|
"declarations": [
|
|
1102
1102
|
{
|
|
1103
1103
|
"kind": "variable",
|
|
1104
|
-
"name": "
|
|
1105
|
-
"default": "class
|
|
1106
|
-
"description": "
|
|
1104
|
+
"name": "KRContextMenu",
|
|
1105
|
+
"default": "class KRContextMenu extends LitElement { constructor() { super(...arguments); this.items = []; this.resolvePromise = null; this.boundHandleOutsideClick = this.handleOutsideClick.bind(this); this.boundHandleKeyDown = this.handleKeyDown.bind(this); } static async open(options) { // Remove any existing context menu const existing = document.querySelector('kr-context-menu'); if (existing) { existing.remove(); } // Create and position the menu const menu = document.createElement('kr-context-menu'); document.body.appendChild(menu); return menu.show(options); } async show(options) { this.items = options.items; this.style.left = `${options.x}px`; this.style.top = `${options.y}px`; // Adjust position if menu would go off screen await this.updateComplete; const rect = this.getBoundingClientRect(); if (rect.right > window.innerWidth) { this.style.left = `${options.x - rect.width}px`; } if (rect.bottom > window.innerHeight) { this.style.top = `${options.y - rect.height}px`; } // Add event listeners after a microtask to avoid the current event triggering close requestAnimationFrame(() => { document.addEventListener('click', this.boundHandleOutsideClick); document.addEventListener('contextmenu', this.boundHandleOutsideClick); document.addEventListener('keydown', this.boundHandleKeyDown); }); return new Promise((resolve) => { this.resolvePromise = resolve; }); } handleOutsideClick(e) { if (!this.contains(e.target)) { this.close(null); } } handleKeyDown(e) { if (e.key === 'Escape') { this.close(null); } } handleItemClick(item) { if (!item.disabled && !item.divider) { this.close(item); } } close(result) { document.removeEventListener('click', this.boundHandleOutsideClick); document.removeEventListener('contextmenu', this.boundHandleOutsideClick); document.removeEventListener('keydown', this.boundHandleKeyDown); if (this.resolvePromise) { this.resolvePromise(result); this.resolvePromise = null; } this.remove(); } render() { return html ` <div class=\"menu\"> ${this.items.map(item => item.divider ? html `<div class=\"menu__divider\"></div>` : html ` <button class=\"menu__item\" ?disabled=${item.disabled} @click=${() => this.handleItemClick(item)} > ${item.icon ? html `<span class=\"menu__item-icon\">${item.icon}</span>` : null} ${item.label} </button> `)} </div> `; } }",
|
|
1106
|
+
"description": "Context menu component that can be opened programmatically.\n\nUsage:\n```ts\nconst result = await ContextMenu.open({\n x: event.clientX,\n y: event.clientY,\n items: [\n { id: 'edit', label: 'Edit Item' },\n { id: 'divider', label: '', divider: true },\n { id: 'add-above', label: 'Add Item Above' },\n { id: 'add-below', label: 'Add Item Below' },\n ]\n});\n\nif (result) {\n console.log('Selected:', result.id);\n}\n```"
|
|
1107
1107
|
}
|
|
1108
1108
|
],
|
|
1109
1109
|
"exports": [
|
|
1110
1110
|
{
|
|
1111
1111
|
"kind": "js",
|
|
1112
|
-
"name": "
|
|
1112
|
+
"name": "KRContextMenu",
|
|
1113
1113
|
"declaration": {
|
|
1114
|
-
"name": "
|
|
1115
|
-
"module": "dist/
|
|
1114
|
+
"name": "KRContextMenu",
|
|
1115
|
+
"module": "dist/context-menu/context-menu.js"
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
1118
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kodaris/krubble-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "Krubble Lit Web Components Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -69,6 +69,10 @@
|
|
|
69
69
|
"./select-option": {
|
|
70
70
|
"types": "./dist/form/select-option.d.ts",
|
|
71
71
|
"import": "./dist/form/select-option.js"
|
|
72
|
+
},
|
|
73
|
+
"./form/detail-field": {
|
|
74
|
+
"types": "./dist/form/detail-field/detail-field.d.ts",
|
|
75
|
+
"import": "./dist/form/detail-field/detail-field.js"
|
|
72
76
|
}
|
|
73
77
|
},
|
|
74
78
|
"files": [
|