@dile/ui 2.20.0 → 2.20.1

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.
@@ -33,27 +33,32 @@ export class DileCopyMarkdownUrl extends LitElement {
33
33
  .feedbackText="${this.feedbackText}"
34
34
  .copiedDuration="${this.copiedDuration}"
35
35
  ?hideIcon="${this.hideIcon}"
36
- @click="${this.handleClick}"
37
36
  >
38
37
  <slot></slot>
39
38
  </dile-copy-text>
40
39
  `;
41
40
  }
42
41
 
43
- async handleClick(e) {
44
- if (this.loading) {
45
- e.preventDefault();
46
- return;
47
- }
42
+ connectedCallback() {
43
+ super.connectedCallback();
44
+ // Listen in capture phase to intercept click before dile-copy-text handles it
45
+ this.addEventListener('click', (e) => this.handleClickCapture(e), true);
46
+ }
48
47
 
48
+ async handleClickCapture(e) {
49
+ // If no content yet and URL is set, fetch before letting dile-copy-text handle the copy
49
50
  if (!this.content && this.url) {
50
51
  e.preventDefault();
52
+ e.stopPropagation();
53
+
51
54
  await this.fetchContent();
52
55
 
53
- // After fetching, trigger copy on the component using its public API
54
- const copyComponent = this.shadowRoot.querySelector('#copy-component');
55
- if (copyComponent && this.content) {
56
- await copyComponent.copy();
56
+ // Only trigger copy if fetch was successful
57
+ if (this.content && !this.error) {
58
+ const copyComponent = this.shadowRoot.querySelector('#copy-component');
59
+ if (copyComponent) {
60
+ await copyComponent.copy();
61
+ }
57
62
  }
58
63
  }
59
64
  }
@@ -61,13 +66,7 @@ export class DileCopyMarkdownUrl extends LitElement {
61
66
  async fetchContent() {
62
67
  if (!this.url) {
63
68
  this.error = 'URL is not set';
64
- this.dispatchEvent(
65
- new CustomEvent('dile-copy-markdown-url-error', {
66
- detail: { message: this.error },
67
- bubbles: true,
68
- composed: true
69
- })
70
- );
69
+ this.dispatchError(this.error);
71
70
  return;
72
71
  }
73
72
 
@@ -84,16 +83,19 @@ export class DileCopyMarkdownUrl extends LitElement {
84
83
  this.content = await response.text();
85
84
  } catch (err) {
86
85
  this.error = err.message || 'Error fetching content';
87
-
88
- this.dispatchEvent(
89
- new CustomEvent('dile-copy-markdown-url-error', {
90
- detail: { message: this.error },
91
- bubbles: true,
92
- composed: true
93
- })
94
- );
86
+ this.dispatchError(this.error);
95
87
  } finally {
96
88
  this.loading = false;
97
89
  }
98
90
  }
91
+
92
+ dispatchError(message) {
93
+ this.dispatchEvent(
94
+ new CustomEvent('dile-copy-markdown-url-error', {
95
+ detail: { message },
96
+ bubbles: true,
97
+ composed: true
98
+ })
99
+ );
100
+ }
99
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.20.0",
3
+ "version": "2.20.1",
4
4
  "description": "UI Core components from dile-components.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "cd0b6acfaed41004ccd714f0ad586bc66b303479"
29
+ "gitHead": "7194ae653716358e673eb70383662cfb86247260"
30
30
  }