@colletdev/core 0.1.8 → 0.1.9

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.
@@ -5205,12 +5205,12 @@
5205
5205
  "fieldName": "id"
5206
5206
  },
5207
5207
  {
5208
- "name": "role",
5208
+ "name": "text-role",
5209
5209
  "type": {
5210
5210
  "text": "'display' | 'h1' | 'h2' | 'h3' | 'label-lg' | 'label-md' | 'label-sm' | 'body-lg' | 'body-md' | 'body-sm' | 'overline' | 'caption' | 'code'"
5211
5211
  },
5212
5212
  "default": "\"\"",
5213
- "fieldName": "role"
5213
+ "fieldName": "text_role"
5214
5214
  },
5215
5215
  {
5216
5216
  "name": "align",
@@ -23,7 +23,7 @@
23
23
  import { initWasm, loadSharedStyles, loadInlineSharedStyles, loadMotionStyles, loadInlineMotionStyles, injectTokensToHead, injectFoucPrevention, CxElement, CxFormElement } from '../src/runtime.js';
24
24
 
25
25
  // Package version — used for CDN fallback URL
26
- const PKG_VERSION = '0.1.7';
26
+ const PKG_VERSION = '0.1.8';
27
27
 
28
28
  // ─── Lazy WASM + CSS ───
29
29
  // WASM glue and CSS strings are NOT imported at module level.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colletdev/core",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Rust/WASM Custom Elements — 48 production-grade UI components",
5
5
  "type": "module",
6
6
  "main": "generated/index.js",
@@ -1,4 +1,9 @@
1
- // Auto-generated by scripts/generate-elements.mjsDO NOT EDIT
1
+ // Custom behavior for <cx-code-block>copy-to-clipboard with visual feedback.
2
+ //
3
+ // The Rust component renders a [data-copy-code] button in the titlebar
4
+ // (Standard variant) or as a group-hover overlay (Minimal variant).
5
+ // This Custom Element adds clipboard write + icon swap on click.
6
+ //
2
7
  // Source: crates/wasm-api/src/code_block.rs
3
8
 
4
9
  export function defineCxCodeBlock(wasmFn, baseClass) {
@@ -7,8 +12,33 @@ export function defineCxCodeBlock(wasmFn, baseClass) {
7
12
  static _booleanAttrs = new Set(['line-numbers', 'copy-button', 'traffic-lights', 'slotted']);
8
13
  static _hostDisplay = 'block';
9
14
 
10
-
11
15
  connectedCallback() {
16
+ if (!this._isInitialized) {
17
+ this._markInitialized();
18
+
19
+ // Copy button click → clipboard write → icon swap feedback.
20
+ this._shadow.addEventListener('click', (e) => {
21
+ const copyBtn = e.target.closest('[data-copy-code]');
22
+ if (!copyBtn) return;
23
+
24
+ const codeEl = this._shadow.querySelector('[data-code-content]');
25
+ if (!codeEl) return;
26
+
27
+ const text = codeEl.textContent || '';
28
+ navigator.clipboard.writeText(text).then(() => {
29
+ const iconSpan = copyBtn.querySelector('span');
30
+ if (!iconSpan) return;
31
+ const original = iconSpan.innerHTML;
32
+ iconSpan.innerHTML = '<svg class="size-full" aria-hidden="true"><use href="#icon-check"></use></svg>';
33
+ copyBtn.setAttribute('aria-label', 'Copied!');
34
+ setTimeout(() => {
35
+ iconSpan.innerHTML = original;
36
+ copyBtn.setAttribute('aria-label', 'Copy code');
37
+ }, 2000);
38
+ });
39
+ });
40
+ } // end _isInitialized guard
41
+
12
42
  super.connectedCallback();
13
43
  }
14
44
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  export interface CxTextAttributes {
5
5
  id?: string;
6
- role?: 'display' | 'h1' | 'h2' | 'h3' | 'label-lg' | 'label-md' | 'label-sm' | 'body-lg' | 'body-md' | 'body-sm' | 'overline' | 'caption' | 'code';
6
+ textRole?: 'display' | 'h1' | 'h2' | 'h3' | 'label-lg' | 'label-md' | 'label-sm' | 'body-lg' | 'body-md' | 'body-sm' | 'overline' | 'caption' | 'code';
7
7
  content?: string;
8
8
  align?: 'start' | 'center' | 'end';
9
9
  color?: 'primary' | 'inverse' | 'muted';
@@ -3,7 +3,7 @@
3
3
 
4
4
  export function defineCxText(wasmFn, baseClass) {
5
5
  class CxText extends baseClass {
6
- static observedAttributes = ['id', 'role', 'align', 'color', 'muted', 'strong', 'italic', 'underline', 'underline-strong', 'truncate', 'line-clamp', 'balance', 'prose', 'element-as'];
6
+ static observedAttributes = ['id', 'text-role', 'align', 'color', 'muted', 'strong', 'italic', 'underline', 'underline-strong', 'truncate', 'line-clamp', 'balance', 'prose', 'element-as'];
7
7
  static _booleanAttrs = new Set(['muted', 'strong', 'italic', 'underline', 'underline-strong', 'truncate', 'balance', 'prose']);
8
8
  static _numericAttrs = new Set(['line-clamp']);
9
9
  static _focusable = false;
Binary file