blue-web 1.11.0 → 1.11.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.
@@ -1 +1 @@
1
- (()=>{"use strict";class t extends HTMLElement{startX=0;startY=0;constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.render()}render(){this.shadowRoot&&(this.shadowRoot.innerHTML='\n <style>\n button {\n display: block;\n margin: 0;\n padding: 0;\n appearance: none;\n background-color: transparent;\n border: none;\n line-height: 1;\n outline: 0;\n }\n\n button:focus-visible + div {\n outline: 0;\n box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 25%);\n border-color: rgba(var(--bs-primary-rgb), 50%);\n }\n\n div {\n display: inline-block;\n box-sizing: border-box;\n width: auto;\n max-width: 100%;\n border-color: transparent;\n border-radius: var(--bs-border-radius-sm, 3px);\n border: 1px solid transparent;\n transition: background 0.2s;\n }\n\n div:hover {\n background-color: var(--bs-secondary-bg-subtle);\n }\n </style>\n <button aria-label="Edit"></button>\n <div role="presentation">\n <slot></slot>\n </div>\n ',this.button=this.shadowRoot.querySelector("button"),this.container=this.shadowRoot.querySelector("div"),this.button.addEventListener("click",this.onEditRequested.bind(this)),this.container.addEventListener("click",this.onReadViewClick.bind(this)),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)))}onEditRequested(){this.dispatchEvent(new CustomEvent("EditRequested",{bubbles:!0,composed:!0}))}onMouseDown(t){this.startX=t.clientX,this.startY=t.clientY}mouseHasMovedAfterMouseDown(t){return Math.abs(this.startX-t.clientX)>=5||Math.abs(this.startY-t.clientY)>=5}onReadViewClick(t){"a"===t.target.tagName.toLowerCase()||this.mouseHasMovedAfterMouseDown(t)||(t.preventDefault(),this.onEditRequested())}}customElements.define("read-view",t)})();
1
+ (()=>{"use strict";class t extends HTMLElement{startX=0;startY=0;constructor(){super(),this.attachShadow({mode:"open"})}static get observedAttributes(){return["disabled"]}connectedCallback(){this.render()}attributeChangedCallback(t,e,n){"disabled"===t&&this.updateDisabledState()}render(){this.shadowRoot&&(this.shadowRoot.innerHTML='\n <style>\n button {\n display: block;\n margin: 0;\n padding: 0;\n appearance: none;\n background-color: transparent;\n border: none;\n line-height: 1;\n outline: 0;\n }\n\n button:focus-visible + div {\n outline: 0;\n box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 25%);\n border-color: rgba(var(--bs-primary-rgb), 50%);\n }\n\n div {\n display: inline-block;\n box-sizing: border-box;\n width: auto;\n max-width: 100%;\n border-color: transparent;\n border-radius: var(--bs-border-radius-sm, 3px);\n border: 1px solid transparent;\n transition: background 0.2s;\n }\n\n div:hover {\n background-color: var(--bs-secondary-bg-subtle);\n }\n\n :host([disabled]) div {\n background-color: transparent;\n }\n </style>\n <button aria-label="Edit"></button>\n <div role="presentation">\n <slot></slot>\n </div>\n ',this.button=this.shadowRoot.querySelector("button"),this.container=this.shadowRoot.querySelector("div"),this.button.addEventListener("click",this.onEditRequested.bind(this)),this.container.addEventListener("click",this.onReadViewClick.bind(this)),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),this.updateDisabledState())}updateDisabledState(){const t=this.hasAttribute("disabled");this.button?.setAttribute("aria-disabled",String(t)),this.container?.setAttribute("aria-disabled",String(t))}onEditRequested(){this.hasAttribute("disabled")||this.dispatchEvent(new CustomEvent("EditRequested",{bubbles:!0,composed:!0}))}onMouseDown(t){this.hasAttribute("disabled")||(this.startX=t.clientX,this.startY=t.clientY)}mouseHasMovedAfterMouseDown(t){return Math.abs(this.startX-t.clientX)>=5||Math.abs(this.startY-t.clientY)>=5}onReadViewClick(t){this.hasAttribute("disabled")||"a"===t.target.tagName.toLowerCase()||this.mouseHasMovedAfterMouseDown(t)||(t.preventDefault(),this.onEditRequested())}}customElements.define("read-view",t)})();
@@ -3,6 +3,7 @@
3
3
  * Fires event "EditRequested" when the user clicks the read view.
