@aquera/nile-elements 0.0.5-3 → 0.0.5-4

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent nile-elements following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "nile-elements",
6
- "version": "0.0.5-3",
6
+ "version": "0.0.5-4",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -25,7 +25,7 @@ export const styles = css`
25
25
  gap: 8px;
26
26
  height: 38px;
27
27
  box-sizing: border-box;
28
- cursor: pointer
28
+ cursor: pointer;
29
29
  }
30
30
 
31
31
  .link__label {
@@ -43,7 +43,7 @@ export const styles = css`
43
43
  color: rgba(0, 94, 166, 0.5);
44
44
  cursor: not-allowed;
45
45
  opacity: 0.6;
46
- pointer-events:none;
46
+ pointer-events: none;
47
47
  }
48
48
 
49
49
  :host(.link--disabled) {
@@ -71,6 +71,10 @@ export const styles = css`
71
71
  border-radius: 4px;
72
72
  background: rgba(0, 94, 166, 0.1);
73
73
  }
74
+
75
+ :host([disabled]) {
76
+ pointer-events: none;
77
+ }
74
78
  `;
75
79
 
76
80
  export default [styles];
@@ -22,16 +22,20 @@ import { watch } from '../internal/watch';
22
22
  */
23
23
  @customElement('nile-link')
24
24
  export class NileLink extends NileElement {
25
+ /**
26
+ * The styles for Link
27
+ * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
28
+ */
29
+ public static get styles(): CSSResultArray {
30
+ return [styles];
31
+ }
25
32
 
26
- /**
27
- * The styles for Link
28
- * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
29
- */
30
- public static get styles(): CSSResultArray {
31
- return [styles];
32
- }
33
-
34
- private readonly hasSlotController = new HasSlotController(this, '[default]', 'prefix', 'suffix');
33
+ private readonly hasSlotController = new HasSlotController(
34
+ this,
35
+ '[default]',
36
+ 'prefix',
37
+ 'suffix'
38
+ );
35
39
 
36
40
  @state() private hasFocus = false;
37
41
 
@@ -40,6 +44,25 @@ export class NileLink extends NileElement {
40
44
 
41
45
  @property({ type: Boolean }) button = false;
42
46
 
47
+ connectedCallback() {
48
+ super.connectedCallback();
49
+ this.handleHostClick = this.handleHostClick.bind(this);
50
+ this.addEventListener('click', this.handleHostClick);
51
+ }
52
+
53
+ disconnectedCallback() {
54
+ super.disconnectedCallback();
55
+ this.removeEventListener('click', this.handleHostClick);
56
+ }
57
+
58
+ private handleHostClick(event: MouseEvent) {
59
+ // Prevent the click event from being emitted when the button is disabled
60
+ if (this.disabled) {
61
+ event.preventDefault();
62
+ event.stopImmediatePropagation();
63
+ event.stopPropagation();
64
+ }
65
+ }
43
66
 
44
67
  private handleBlur() {
45
68
  this.hasFocus = false;
@@ -51,21 +74,24 @@ export class NileLink extends NileElement {
51
74
  this.emit('nile-focus');
52
75
  }
53
76
 
54
- /**
55
- * Render method
56
- * @slot This is a slot test
57
- */
58
- public render(): TemplateResult {
77
+ /**
78
+ * Render method
79
+ * @slot This is a slot test
80
+ */
81
+ public render(): TemplateResult {
59
82
  return html`
60
83
  <div
61
84
  part="base"
62
85
  class=${classMap({
63
86
  link: true,
64
87
  'link--disabled': this.disabled,
65
- 'link__button': this.button
88
+ link__button: this.button,
66
89
  })}
67
90
  ?disabled=${ifDefined(this.disabled)}
68
- title=${this.title /* An empty title prevents browser validation tooltips from appearing on hover */}
91
+ title=${
92
+ this
93
+ .title /* An empty title prevents browser validation tooltips from appearing on hover */
94
+ }
69
95
  aria-disabled=${this.disabled ? 'true' : 'false'}
70
96
  tabindex=${this.disabled ? '-1' : '0'}
71
97
  @blur=${this.handleBlur}
@@ -78,8 +104,7 @@ export class NileLink extends NileElement {
78
104
  `;
79
105
  }
80
106
 
81
-
82
- /* #endregion */
107
+ /* #endregion */
83
108
  }
84
109
 
85
110
  export default NileLink;