@waaelg/dga-design-system 0.4.3 → 0.4.5

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/dist/index.js CHANGED
@@ -1,49 +1,49 @@
1
1
  class d {
2
- constructor(e) {
3
- this.root = e, this.handleClick = this.handleClick.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.init();
2
+ constructor(t) {
3
+ this.root = t, this.handleClick = this.handleClick.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.init();
4
4
  }
5
5
  init() {
6
6
  this.root.addEventListener("click", this.handleClick), this.root.addEventListener("keydown", this.handleKeydown);
7
7
  }
8
- handleClick(e) {
9
- const t = e.target.closest(".dga-acc-header");
10
- t && this.root.contains(t) && this.toggle(t);
8
+ handleClick(t) {
9
+ const e = t.target.closest(".dga-acc-header");
10
+ e && this.root.contains(e) && this.toggle(e);
11
11
  }
12
- handleKeydown(e) {
13
- const t = e.target.closest(".dga-acc-header");
14
- !t || !this.root.contains(t) || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.toggle(t));
12
+ handleKeydown(t) {
13
+ const e = t.target.closest(".dga-acc-header");
14
+ !e || !this.root.contains(e) || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.toggle(e));
15
15
  }
16
- toggle(e) {
17
- const t = e.parentElement;
18
- t && (t.classList.contains("dga-acc-item--active") ? this.close(t) : this.open(t));
16
+ toggle(t) {
17
+ const e = t.parentElement;
18
+ e && (e.classList.contains("dga-acc-item--active") ? this.close(e) : this.open(e));
19
19
  }
20
- open(e) {
21
- e.classList.add("dga-acc-item--active"), e.querySelector(".dga-acc-header")?.setAttribute("aria-expanded", "true");
20
+ open(t) {
21
+ t.classList.add("dga-acc-item--active"), t.querySelector(".dga-acc-header")?.setAttribute("aria-expanded", "true");
22
22
  }
23
- close(e) {
24
- e.classList.remove("dga-acc-item--active"), e.querySelector(".dga-acc-header")?.setAttribute("aria-expanded", "false");
23
+ close(t) {
24
+ t.classList.remove("dga-acc-item--active"), t.querySelector(".dga-acc-header")?.setAttribute("aria-expanded", "false");
25
25
  }
26
26
  closeAll() {
27
- this.root.querySelectorAll(".dga-acc-item").forEach((e) => {
28
- this.close(e);
27
+ this.root.querySelectorAll(".dga-acc-item").forEach((t) => {
28
+ this.close(t);
29
29
  });
30
30
  }
31
31
  destroy() {
32
32
  this.root.removeEventListener("click", this.handleClick), this.root.removeEventListener("keydown", this.handleKeydown);
33
33
  }
34
34
  }
35
- class m {
36
- constructor(e) {
37
- this.accordion = e, this.controller = new d(e);
35
+ class w {
36
+ constructor(t) {
37
+ this.accordion = t, this.controller = new d(t);
38
38
  }
39
- toggle(e) {
40
- this.controller.toggle(e);
39
+ toggle(t) {
40
+ this.controller.toggle(t);
41
41
  }
42
- open(e) {
43
- this.controller.open(e);
42
+ open(t) {
43
+ this.controller.open(t);
44
44
  }
45
- close(e) {
46
- this.controller.close(e);
45
+ close(t) {
46
+ this.controller.close(t);
47
47
  }
48
48
  closeAll() {
49
49
  this.controller.closeAll();
@@ -52,101 +52,114 @@ class m {
52
52
  this.controller.destroy();
53
53
  }
54
54
  }
55
- class b {
56
- constructor(e = document) {
57
- this.root = e, this.handleCloseClick = this.handleCloseClick.bind(this), this.init();
55
+ class E {
56
+ constructor(t = document) {
57
+ this.root = t, this.handleCloseClick = this.handleCloseClick.bind(this), this.init();
58
58
  }
59
59
  init() {
60
60
  this.root.addEventListener("click", this.handleCloseClick);
61
61
  }
62
- handleCloseClick(e) {
63
- const t = e.target.closest("[data-alert-close]");
64
- if (!t)
62
+ handleCloseClick(t) {
63
+ const e = t.target.closest("[data-alert-close]");
64
+ if (!e)
65
65
  return;
66
- const i = t.closest(".dga-alert");
66
+ const i = e.closest(".dga-alert");
67
67
  i && (i.style.display = "none");
68
68
  }
69
69
  destroy() {
70
70
  this.root.removeEventListener("click", this.handleCloseClick);
71
71
  }
72
72
  }
73
- function a(s) {
73
+ function c(s) {
74
74
  return s.startsWith("#") || s.startsWith("var(") ? s : `var(--${s})`;
75
75
  }
76
- function r(s = []) {
76
+ function h(s = []) {
77
77
  return `conic-gradient(${s.map(
78
- (t) => `${a(t.color)} ${t.from} ${t.to}`
78
+ (e) => `${c(e.color)} ${e.from} ${e.to}`
79
79
  ).join(", ")})`;
80
80
  }
81
- function l(s = []) {
81
+ function u(s = []) {
82
82
  return `<div class="dga-pie-chart__labels">${s.map(
83
- (t) => `<span class="dga-pie-chart__label"><span class="dga-pie-chart__circle" style="background-color: ${a(
84
- t.color
85
- )}"></span>${t.label}</span>`
83
+ (e) => `<span class="dga-pie-chart__label"><span class="dga-pie-chart__circle" style="background-color: ${c(
84
+ e.color
85
+ )}"></span>${e.label}</span>`
86
86
  ).join("")}</div>`;
87
87
  }
88
- function h(s, e = [], { hole: t = !1 } = {}) {
89
- s && (s.classList.add("dga-pie-chart"), s.setAttribute("data-hole", t ? "true" : "false"), s.style.background = r(e), s.innerHTML = l(e));
88
+ function v(s) {
89
+ if (!s) return [];
90
+ try {
91
+ const t = JSON.parse(s);
92
+ return Array.isArray(t) ? t : [];
93
+ } catch {
94
+ return console.warn("dga-pie-chart: invalid data attribute JSON"), [];
95
+ }
96
+ }
97
+ function g(s, t = [], { hole: e = !1 } = {}) {
98
+ s && (s.classList.add("dga-pie-chart"), s.setAttribute("data-hole", e ? "true" : "false"), s.style.background = h(t), s.innerHTML = u(t));
90
99
  }
91
- class v {
92
- constructor(e, t = []) {
93
- this.chart = e, this.data = t, this.init();
100
+ class x {
101
+ constructor(t, e = []) {
102
+ this.chart = t, this.data = e, this.init();
94
103
  }
95
104
  init() {
96
- const e = this.chart.getAttribute("data-hole") === "true";
97
- h(this.chart, this.data, { hole: e });
105
+ const t = this.chart.getAttribute("data-hole") === "true";
106
+ g(this.chart, this.data, { hole: t });
98
107
  }
99
108
  generateGradient() {
100
- return r(this.data);
109
+ return h(this.data);
101
110
  }
102
111
  generateLabels() {
103
- return l(this.data);
112
+ return u(this.data);
104
113
  }
105
114
  }
106
- async function u(s) {
115
+ async function p(s) {
107
116
  try {
108
117
  if (navigator.clipboard?.writeText)
109
118
  return await navigator.clipboard.writeText(s), !0;
110
119
  } catch {
111
120
  }
112
- const e = document.createElement("textarea");
113
- e.value = s, e.setAttribute("readonly", ""), e.style.position = "absolute", e.style.left = "-9999px", document.body.appendChild(e), e.select();
114
- const t = document.execCommand("copy");
115
- return document.body.removeChild(e), t;
121
+ const t = document.createElement("textarea");
122
+ t.value = s, t.setAttribute("readonly", ""), t.style.position = "absolute", t.style.left = "-9999px", document.body.appendChild(t), t.select();
123
+ const e = document.execCommand("copy");
124
+ return document.body.removeChild(t), e;
116
125
  }
117
- async function p(s, e = 1200) {
118
- const t = s.getAttribute("aria-label") || "Copy code";
126
+ const l = `<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
127
+ <rect x="9" y="9" width="11" height="11" rx="2" stroke-width="1.75"></rect>
128
+ <path d="M6 15H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v1" stroke-width="1.75" stroke-linecap="round"></path>
129
+ </svg>`;
130
+ async function b(s, t = 1200) {
131
+ const e = s.getAttribute("aria-label") || "Copy code";
119
132
  s.setAttribute("aria-label", "Copied"), s.setAttribute("data-copied", "true"), window.setTimeout(() => {
120
- s.setAttribute("aria-label", t), s.setAttribute("data-copied", "false");
121
- }, e);
133
+ s.setAttribute("aria-label", e), s.setAttribute("data-copied", "false");
134
+ }, t);
122
135
  }
123
- class y {
124
- constructor(e = document) {
125
- this.root = e, this.handleCopyClick = this.handleCopyClick.bind(this), this.init();
136
+ class D {
137
+ constructor(t = document) {
138
+ this.root = t, this.handleCopyClick = this.handleCopyClick.bind(this), this.init();
126
139
  }
127
140
  init() {
128
141
  this.root.addEventListener("click", this.handleCopyClick);
129
142
  }
130
- async handleCopyClick(e) {
131
- const t = e.target.closest(
143
+ async handleCopyClick(t) {
144
+ const e = t.target.closest(
132
145
  ".dga-code-snippet-inline__copy, .dga-code-snippet-multiline__copy"
133
146
  );
134
- if (!t) return;
135
- const i = t.closest(".dga-code-snippet-inline"), n = t.closest(".dga-code-snippet-multiline");
136
- let o = "";
137
- i ? o = i.querySelector(
147
+ if (!e) return;
148
+ const i = e.closest(".dga-code-snippet-inline"), n = e.closest(".dga-code-snippet-multiline");
149
+ let a = "";
150
+ i ? a = i.querySelector(
138
151
  ".dga-code-snippet-inline__content"
139
- )?.textContent?.trim() || "" : n && (o = n.querySelector(
152
+ )?.textContent?.trim() || "" : n && (a = n.querySelector(
140
153
  ".dga-code-snippet-multiline__code code"
141
- )?.textContent || ""), !(!o || !await u(o)) && await p(t);
154
+ )?.textContent || ""), !(!a || !await p(a)) && await b(e);
142
155
  }
143
156
  destroy() {
144
157
  this.root.removeEventListener("click", this.handleCopyClick);
145
158
  }
146
159
  }
147
- class f {
148
- constructor(e = {}) {
149
- if (this.navbar = e.navbar || document.querySelector(".dga-navbar"), this.verifyBar = e.verifyBar || null, !this.navbar) {
160
+ class T {
161
+ constructor(t = {}) {
162
+ if (this.navbar = t.navbar || document.querySelector(".dga-navbar"), this.verifyBar = t.verifyBar || null, !this.navbar) {
150
163
  console.warn("DGA Navbar elements not found");
151
164
  return;
152
165
  }
@@ -154,7 +167,7 @@ class f {
154
167
  console.warn("DGA Menu element not found");
155
168
  return;
156
169
  }
157
- this.boundToggleDropdown = (t) => this.toggleDropdown(t), this.boundToggleMobileMenu = (t) => this.toggleMobileMenu(t), this.boundCloseAllDropdowns = (t) => this.closeAllDropdowns(t), this.boundHandleResize = () => this.handleResize(), this.boundHandleKeyboard = (t) => this.handleKeyboard(t), this.init();
170
+ this.boundToggleDropdown = (e) => this.toggleDropdown(e), this.boundToggleMobileMenu = (e) => this.toggleMobileMenu(e), this.boundCloseAllDropdowns = (e) => this.closeAllDropdowns(e), this.boundHandleResize = () => this.handleResize(), this.boundHandleKeyboard = (e) => this.handleKeyboard(e), this.init();
158
171
  }
159
172
  get isActive() {
160
173
  return this.isMobileMenuOpen() || this.isNormalDropdownOpen();
@@ -163,31 +176,31 @@ class f {
163
176
  this.handleResize(), this.bindEvents();
164
177
  }
165
178
  bindEvents() {
166
- this.menuItems.forEach((e) => {
167
- e.addEventListener("click", this.boundToggleDropdown);
168
- }), this.toggler?.addEventListener("click", this.boundToggleMobileMenu), document.addEventListener("click", this.boundCloseAllDropdowns), window.addEventListener("resize", this.boundHandleResize), this.menuItems.forEach((e) => {
169
- e.addEventListener("keydown", this.boundHandleKeyboard);
179
+ this.menuItems.forEach((t) => {
180
+ t.addEventListener("click", this.boundToggleDropdown);
181
+ }), this.toggler?.addEventListener("click", this.boundToggleMobileMenu), document.addEventListener("click", this.boundCloseAllDropdowns), window.addEventListener("resize", this.boundHandleResize), this.menuItems.forEach((t) => {
182
+ t.addEventListener("keydown", this.boundHandleKeyboard);
170
183
  });
171
184
  }
172
- toggleDropdown(e) {
173
- e.preventDefault(), e.stopPropagation(), this.verifyBar && this.verifyBar.isOpen && this.verifyBar.closePanel();
174
- const t = e.currentTarget, i = t.parentElement, n = i.classList.contains("active");
175
- this.closeAllDropdowns(), n || (i.classList.add("active"), t.classList.add("dga-menu-item-selected"), t.setAttribute("aria-expanded", "true"), i.querySelector(".dga-dropdown").style.top = `${this.navbarHeight + this.navbarTop}px`);
185
+ toggleDropdown(t) {
186
+ t.preventDefault(), t.stopPropagation(), this.verifyBar && this.verifyBar.isOpen && this.verifyBar.closePanel();
187
+ const e = t.currentTarget, i = e.parentElement, n = i.classList.contains("active");
188
+ this.closeAllDropdowns(), n || (i.classList.add("active"), e.classList.add("dga-menu-item-selected"), e.setAttribute("aria-expanded", "true"), i.querySelector(".dga-dropdown").style.top = `${this.navbarHeight + this.navbarTop}px`);
176
189
  }
177
- toggleMobileMenu(e) {
178
- e.stopPropagation(), this.verifyBar && this.verifyBar.isOpen && this.verifyBar.closePanel(), this.menu.classList.toggle("dga-menu-open"), this.menu.classList.contains("dga-menu-open") ? (document.body.classList.add("no-scroll"), this.menu.style.height = `calc(100vh - ${this.navbarHeight}px - ${this.navbarTop}px)`) : (document.body.classList.remove("no-scroll"), this.menu.style.height = "0px"), this.menu.style.top = `${this.navbarTop + this.navbarHeight}px`;
179
- const t = this.menu.classList.contains("dga-menu-open");
180
- this.toggler.setAttribute("aria-expanded", t), this.toggler.setAttribute(
190
+ toggleMobileMenu(t) {
191
+ t.stopPropagation(), this.verifyBar && this.verifyBar.isOpen && this.verifyBar.closePanel(), this.menu.classList.toggle("dga-menu-open"), this.menu.classList.contains("dga-menu-open") ? (document.body.classList.add("no-scroll"), this.menu.style.height = `calc(100vh - ${this.navbarHeight}px - ${this.navbarTop}px)`) : (document.body.classList.remove("no-scroll"), this.menu.style.height = "0px"), this.menu.style.top = `${this.navbarTop + this.navbarHeight}px`;
192
+ const e = this.menu.classList.contains("dga-menu-open");
193
+ this.toggler.setAttribute("aria-expanded", e), this.toggler.setAttribute(
181
194
  "aria-label",
182
- t ? "Close menu" : "Open menu"
195
+ e ? "Close menu" : "Open menu"
183
196
  );
184
197
  }
185
198
  // Public method to close menu programmatically (without event)
186
199
  closeMenu() {
187
200
  this.closeAllDropdowns(), this.isMobileMenuOpen() && (this.menu.classList.remove("dga-menu-open"), document.body.classList.remove("no-scroll"), this.menu.style.height = "0px", this.toggler.setAttribute("aria-expanded", "false"), this.toggler.setAttribute("aria-label", "Open menu"));
188
201
  }
189
- closeAllDropdowns(e) {
190
- if (e && e.target.closest(".dga-dropdown-content"))
202
+ closeAllDropdowns(t) {
203
+ if (t && t.target.closest(".dga-dropdown-content"))
191
204
  return;
192
205
  this.navbar.querySelectorAll(".dga-menu > li.active").forEach((i) => {
193
206
  i.classList.remove("active");
@@ -195,21 +208,21 @@ class f {
195
208
  n?.classList.remove("dga-menu-item-selected"), n?.setAttribute("aria-expanded", "false");
196
209
  });
197
210
  }
198
- handleKeyboard(e) {
199
- e.key === "Escape" && (this.closeAllDropdowns(), e.currentTarget.focus()), (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.toggleDropdown(e));
211
+ handleKeyboard(t) {
212
+ t.key === "Escape" && (this.closeAllDropdowns(), t.currentTarget.focus()), (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.toggleDropdown(t));
200
213
  }
201
214
  handleResize() {
202
- const e = window.innerWidth;
215
+ const t = window.innerWidth;
203
216
  document.body.classList.remove(
204
217
  "size_desktop",
205
218
  "size_tablet",
206
219
  "size_mobile"
207
- ), e > 769 ? (document.body.classList.add("size_desktop"), this.closeAllDropdowns(), this.menu.classList.remove("dga-menu-open"), document.body.classList.remove("no-scroll")) : e <= 769 && e > 375 ? document.body.classList.add("size_tablet") : document.body.classList.add("size_mobile");
220
+ ), t > 769 ? (document.body.classList.add("size_desktop"), this.closeAllDropdowns(), this.menu.classList.remove("dga-menu-open"), document.body.classList.remove("no-scroll")) : t <= 769 && t > 375 ? document.body.classList.add("size_tablet") : document.body.classList.add("size_mobile");
208
221
  }
209
222
  // Public method to destroy the component
210
223
  destroy() {
211
- this.menuItems.forEach((e) => {
212
- e.removeEventListener("click", this.boundToggleDropdown), e.removeEventListener("keydown", this.boundHandleKeyboard);
224
+ this.menuItems.forEach((t) => {
225
+ t.removeEventListener("click", this.boundToggleDropdown), t.removeEventListener("keydown", this.boundHandleKeyboard);
213
226
  }), this.toggler?.removeEventListener("click", this.boundToggleMobileMenu), document.removeEventListener("click", this.boundCloseAllDropdowns), window.removeEventListener("resize", this.boundHandleResize);
214
227
  }
215
228
  isMobileMenuOpen() {
@@ -219,9 +232,9 @@ class f {
219
232
  return this.navbar.querySelectorAll(".dga-menu > li.active").length > 0;
220
233
  }
221
234
  }
222
- class w {
223
- constructor(e = {}) {
224
- if (this.isOpen = !1, this.verifyBar = document.getElementById("dga-verify-bar"), this.menu = e.menu || null, this.btn = document.getElementById("dga-verifyBtn"), this.content = document.getElementById("dga-verify-bar_content"), this.boundToggle = () => {
235
+ class M {
236
+ constructor(t = {}) {
237
+ if (this.isOpen = !1, this.verifyBar = document.getElementById("dga-verify-bar"), this.menu = t.menu || null, this.btn = document.getElementById("dga-verifyBtn"), this.content = document.getElementById("dga-verify-bar_content"), this.boundToggle = () => {
225
238
  this.isOpen ? this.closePanel() : this.openPanel();
226
239
  }, !this.verifyBar || !this.btn || !this.content) {
227
240
  console.warn("DGA Verify Bar elements not found");
@@ -242,12 +255,266 @@ class w {
242
255
  this.btn?.removeEventListener("click", this.boundToggle);
243
256
  }
244
257
  }
258
+ function o(s = "") {
259
+ return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
260
+ }
261
+ const y = "info-color";
262
+ class f extends HTMLElement {
263
+ static get observedAttributes() {
264
+ return ["variant", "title", "dismissible"];
265
+ }
266
+ constructor() {
267
+ super(), this._boundDismiss = this._handleDismiss.bind(this);
268
+ }
269
+ connectedCallback() {
270
+ this._scheduleInitialRender();
271
+ }
272
+ _scheduleInitialRender() {
273
+ requestAnimationFrame(() => {
274
+ this._captureBodyContent(), this._render();
275
+ });
276
+ }
277
+ _captureBodyContent() {
278
+ if (this._bodyContent || this.querySelector(".dga-alert-content"))
279
+ return;
280
+ const t = this.innerHTML.trim();
281
+ t && (this._bodyContent = t);
282
+ }
283
+ disconnectedCallback() {
284
+ this._closeButton?.removeEventListener("click", this._boundDismiss);
285
+ }
286
+ attributeChangedCallback() {
287
+ this.isConnected && this._render();
288
+ }
289
+ _render() {
290
+ const t = this.getAttribute("variant") || y, e = this.getAttribute("title") || "", i = this.hasAttribute("dismissible"), n = this._bodyContent || "";
291
+ this.className = "dga-alert", this.setAttribute("data-variant", t);
292
+ const a = e ? `<h4 class="dga-alert-title">${o(e)}</h4>` : "", r = i ? '<button class="dga-alert-close" type="button" data-alert-close aria-label="Dismiss alert">×</button>' : "";
293
+ this.innerHTML = `
294
+ <span class="dga-alert-icon" aria-hidden="true"></span>
295
+ <div class="dga-alert-content">
296
+ ${a}
297
+ <div class="dga-alert-body">${n}</div>
298
+ </div>
299
+ ${r}
300
+ `, this._closeButton = this.querySelector("[data-alert-close]"), this._closeButton?.removeEventListener("click", this._boundDismiss), this._closeButton?.addEventListener("click", this._boundDismiss);
301
+ }
302
+ _handleDismiss() {
303
+ this.style.display = "none", this.dispatchEvent(
304
+ new CustomEvent("dga-alert-dismiss", { bubbles: !0, composed: !0 })
305
+ );
306
+ }
307
+ }
308
+ customElements.define("dga-alert", f);
309
+ class _ extends HTMLElement {
310
+ static get observedAttributes() {
311
+ return ["title", "size", "open"];
312
+ }
313
+ connectedCallback() {
314
+ this._bodyContent || (this._bodyContent = this.innerHTML.trim()), this._render();
315
+ }
316
+ attributeChangedCallback() {
317
+ this.isConnected && this._render();
318
+ }
319
+ _render() {
320
+ const t = this.getAttribute("title") || "", e = this.getAttribute("size") || "md", i = this.hasAttribute("open"), n = this._bodyContent || "";
321
+ this.innerHTML = `
322
+ <div class="dga-acc-item${i ? " dga-acc-item--active" : ""}">
323
+ <button class="dga-acc-header" data-size="${o(e)}" aria-expanded="${i ? "true" : "false"}">
324
+ <span>${o(t)}</span>
325
+ </button>
326
+ <div class="dga-acc-content">
327
+ <div class="dga-acc-body">${n}</div>
328
+ </div>
329
+ </div>
330
+ `;
331
+ }
332
+ }
333
+ class C extends HTMLElement {
334
+ constructor() {
335
+ super(), this._controller = null;
336
+ }
337
+ connectedCallback() {
338
+ this.classList.add("dga-acc"), this._controller?.destroy(), this._controller = new d(this);
339
+ }
340
+ disconnectedCallback() {
341
+ this._controller?.destroy(), this._controller = null;
342
+ }
343
+ }
344
+ customElements.define("dga-accordion-item", _);
345
+ customElements.define("dga-accordion", C);
346
+ class A extends HTMLElement {
347
+ static get observedAttributes() {
348
+ return ["code", "multiline"];
349
+ }
350
+ constructor() {
351
+ super(), this._boundCopy = this._handleCopy.bind(this);
352
+ }
353
+ connectedCallback() {
354
+ this._codeContent || (this._codeContent = this.getAttribute("code")?.trim() || this.textContent?.trim() || ""), this._render();
355
+ }
356
+ disconnectedCallback() {
357
+ this._copyButton?.removeEventListener("click", this._boundCopy);
358
+ }
359
+ attributeChangedCallback() {
360
+ this.isConnected && this._render();
361
+ }
362
+ _render() {
363
+ const t = this.hasAttribute("multiline"), e = this.getAttribute("code")?.trim() || this._codeContent || "";
364
+ t ? (this.innerHTML = `
365
+ <div class="dga-code-snippet-multiline">
366
+ <div class="dga-code-snippet-multiline__body">
367
+ <pre class="dga-code-snippet-multiline__code"><code>${o(e)}</code></pre>
368
+ <button type="button" class="dga-code-snippet-multiline__copy" aria-label="Copy code" data-copied="false">
369
+ ${l}
370
+ </button>
371
+ </div>
372
+ </div>
373
+ `, this._copyButton = this.querySelector(".dga-code-snippet-multiline__copy")) : (this.innerHTML = `
374
+ <div class="dga-code-snippet-inline">
375
+ <div class="dga-code-snippet-inline__content">${o(e)}</div>
376
+ <button type="button" class="dga-code-snippet-inline__copy" aria-label="Copy code" data-copied="false">
377
+ ${l}
378
+ </button>
379
+ </div>
380
+ `, this._copyButton = this.querySelector(".dga-code-snippet-inline__copy")), this._copyButton?.removeEventListener("click", this._boundCopy), this._copyButton?.addEventListener("click", this._boundCopy);
381
+ }
382
+ async _handleCopy() {
383
+ const t = this.getAttribute("code")?.trim() || this._codeContent || "";
384
+ !t || !this._copyButton || !await p(t) || (await b(this._copyButton), this.dispatchEvent(
385
+ new CustomEvent("dga-code-copy", { bubbles: !0, composed: !0 })
386
+ ));
387
+ }
388
+ }
389
+ customElements.define("dga-code-snippet", A);
390
+ class k extends HTMLElement {
391
+ static get observedAttributes() {
392
+ return ["data", "hole"];
393
+ }
394
+ connectedCallback() {
395
+ this._render();
396
+ }
397
+ attributeChangedCallback() {
398
+ this.isConnected && this._render();
399
+ }
400
+ _render() {
401
+ const t = v(this.getAttribute("data")), e = this.hasAttribute("hole") && this.getAttribute("hole") !== "false";
402
+ g(this, t, { hole: e });
403
+ }
404
+ }
405
+ customElements.define("dga-pie-chart", k);
406
+ class L extends HTMLElement {
407
+ static get observedAttributes() {
408
+ return ["registration-number", "registration-link", "domain"];
409
+ }
410
+ constructor() {
411
+ super(), this.isOpen = !1, this._btn = null, this._content = null, this._wrapper = null, this._boundToggle = () => this.isOpen ? this._close() : this._open();
412
+ }
413
+ connectedCallback() {
414
+ this._render();
415
+ }
416
+ disconnectedCallback() {
417
+ this._btn?.removeEventListener("click", this._boundToggle);
418
+ }
419
+ attributeChangedCallback() {
420
+ this.isConnected && this._render();
421
+ }
422
+ _render() {
423
+ const t = this.getAttribute("registration-number") || "20250105758", e = this.getAttribute("registration-link") || "https://raqmi.dga.gov.sa/platforms/platforms/9ebc5e60-9081-4653-bfb9-08dd2a2f8633/platform-license", i = this._normalizeLink(e), n = this.getAttribute("domain") || ".edu.sa";
424
+ this.innerHTML = `
425
+ <div id="dga-verify-bar" class="dga-bg-gray-100 closed">
426
+ <div class="dga-container dga-py-2">
427
+ <div id="dga-verify-bar_bar" class="dga-row">
428
+ <div class="dga-col">
429
+ <div class="dga-d-flex dga-align-items-center dga-gap-2">
430
+ <span><img src="${this._assetUrl("saudiFlag.svg")}" alt="علم المملكة العربية السعودية" /></span>
431
+ <span class="dga-text-sm">موقع حكومي رسمي تابع لحكومة المملكة العربية السعودية</span>
432
+ <span>
433
+ <button id="dga-verifyBtn" class="dga-btn dga-btn-subtle dga-text-primary-500" data-verify-toggle aria-expanded="false">
434
+ كيف تتحقق
435
+ </button>
436
+ </span>
437
+ </div>
438
+ </div>
439
+ </div>
440
+
441
+ <div id="dga-verify-bar_content" class="dga-row dga-pt-10 dga-pb-8" data-verify-content style="display: ${this.isOpen ? "flex" : "none"};">
442
+ <div class="dga-col-md-6 dga-pb-8">
443
+ <div class="dga-d-flex dga-gap-4">
444
+ <div><img src="${this._assetUrl("link-icon.svg")}" alt="" /></div>
445
+ <div class="dga-w-full dga-d-flex dga-flex-col dga-gap-2">
446
+ <h3 class="dga-text-xl dga-fw-bold">
447
+ روابط المواقع الالكترونية الرسمية السعودية تنتهي بـ
448
+ <span class="dga-text-primary-500">${n}</span>
449
+ </h3>
450
+ <p>
451
+ جميع روابط المواقع الرسمية التابعة للجهات الحكومية في المملكة
452
+ العربية السعودية تنتهي بـ ${n}
453
+ </p>
454
+ </div>
455
+ </div>
456
+ </div>
457
+
458
+ <div class="dga-col-md-6 dga-pb-8">
459
+ <div class="dga-d-flex dga-gap-4">
460
+ <div><img src="${this._assetUrl("square-lock-password.svg")}" alt="" /></div>
461
+ <div class="dga-w-full dga-d-flex dga-flex-col dga-gap-2">
462
+ <h3 class="dga-text-xl dga-fw-bold">
463
+ المواقع الالكترونية الحكومية تستخدم بروتوكول
464
+ <span class="dga-text-primary-500">HTTPS</span> للتشفير و الأمان.
465
+ </h3>
466
+ <p>
467
+ المواقع الالكترونية الآمنة في المملكة العربية السعودية تستخدم
468
+ بروتوكول HTTPS للتشفير.
469
+ </p>
470
+ </div>
471
+ </div>
472
+ </div>
473
+
474
+ <div class="dga-col-12">
475
+ <div class="dga-d-flex dga-align-items-center dga-gap-3 dga-bg-white dga-text-md dga-rounded-md dga-py-2 dga-px-7">
476
+ <img src="${this._assetUrl("DGA-logo-icon.svg")}" alt="شعار هيئة الحكومة الرقمية" />
477
+ مسجل لدى هيئة الحكومة الرقمية برقم :
478
+ <a href="${i}" class="dga-link">${t}</a>
479
+ </div>
480
+ </div>
481
+ </div>
482
+ </div>
483
+ </div>
484
+ `, this._btn?.removeEventListener("click", this._boundToggle), this._wrapper = this.querySelector("#dga-verify-bar"), this._btn = this.querySelector("[data-verify-toggle]"), this._content = this.querySelector("[data-verify-content]"), this._btn?.addEventListener("click", this._boundToggle);
485
+ }
486
+ _open() {
487
+ this._content.style.display = "flex", this.isOpen = !0, this._btn?.setAttribute("aria-expanded", "true"), this._wrapper?.classList.replace("closed", "opend");
488
+ }
489
+ _close() {
490
+ this._content.style.display = "none", this.isOpen = !1, this._btn?.setAttribute("aria-expanded", "false"), this._wrapper?.classList.replace("opend", "closed");
491
+ }
492
+ _assetUrl(t) {
493
+ return {
494
+ // TODO: replace with the official Saudi flag asset once added to public/.
495
+ "saudiFlag.svg": "/marker.svg",
496
+ "link-icon.svg": "/link-icon.svg",
497
+ "square-lock-password.svg": "/square-lock-password.svg",
498
+ "DGA-logo-icon.svg": "/DGA-logo-icon.svg"
499
+ }[t] || `/${t}`;
500
+ }
501
+ _normalizeLink(t) {
502
+ try {
503
+ return new URL(t, window.location.href).href;
504
+ } catch {
505
+ return "#";
506
+ }
507
+ }
508
+ }
509
+ customElements.define("dga-verify-bar", L);
510
+ const B = !0;
245
511
  export {
246
- m as DGAAccordion,
247
- b as DGAAlert,
248
- v as DGAChart,
249
- y as DGACodeSnippet,
250
- f as DGAMenuDropDown,
251
- w as DGAVerifyBar
512
+ w as DGAAccordion,
513
+ E as DGAAlert,
514
+ x as DGAChart,
515
+ D as DGACodeSnippet,
516
+ T as DGAMenuDropDown,
517
+ M as DGAVerifyBar,
518
+ B as DGA_WEB_COMPONENTS_REGISTERED
252
519
  };
253
520
  //# sourceMappingURL=index.js.map