4
4
  * @element read-view
5
5
  * @fires EditRequested
6
+ * @attr {boolean} disabled - Disables the component, preventing interactions and removing hover effects.
6
7
  * @cssprop --bs-primary-rgb - The primary color as an RGB value.
7
8
  * @cssprop --bs-secondary-bg-subtle - The subtle background color for the read view.
8
9
  * @cssprop --bs-border-radius-sm - The border radius for the read view.
@@ -22,8 +23,11 @@ export declare class ReadView extends HTMLElement {
22
23
  private startX;
23
24
  private startY;
24
25
  constructor();
26
+ static get observedAttributes(): string[];
25
27
  connectedCallback(): void;
28
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
26
29
  private render;
30
+ private updateDisabledState;
27
31
  private onEditRequested;
28
32
  private onMouseDown;
29
33
  private mouseHasMovedAfterMouseDown;
@@ -11,6 +11,7 @@ const DRAG_THRESHOLD = 5;
11
11
  * Fires event "EditRequested" when the user clicks the read view.
12
12
  * @element read-view
13
13
  * @fires EditRequested
14
+ * @attr {boolean} disabled - Disables the component, preventing interactions and removing hover effects.
14
15
  * @cssprop --bs-primary-rgb - The primary color as an RGB value.
15
16
  * @cssprop --bs-secondary-bg-subtle - The subtle background color for the read view.
16
17
  * @cssprop --bs-border-radius-sm - The border radius for the read view.
@@ -33,9 +34,17 @@ class ReadView extends HTMLElement {
33
34
  mode: "open"
34
35
  });
35
36
  }
37
+ static get observedAttributes() {
38
+ return ["disabled"];
39
+ }
36
40
  connectedCallback() {
37
41
  this.render();
38
42
  }
43
+ attributeChangedCallback(name, oldValue, newValue) {
44
+ if (name === "disabled") {
45
+ this.updateDisabledState();
46
+ }
47
+ }
39
48
  render() {
40
49
  if (!this.shadowRoot) return;
41
50
  this.shadowRoot.innerHTML = /* HTML */`
@@ -71,6 +80,10 @@ class ReadView extends HTMLElement {
71
80
  div:hover {
72
81
  background-color: var(--bs-secondary-bg-subtle);
73
82
  }
83
+
84
+ :host([disabled]) div {
85
+ background-color: transparent;
86
+ }
74
87
  </style>
75
88
  <button aria-label="Edit"></button>
76
89
  <div role="presentation">
@@ -82,14 +95,22 @@ class ReadView extends HTMLElement {
82
95
  this.button.addEventListener("click", this.onEditRequested.bind(this));
83
96
  this.container.addEventListener("click", this.onReadViewClick.bind(this));
84
97
  this.container.addEventListener("mousedown", this.onMouseDown.bind(this));
98
+ this.updateDisabledState();
99
+ }
100
+ updateDisabledState() {
101
+ const isDisabled = this.hasAttribute("disabled");
102
+ this.button?.setAttribute("aria-disabled", String(isDisabled));
103
+ this.container?.setAttribute("aria-disabled", String(isDisabled));
85
104
  }
86
105
  onEditRequested() {
106
+ if (this.hasAttribute("disabled")) return;
87
107
  this.dispatchEvent(new CustomEvent("EditRequested", {
88
108
  bubbles: true,
89
109
  composed: true
90
110
  }));
91
111
  }
92
112
  onMouseDown(event) {
113
+ if (this.hasAttribute("disabled")) return;
93
114
  this.startX = event.clientX;
94
115
  this.startY = event.clientY;
95
116
  }
@@ -97,6 +118,7 @@ class ReadView extends HTMLElement {
97
118
  return Math.abs(this.startX - event.clientX) >= DRAG_THRESHOLD || Math.abs(this.startY - event.clientY) >= DRAG_THRESHOLD;
98
119
  }
99
120
  onReadViewClick(event) {
121
+ if (this.hasAttribute("disabled")) return;
100
122
  const target = event.target;
101
123
  if (target.tagName.toLowerCase() !== "a" && !this.mouseHasMovedAfterMouseDown(event)) {
102
124
  event.preventDefault();