diff --git a/CHANGELOG.md b/CHANGELOG.md index ebfa3db..073c4f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,43 @@ # Change Log +## [1.0.2] 2024-12-19 + +### Added for NPM + +- All components are now updated with weakset + - to prevent memory leaks + - to prevent multiple instances of the same component from being created + - duplicate instances of the same component will be ignored + - will initialize the components only once + +## [1.0.1] 2024-12-18 + +### Added for NPM + +- Added export for esm ## David AI - Release 1.0.0 - 2024-12-18 + **Rename the project from Tailwind Starter Kit to David AI** ### Changed + - The project name from Tailwind Starter Kit to David AI - Added David UI HTML components - Added David AI JavaScript components - Added David UI Docs pages ## [1.1.0] 2021-03-23 + ### Bug fixing + - https://github.com/creativetimofficial/tailwind-starter-kit/issues/19 - https://github.com/creativetimofficial/tailwind-starter-kit/issues/16 - https://github.com/creativetimofficial/tailwind-starter-kit/issues/10 - Thanks to this comment https://github.com/creativetimofficial/tailwind-starter-kit/issues/10#issuecomment-730641008 from @ryanwinchester + ### Major style changes + - The upgrade of Tailwind CSS from version 1 to version 2, will cause multiple style changes, check them out on the official Tailwind CSS websites: - https://blog.tailwindcss.com/tailwindcss-v2 - https://tailwindcss.com/ @@ -37,15 +58,22 @@ - For the colors, the only change that we made, is the fact that we've added all Tailwind CSS colors to our `tailwind.config.js` files, and inside our product, all `{type}-green-{number}` classes were renamed to `{type}-emerald-{number}` - We've also added on most of our inputs the `border-0` class - And on the inputs that were checkboxes, beside the `border-0` class, we've also had to add `rounded` class as well + ### Deleted components + ### Added components + - We've also added our first NextJS page: `Landing Page/next-landing-page` - Here is the PR for it: https://github.com/creativetimofficial/tailwind-starter-kit/pull/11 - Special thanks to @MeridjaNassim - If you want to add new pages, feel free to open a PR: https://github.com/creativetimofficial/tailwind-starter-kit/pulls + ### Deleted dependencies + - `popper.js` + ### Added dependencies + - `@popperjs/core@2.9.1` - So, we've changed the way we use Popper, check out our docs here: - https://www.creative-tim.com/learning-lab/tailwind-starter-kit/documentation/vue/dropdown (you can check the Angular, JS and React as well from here) - https://www.creative-tim.com/learning-lab/tailwind-starter-kit/documentation/vue/popovers/left (you can check the Angular, JS and React as well from here) @@ -53,7 +81,9 @@ - `typescript` (for the React versions to stop console warnings - NOTE: the projects are not based on TypeScript) - `@vue/compiler-sfc@3.0.7` (for the VueJS versions since we've upgraded to Vue@3) - `vue-router@4.0.5` (for the VueJS versions since we've upgraded to Vue@3) + ### Angular Updated dependencies + ``` @angular/animations 8.2.12 → 11.2.6 @angular/common 8.2.12 → 11.2.6 @@ -88,12 +118,16 @@ ts-node 7.0.0 → 9.1.1 tslint 5.15.0 → 6.1.3 typescript 3.5.3 → 4.0.7 ``` + ### HTML Updated dependencies + ``` @fortawesome/fontawesome-free 5.11.2 → 5.15.3 chart.js 2.9.3 → 2.9.4 ``` + ### React Updated dependencies + ``` @fortawesome/fontawesome-free 5.11.2 → 5.15.3 chart.js 2.9.3 → 2.9.4 @@ -103,7 +137,9 @@ react-router 5.1.2 → 5.2.0 react-router-dom 5.1.2 → 5.2.0 react-scripts 3.2.0 → 4.0.3 ``` + ### VueJS Updated dependencies + ``` @fortawesome/fontawesome-free 5.11.2 → 5.15.3 chart.js 2.9.3 → 2.9.4 @@ -117,7 +153,9 @@ eslint 5.16.0 → 7.22.0 eslint-plugin-vue 5.0.0 → 7.8.0 vue-template-compiler 2.6.10 → 2.6.12 ``` + ### NextJS Updated dependencies + ``` @fortawesome/fontawesome-free ^5.15.0 → ^5.15.3 next-images ^1.6.0 → ^1.7.0 @@ -131,12 +169,15 @@ sass ^1.26.11 → ^1.32.8 tailwindcss ^1.8.10 → ^2.0.4 typescript 4.0 → 4.2 ``` + ### Warning -_When doing a clean install, you might have some warnings, those come from `node_modules` and do not affect the project in any way._ +_When doing a clean install, you might have some warnings, those come from `node_modules` and do not affect the project in any way._ ## [1.0.0] 2019-12-20 + ### Original Release + - Generated Tailwind CSS files using the following documentation: https://www.creative-tim.com/learning-lab/tailwind-starter-kit/documentation/build-tools - Created files and projects for each of the Example Pages from the above link, for - Angular diff --git a/packages/dist/david-ai.esm.js b/packages/dist/david-ai.esm.js index 3b607a3..b73cfda 100644 --- a/packages/dist/david-ai.esm.js +++ b/packages/dist/david-ai.esm.js @@ -27,6 +27,31 @@ function loadPopperJs() { return popperReady; } +function asyncGeneratorStep(n, t, e, r, o, a, c) { + try { + var i = n[a](c), + u = i.value; + } catch (n) { + return void e(n); + } + i.done ? t(u) : Promise.resolve(u).then(r, o); +} +function _asyncToGenerator(n) { + return function () { + var t = this, + e = arguments; + return new Promise(function (r, o) { + var a = n.apply(t, e); + function _next(n) { + asyncGeneratorStep(a, r, o, _next, _throw, "next", n); + } + function _throw(n) { + asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); + } + _next(void 0); + }); + }; +} function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } @@ -41,6 +66,307 @@ function _createClass(e, r, t) { writable: !1 }), e; } +function _regeneratorRuntime() { + _regeneratorRuntime = function () { + return e; + }; + var t, + e = {}, + r = Object.prototype, + n = r.hasOwnProperty, + o = Object.defineProperty || function (t, e, r) { + t[e] = r.value; + }, + i = "function" == typeof Symbol ? Symbol : {}, + a = i.iterator || "@@iterator", + c = i.asyncIterator || "@@asyncIterator", + u = i.toStringTag || "@@toStringTag"; + function define(t, e, r) { + return Object.defineProperty(t, e, { + value: r, + enumerable: !0, + configurable: !0, + writable: !0 + }), t[e]; + } + try { + define({}, ""); + } catch (t) { + define = function (t, e, r) { + return t[e] = r; + }; + } + function wrap(t, e, r, n) { + var i = e && e.prototype instanceof Generator ? e : Generator, + a = Object.create(i.prototype), + c = new Context(n || []); + return o(a, "_invoke", { + value: makeInvokeMethod(t, r, c) + }), a; + } + function tryCatch(t, e, r) { + try { + return { + type: "normal", + arg: t.call(e, r) + }; + } catch (t) { + return { + type: "throw", + arg: t + }; + } + } + e.wrap = wrap; + var h = "suspendedStart", + l = "suspendedYield", + f = "executing", + s = "completed", + y = {}; + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + var p = {}; + define(p, a, function () { + return this; + }); + var d = Object.getPrototypeOf, + v = d && d(d(values([]))); + v && v !== r && n.call(v, a) && (p = v); + var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); + function defineIteratorMethods(t) { + ["next", "throw", "return"].forEach(function (e) { + define(t, e, function (t) { + return this._invoke(e, t); + }); + }); + } + function AsyncIterator(t, e) { + function invoke(r, o, i, a) { + var c = tryCatch(t[r], t, o); + if ("throw" !== c.type) { + var u = c.arg, + h = u.value; + return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { + invoke("next", t, i, a); + }, function (t) { + invoke("throw", t, i, a); + }) : e.resolve(h).then(function (t) { + u.value = t, i(u); + }, function (t) { + return invoke("throw", t, i, a); + }); + } + a(c.arg); + } + var r; + o(this, "_invoke", { + value: function (t, n) { + function callInvokeWithMethodAndArg() { + return new e(function (e, r) { + invoke(t, n, e, r); + }); + } + return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); + } + }); + } + function makeInvokeMethod(e, r, n) { + var o = h; + return function (i, a) { + if (o === f) throw Error("Generator is already running"); + if (o === s) { + if ("throw" === i) throw a; + return { + value: t, + done: !0 + }; + } + for (n.method = i, n.arg = a;;) { + var c = n.delegate; + if (c) { + var u = maybeInvokeDelegate(c, n); + if (u) { + if (u === y) continue; + return u; + } + } + if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { + if (o === h) throw o = s, n.arg; + n.dispatchException(n.arg); + } else "return" === n.method && n.abrupt("return", n.arg); + o = f; + var p = tryCatch(e, r, n); + if ("normal" === p.type) { + if (o = n.done ? s : l, p.arg === y) continue; + return { + value: p.arg, + done: n.done + }; + } + "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); + } + }; + } + function maybeInvokeDelegate(e, r) { + var n = r.method, + o = e.iterator[n]; + if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; + var i = tryCatch(o, e.iterator, r.arg); + if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; + var a = i.arg; + return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); + } + function pushTryEntry(t) { + var e = { + tryLoc: t[0] + }; + 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); + } + function resetTryEntry(t) { + var e = t.completion || {}; + e.type = "normal", delete e.arg, t.completion = e; + } + function Context(t) { + this.tryEntries = [{ + tryLoc: "root" + }], t.forEach(pushTryEntry, this), this.reset(!0); + } + function values(e) { + if (e || "" === e) { + var r = e[a]; + if (r) return r.call(e); + if ("function" == typeof e.next) return e; + if (!isNaN(e.length)) { + var o = -1, + i = function next() { + for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; + return next.value = t, next.done = !0, next; + }; + return i.next = i; + } + } + throw new TypeError(typeof e + " is not iterable"); + } + return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { + value: GeneratorFunctionPrototype, + configurable: !0 + }), o(GeneratorFunctionPrototype, "constructor", { + value: GeneratorFunction, + configurable: !0 + }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { + var e = "function" == typeof t && t.constructor; + return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); + }, e.mark = function (t) { + return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; + }, e.awrap = function (t) { + return { + __await: t + }; + }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { + return this; + }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { + void 0 === i && (i = Promise); + var a = new AsyncIterator(wrap(t, r, n, o), i); + return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { + return t.done ? t.value : a.next(); + }); + }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { + return this; + }), define(g, "toString", function () { + return "[object Generator]"; + }), e.keys = function (t) { + var e = Object(t), + r = []; + for (var n in e) r.push(n); + return r.reverse(), function next() { + for (; r.length;) { + var t = r.pop(); + if (t in e) return next.value = t, next.done = !1, next; + } + return next.done = !0, next; + }; + }, e.values = values, Context.prototype = { + constructor: Context, + reset: function (e) { + if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); + }, + stop: function () { + this.done = !0; + var t = this.tryEntries[0].completion; + if ("throw" === t.type) throw t.arg; + return this.rval; + }, + dispatchException: function (e) { + if (this.done) throw e; + var r = this; + function handle(n, o) { + return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; + } + for (var o = this.tryEntries.length - 1; o >= 0; --o) { + var i = this.tryEntries[o], + a = i.completion; + if ("root" === i.tryLoc) return handle("end"); + if (i.tryLoc <= this.prev) { + var c = n.call(i, "catchLoc"), + u = n.call(i, "finallyLoc"); + if (c && u) { + if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); + if (this.prev < i.finallyLoc) return handle(i.finallyLoc); + } else if (c) { + if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); + } else { + if (!u) throw Error("try statement without catch or finally"); + if (this.prev < i.finallyLoc) return handle(i.finallyLoc); + } + } + } + }, + abrupt: function (t, e) { + for (var r = this.tryEntries.length - 1; r >= 0; --r) { + var o = this.tryEntries[r]; + if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { + var i = o; + break; + } + } + i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); + var a = i ? i.completion : {}; + return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); + }, + complete: function (t, e) { + if ("throw" === t.type) throw t.arg; + return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; + }, + finish: function (t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; + } + }, + catch: function (t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.tryLoc === t) { + var n = r.completion; + if ("throw" === n.type) { + var o = n.arg; + resetTryEntry(r); + } + return o; + } + } + throw Error("illegal catch attempt"); + }, + delegateYield: function (e, r, n) { + return this.delegate = { + iterator: values(e), + resultName: r, + nextLoc: n + }, "next" === this.method && (this.arg = t), y; + } + }, e; +} function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; @@ -56,7 +382,7 @@ function _toPropertyKey(t) { return "symbol" == typeof i ? i : i + ""; } -// Dropdown component +var initializedDropdowns = new WeakSet(); var Dropdown = /*#__PURE__*/function () { function Dropdown(dropdownElement) { _classCallCheck(this, Dropdown); @@ -64,44 +390,50 @@ var Dropdown = /*#__PURE__*/function () { this.button = this.dropdown.querySelector('[data-dui-toggle="dropdown"]'); this.menu = this.dropdown.querySelector('[data-dui-role="menu"]'); this.popperInstance = null; - - // Get placement dynamically or default to 'bottom-start' this.placement = this.dropdown.getAttribute("data-dui-placement") || "bottom-start"; this.init(); } return _createClass(Dropdown, [{ key: "init", - value: function init() { - var _this = this; - // Initialize Popper.js - this.popperInstance = Popper.createPopper(this.button, this.menu, { - placement: this.placement, - modifiers: [{ - name: "offset", - options: { - offset: [0, 5] + value: function () { + var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { + var _this = this; + return _regeneratorRuntime().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return loadPopperJs(); + case 2: + // Initialize Popper.js + this.popperInstance = Popper.createPopper(this.button, this.menu, { + placement: this.placement, + modifiers: [{ + name: "offset", + options: { + offset: [0, 5] + } + }] + }); + + // Event listeners + this.button.addEventListener("click", function (e) { + e.stopPropagation(); + _this.toggleDropdown(); + }); + document.addEventListener("click", function (e) { + if (!_this.dropdown.contains(e.target)) _this.closeDropdown(); + }); + case 5: + case "end": + return _context.stop(); } - }] - }); - - // Check for open attribute - if (this.dropdown.hasAttribute("data-dui-open")) { - this.openDropdown(); + }, _callee, this); + })); + function init() { + return _init.apply(this, arguments); } - - // Toggle dropdown on button click - this.button.addEventListener("click", function (e) { - e.stopPropagation(); - _this.toggleDropdown(); - }); - - // Close dropdown on outside click - document.addEventListener("click", function (e) { - if (!_this.dropdown.contains(e.target)) { - _this.closeDropdown(); - } - }); - } + return init; + }() }, { key: "toggleDropdown", value: function toggleDropdown() { @@ -115,7 +447,6 @@ var Dropdown = /*#__PURE__*/function () { this.menu.hidden = false; this.menu.classList.remove("hidden"); this.popperInstance.update(); - this.closeSiblings(); } }, { key: "closeDropdown", @@ -124,31 +455,25 @@ var Dropdown = /*#__PURE__*/function () { this.menu.hidden = true; this.menu.classList.add("hidden"); } - }, { - key: "closeSiblings", - value: function closeSiblings() { - var _this2 = this; - var siblingMenus = this.dropdown.parentElement.querySelectorAll('[data-dui-role="menu"]:not(.hidden)'); - siblingMenus.forEach(function (siblingMenu) { - if (siblingMenu !== _this2.menu) { - siblingMenu.classList.add("hidden"); - siblingMenu.parentElement.querySelector('[data-dui-toggle="dropdown"]').setAttribute("aria-expanded", "false"); - } - }); - } }]); }(); function initDropdowns() { document.querySelectorAll(".dropdown").forEach(function (dropdownElement) { - new Dropdown(dropdownElement); + if (!initializedDropdowns.has(dropdownElement)) { + new Dropdown(dropdownElement); + initializedDropdowns.add(dropdownElement); + } }); } -// Popover component +var initializedPopovers = new WeakSet(); // Prevent duplicate initialization +var activePopovers = []; // Track active popovers for cleanup + function initPopovers() { - var popoverTriggers = document.querySelectorAll("[data-dui-toggle='popover']"); - popoverTriggers.forEach(function (trigger) { + document.querySelectorAll("[data-dui-toggle='popover']").forEach(function (trigger) { var _trigger$nextElementS; + if (initializedPopovers.has(trigger)) return; // Avoid re-initializing + var placement = trigger.getAttribute("data-dui-placement") || "top"; var popoverClasses = trigger.getAttribute("data-dui-popover-class") || "popover-default"; var plainContent = trigger.getAttribute("data-dui-content"); @@ -187,9 +512,12 @@ function initPopovers() { }] }); - // Store references for cleanup - trigger._popoverInstance = popoverInstance; - trigger._popoverElement = popoverElement; + // Track active popovers for cleanup + activePopovers.push({ + trigger: trigger, + popoverElement: popoverElement, + popoverInstance: popoverInstance + }); } // Function to close the popover @@ -203,6 +531,11 @@ function initPopovers() { popoverElement.remove(); popoverElement = null; } + + // Remove from active popovers + activePopovers = activePopovers.filter(function (p) { + return p.trigger !== trigger; + }); } // Toggle popover on click @@ -219,14 +552,58 @@ function initPopovers() { if (isOpenByDefault) { openPopover(); } + + // Mark as initialized + initializedPopovers.add(trigger); }); } -// Tooltip component +// Cleanup function to destroy all active popovers +function cleanupPopovers() { + activePopovers.forEach(function (_ref) { + var popoverElement = _ref.popoverElement, + popoverInstance = _ref.popoverInstance; + if (popoverInstance) popoverInstance.destroy(); + if (popoverElement) popoverElement.remove(); + }); + activePopovers = []; +} + +// Combined initialization function +function loadAndInitPopovers() { + return _loadAndInitPopovers.apply(this, arguments); +} + +// Auto-initialize Popovers in the Browser Environment +function _loadAndInitPopovers() { + _loadAndInitPopovers = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { + return _regeneratorRuntime().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return loadPopperJs(); + case 2: + initPopovers(); + case 3: + case "end": + return _context.stop(); + } + }, _callee); + })); + return _loadAndInitPopovers.apply(this, arguments); +} +if (typeof window !== "undefined" && typeof document !== "undefined") { + loadAndInitPopovers(); +} + +var initializedTooltips = new WeakSet(); // Prevent duplicate initialization +var activeTooltips = []; // Track active tooltips for cleanup + function initTooltips() { - var tooltipTriggers = document.querySelectorAll("[data-dui-toggle='tooltip']"); - tooltipTriggers.forEach(function (trigger) { + document.querySelectorAll("[data-dui-toggle='tooltip']").forEach(function (trigger) { var _trigger$nextElementS; + if (initializedTooltips.has(trigger)) return; // Avoid re-initializing + var title = trigger.getAttribute("data-dui-title"); // Plain text content var placement = trigger.getAttribute("data-dui-placement") || "top"; var tooltipClasses = trigger.getAttribute("data-dui-tooltip-class") || "tooltip-default"; @@ -239,10 +616,8 @@ function initTooltips() { customContentElement = trigger.nextElementSibling; } - // Show the tooltip + // Function to show the tooltip function showTooltip() { - if (tooltipElement) return; // Avoid duplicate tooltips - tooltipElement = document.createElement("div"); tooltipElement.className = tooltipClasses; @@ -258,8 +633,6 @@ function initTooltips() { return; } document.body.appendChild(tooltipElement); - - // Create Popper.js instance tooltipInstance = Popper.createPopper(trigger, tooltipElement, { placement: placement, modifiers: [{ @@ -269,48 +642,96 @@ function initTooltips() { } }] }); + + // Track active tooltips for cleanup + activeTooltips.push({ + trigger: trigger, + tooltipElement: tooltipElement, + tooltipInstance: tooltipInstance + }); } - // Hide the tooltip + // Function to hide the tooltip function hideTooltip() { - if (tooltipElement && !trigger.classList.contains("static-tooltip")) { + if (tooltipInstance) { tooltipInstance.destroy(); tooltipInstance = null; + } + if (tooltipElement) { tooltipElement.remove(); tooltipElement = null; } + + // Remove from active tooltips + activeTooltips = activeTooltips.filter(function (t) { + return t.trigger !== trigger; + }); } - // Event Listeners + // Add event listeners for showing and hiding tooltips trigger.addEventListener("mouseenter", showTooltip); trigger.addEventListener("mouseleave", hideTooltip); - // Toggle static tooltips on click - trigger.addEventListener("click", function () { - if (trigger.classList.contains("static-tooltip")) { - trigger.classList.remove("static-tooltip"); - hideTooltip(); - } else { - trigger.classList.add("static-tooltip"); - showTooltip(); - } - }); + // Mark as initialized + initializedTooltips.add(trigger); }); } +// Cleanup function to destroy all active tooltips +function cleanupTooltips() { + activeTooltips.forEach(function (_ref) { + var tooltipElement = _ref.tooltipElement, + tooltipInstance = _ref.tooltipInstance; + if (tooltipInstance) tooltipInstance.destroy(); + if (tooltipElement) tooltipElement.remove(); + }); + activeTooltips = []; +} + +// Combined initialization function +function loadAndInitTooltips() { + return _loadAndInitTooltips.apply(this, arguments); +} + +// Auto-initialize Tooltips in the Browser Environment +function _loadAndInitTooltips() { + _loadAndInitTooltips = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { + return _regeneratorRuntime().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return loadPopperJs(); + case 2: + initTooltips(); + case 3: + case "end": + return _context.stop(); + } + }, _callee); + })); + return _loadAndInitTooltips.apply(this, arguments); +} +if (typeof window !== "undefined" && typeof document !== "undefined") { + loadAndInitTooltips(); +} + // src/alert/alert.js +var initializedElements$1 = new WeakSet(); function closeAlert(event) { var button = event.currentTarget; var alert = button.closest('[role="alert"]'); if (alert) { - alert.parentNode.removeChild(alert); + alert.remove(); // Remove the alert } } function initAlert() { - var dismissButtons = document.querySelectorAll("[data-dui-dismiss='alert']"); - dismissButtons.forEach(function (button) { - button.addEventListener("click", closeAlert); + // Attach event listeners only to buttons that haven't been initialized + document.querySelectorAll("[data-dui-dismiss='alert']").forEach(function (button) { + if (!initializedElements$1.has(button)) { + button.addEventListener("click", closeAlert); + initializedElements$1.add(button); // Track this button as initialized + } }); } @@ -320,6 +741,7 @@ if (typeof window !== 'undefined') { } // Collapse component +var initializedElements = new WeakSet(); function toggleCollapse(event) { var collapseID = event.currentTarget.getAttribute("data-dui-target"); if (collapseID && collapseID.startsWith("#")) { @@ -342,7 +764,10 @@ function toggleCollapse(event) { } function initCollapse() { document.querySelectorAll("[data-dui-toggle='collapse']").forEach(function (button) { - button.addEventListener("click", toggleCollapse); + if (!initializedElements.has(button)) { + button.addEventListener("click", toggleCollapse); + initializedElements.add(button); // Mark as initialized + } }); } @@ -359,25 +784,34 @@ function initTabs() { var tabContents = tabGroup.querySelectorAll(".tab-content"); var indicator = tabList.querySelector(".tab-indicator"); var isVertical = tabGroup.getAttribute("data-dui-orientation") === "vertical"; - - // Function to update the indicator position dynamically function updateIndicator(link) { var rect = link.getBoundingClientRect(); var parentRect = tabList.getBoundingClientRect(); - if (isVertical) { - // For vertical tabs - indicator.style.height = "".concat(rect.height, "px"); - indicator.style.transform = "translateY(".concat(rect.top - parentRect.top, "px)"); - } else { - // For horizontal tabs - indicator.style.width = "".concat(rect.width, "px"); - indicator.style.transform = "translateX(".concat(rect.left - parentRect.left, "px)"); - } - } + requestAnimationFrame(function () { + if (isVertical) { + var offsetY = rect.top - parentRect.top; + var height = rect.height; + + // Apply styles dynamically for vertical orientation + indicator.style.transform = "translateY(".concat(offsetY, "px)"); + indicator.style.height = "".concat(height, "px"); + } else { + var offsetX = rect.left - parentRect.left; + var width = rect.width; + + // Apply styles dynamically for horizontal orientation + indicator.style.transform = "translateX(".concat(offsetX, "px)"); + indicator.style.width = "".concat(width, "px"); + } - // Function to handle tab activation + // Make the indicator visible + indicator.classList.remove("hidden"); + indicator.style.opacity = "1"; + indicator.style.scale = "1"; + }); + } function activateTab(link) { - // Deactivate all tabs and hide contents + // Deactivate all tabs and hide their content tabLinks.forEach(function (item) { return item.classList.remove("active"); }); @@ -398,17 +832,19 @@ function initTabs() { updateIndicator(link); } - // Initialize the tabs - tabLinks.forEach(function (link) { - // If a tab is already active, update the indicator - if (link.classList.contains("active")) { - activateTab(link); + // Check for the tab with the `active` class and set the indicator initially + setTimeout(function () { + var activeLink = tabList.querySelector(".tab-link.active"); + if (activeLink) { + activateTab(activeLink); } + }, 100); - // Add click event listener to each tab link + // Initialize click event listeners for each tab + tabLinks.forEach(function (link) { link.addEventListener("click", function (event) { - event.preventDefault(); - activateTab(link); + event.preventDefault(); // Prevent default browser behavior + activateTab(link); // Activate the clicked tab and update the indicator }); }); }); @@ -416,11 +852,14 @@ function initTabs() { // Auto-initialize tabs in the browser if (typeof window !== "undefined") { - initTabs(); + document.addEventListener("DOMContentLoaded", function () { + initTabs(); + }); } // Modal Component +var initializedModals = new WeakSet(); function toggleModal(event) { var modalID = event.currentTarget.getAttribute("data-dui-target"); var modal = document.querySelector(modalID); @@ -473,15 +912,21 @@ function closeOnOutsideClick(event) { } function initModal() { document.querySelectorAll("[data-dui-toggle='modal']").forEach(function (trigger) { - trigger.addEventListener("click", toggleModal); + if (!initializedModals.has(trigger)) { + trigger.addEventListener("click", toggleModal); + initializedModals.add(trigger); + } }); document.querySelectorAll("[data-dui-dismiss='modal']").forEach(function (button) { - button.addEventListener("click", closeModal); + if (!initializedModals.has(button)) { + button.addEventListener("click", closeModal); + initializedModals.add(button); + } }); } // Auto-initialize Modals in the Browser Environment -if (typeof window !== "undefined") { +if (typeof window !== "undefined" && typeof document !== "undefined") { initModal(); } @@ -491,13 +936,15 @@ var DavidAI = { initCollapse: initCollapse, initDropdowns: initDropdowns, initPopovers: initPopovers, + cleanupPopovers: cleanupPopovers, initTooltips: initTooltips, + cleanupTooltips: cleanupTooltips, initTabs: initTabs, initModal: initModal }; // Auto-initialize components in the browser -if (typeof window !== "undefined") { +if (typeof window !== "undefined" && typeof document !== "undefined") { // Initialize Popper-independent components initAlert(); initCollapse(); @@ -517,5 +964,5 @@ if (typeof window !== "undefined") { window.DavidAI = DavidAI; } -export { DavidAI as default, initAlert, initCollapse, initDropdowns, initModal, initPopovers, initTabs, initTooltips }; +export { cleanupPopovers, cleanupTooltips, DavidAI as default, initAlert, initCollapse, initDropdowns, initModal, initPopovers, initTabs, initTooltips }; //# sourceMappingURL=david-ai.esm.js.map diff --git a/packages/dist/david-ai.esm.js.map b/packages/dist/david-ai.esm.js.map index e08b6eb..8acab09 100644 --- a/packages/dist/david-ai.esm.js.map +++ b/packages/dist/david-ai.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"david-ai.esm.js","sources":["../src/utils/loadPopper.js","../src/dropdown/dropdown.js","../src/popover/popover.js","../src/tooltip/tooltip.js","../src/alert/alert.js","../src/collapse/collapse.js","../src/tabs/tabs.js","../src/modal/modal.js","../src/index.js"],"sourcesContent":["var popperLoaded = false; // Singleton flag to track loading state\nvar popperReady = null; // Promise to handle loading Popper.js once\n\nexport function loadPopperJs() {\n if (popperLoaded) {\n return popperReady; // Return the existing Promise if already loading or loaded\n }\n popperLoaded = true; // Mark Popper.js as being loaded\n\n popperReady = new Promise(function (resolve, reject) {\n if (window.Popper) {\n resolve(window.Popper); // If already loaded globally, resolve immediately\n return;\n }\n var script = document.createElement(\"script\");\n script.src = \"https://unpkg.com/@popperjs/core@2\";\n script.defer = true;\n script.onload = function () {\n window.Popper = window.Popper || window.Popper; // Expose Popper globally\n resolve(window.Popper); // Resolve once Popper.js is loaded\n };\n script.onerror = function () {\n reject(new Error(\"Failed to load Popper.js\"));\n };\n document.head.appendChild(script);\n });\n\n return popperReady;\n}\n","// Dropdown component\nexport class Dropdown {\n constructor(dropdownElement) {\n this.dropdown = dropdownElement;\n this.button = this.dropdown.querySelector('[data-dui-toggle=\"dropdown\"]');\n this.menu = this.dropdown.querySelector('[data-dui-role=\"menu\"]');\n this.popperInstance = null;\n\n // Get placement dynamically or default to 'bottom-start'\n this.placement = this.dropdown.getAttribute(\"data-dui-placement\") || \"bottom-start\";\n\n this.init();\n }\n\n init() {\n // Initialize Popper.js\n this.popperInstance = Popper.createPopper(this.button, this.menu, {\n placement: this.placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 5] } }],\n });\n\n // Check for open attribute\n if (this.dropdown.hasAttribute(\"data-dui-open\")) {\n this.openDropdown();\n }\n\n // Toggle dropdown on button click\n this.button.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n this.toggleDropdown();\n });\n\n // Close dropdown on outside click\n document.addEventListener(\"click\", (e) => {\n if (!this.dropdown.contains(e.target)) {\n this.closeDropdown();\n }\n });\n }\n\n toggleDropdown() {\n const isExpanded = this.button.getAttribute(\"aria-expanded\") === \"true\";\n isExpanded ? this.closeDropdown() : this.openDropdown();\n }\n\n openDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"true\");\n this.menu.hidden = false;\n this.menu.classList.remove(\"hidden\");\n this.popperInstance.update();\n this.closeSiblings();\n }\n\n closeDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"false\");\n this.menu.hidden = true;\n this.menu.classList.add(\"hidden\");\n }\n\n closeSiblings() {\n const siblingMenus = this.dropdown.parentElement.querySelectorAll(\n '[data-dui-role=\"menu\"]:not(.hidden)'\n );\n siblingMenus.forEach((siblingMenu) => {\n if (siblingMenu !== this.menu) {\n siblingMenu.classList.add(\"hidden\");\n siblingMenu.parentElement\n .querySelector('[data-dui-toggle=\"dropdown\"]')\n .setAttribute(\"aria-expanded\", \"false\");\n }\n });\n }\n}\n\nexport function initDropdowns() {\n document.querySelectorAll(\".dropdown\").forEach((dropdownElement) => {\n new Dropdown(dropdownElement);\n });\n}","// Popover component\nexport function initPopovers() {\n const popoverTriggers = document.querySelectorAll(\"[data-dui-toggle='popover']\");\n\n popoverTriggers.forEach(trigger => {\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const popoverClasses = trigger.getAttribute(\"data-dui-popover-class\") || \"popover-default\";\n const plainContent = trigger.getAttribute(\"data-dui-content\");\n const isOpenByDefault = trigger.hasAttribute(\"data-dui-open\");\n\n let popoverInstance = null;\n let popoverElement = null;\n let originalContentElement = null;\n\n // Find content element next to the trigger\n const contentElement = trigger.nextElementSibling?.matches(\"[data-dui-popover-content]\")\n ? trigger.nextElementSibling\n : null;\n\n // Function to open the popover\n function openPopover() {\n popoverElement = document.createElement(\"div\");\n popoverElement.className = popoverClasses;\n\n // Use custom HTML content or plain text\n if (contentElement) {\n originalContentElement = contentElement.cloneNode(true);\n originalContentElement.classList.remove(\"hidden\");\n popoverElement.appendChild(originalContentElement);\n } else if (plainContent) {\n popoverElement.textContent = plainContent;\n } else {\n console.error(\"No content provided for popover:\", trigger);\n return;\n }\n\n document.body.appendChild(popoverElement);\n\n popoverInstance = Popper.createPopper(trigger, popoverElement, {\n placement: placement,\n modifiers: [\n { name: \"offset\", options: { offset: [0, 8] } }\n ],\n });\n\n // Store references for cleanup\n trigger._popoverInstance = popoverInstance;\n trigger._popoverElement = popoverElement;\n }\n\n // Function to close the popover\n function closePopover() {\n if (popoverInstance) {\n popoverInstance.destroy();\n popoverInstance = null;\n\n if (originalContentElement) {\n originalContentElement.classList.add(\"hidden\");\n }\n\n popoverElement.remove();\n popoverElement = null;\n }\n }\n\n // Toggle popover on click\n trigger.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n if (popoverInstance) {\n closePopover();\n } else {\n openPopover();\n }\n });\n\n // Open popover by default if specified\n if (isOpenByDefault) {\n openPopover();\n }\n });\n}\n","// Tooltip component\nexport function initTooltips() {\n const tooltipTriggers = document.querySelectorAll(\"[data-dui-toggle='tooltip']\");\n\n tooltipTriggers.forEach((trigger) => {\n const title = trigger.getAttribute(\"data-dui-title\"); // Plain text content\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const tooltipClasses = trigger.getAttribute(\"data-dui-tooltip-class\") || \"tooltip-default\";\n\n let tooltipInstance = null;\n let tooltipElement = null;\n let customContentElement = null;\n\n // Check for sibling content with custom HTML\n if (trigger.nextElementSibling?.matches(\"[data-dui-tooltip-content]\")) {\n customContentElement = trigger.nextElementSibling;\n }\n\n // Show the tooltip\n function showTooltip() {\n if (tooltipElement) return; // Avoid duplicate tooltips\n\n tooltipElement = document.createElement(\"div\");\n tooltipElement.className = tooltipClasses;\n\n // Use custom HTML content or plain text\n if (customContentElement) {\n const contentClone = customContentElement.cloneNode(true);\n contentClone.classList.remove(\"hidden\");\n tooltipElement.appendChild(contentClone);\n } else if (title) {\n tooltipElement.textContent = title;\n } else {\n console.warn(\"No tooltip content provided for:\", trigger);\n return;\n }\n\n document.body.appendChild(tooltipElement);\n\n // Create Popper.js instance\n tooltipInstance = Popper.createPopper(trigger, tooltipElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n }\n\n // Hide the tooltip\n function hideTooltip() {\n if (tooltipElement && !trigger.classList.contains(\"static-tooltip\")) {\n tooltipInstance.destroy();\n tooltipInstance = null;\n tooltipElement.remove();\n tooltipElement = null;\n }\n }\n\n // Event Listeners\n trigger.addEventListener(\"mouseenter\", showTooltip);\n trigger.addEventListener(\"mouseleave\", hideTooltip);\n\n // Toggle static tooltips on click\n trigger.addEventListener(\"click\", () => {\n if (trigger.classList.contains(\"static-tooltip\")) {\n trigger.classList.remove(\"static-tooltip\");\n hideTooltip();\n } else {\n trigger.classList.add(\"static-tooltip\");\n showTooltip();\n }\n });\n });\n}\n","// src/alert/alert.js\n\nexport function closeAlert(event) {\n const button = event.currentTarget;\n const alert = button.closest('[role=\"alert\"]');\n if (alert) {\n alert.parentNode.removeChild(alert);\n }\n}\n\nexport function initAlert() {\n const dismissButtons = document.querySelectorAll(\"[data-dui-dismiss='alert']\");\n dismissButtons.forEach(button => {\n button.addEventListener(\"click\", closeAlert);\n });\n}\n\n// Auto-initialize if running in a browser environment\nif (typeof window !== 'undefined') {\n initAlert();\n}\n","// Collapse component\nexport function toggleCollapse(event) {\n const collapseID =\n event.currentTarget.getAttribute(\"data-dui-target\")\n\n if (collapseID && collapseID.startsWith(\"#\")) {\n const collapseElement = document.querySelector(collapseID);\n const isExpanded = event.currentTarget.getAttribute(\"aria-expanded\") === \"true\";\n\n if (collapseElement) {\n // Toggle max-height for collapsible content\n collapseElement.style.maxHeight = isExpanded\n ? \"0\"\n : collapseElement.scrollHeight + \"px\";\n\n // Update aria-expanded attribute\n event.currentTarget.setAttribute(\"aria-expanded\", !isExpanded);\n\n // Toggle rotate-180 class on the icon\n const icon = event.currentTarget.querySelector(\"[data-dui-icon]\");\n if (icon) {\n icon.classList.toggle(\"rotate-180\", !isExpanded);\n }\n }\n }\n}\n\nexport function initCollapse() {\n document.querySelectorAll(\"[data-dui-toggle='collapse']\").forEach(button => {\n button.addEventListener(\"click\", toggleCollapse);\n });\n}\n\n// Auto-initialize collapsible components in the browser\nif (typeof window !== 'undefined') {\n initCollapse();\n}\n","// Tabs Component\nexport function initTabs() {\n document.querySelectorAll(\".tab-group\").forEach((tabGroup) => {\n const tabList = tabGroup.querySelector(\"[role='tablist']\");\n const tabLinks = tabList.querySelectorAll(\".tab-link\");\n const tabContents = tabGroup.querySelectorAll(\".tab-content\");\n const indicator = tabList.querySelector(\".tab-indicator\");\n\n const isVertical = tabGroup.getAttribute(\"data-dui-orientation\") === \"vertical\";\n\n // Function to update the indicator position dynamically\n function updateIndicator(link) {\n const rect = link.getBoundingClientRect();\n const parentRect = tabList.getBoundingClientRect();\n\n if (isVertical) {\n // For vertical tabs\n indicator.style.height = `${rect.height}px`;\n indicator.style.transform = `translateY(${rect.top - parentRect.top}px)`;\n } else {\n // For horizontal tabs\n indicator.style.width = `${rect.width}px`;\n indicator.style.transform = `translateX(${rect.left - parentRect.left}px)`;\n }\n }\n\n // Function to handle tab activation\n function activateTab(link) {\n // Deactivate all tabs and hide contents\n tabLinks.forEach((item) => item.classList.remove(\"active\"));\n tabContents.forEach((content) => {\n content.classList.add(\"hidden\");\n content.classList.remove(\"block\");\n });\n\n // Activate the clicked tab\n link.classList.add(\"active\");\n const targetContent = document.getElementById(link.getAttribute(\"data-dui-tab-target\"));\n if (targetContent) {\n targetContent.classList.add(\"block\");\n targetContent.classList.remove(\"hidden\");\n }\n\n // Update the indicator position\n updateIndicator(link);\n }\n\n // Initialize the tabs\n tabLinks.forEach((link) => {\n // If a tab is already active, update the indicator\n if (link.classList.contains(\"active\")) {\n activateTab(link);\n }\n\n // Add click event listener to each tab link\n link.addEventListener(\"click\", (event) => {\n event.preventDefault();\n activateTab(link);\n });\n });\n });\n}\n\n// Auto-initialize tabs in the browser\nif (typeof window !== \"undefined\") {\n initTabs();\n}\n","// Modal Component\n\nexport function toggleModal(event) {\n const modalID = event.currentTarget.getAttribute(\"data-dui-target\");\n const modal = document.querySelector(modalID);\n\n if (modal) {\n const isHidden = modal.classList.contains(\"pointer-events-none\");\n modal.classList.toggle(\"opacity-0\", !isHidden);\n\n if (isHidden) {\n modal.classList.remove(\"pointer-events-none\");\n } else {\n setTimeout(() => modal.classList.add(\"pointer-events-none\"), 300);\n }\n\n modal.classList.toggle(\"opacity-100\", isHidden);\n const modalContent = modal.querySelector(isHidden ? \".scale-95\" : \".scale-100\");\n modalContent.classList.toggle(\"scale-95\", !isHidden);\n modalContent.classList.toggle(\"scale-100\", isHidden);\n modal.setAttribute(\"aria-hidden\", !isHidden);\n\n // Add or remove event listener for clicks outside modal content\n if (isHidden) {\n modal.addEventListener(\"click\", closeOnOutsideClick);\n } else {\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n }\n}\n\nexport function closeModal(event) {\n const modal = event.currentTarget.closest(\".fixed\");\n\n if (modal) {\n modal.classList.add(\"opacity-0\");\n modal.classList.remove(\"opacity-100\");\n const modalContent = modal.querySelector(\".scale-100\");\n modalContent.classList.add(\"scale-95\");\n modalContent.classList.remove(\"scale-100\");\n\n setTimeout(() => {\n modal.classList.add(\"pointer-events-none\");\n modal.setAttribute(\"aria-hidden\", \"true\");\n }, 300);\n\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n}\n\nfunction closeOnOutsideClick(event) {\n const modalContent = event.currentTarget.querySelector(\".scale-100, .scale-95\");\n\n if (!modalContent.contains(event.target)) {\n closeModal({ currentTarget: event.currentTarget });\n }\n}\n\nexport function initModal() {\n document.querySelectorAll(\"[data-dui-toggle='modal']\").forEach((trigger) => {\n trigger.addEventListener(\"click\", toggleModal);\n });\n\n document.querySelectorAll(\"[data-dui-dismiss='modal']\").forEach((button) => {\n button.addEventListener(\"click\", closeModal);\n });\n}\n\n// Auto-initialize Modals in the Browser Environment\nif (typeof window !== \"undefined\") {\n initModal();\n}\n","import { loadPopperJs } from './utils/loadPopper.js';\n\n// Import components\nimport { initDropdowns } from './dropdown/dropdown.js';\nimport { initPopovers } from './popover/popover.js';\nimport { initTooltips } from './tooltip/tooltip.js';\nimport { initAlert } from './alert/alert.js';\nimport { initCollapse } from './collapse/collapse.js';\nimport { initTabs } from './tabs/tabs.js';\nimport { initModal } from './modal/modal.js';\n\n// Export individual components for named imports\nexport {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n initTooltips,\n initTabs,\n initModal\n};\n\n// Combine all features into a global object for default export\nconst DavidAI = {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n initTooltips,\n initTabs,\n initModal\n};\n\n// Auto-initialize components in the browser\nif (typeof window !== \"undefined\") {\n // Initialize Popper-independent components\n initAlert();\n initCollapse();\n initTabs();\n initModal();\n\n // Load Popper.js once, then initialize dependent components\n loadPopperJs()\n .then(() => {\n initDropdowns();\n initPopovers();\n initTooltips();\n })\n .catch((error) => {\n console.error(\"Failed to load Popper.js:\", error);\n });\n\n // Expose DavidAI globally for UMD\n window.DavidAI = DavidAI;\n}\n\nexport default DavidAI;\n"],"names":["popperLoaded","popperReady","loadPopperJs","Promise","resolve","reject","window","Popper","script","document","createElement","src","defer","onload","onerror","Error","head","appendChild","Dropdown","dropdownElement","_classCallCheck","dropdown","button","querySelector","menu","popperInstance","placement","getAttribute","init","_createClass","key","value","_this","createPopper","modifiers","name","options","offset","hasAttribute","openDropdown","addEventListener","e","stopPropagation","toggleDropdown","contains","target","closeDropdown","isExpanded","setAttribute","hidden","classList","remove","update","closeSiblings","add","_this2","siblingMenus","parentElement","querySelectorAll","forEach","siblingMenu","initDropdowns","initPopovers","popoverTriggers","trigger","_trigger$nextElementS","popoverClasses","plainContent","isOpenByDefault","popoverInstance","popoverElement","originalContentElement","contentElement","nextElementSibling","matches","openPopover","className","cloneNode","textContent","console","error","body","_popoverInstance","_popoverElement","closePopover","destroy","event","initTooltips","tooltipTriggers","title","tooltipClasses","tooltipInstance","tooltipElement","customContentElement","showTooltip","contentClone","warn","hideTooltip","closeAlert","currentTarget","alert","closest","parentNode","removeChild","initAlert","dismissButtons","toggleCollapse","collapseID","startsWith","collapseElement","style","maxHeight","scrollHeight","icon","toggle","initCollapse","initTabs","tabGroup","tabList","tabLinks","tabContents","indicator","isVertical","updateIndicator","link","rect","getBoundingClientRect","parentRect","height","concat","transform","top","width","left","activateTab","item","content","targetContent","getElementById","preventDefault","toggleModal","modalID","modal","isHidden","setTimeout","modalContent","closeOnOutsideClick","removeEventListener","closeModal","initModal","DavidAI","then"],"mappings":"AAAA,IAAIA,YAAY,GAAG,KAAK,CAAC;AACzB,IAAIC,WAAW,GAAG,IAAI,CAAC;;AAEhB,SAASC,YAAYA,GAAG;AAC7B,EAAA,IAAIF,YAAY,EAAE;IAChB,OAAOC,WAAW,CAAC;AACrB,GAAA;EACAD,YAAY,GAAG,IAAI,CAAC;;EAEpBC,WAAW,GAAG,IAAIE,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;IACnD,IAAIC,MAAM,CAACC,MAAM,EAAE;AACjBH,MAAAA,OAAO,CAACE,MAAM,CAACC,MAAM,CAAC,CAAC;AACvB,MAAA,OAAA;AACF,KAAA;AACA,IAAA,IAAIC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC7CF,MAAM,CAACG,GAAG,GAAG,oCAAoC,CAAA;IACjDH,MAAM,CAACI,KAAK,GAAG,IAAI,CAAA;IACnBJ,MAAM,CAACK,MAAM,GAAG,YAAY;MAC1BP,MAAM,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM,IAAID,MAAM,CAACC,MAAM,CAAC;AAC/CH,MAAAA,OAAO,CAACE,MAAM,CAACC,MAAM,CAAC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AE,CAAA;AACdC,EAAAA,QAAQ,EAAE,CAAA;AACViC,EAAAA,SAAS,EAAE,CAAA;;AAEX;AACAnJ,EAAAA,YAAY,EAAE,CACXqJ,IAAI,CAAC,YAAM;AACV1F,IAAAA,aAAa,EAAE,CAAA;AACfC,IAAAA,YAAY,EAAE,CAAA;AACdyB,IAAAA,YAAY,EAAE,CAAA;AAChB,GAAC,CAAC,CAAA,OAAA,CACI,CAAC,UAACP,KAAK,EAAK;AAChBD,IAAAA,OAAO,CAACC,KAAK,CAAC,2BAA2B,EAAEA,KAAK,CAAC,CAAA;AACnD,GAAC,CAAC,CAAA;;AAEJ;EACA1E,MAAM,CAACgJ,OAAO,GAAGA,OAAO,CAAA;AAC1B;;;;"} \ No newline at end of file +{"version":3,"file":"david-ai.esm.js","sources":["../src/utils/loadPopper.js","../src/dropdown/dropdown.js","../src/popover/popover.js","../src/tooltip/tooltip.js","../src/alert/alert.js","../src/collapse/collapse.js","../src/tabs/tabs.js","../src/modal/modal.js","../src/index.js"],"sourcesContent":["var popperLoaded = false; // Singleton flag to track loading state\nvar popperReady = null; // Promise to handle loading Popper.js once\n\nexport function loadPopperJs() {\n if (popperLoaded) {\n return popperReady; // Return the existing Promise if already loading or loaded\n }\n popperLoaded = true; // Mark Popper.js as being loaded\n\n popperReady = new Promise(function (resolve, reject) {\n if (window.Popper) {\n resolve(window.Popper); // If already loaded globally, resolve immediately\n return;\n }\n var script = document.createElement(\"script\");\n script.src = \"https://unpkg.com/@popperjs/core@2\";\n script.defer = true;\n script.onload = function () {\n window.Popper = window.Popper || window.Popper; // Expose Popper globally\n resolve(window.Popper); // Resolve once Popper.js is loaded\n };\n script.onerror = function () {\n reject(new Error(\"Failed to load Popper.js\"));\n };\n document.head.appendChild(script);\n });\n\n return popperReady;\n}\n","// Dropdown component\nimport { loadPopperJs } from '../utils/loadPopper'; // Centralized loader\n\nconst initializedDropdowns = new WeakSet();\n\nexport class Dropdown {\n constructor(dropdownElement) {\n this.dropdown = dropdownElement;\n this.button = this.dropdown.querySelector('[data-dui-toggle=\"dropdown\"]');\n this.menu = this.dropdown.querySelector('[data-dui-role=\"menu\"]');\n this.popperInstance = null;\n\n this.placement = this.dropdown.getAttribute(\"data-dui-placement\") || \"bottom-start\";\n\n this.init();\n }\n\n async init() {\n // Ensure Popper.js is loaded\n await loadPopperJs();\n\n // Initialize Popper.js\n this.popperInstance = Popper.createPopper(this.button, this.menu, {\n placement: this.placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 5] } }],\n });\n\n // Event listeners\n this.button.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n this.toggleDropdown();\n });\n\n document.addEventListener(\"click\", (e) => {\n if (!this.dropdown.contains(e.target)) this.closeDropdown();\n });\n }\n\n toggleDropdown() {\n const isExpanded = this.button.getAttribute(\"aria-expanded\") === \"true\";\n isExpanded ? this.closeDropdown() : this.openDropdown();\n }\n\n openDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"true\");\n this.menu.hidden = false;\n this.menu.classList.remove(\"hidden\");\n this.popperInstance.update();\n }\n\n closeDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"false\");\n this.menu.hidden = true;\n this.menu.classList.add(\"hidden\");\n }\n}\n\nexport function initDropdowns() {\n document.querySelectorAll(\".dropdown\").forEach((dropdownElement) => {\n if (!initializedDropdowns.has(dropdownElement)) {\n new Dropdown(dropdownElement);\n initializedDropdowns.add(dropdownElement);\n }\n });\n}\n","// Popover Component\nimport { loadPopperJs } from '../utils/loadPopper';\n\nconst initializedPopovers = new WeakSet(); // Prevent duplicate initialization\nlet activePopovers = []; // Track active popovers for cleanup\n\nexport function initPopovers() {\n document.querySelectorAll(\"[data-dui-toggle='popover']\").forEach((trigger) => {\n if (initializedPopovers.has(trigger)) return; // Avoid re-initializing\n\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const popoverClasses = trigger.getAttribute(\"data-dui-popover-class\") || \"popover-default\";\n const plainContent = trigger.getAttribute(\"data-dui-content\");\n const isOpenByDefault = trigger.hasAttribute(\"data-dui-open\");\n\n let popoverInstance = null;\n let popoverElement = null;\n let originalContentElement = null;\n\n // Find content element next to the trigger\n const contentElement = trigger.nextElementSibling?.matches(\"[data-dui-popover-content]\")\n ? trigger.nextElementSibling\n : null;\n\n // Function to open the popover\n function openPopover() {\n popoverElement = document.createElement(\"div\");\n popoverElement.className = popoverClasses;\n\n // Use custom HTML content or plain text\n if (contentElement) {\n originalContentElement = contentElement.cloneNode(true);\n originalContentElement.classList.remove(\"hidden\");\n popoverElement.appendChild(originalContentElement);\n } else if (plainContent) {\n popoverElement.textContent = plainContent;\n } else {\n console.error(\"No content provided for popover:\", trigger);\n return;\n }\n\n document.body.appendChild(popoverElement);\n\n popoverInstance = Popper.createPopper(trigger, popoverElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n\n // Track active popovers for cleanup\n activePopovers.push({ trigger, popoverElement, popoverInstance });\n }\n\n // Function to close the popover\n function closePopover() {\n if (popoverInstance) {\n popoverInstance.destroy();\n popoverInstance = null;\n\n if (originalContentElement) {\n originalContentElement.classList.add(\"hidden\");\n }\n\n popoverElement.remove();\n popoverElement = null;\n }\n\n // Remove from active popovers\n activePopovers = activePopovers.filter((p) => p.trigger !== trigger);\n }\n\n // Toggle popover on click\n trigger.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n if (popoverInstance) {\n closePopover();\n } else {\n openPopover();\n }\n });\n\n // Open popover by default if specified\n if (isOpenByDefault) {\n openPopover();\n }\n\n // Mark as initialized\n initializedPopovers.add(trigger);\n });\n}\n\n// Cleanup function to destroy all active popovers\nexport function cleanupPopovers() {\n activePopovers.forEach(({ popoverElement, popoverInstance }) => {\n if (popoverInstance) popoverInstance.destroy();\n if (popoverElement) popoverElement.remove();\n });\n activePopovers = [];\n}\n\n// Combined initialization function\nexport async function loadAndInitPopovers() {\n await loadPopperJs();\n initPopovers();\n}\n\n// Auto-initialize Popovers in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n loadAndInitPopovers();\n}\n","// Tooltip Component\nimport { loadPopperJs } from '../utils/loadPopper';\n\nconst initializedTooltips = new WeakSet(); // Prevent duplicate initialization\nlet activeTooltips = []; // Track active tooltips for cleanup\n\nexport function initTooltips() {\n document.querySelectorAll(\"[data-dui-toggle='tooltip']\").forEach((trigger) => {\n if (initializedTooltips.has(trigger)) return; // Avoid re-initializing\n\n const title = trigger.getAttribute(\"data-dui-title\"); // Plain text content\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const tooltipClasses = trigger.getAttribute(\"data-dui-tooltip-class\") || \"tooltip-default\";\n\n let tooltipInstance = null;\n let tooltipElement = null;\n let customContentElement = null;\n\n // Check for sibling content with custom HTML\n if (trigger.nextElementSibling?.matches(\"[data-dui-tooltip-content]\")) {\n customContentElement = trigger.nextElementSibling;\n }\n\n // Function to show the tooltip\n function showTooltip() {\n tooltipElement = document.createElement(\"div\");\n tooltipElement.className = tooltipClasses;\n\n // Use custom HTML content or plain text\n if (customContentElement) {\n const contentClone = customContentElement.cloneNode(true);\n contentClone.classList.remove(\"hidden\");\n tooltipElement.appendChild(contentClone);\n } else if (title) {\n tooltipElement.textContent = title;\n } else {\n console.warn(\"No tooltip content provided for:\", trigger);\n return;\n }\n\n document.body.appendChild(tooltipElement);\n\n tooltipInstance = Popper.createPopper(trigger, tooltipElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n\n // Track active tooltips for cleanup\n activeTooltips.push({ trigger, tooltipElement, tooltipInstance });\n }\n\n // Function to hide the tooltip\n function hideTooltip() {\n if (tooltipInstance) {\n tooltipInstance.destroy();\n tooltipInstance = null;\n }\n\n if (tooltipElement) {\n tooltipElement.remove();\n tooltipElement = null;\n }\n\n // Remove from active tooltips\n activeTooltips = activeTooltips.filter((t) => t.trigger !== trigger);\n }\n\n // Add event listeners for showing and hiding tooltips\n trigger.addEventListener(\"mouseenter\", showTooltip);\n trigger.addEventListener(\"mouseleave\", hideTooltip);\n\n // Mark as initialized\n initializedTooltips.add(trigger);\n });\n}\n\n// Cleanup function to destroy all active tooltips\nexport function cleanupTooltips() {\n activeTooltips.forEach(({ tooltipElement, tooltipInstance }) => {\n if (tooltipInstance) tooltipInstance.destroy();\n if (tooltipElement) tooltipElement.remove();\n });\n activeTooltips = [];\n}\n\n// Combined initialization function\nexport async function loadAndInitTooltips() {\n await loadPopperJs();\n initTooltips();\n}\n\n// Auto-initialize Tooltips in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n loadAndInitTooltips();\n}\n","// src/alert/alert.js\n\nconst initializedElements = new WeakSet();\n\nexport function closeAlert(event) {\n const button = event.currentTarget;\n const alert = button.closest('[role=\"alert\"]');\n if (alert) {\n alert.remove(); // Remove the alert\n }\n}\n\nexport function initAlert() {\n // Attach event listeners only to buttons that haven't been initialized\n document.querySelectorAll(\"[data-dui-dismiss='alert']\").forEach((button) => {\n if (!initializedElements.has(button)) {\n button.addEventListener(\"click\", closeAlert);\n initializedElements.add(button); // Track this button as initialized\n }\n });\n}\n\n// Auto-initialize if running in a browser environment\nif (typeof window !== 'undefined') {\n initAlert();\n}\n","// Collapse component\nconst initializedElements = new WeakSet();\n\nexport function toggleCollapse(event) {\n const collapseID = event.currentTarget.getAttribute(\"data-dui-target\");\n\n if (collapseID && collapseID.startsWith(\"#\")) {\n const collapseElement = document.querySelector(collapseID);\n const isExpanded =\n event.currentTarget.getAttribute(\"aria-expanded\") === \"true\";\n\n if (collapseElement) {\n // Toggle max-height for collapsible content\n collapseElement.style.maxHeight = isExpanded\n ? \"0\"\n : collapseElement.scrollHeight + \"px\";\n\n // Update aria-expanded attribute\n event.currentTarget.setAttribute(\"aria-expanded\", !isExpanded);\n\n // Toggle rotate-180 class on the icon\n const icon = event.currentTarget.querySelector(\"[data-dui-icon]\");\n if (icon) {\n icon.classList.toggle(\"rotate-180\", !isExpanded);\n }\n }\n }\n}\n\nexport function initCollapse() {\n document\n .querySelectorAll(\"[data-dui-toggle='collapse']\")\n .forEach((button) => {\n if (!initializedElements.has(button)) {\n button.addEventListener(\"click\", toggleCollapse);\n initializedElements.add(button); // Mark as initialized\n }\n });\n}\n\n// Auto-initialize collapsible components in the browser\nif (typeof window !== 'undefined') {\n initCollapse();\n}\n","// Tabs Component\nexport function initTabs() {\n document.querySelectorAll(\".tab-group\").forEach((tabGroup) => {\n const tabList = tabGroup.querySelector(\"[role='tablist']\");\n const tabLinks = tabList.querySelectorAll(\".tab-link\");\n const tabContents = tabGroup.querySelectorAll(\".tab-content\");\n const indicator = tabList.querySelector(\".tab-indicator\");\n const isVertical = tabGroup.getAttribute(\"data-dui-orientation\") === \"vertical\";\n\n function updateIndicator(link) {\n const rect = link.getBoundingClientRect();\n const parentRect = tabList.getBoundingClientRect();\n\n requestAnimationFrame(() => {\n if (isVertical) {\n const offsetY = rect.top - parentRect.top;\n const height = rect.height;\n\n // Apply styles dynamically for vertical orientation\n indicator.style.transform = `translateY(${offsetY}px)`;\n indicator.style.height = `${height}px`;\n } else {\n const offsetX = rect.left - parentRect.left;\n const width = rect.width;\n\n // Apply styles dynamically for horizontal orientation\n indicator.style.transform = `translateX(${offsetX}px)`;\n indicator.style.width = `${width}px`;\n }\n\n // Make the indicator visible\n indicator.classList.remove(\"hidden\");\n indicator.style.opacity = \"1\";\n indicator.style.scale = \"1\";\n });\n }\n\n function activateTab(link) {\n // Deactivate all tabs and hide their content\n tabLinks.forEach((item) => item.classList.remove(\"active\"));\n tabContents.forEach((content) => {\n content.classList.add(\"hidden\");\n content.classList.remove(\"block\");\n });\n\n // Activate the clicked tab\n link.classList.add(\"active\");\n const targetContent = document.getElementById(link.getAttribute(\"data-dui-tab-target\"));\n if (targetContent) {\n targetContent.classList.add(\"block\");\n targetContent.classList.remove(\"hidden\");\n }\n\n // Update the indicator position\n updateIndicator(link);\n }\n\n // Check for the tab with the `active` class and set the indicator initially\n setTimeout(() => {\n const activeLink = tabList.querySelector(\".tab-link.active\");\n if (activeLink) {\n activateTab(activeLink);\n }\n }, 100);\n\n // Initialize click event listeners for each tab\n tabLinks.forEach((link) => {\n link.addEventListener(\"click\", (event) => {\n event.preventDefault(); // Prevent default browser behavior\n activateTab(link); // Activate the clicked tab and update the indicator\n });\n });\n });\n}\n\n// Auto-initialize tabs in the browser\nif (typeof window !== \"undefined\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n initTabs();\n });\n}\n\n\n\n\n\n\n\n\n","// Modal Component\n\nconst initializedModals = new WeakSet();\n\nexport function toggleModal(event) {\n const modalID = event.currentTarget.getAttribute(\"data-dui-target\");\n const modal = document.querySelector(modalID);\n\n if (modal) {\n const isHidden = modal.classList.contains(\"pointer-events-none\");\n modal.classList.toggle(\"opacity-0\", !isHidden);\n\n if (isHidden) {\n modal.classList.remove(\"pointer-events-none\");\n } else {\n setTimeout(() => modal.classList.add(\"pointer-events-none\"), 300);\n }\n\n modal.classList.toggle(\"opacity-100\", isHidden);\n const modalContent = modal.querySelector(isHidden ? \".scale-95\" : \".scale-100\");\n modalContent.classList.toggle(\"scale-95\", !isHidden);\n modalContent.classList.toggle(\"scale-100\", isHidden);\n modal.setAttribute(\"aria-hidden\", !isHidden);\n\n // Add or remove event listener for clicks outside modal content\n if (isHidden) {\n modal.addEventListener(\"click\", closeOnOutsideClick);\n } else {\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n }\n}\n\nexport function closeModal(event) {\n const modal = event.currentTarget.closest(\".fixed\");\n\n if (modal) {\n modal.classList.add(\"opacity-0\");\n modal.classList.remove(\"opacity-100\");\n const modalContent = modal.querySelector(\".scale-100\");\n modalContent.classList.add(\"scale-95\");\n modalContent.classList.remove(\"scale-100\");\n\n setTimeout(() => {\n modal.classList.add(\"pointer-events-none\");\n modal.setAttribute(\"aria-hidden\", \"true\");\n }, 300);\n\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n}\n\nfunction closeOnOutsideClick(event) {\n const modalContent = event.currentTarget.querySelector(\".scale-100, .scale-95\");\n\n if (!modalContent.contains(event.target)) {\n closeModal({ currentTarget: event.currentTarget });\n }\n}\n\nexport function initModal() {\n document.querySelectorAll(\"[data-dui-toggle='modal']\").forEach((trigger) => {\n if (!initializedModals.has(trigger)) {\n trigger.addEventListener(\"click\", toggleModal);\n initializedModals.add(trigger);\n }\n });\n\n document.querySelectorAll(\"[data-dui-dismiss='modal']\").forEach((button) => {\n if (!initializedModals.has(button)) {\n button.addEventListener(\"click\", closeModal);\n initializedModals.add(button);\n }\n });\n}\n\n// Auto-initialize Modals in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n initModal();\n}\n","import { loadPopperJs } from './utils/loadPopper.js';\n\n// Import components\nimport { initDropdowns } from './dropdown/dropdown.js';\nimport { initPopovers, cleanupPopovers } from './popover/popover.js';\nimport { initTooltips, cleanupTooltips } from './tooltip/tooltip.js';\nimport { initAlert } from './alert/alert.js';\nimport { initCollapse } from './collapse/collapse.js';\nimport { initTabs } from './tabs/tabs.js';\nimport { initModal } from './modal/modal.js';\n\n// Export individual components for named imports\nexport {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n cleanupPopovers,\n initTooltips,\n cleanupTooltips,\n initTabs,\n initModal\n};\n\n// Combine all features into a global object for default export\nconst DavidAI = {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n cleanupPopovers,\n initTooltips,\n cleanupTooltips,\n initTabs,\n initModal\n};\n\n// Auto-initialize components in the browser\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n // Initialize Popper-independent components\n initAlert();\n initCollapse();\n initTabs();\n initModal();\n\n // Load Popper.js once, then initialize dependent components\n loadPopperJs()\n .then(() => {\n initDropdowns();\n initPopovers();\n initTooltips();\n })\n .catch((error) => {\n console.error(\"Failed to load Popper.js:\", error);\n });\n\n // Expose DavidAI globally for UMD\n window.DavidAI = DavidAI;\n}\n\nexport default DavidAI;\n"],"names":["popperLoaded","popperReady","loadPopperJs","Promise","resolve","reject","window","Popper","script","document","createElement","src","defer","onload","onerror","Error","head","appendChild","initializedDropdowns","WeakSet","Dropdown","dropdownElement","_classCallCheck","dropdown","button","querySelector","menu","popperInstance","placement","getAttribute","init","_createClass","key","value","_init","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_this","wrap","_callee$","_context","prev","next","createPopper","modifiers","name","options","offset","addEventListener","e","stopPropagation","toggleDropdown","contains","target","closeDropdown","stop","apply","arguments","isExpanded","openDropdown","setAttribute","hidden","classList","remove","update","add","initDropdowns","querySelectorAll","forEach","has","initializedPopovers","activePopovers","initPopovers","trigger","_trigger$nextElementS","popoverClasses","plainContent","isOpenByDefault","hasAttribute","popoverInstance","popoverElement","originalContentElement","contentElement","nextElementSibling","matches","openPopover","className","cloneNode","textContent","console","error","body","push","closePopover","destroy","filter","p","event","cleanupPopovers","_ref","loadAndInitPopovers","_loadAndInitPopovers","initializedTooltips","activeTooltips","initTooltips","title","tooltipClasses","tooltipInstance","tooltipElement","customContentElement","showTooltip","contentClone","warn","hideTooltip","t","cleanupTooltips","loadAndInitTooltips","_loadAndInitTooltips","initializedElements","closeAlert","currentTarget","alert","closest","initAlert","toggleCollapse","collapseID","startsWith","collapseElement","style","maxHeight","scrollHeight","icon","toggle","initCollapse","initTabs","tabGroup","tabList","tabLinks","tabContents","indicator","isVertical","updateIndicator","link","rect","getBoundingClientRect","parentRect","requestAnimationFrame","offsetY","top","height","transform","concat","offsetX","left","width","opacity","scale","activateTab","item","content","targetContent","getElementById","setTimeout","activeLink","preventDefault","initializedModals","toggleModal","modalID","modal","isHidden","modalContent","closeOnOutsideClick","removeEventListener","closeModal","initModal","DavidAI","then"],"mappings":"AAAA,IAAIA,YAAY,GAAG,KAAK,CAAC;AACzB,IAAIC,WAAW,GAAG,IAAI,CAAC;;AAEhB,SAASC,YAAYA,GAAG;AAC7B,EAAA,IAAIF,YAAY,EAAE;IAChB,OAAOC,WAAW,CAAC;AACrB,GAAA;EACAD,YAAY,GAAG,IAAI,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dist/david-ai.js index d5d0ef7..5563357 100644 --- a/packages/dist/david-ai.js +++ b/packages/dist/david-ai.js @@ -33,6 +33,31 @@ return popperReady; } + function asyncGeneratorStep(n, t, e, r, o, a, c) { + try { + var i = n[a](c), + u = i.value; + } catch (n) { + return void e(n); + } + i.done ? t(u) : Promise.resolve(u).then(r, o); + } + function _asyncToGenerator(n) { + return function () { + var t = this, + e = arguments; + return new Promise(function (r, o) { + var a = n.apply(t, e); + function _next(n) { + asyncGeneratorStep(a, r, o, _next, _throw, "next", n); + } + function _throw(n) { + asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); + } + _next(void 0); + }); + }; + } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } @@ -47,6 +72,307 @@ writable: !1 }), e; } + function _regeneratorRuntime() { + _regeneratorRuntime = function () { + return e; + }; + var t, + e = {}, + r = Object.prototype, + n = r.hasOwnProperty, + o = Object.defineProperty || function (t, e, r) { + t[e] = r.value; + }, + i = "function" == typeof Symbol ? Symbol : {}, + a = i.iterator || "@@iterator", + c = i.asyncIterator || "@@asyncIterator", + u = i.toStringTag || "@@toStringTag"; + function define(t, e, r) { + return Object.defineProperty(t, e, { + value: r, + enumerable: !0, + configurable: !0, + writable: !0 + }), t[e]; + } + try { + define({}, ""); + } catch (t) { + define = function (t, e, r) { + return t[e] = r; + }; + } + function wrap(t, e, r, n) { + var i = e && e.prototype instanceof Generator ? e : Generator, + a = Object.create(i.prototype), + c = new Context(n || []); + return o(a, "_invoke", { + value: makeInvokeMethod(t, r, c) + }), a; + } + function tryCatch(t, e, r) { + try { + return { + type: "normal", + arg: t.call(e, r) + }; + } catch (t) { + return { + type: "throw", + arg: t + }; + } + } + e.wrap = wrap; + var h = "suspendedStart", + l = "suspendedYield", + f = "executing", + s = "completed", + y = {}; + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + var p = {}; + define(p, a, function () { + return this; + }); + var d = Object.getPrototypeOf, + v = d && d(d(values([]))); + v && v !== r && n.call(v, a) && (p = v); + var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); + function defineIteratorMethods(t) { + ["next", "throw", "return"].forEach(function (e) { + define(t, e, function (t) { + return this._invoke(e, t); + }); + }); + } + function AsyncIterator(t, e) { + function invoke(r, o, i, a) { + var c = tryCatch(t[r], t, o); + if ("throw" !== c.type) { + var u = c.arg, + h = u.value; + return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { + invoke("next", t, i, a); + }, function (t) { + invoke("throw", t, i, a); + }) : e.resolve(h).then(function (t) { + u.value = t, i(u); + }, function (t) { + return invoke("throw", t, i, a); + }); + } + a(c.arg); + } + var r; + o(this, "_invoke", { + value: function (t, n) { + function callInvokeWithMethodAndArg() { + return new e(function (e, r) { + invoke(t, n, e, r); + }); + } + return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); + } + }); + } + function makeInvokeMethod(e, r, n) { + var o = h; + return function (i, a) { + if (o === f) throw Error("Generator is already running"); + if (o === s) { + if ("throw" === i) throw a; + return { + value: t, + done: !0 + }; + } + for (n.method = i, n.arg = a;;) { + var c = n.delegate; + if (c) { + var u = maybeInvokeDelegate(c, n); + if (u) { + if (u === y) continue; + return u; + } + } + if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { + if (o === h) throw o = s, n.arg; + n.dispatchException(n.arg); + } else "return" === n.method && n.abrupt("return", n.arg); + o = f; + var p = tryCatch(e, r, n); + if ("normal" === p.type) { + if (o = n.done ? s : l, p.arg === y) continue; + return { + value: p.arg, + done: n.done + }; + } + "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); + } + }; + } + function maybeInvokeDelegate(e, r) { + var n = r.method, + o = e.iterator[n]; + if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; + var i = tryCatch(o, e.iterator, r.arg); + if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; + var a = i.arg; + return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); + } + function pushTryEntry(t) { + var e = { + tryLoc: t[0] + }; + 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); + } + function resetTryEntry(t) { + var e = t.completion || {}; + e.type = "normal", delete e.arg, t.completion = e; + } + function Context(t) { + this.tryEntries = [{ + tryLoc: "root" + }], t.forEach(pushTryEntry, this), this.reset(!0); + } + function values(e) { + if (e || "" === e) { + var r = e[a]; + if (r) return r.call(e); + if ("function" == typeof e.next) return e; + if (!isNaN(e.length)) { + var o = -1, + i = function next() { + for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; + return next.value = t, next.done = !0, next; + }; + return i.next = i; + } + } + throw new TypeError(typeof e + " is not iterable"); + } + return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { + value: GeneratorFunctionPrototype, + configurable: !0 + }), o(GeneratorFunctionPrototype, "constructor", { + value: GeneratorFunction, + configurable: !0 + }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { + var e = "function" == typeof t && t.constructor; + return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); + }, e.mark = function (t) { + return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; + }, e.awrap = function (t) { + return { + __await: t + }; + }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { + return this; + }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { + void 0 === i && (i = Promise); + var a = new AsyncIterator(wrap(t, r, n, o), i); + return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { + return t.done ? t.value : a.next(); + }); + }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { + return this; + }), define(g, "toString", function () { + return "[object Generator]"; + }), e.keys = function (t) { + var e = Object(t), + r = []; + for (var n in e) r.push(n); + return r.reverse(), function next() { + for (; r.length;) { + var t = r.pop(); + if (t in e) return next.value = t, next.done = !1, next; + } + return next.done = !0, next; + }; + }, e.values = values, Context.prototype = { + constructor: Context, + reset: function (e) { + if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); + }, + stop: function () { + this.done = !0; + var t = this.tryEntries[0].completion; + if ("throw" === t.type) throw t.arg; + return this.rval; + }, + dispatchException: function (e) { + if (this.done) throw e; + var r = this; + function handle(n, o) { + return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; + } + for (var o = this.tryEntries.length - 1; o >= 0; --o) { + var i = this.tryEntries[o], + a = i.completion; + if ("root" === i.tryLoc) return handle("end"); + if (i.tryLoc <= this.prev) { + var c = n.call(i, "catchLoc"), + u = n.call(i, "finallyLoc"); + if (c && u) { + if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); + if (this.prev < i.finallyLoc) return handle(i.finallyLoc); + } else if (c) { + if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); + } else { + if (!u) throw Error("try statement without catch or finally"); + if (this.prev < i.finallyLoc) return handle(i.finallyLoc); + } + } + } + }, + abrupt: function (t, e) { + for (var r = this.tryEntries.length - 1; r >= 0; --r) { + var o = this.tryEntries[r]; + if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { + var i = o; + break; + } + } + i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); + var a = i ? i.completion : {}; + return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); + }, + complete: function (t, e) { + if ("throw" === t.type) throw t.arg; + return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; + }, + finish: function (t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; + } + }, + catch: function (t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.tryLoc === t) { + var n = r.completion; + if ("throw" === n.type) { + var o = n.arg; + resetTryEntry(r); + } + return o; + } + } + throw Error("illegal catch attempt"); + }, + delegateYield: function (e, r, n) { + return this.delegate = { + iterator: values(e), + resultName: r, + nextLoc: n + }, "next" === this.method && (this.arg = t), y; + } + }, e; + } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; @@ -62,7 +388,7 @@ return "symbol" == typeof i ? i : i + ""; } - // Dropdown component + var initializedDropdowns = new WeakSet(); var Dropdown = /*#__PURE__*/function () { function Dropdown(dropdownElement) { _classCallCheck(this, Dropdown); @@ -70,44 +396,50 @@ this.button = this.dropdown.querySelector('[data-dui-toggle="dropdown"]'); this.menu = this.dropdown.querySelector('[data-dui-role="menu"]'); this.popperInstance = null; - - // Get placement dynamically or default to 'bottom-start' this.placement = this.dropdown.getAttribute("data-dui-placement") || "bottom-start"; this.init(); } return _createClass(Dropdown, [{ key: "init", - value: function init() { - var _this = this; - // Initialize Popper.js - this.popperInstance = Popper.createPopper(this.button, this.menu, { - placement: this.placement, - modifiers: [{ - name: "offset", - options: { - offset: [0, 5] + value: function () { + var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { + var _this = this; + return _regeneratorRuntime().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return loadPopperJs(); + case 2: + // Initialize Popper.js + this.popperInstance = Popper.createPopper(this.button, this.menu, { + placement: this.placement, + modifiers: [{ + name: "offset", + options: { + offset: [0, 5] + } + }] + }); + + // Event listeners + this.button.addEventListener("click", function (e) { + e.stopPropagation(); + _this.toggleDropdown(); + }); + document.addEventListener("click", function (e) { + if (!_this.dropdown.contains(e.target)) _this.closeDropdown(); + }); + case 5: + case "end": + return _context.stop(); } - }] - }); - - // Check for open attribute - if (this.dropdown.hasAttribute("data-dui-open")) { - this.openDropdown(); + }, _callee, this); + })); + function init() { + return _init.apply(this, arguments); } - - // Toggle dropdown on button click - this.button.addEventListener("click", function (e) { - e.stopPropagation(); - _this.toggleDropdown(); - }); - - // Close dropdown on outside click - document.addEventListener("click", function (e) { - if (!_this.dropdown.contains(e.target)) { - _this.closeDropdown(); - } - }); - } + return init; + }() }, { key: "toggleDropdown", value: function toggleDropdown() { @@ -121,7 +453,6 @@ this.menu.hidden = false; this.menu.classList.remove("hidden"); this.popperInstance.update(); - this.closeSiblings(); } }, { key: "closeDropdown", @@ -130,31 +461,25 @@ this.menu.hidden = true; this.menu.classList.add("hidden"); } - }, { - key: "closeSiblings", - value: function closeSiblings() { - var _this2 = this; - var siblingMenus = this.dropdown.parentElement.querySelectorAll('[data-dui-role="menu"]:not(.hidden)'); - siblingMenus.forEach(function (siblingMenu) { - if (siblingMenu !== _this2.menu) { - siblingMenu.classList.add("hidden"); - siblingMenu.parentElement.querySelector('[data-dui-toggle="dropdown"]').setAttribute("aria-expanded", "false"); - } - }); - } }]); }(); function initDropdowns() { document.querySelectorAll(".dropdown").forEach(function (dropdownElement) { - new Dropdown(dropdownElement); + if (!initializedDropdowns.has(dropdownElement)) { + new Dropdown(dropdownElement); + initializedDropdowns.add(dropdownElement); + } }); } - // Popover component + var initializedPopovers = new WeakSet(); // Prevent duplicate initialization + var activePopovers = []; // Track active popovers for cleanup + function initPopovers() { - var popoverTriggers = document.querySelectorAll("[data-dui-toggle='popover']"); - popoverTriggers.forEach(function (trigger) { + document.querySelectorAll("[data-dui-toggle='popover']").forEach(function (trigger) { var _trigger$nextElementS; + if (initializedPopovers.has(trigger)) return; // Avoid re-initializing + var placement = trigger.getAttribute("data-dui-placement") || "top"; var popoverClasses = trigger.getAttribute("data-dui-popover-class") || "popover-default"; var plainContent = trigger.getAttribute("data-dui-content"); @@ -193,9 +518,12 @@ }] }); - // Store references for cleanup - trigger._popoverInstance = popoverInstance; - trigger._popoverElement = popoverElement; + // Track active popovers for cleanup + activePopovers.push({ + trigger: trigger, + popoverElement: popoverElement, + popoverInstance: popoverInstance + }); } // Function to close the popover @@ -209,6 +537,11 @@ popoverElement.remove(); popoverElement = null; } + + // Remove from active popovers + activePopovers = activePopovers.filter(function (p) { + return p.trigger !== trigger; + }); } // Toggle popover on click @@ -225,14 +558,58 @@ if (isOpenByDefault) { openPopover(); } + + // Mark as initialized + initializedPopovers.add(trigger); }); } - // Tooltip component + // Cleanup function to destroy all active popovers + function cleanupPopovers() { + activePopovers.forEach(function (_ref) { + var popoverElement = _ref.popoverElement, + popoverInstance = _ref.popoverInstance; + if (popoverInstance) popoverInstance.destroy(); + if (popoverElement) popoverElement.remove(); + }); + activePopovers = []; + } + + // Combined initialization function + function loadAndInitPopovers() { + return _loadAndInitPopovers.apply(this, arguments); + } + + // Auto-initialize Popovers in the Browser Environment + function _loadAndInitPopovers() { + _loadAndInitPopovers = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { + return _regeneratorRuntime().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return loadPopperJs(); + case 2: + initPopovers(); + case 3: + case "end": + return _context.stop(); + } + }, _callee); + })); + return _loadAndInitPopovers.apply(this, arguments); + } + if (typeof window !== "undefined" && typeof document !== "undefined") { + loadAndInitPopovers(); + } + + var initializedTooltips = new WeakSet(); // Prevent duplicate initialization + var activeTooltips = []; // Track active tooltips for cleanup + function initTooltips() { - var tooltipTriggers = document.querySelectorAll("[data-dui-toggle='tooltip']"); - tooltipTriggers.forEach(function (trigger) { + document.querySelectorAll("[data-dui-toggle='tooltip']").forEach(function (trigger) { var _trigger$nextElementS; + if (initializedTooltips.has(trigger)) return; // Avoid re-initializing + var title = trigger.getAttribute("data-dui-title"); // Plain text content var placement = trigger.getAttribute("data-dui-placement") || "top"; var tooltipClasses = trigger.getAttribute("data-dui-tooltip-class") || "tooltip-default"; @@ -245,10 +622,8 @@ customContentElement = trigger.nextElementSibling; } - // Show the tooltip + // Function to show the tooltip function showTooltip() { - if (tooltipElement) return; // Avoid duplicate tooltips - tooltipElement = document.createElement("div"); tooltipElement.className = tooltipClasses; @@ -264,8 +639,6 @@ return; } document.body.appendChild(tooltipElement); - - // Create Popper.js instance tooltipInstance = Popper.createPopper(trigger, tooltipElement, { placement: placement, modifiers: [{ @@ -275,48 +648,96 @@ } }] }); + + // Track active tooltips for cleanup + activeTooltips.push({ + trigger: trigger, + tooltipElement: tooltipElement, + tooltipInstance: tooltipInstance + }); } - // Hide the tooltip + // Function to hide the tooltip function hideTooltip() { - if (tooltipElement && !trigger.classList.contains("static-tooltip")) { + if (tooltipInstance) { tooltipInstance.destroy(); tooltipInstance = null; + } + if (tooltipElement) { tooltipElement.remove(); tooltipElement = null; } + + // Remove from active tooltips + activeTooltips = activeTooltips.filter(function (t) { + return t.trigger !== trigger; + }); } - // Event Listeners + // Add event listeners for showing and hiding tooltips trigger.addEventListener("mouseenter", showTooltip); trigger.addEventListener("mouseleave", hideTooltip); - // Toggle static tooltips on click - trigger.addEventListener("click", function () { - if (trigger.classList.contains("static-tooltip")) { - trigger.classList.remove("static-tooltip"); - hideTooltip(); - } else { - trigger.classList.add("static-tooltip"); - showTooltip(); - } - }); + // Mark as initialized + initializedTooltips.add(trigger); }); } + // Cleanup function to destroy all active tooltips + function cleanupTooltips() { + activeTooltips.forEach(function (_ref) { + var tooltipElement = _ref.tooltipElement, + tooltipInstance = _ref.tooltipInstance; + if (tooltipInstance) tooltipInstance.destroy(); + if (tooltipElement) tooltipElement.remove(); + }); + activeTooltips = []; + } + + // Combined initialization function + function loadAndInitTooltips() { + return _loadAndInitTooltips.apply(this, arguments); + } + + // Auto-initialize Tooltips in the Browser Environment + function _loadAndInitTooltips() { + _loadAndInitTooltips = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() { + return _regeneratorRuntime().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return loadPopperJs(); + case 2: + initTooltips(); + case 3: + case "end": + return _context.stop(); + } + }, _callee); + })); + return _loadAndInitTooltips.apply(this, arguments); + } + if (typeof window !== "undefined" && typeof document !== "undefined") { + loadAndInitTooltips(); + } + // src/alert/alert.js + var initializedElements$1 = new WeakSet(); function closeAlert(event) { var button = event.currentTarget; var alert = button.closest('[role="alert"]'); if (alert) { - alert.parentNode.removeChild(alert); + alert.remove(); // Remove the alert } } function initAlert() { - var dismissButtons = document.querySelectorAll("[data-dui-dismiss='alert']"); - dismissButtons.forEach(function (button) { - button.addEventListener("click", closeAlert); + // Attach event listeners only to buttons that haven't been initialized + document.querySelectorAll("[data-dui-dismiss='alert']").forEach(function (button) { + if (!initializedElements$1.has(button)) { + button.addEventListener("click", closeAlert); + initializedElements$1.add(button); // Track this button as initialized + } }); } @@ -326,6 +747,7 @@ } // Collapse component + var initializedElements = new WeakSet(); function toggleCollapse(event) { var collapseID = event.currentTarget.getAttribute("data-dui-target"); if (collapseID && collapseID.startsWith("#")) { @@ -348,7 +770,10 @@ } function initCollapse() { document.querySelectorAll("[data-dui-toggle='collapse']").forEach(function (button) { - button.addEventListener("click", toggleCollapse); + if (!initializedElements.has(button)) { + button.addEventListener("click", toggleCollapse); + initializedElements.add(button); // Mark as initialized + } }); } @@ -365,25 +790,34 @@ var tabContents = tabGroup.querySelectorAll(".tab-content"); var indicator = tabList.querySelector(".tab-indicator"); var isVertical = tabGroup.getAttribute("data-dui-orientation") === "vertical"; - - // Function to update the indicator position dynamically function updateIndicator(link) { var rect = link.getBoundingClientRect(); var parentRect = tabList.getBoundingClientRect(); - if (isVertical) { - // For vertical tabs - indicator.style.height = "".concat(rect.height, "px"); - indicator.style.transform = "translateY(".concat(rect.top - parentRect.top, "px)"); - } else { - // For horizontal tabs - indicator.style.width = "".concat(rect.width, "px"); - indicator.style.transform = "translateX(".concat(rect.left - parentRect.left, "px)"); - } - } + requestAnimationFrame(function () { + if (isVertical) { + var offsetY = rect.top - parentRect.top; + var height = rect.height; + + // Apply styles dynamically for vertical orientation + indicator.style.transform = "translateY(".concat(offsetY, "px)"); + indicator.style.height = "".concat(height, "px"); + } else { + var offsetX = rect.left - parentRect.left; + var width = rect.width; + + // Apply styles dynamically for horizontal orientation + indicator.style.transform = "translateX(".concat(offsetX, "px)"); + indicator.style.width = "".concat(width, "px"); + } - // Function to handle tab activation + // Make the indicator visible + indicator.classList.remove("hidden"); + indicator.style.opacity = "1"; + indicator.style.scale = "1"; + }); + } function activateTab(link) { - // Deactivate all tabs and hide contents + // Deactivate all tabs and hide their content tabLinks.forEach(function (item) { return item.classList.remove("active"); }); @@ -404,17 +838,19 @@ updateIndicator(link); } - // Initialize the tabs - tabLinks.forEach(function (link) { - // If a tab is already active, update the indicator - if (link.classList.contains("active")) { - activateTab(link); + // Check for the tab with the `active` class and set the indicator initially + setTimeout(function () { + var activeLink = tabList.querySelector(".tab-link.active"); + if (activeLink) { + activateTab(activeLink); } + }, 100); - // Add click event listener to each tab link + // Initialize click event listeners for each tab + tabLinks.forEach(function (link) { link.addEventListener("click", function (event) { - event.preventDefault(); - activateTab(link); + event.preventDefault(); // Prevent default browser behavior + activateTab(link); // Activate the clicked tab and update the indicator }); }); }); @@ -422,11 +858,14 @@ // Auto-initialize tabs in the browser if (typeof window !== "undefined") { - initTabs(); + document.addEventListener("DOMContentLoaded", function () { + initTabs(); + }); } // Modal Component + var initializedModals = new WeakSet(); function toggleModal(event) { var modalID = event.currentTarget.getAttribute("data-dui-target"); var modal = document.querySelector(modalID); @@ -479,15 +918,21 @@ } function initModal() { document.querySelectorAll("[data-dui-toggle='modal']").forEach(function (trigger) { - trigger.addEventListener("click", toggleModal); + if (!initializedModals.has(trigger)) { + trigger.addEventListener("click", toggleModal); + initializedModals.add(trigger); + } }); document.querySelectorAll("[data-dui-dismiss='modal']").forEach(function (button) { - button.addEventListener("click", closeModal); + if (!initializedModals.has(button)) { + button.addEventListener("click", closeModal); + initializedModals.add(button); + } }); } // Auto-initialize Modals in the Browser Environment - if (typeof window !== "undefined") { + if (typeof window !== "undefined" && typeof document !== "undefined") { initModal(); } @@ -497,13 +942,15 @@ initCollapse: initCollapse, initDropdowns: initDropdowns, initPopovers: initPopovers, + cleanupPopovers: cleanupPopovers, initTooltips: initTooltips, + cleanupTooltips: cleanupTooltips, initTabs: initTabs, initModal: initModal }; // Auto-initialize components in the browser - if (typeof window !== "undefined") { + if (typeof window !== "undefined" && typeof document !== "undefined") { // Initialize Popper-independent components initAlert(); initCollapse(); @@ -523,6 +970,8 @@ window.DavidAI = DavidAI; } + exports.cleanupPopovers = cleanupPopovers; + exports.cleanupTooltips = cleanupTooltips; exports.default = DavidAI; exports.initAlert = initAlert; exports.initCollapse = initCollapse; diff --git a/packages/dist/david-ai.js.map b/packages/dist/david-ai.js.map index 6fd4f58..82ef38c 100644 --- a/packages/dist/david-ai.js.map +++ b/packages/dist/david-ai.js.map @@ -1 +1 @@ -{"version":3,"file":"david-ai.js","sources":["../src/utils/loadPopper.js","../src/dropdown/dropdown.js","../src/popover/popover.js","../src/tooltip/tooltip.js","../src/alert/alert.js","../src/collapse/collapse.js","../src/tabs/tabs.js","../src/modal/modal.js","../src/index.js"],"sourcesContent":["var popperLoaded = false; // Singleton flag to track loading state\nvar popperReady = null; // Promise to handle loading Popper.js once\n\nexport function loadPopperJs() {\n if (popperLoaded) {\n return popperReady; // Return the existing Promise if already loading or loaded\n }\n popperLoaded = true; // Mark Popper.js as being loaded\n\n popperReady = new Promise(function (resolve, reject) {\n if (window.Popper) {\n resolve(window.Popper); // If already loaded globally, resolve immediately\n return;\n }\n var script = document.createElement(\"script\");\n script.src = \"https://unpkg.com/@popperjs/core@2\";\n script.defer = true;\n script.onload = function () {\n window.Popper = window.Popper || window.Popper; // Expose Popper globally\n resolve(window.Popper); // Resolve once Popper.js is loaded\n };\n script.onerror = function () {\n reject(new Error(\"Failed to load Popper.js\"));\n };\n document.head.appendChild(script);\n });\n\n return popperReady;\n}\n","// Dropdown component\nexport class Dropdown {\n constructor(dropdownElement) {\n this.dropdown = dropdownElement;\n this.button = this.dropdown.querySelector('[data-dui-toggle=\"dropdown\"]');\n this.menu = this.dropdown.querySelector('[data-dui-role=\"menu\"]');\n this.popperInstance = null;\n\n // Get placement dynamically or default to 'bottom-start'\n this.placement = this.dropdown.getAttribute(\"data-dui-placement\") || \"bottom-start\";\n\n this.init();\n }\n\n init() {\n // Initialize Popper.js\n this.popperInstance = Popper.createPopper(this.button, this.menu, {\n placement: this.placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 5] } }],\n });\n\n // Check for open attribute\n if (this.dropdown.hasAttribute(\"data-dui-open\")) {\n this.openDropdown();\n }\n\n // Toggle dropdown on button click\n this.button.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n this.toggleDropdown();\n });\n\n // Close dropdown on outside click\n document.addEventListener(\"click\", (e) => {\n if (!this.dropdown.contains(e.target)) {\n this.closeDropdown();\n }\n });\n }\n\n toggleDropdown() {\n const isExpanded = this.button.getAttribute(\"aria-expanded\") === \"true\";\n isExpanded ? this.closeDropdown() : this.openDropdown();\n }\n\n openDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"true\");\n this.menu.hidden = false;\n this.menu.classList.remove(\"hidden\");\n this.popperInstance.update();\n this.closeSiblings();\n }\n\n closeDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"false\");\n this.menu.hidden = true;\n this.menu.classList.add(\"hidden\");\n }\n\n closeSiblings() {\n const siblingMenus = this.dropdown.parentElement.querySelectorAll(\n '[data-dui-role=\"menu\"]:not(.hidden)'\n );\n siblingMenus.forEach((siblingMenu) => {\n if (siblingMenu !== this.menu) {\n siblingMenu.classList.add(\"hidden\");\n siblingMenu.parentElement\n .querySelector('[data-dui-toggle=\"dropdown\"]')\n .setAttribute(\"aria-expanded\", \"false\");\n }\n });\n }\n}\n\nexport function initDropdowns() {\n document.querySelectorAll(\".dropdown\").forEach((dropdownElement) => {\n new Dropdown(dropdownElement);\n });\n}","// Popover component\nexport function initPopovers() {\n const popoverTriggers = document.querySelectorAll(\"[data-dui-toggle='popover']\");\n\n popoverTriggers.forEach(trigger => {\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const popoverClasses = trigger.getAttribute(\"data-dui-popover-class\") || \"popover-default\";\n const plainContent = trigger.getAttribute(\"data-dui-content\");\n const isOpenByDefault = trigger.hasAttribute(\"data-dui-open\");\n\n let popoverInstance = null;\n let popoverElement = null;\n let originalContentElement = null;\n\n // Find content element next to the trigger\n const contentElement = trigger.nextElementSibling?.matches(\"[data-dui-popover-content]\")\n ? trigger.nextElementSibling\n : null;\n\n // Function to open the popover\n function openPopover() {\n popoverElement = document.createElement(\"div\");\n popoverElement.className = popoverClasses;\n\n // Use custom HTML content or plain text\n if (contentElement) {\n originalContentElement = contentElement.cloneNode(true);\n originalContentElement.classList.remove(\"hidden\");\n popoverElement.appendChild(originalContentElement);\n } else if (plainContent) {\n popoverElement.textContent = plainContent;\n } else {\n console.error(\"No content provided for popover:\", trigger);\n return;\n }\n\n document.body.appendChild(popoverElement);\n\n popoverInstance = Popper.createPopper(trigger, popoverElement, {\n placement: placement,\n modifiers: [\n { name: \"offset\", options: { offset: [0, 8] } }\n ],\n });\n\n // Store references for cleanup\n trigger._popoverInstance = popoverInstance;\n trigger._popoverElement = popoverElement;\n }\n\n // Function to close the popover\n function closePopover() {\n if (popoverInstance) {\n popoverInstance.destroy();\n popoverInstance = null;\n\n if (originalContentElement) {\n originalContentElement.classList.add(\"hidden\");\n }\n\n popoverElement.remove();\n popoverElement = null;\n }\n }\n\n // Toggle popover on click\n trigger.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n if (popoverInstance) {\n closePopover();\n } else {\n openPopover();\n }\n });\n\n // Open popover by default if specified\n if (isOpenByDefault) {\n openPopover();\n }\n });\n}\n","// Tooltip component\nexport function initTooltips() {\n const tooltipTriggers = document.querySelectorAll(\"[data-dui-toggle='tooltip']\");\n\n tooltipTriggers.forEach((trigger) => {\n const title = trigger.getAttribute(\"data-dui-title\"); // Plain text content\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const tooltipClasses = trigger.getAttribute(\"data-dui-tooltip-class\") || \"tooltip-default\";\n\n let tooltipInstance = null;\n let tooltipElement = null;\n let customContentElement = null;\n\n // Check for sibling content with custom HTML\n if (trigger.nextElementSibling?.matches(\"[data-dui-tooltip-content]\")) {\n customContentElement = trigger.nextElementSibling;\n }\n\n // Show the tooltip\n function showTooltip() {\n if (tooltipElement) return; // Avoid duplicate tooltips\n\n tooltipElement = document.createElement(\"div\");\n tooltipElement.className = tooltipClasses;\n\n // Use custom HTML content or plain text\n if (customContentElement) {\n const contentClone = customContentElement.cloneNode(true);\n contentClone.classList.remove(\"hidden\");\n tooltipElement.appendChild(contentClone);\n } else if (title) {\n tooltipElement.textContent = title;\n } else {\n console.warn(\"No tooltip content provided for:\", trigger);\n return;\n }\n\n document.body.appendChild(tooltipElement);\n\n // Create Popper.js instance\n tooltipInstance = Popper.createPopper(trigger, tooltipElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n }\n\n // Hide the tooltip\n function hideTooltip() {\n if (tooltipElement && !trigger.classList.contains(\"static-tooltip\")) {\n tooltipInstance.destroy();\n tooltipInstance = null;\n tooltipElement.remove();\n tooltipElement = null;\n }\n }\n\n // Event Listeners\n trigger.addEventListener(\"mouseenter\", showTooltip);\n trigger.addEventListener(\"mouseleave\", hideTooltip);\n\n // Toggle static tooltips on click\n trigger.addEventListener(\"click\", () => {\n if (trigger.classList.contains(\"static-tooltip\")) {\n trigger.classList.remove(\"static-tooltip\");\n hideTooltip();\n } else {\n trigger.classList.add(\"static-tooltip\");\n showTooltip();\n }\n });\n });\n}\n","// src/alert/alert.js\n\nexport function closeAlert(event) {\n const button = event.currentTarget;\n const alert = button.closest('[role=\"alert\"]');\n if (alert) {\n alert.parentNode.removeChild(alert);\n }\n}\n\nexport function initAlert() {\n const dismissButtons = document.querySelectorAll(\"[data-dui-dismiss='alert']\");\n dismissButtons.forEach(button => {\n button.addEventListener(\"click\", closeAlert);\n });\n}\n\n// Auto-initialize if running in a browser environment\nif (typeof window !== 'undefined') {\n initAlert();\n}\n","// Collapse component\nexport function toggleCollapse(event) {\n const collapseID =\n event.currentTarget.getAttribute(\"data-dui-target\")\n\n if (collapseID && collapseID.startsWith(\"#\")) {\n const collapseElement = document.querySelector(collapseID);\n const isExpanded = event.currentTarget.getAttribute(\"aria-expanded\") === \"true\";\n\n if (collapseElement) {\n // Toggle max-height for collapsible content\n collapseElement.style.maxHeight = isExpanded\n ? \"0\"\n : collapseElement.scrollHeight + \"px\";\n\n // Update aria-expanded attribute\n event.currentTarget.setAttribute(\"aria-expanded\", !isExpanded);\n\n // Toggle rotate-180 class on the icon\n const icon = event.currentTarget.querySelector(\"[data-dui-icon]\");\n if (icon) {\n icon.classList.toggle(\"rotate-180\", !isExpanded);\n }\n }\n }\n}\n\nexport function initCollapse() {\n document.querySelectorAll(\"[data-dui-toggle='collapse']\").forEach(button => {\n button.addEventListener(\"click\", toggleCollapse);\n });\n}\n\n// Auto-initialize collapsible components in the browser\nif (typeof window !== 'undefined') {\n initCollapse();\n}\n","// Tabs Component\nexport function initTabs() {\n document.querySelectorAll(\".tab-group\").forEach((tabGroup) => {\n const tabList = tabGroup.querySelector(\"[role='tablist']\");\n const tabLinks = tabList.querySelectorAll(\".tab-link\");\n const tabContents = tabGroup.querySelectorAll(\".tab-content\");\n const indicator = tabList.querySelector(\".tab-indicator\");\n\n const isVertical = tabGroup.getAttribute(\"data-dui-orientation\") === \"vertical\";\n\n // Function to update the indicator position dynamically\n function updateIndicator(link) {\n const rect = link.getBoundingClientRect();\n const parentRect = tabList.getBoundingClientRect();\n\n if (isVertical) {\n // For vertical tabs\n indicator.style.height = `${rect.height}px`;\n indicator.style.transform = `translateY(${rect.top - parentRect.top}px)`;\n } else {\n // For horizontal tabs\n indicator.style.width = `${rect.width}px`;\n indicator.style.transform = `translateX(${rect.left - parentRect.left}px)`;\n }\n }\n\n // Function to handle tab activation\n function activateTab(link) {\n // Deactivate all tabs and hide contents\n tabLinks.forEach((item) => item.classList.remove(\"active\"));\n tabContents.forEach((content) => {\n content.classList.add(\"hidden\");\n content.classList.remove(\"block\");\n });\n\n // Activate the clicked tab\n link.classList.add(\"active\");\n const targetContent = document.getElementById(link.getAttribute(\"data-dui-tab-target\"));\n if (targetContent) {\n targetContent.classList.add(\"block\");\n targetContent.classList.remove(\"hidden\");\n }\n\n // Update the indicator position\n updateIndicator(link);\n }\n\n // Initialize the tabs\n tabLinks.forEach((link) => {\n // If a tab is already active, update the indicator\n if (link.classList.contains(\"active\")) {\n activateTab(link);\n }\n\n // Add click event listener to each tab link\n link.addEventListener(\"click\", (event) => {\n event.preventDefault();\n activateTab(link);\n });\n });\n });\n}\n\n// Auto-initialize tabs in the browser\nif (typeof window !== \"undefined\") {\n initTabs();\n}\n","// Modal Component\n\nexport function toggleModal(event) {\n const modalID = event.currentTarget.getAttribute(\"data-dui-target\");\n const modal = document.querySelector(modalID);\n\n if (modal) {\n const isHidden = modal.classList.contains(\"pointer-events-none\");\n modal.classList.toggle(\"opacity-0\", !isHidden);\n\n if (isHidden) {\n modal.classList.remove(\"pointer-events-none\");\n } else {\n setTimeout(() => modal.classList.add(\"pointer-events-none\"), 300);\n }\n\n modal.classList.toggle(\"opacity-100\", isHidden);\n const modalContent = modal.querySelector(isHidden ? \".scale-95\" : \".scale-100\");\n modalContent.classList.toggle(\"scale-95\", !isHidden);\n modalContent.classList.toggle(\"scale-100\", isHidden);\n modal.setAttribute(\"aria-hidden\", !isHidden);\n\n // Add or remove event listener for clicks outside modal content\n if (isHidden) {\n modal.addEventListener(\"click\", closeOnOutsideClick);\n } else {\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n }\n}\n\nexport function closeModal(event) {\n const modal = event.currentTarget.closest(\".fixed\");\n\n if (modal) {\n modal.classList.add(\"opacity-0\");\n modal.classList.remove(\"opacity-100\");\n const modalContent = modal.querySelector(\".scale-100\");\n modalContent.classList.add(\"scale-95\");\n modalContent.classList.remove(\"scale-100\");\n\n setTimeout(() => {\n modal.classList.add(\"pointer-events-none\");\n modal.setAttribute(\"aria-hidden\", \"true\");\n }, 300);\n\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n}\n\nfunction closeOnOutsideClick(event) {\n const modalContent = event.currentTarget.querySelector(\".scale-100, .scale-95\");\n\n if (!modalContent.contains(event.target)) {\n closeModal({ currentTarget: event.currentTarget });\n }\n}\n\nexport function initModal() {\n document.querySelectorAll(\"[data-dui-toggle='modal']\").forEach((trigger) => {\n trigger.addEventListener(\"click\", toggleModal);\n });\n\n document.querySelectorAll(\"[data-dui-dismiss='modal']\").forEach((button) => {\n button.addEventListener(\"click\", closeModal);\n });\n}\n\n// Auto-initialize Modals in the Browser Environment\nif (typeof window !== \"undefined\") {\n initModal();\n}\n","import { loadPopperJs } from './utils/loadPopper.js';\n\n// Import components\nimport { initDropdowns } from './dropdown/dropdown.js';\nimport { initPopovers } from './popover/popover.js';\nimport { initTooltips } from './tooltip/tooltip.js';\nimport { initAlert } from './alert/alert.js';\nimport { initCollapse } from './collapse/collapse.js';\nimport { initTabs } from './tabs/tabs.js';\nimport { initModal } from './modal/modal.js';\n\n// Export individual components for named imports\nexport {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n initTooltips,\n initTabs,\n initModal\n};\n\n// Combine all features into a global object for default export\nconst DavidAI = {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n initTooltips,\n initTabs,\n initModal\n};\n\n// Auto-initialize components in the browser\nif (typeof window !== \"undefined\") {\n // Initialize Popper-independent components\n initAlert();\n initCollapse();\n initTabs();\n initModal();\n\n // Load Popper.js once, then initialize dependent components\n loadPopperJs()\n .then(() => {\n initDropdowns();\n initPopovers();\n initTooltips();\n })\n .catch((error) => {\n console.error(\"Failed to load Popper.js:\", error);\n });\n\n // Expose DavidAI globally for UMD\n window.DavidAI = DavidAI;\n}\n\nexport default DavidAI;\n"],"names":["popperLoaded","popperReady","loadPopperJs","Promise","resolve","reject","window","Popper","script","document","createElement","src","defer","onload","onerror","Error","head","appendChild","Dropdown","dropdownElement","_classCallCheck","dropdown","button","querySelector","menu","popperInstance","placement","getAttribute","init","_createClass","key","value","_this","createPopper","modifiers","name","options","offset","hasAttribute","openDropdown","addEventListener","e","stopPropagation","toggleDropdown","contains","target","closeDropdown","isExpanded","setAttribute","hidden","classList","remove","update","closeSiblings","add","_this2","siblingMenus","parentElement","querySelectorAll","forEach","siblingMenu","initDropdowns","initPopovers","popoverTriggers","trigger","_trigger$nextElementS","popoverClasses","plainContent","isOpenByDefault","popoverInstance","popoverElement","originalContentElement","contentElement","nextElementSibling","matches","openPopover","className","cloneNode","textContent","console","error","body","_popoverInstance","_popoverElement","closePopover","destroy","event","initTooltips","tooltipTriggers","title","tooltipClasses","tooltipInstance","tooltipElement","customContentElement","showTooltip","contentClone","warn","hideTooltip","closeAlert","currentTarget","alert","closest","parentNode","removeChild","initAlert","dismissButtons","toggleCollapse","collapseID","startsWith","collapseElement","style","maxHeight","scrollHeight","icon","toggle","initCollapse","initTabs","tabGroup","tabList","tabLinks","tabContents","indicator","isVertical","updateIndicator","link","rect","getBoundingClientRect","parentRect","height","concat","transform","top","width","left","activateTab","item","content","targetContent","getElementById","preventDefault","toggleModal","modalID","modal","isHidden","setTimeout","modalContent","closeOnOutsideClick","removeEventListener","closeModal","initModal","DavidAI","then"],"mappings":";;;;;;EAAA,IAAIA,YAAY,GAAG,KAAK,CAAC;EACzB,IAAIC,WAAW,GAAG,IAAI,CAAC;;EAEhB,SAASC,YAAYA,GAAG;EAC7B,EAAA,IAAIF,YAAY,EAAE;MAChB,OAAOC,WAAW,CAAC;EACrB,GAAA;IACAD,YAAY,GAAG,IAAI,CAAC;;IAEpBC,WAAW,GAAG,IAAIE,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;MACnD,IAAIC,MAAM,CAACC,MAAM,EAAE;EACjBH,MAAAA,OAAO,CAACE,MAAM,CAACC,MAAM,CAAC,CAAC;EACvB,MAAA,OAAA;EACF,KAAA;EACA,IAAA,IAAIC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC,CAAA;MAC7CF,MAAM,CAACG,GAAG,GAAG,oCAAoC,CAAA;MACjDH,MAAM,CAACI,KAAK,GAAG,IAAI,CAAA;MACnBJ,MAAM,CAACK,MAAM,GAAG,YAAY;QAC1BP,MAAM,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM,IAAID,MAAM,CAACC,MAAM,CAAC;EAC/CH,MAAAA,OAAO,CAACE,MAAM,CAACC,MAAM,CAAC,CAAC;OACxB,CAAA;MACDC,MAAM,CAACM,OAAO,GAAG,YAAY;EAC3BT,MAAAA,MAAM,CAAC,IAAIU,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAA;OAC9C,CAAA;EACDN,IAAAA,QAAQ,CAACO,IAAI,CAACC,WAAW,CAACT,MAAM,CAAC,CAAA;EACnC,GAAC,CAAC,CAAA;EAEF,EAAA,OAAOP,WAAW,CAAA;EACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EC5BA;EACA,IAAaiB,QAAQ,gBAAA,YAAA;IACnB,SAAAA,QAAAA,CAAYC,eAAe,EAAE;EAAAC,IAAAA,eAAA,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AACgJ,OAAO,GAAGA,OAAO,CAAA;EAC1B;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"david-ai.js","sources":["../src/utils/loadPopper.js","../src/dropdown/dropdown.js","../src/popover/popover.js","../src/tooltip/tooltip.js","../src/alert/alert.js","../src/collapse/collapse.js","../src/tabs/tabs.js","../src/modal/modal.js","../src/index.js"],"sourcesContent":["var popperLoaded = false; // Singleton flag to track loading state\nvar popperReady = null; // Promise to handle loading Popper.js once\n\nexport function loadPopperJs() {\n if (popperLoaded) {\n return popperReady; // Return the existing Promise if already loading or loaded\n }\n popperLoaded = true; // Mark Popper.js as being loaded\n\n popperReady = new Promise(function (resolve, reject) {\n if (window.Popper) {\n resolve(window.Popper); // If already loaded globally, resolve immediately\n return;\n }\n var script = document.createElement(\"script\");\n script.src = \"https://unpkg.com/@popperjs/core@2\";\n script.defer = true;\n script.onload = function () {\n window.Popper = window.Popper || window.Popper; // Expose Popper globally\n resolve(window.Popper); // Resolve once Popper.js is loaded\n };\n script.onerror = function () {\n reject(new Error(\"Failed to load Popper.js\"));\n };\n document.head.appendChild(script);\n });\n\n return popperReady;\n}\n","// Dropdown component\nimport { loadPopperJs } from '../utils/loadPopper'; // Centralized loader\n\nconst initializedDropdowns = new WeakSet();\n\nexport class Dropdown {\n constructor(dropdownElement) {\n this.dropdown = dropdownElement;\n this.button = this.dropdown.querySelector('[data-dui-toggle=\"dropdown\"]');\n this.menu = this.dropdown.querySelector('[data-dui-role=\"menu\"]');\n this.popperInstance = null;\n\n this.placement = this.dropdown.getAttribute(\"data-dui-placement\") || \"bottom-start\";\n\n this.init();\n }\n\n async init() {\n // Ensure Popper.js is loaded\n await loadPopperJs();\n\n // Initialize Popper.js\n this.popperInstance = Popper.createPopper(this.button, this.menu, {\n placement: this.placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 5] } }],\n });\n\n // Event listeners\n this.button.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n this.toggleDropdown();\n });\n\n document.addEventListener(\"click\", (e) => {\n if (!this.dropdown.contains(e.target)) this.closeDropdown();\n });\n }\n\n toggleDropdown() {\n const isExpanded = this.button.getAttribute(\"aria-expanded\") === \"true\";\n isExpanded ? this.closeDropdown() : this.openDropdown();\n }\n\n openDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"true\");\n this.menu.hidden = false;\n this.menu.classList.remove(\"hidden\");\n this.popperInstance.update();\n }\n\n closeDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"false\");\n this.menu.hidden = true;\n this.menu.classList.add(\"hidden\");\n }\n}\n\nexport function initDropdowns() {\n document.querySelectorAll(\".dropdown\").forEach((dropdownElement) => {\n if (!initializedDropdowns.has(dropdownElement)) {\n new Dropdown(dropdownElement);\n initializedDropdowns.add(dropdownElement);\n }\n });\n}\n","// Popover Component\nimport { loadPopperJs } from '../utils/loadPopper';\n\nconst initializedPopovers = new WeakSet(); // Prevent duplicate initialization\nlet activePopovers = []; // Track active popovers for cleanup\n\nexport function initPopovers() {\n document.querySelectorAll(\"[data-dui-toggle='popover']\").forEach((trigger) => {\n if (initializedPopovers.has(trigger)) return; // Avoid re-initializing\n\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const popoverClasses = trigger.getAttribute(\"data-dui-popover-class\") || \"popover-default\";\n const plainContent = trigger.getAttribute(\"data-dui-content\");\n const isOpenByDefault = trigger.hasAttribute(\"data-dui-open\");\n\n let popoverInstance = null;\n let popoverElement = null;\n let originalContentElement = null;\n\n // Find content element next to the trigger\n const contentElement = trigger.nextElementSibling?.matches(\"[data-dui-popover-content]\")\n ? trigger.nextElementSibling\n : null;\n\n // Function to open the popover\n function openPopover() {\n popoverElement = document.createElement(\"div\");\n popoverElement.className = popoverClasses;\n\n // Use custom HTML content or plain text\n if (contentElement) {\n originalContentElement = contentElement.cloneNode(true);\n originalContentElement.classList.remove(\"hidden\");\n popoverElement.appendChild(originalContentElement);\n } else if (plainContent) {\n popoverElement.textContent = plainContent;\n } else {\n console.error(\"No content provided for popover:\", trigger);\n return;\n }\n\n document.body.appendChild(popoverElement);\n\n popoverInstance = Popper.createPopper(trigger, popoverElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n\n // Track active popovers for cleanup\n activePopovers.push({ trigger, popoverElement, popoverInstance });\n }\n\n // Function to close the popover\n function closePopover() {\n if (popoverInstance) {\n popoverInstance.destroy();\n popoverInstance = null;\n\n if (originalContentElement) {\n originalContentElement.classList.add(\"hidden\");\n }\n\n popoverElement.remove();\n popoverElement = null;\n }\n\n // Remove from active popovers\n activePopovers = activePopovers.filter((p) => p.trigger !== trigger);\n }\n\n // Toggle popover on click\n trigger.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n if (popoverInstance) {\n closePopover();\n } else {\n openPopover();\n }\n });\n\n // Open popover by default if specified\n if (isOpenByDefault) {\n openPopover();\n }\n\n // Mark as initialized\n initializedPopovers.add(trigger);\n });\n}\n\n// Cleanup function to destroy all active popovers\nexport function cleanupPopovers() {\n activePopovers.forEach(({ popoverElement, popoverInstance }) => {\n if (popoverInstance) popoverInstance.destroy();\n if (popoverElement) popoverElement.remove();\n });\n activePopovers = [];\n}\n\n// Combined initialization function\nexport async function loadAndInitPopovers() {\n await loadPopperJs();\n initPopovers();\n}\n\n// Auto-initialize Popovers in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n loadAndInitPopovers();\n}\n","// Tooltip Component\nimport { loadPopperJs } from '../utils/loadPopper';\n\nconst initializedTooltips = new WeakSet(); // Prevent duplicate initialization\nlet activeTooltips = []; // Track active tooltips for cleanup\n\nexport function initTooltips() {\n document.querySelectorAll(\"[data-dui-toggle='tooltip']\").forEach((trigger) => {\n if (initializedTooltips.has(trigger)) return; // Avoid re-initializing\n\n const title = trigger.getAttribute(\"data-dui-title\"); // Plain text content\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const tooltipClasses = trigger.getAttribute(\"data-dui-tooltip-class\") || \"tooltip-default\";\n\n let tooltipInstance = null;\n let tooltipElement = null;\n let customContentElement = null;\n\n // Check for sibling content with custom HTML\n if (trigger.nextElementSibling?.matches(\"[data-dui-tooltip-content]\")) {\n customContentElement = trigger.nextElementSibling;\n }\n\n // Function to show the tooltip\n function showTooltip() {\n tooltipElement = document.createElement(\"div\");\n tooltipElement.className = tooltipClasses;\n\n // Use custom HTML content or plain text\n if (customContentElement) {\n const contentClone = customContentElement.cloneNode(true);\n contentClone.classList.remove(\"hidden\");\n tooltipElement.appendChild(contentClone);\n } else if (title) {\n tooltipElement.textContent = title;\n } else {\n console.warn(\"No tooltip content provided for:\", trigger);\n return;\n }\n\n document.body.appendChild(tooltipElement);\n\n tooltipInstance = Popper.createPopper(trigger, tooltipElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n\n // Track active tooltips for cleanup\n activeTooltips.push({ trigger, tooltipElement, tooltipInstance });\n }\n\n // Function to hide the tooltip\n function hideTooltip() {\n if (tooltipInstance) {\n tooltipInstance.destroy();\n tooltipInstance = null;\n }\n\n if (tooltipElement) {\n tooltipElement.remove();\n tooltipElement = null;\n }\n\n // Remove from active tooltips\n activeTooltips = activeTooltips.filter((t) => t.trigger !== trigger);\n }\n\n // Add event listeners for showing and hiding tooltips\n trigger.addEventListener(\"mouseenter\", showTooltip);\n trigger.addEventListener(\"mouseleave\", hideTooltip);\n\n // Mark as initialized\n initializedTooltips.add(trigger);\n });\n}\n\n// Cleanup function to destroy all active tooltips\nexport function cleanupTooltips() {\n activeTooltips.forEach(({ tooltipElement, tooltipInstance }) => {\n if (tooltipInstance) tooltipInstance.destroy();\n if (tooltipElement) tooltipElement.remove();\n });\n activeTooltips = [];\n}\n\n// Combined initialization function\nexport async function loadAndInitTooltips() {\n await loadPopperJs();\n initTooltips();\n}\n\n// Auto-initialize Tooltips in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n loadAndInitTooltips();\n}\n","// src/alert/alert.js\n\nconst initializedElements = new WeakSet();\n\nexport function closeAlert(event) {\n const button = event.currentTarget;\n const alert = button.closest('[role=\"alert\"]');\n if (alert) {\n alert.remove(); // Remove the alert\n }\n}\n\nexport function initAlert() {\n // Attach event listeners only to buttons that haven't been initialized\n document.querySelectorAll(\"[data-dui-dismiss='alert']\").forEach((button) => {\n if (!initializedElements.has(button)) {\n button.addEventListener(\"click\", closeAlert);\n initializedElements.add(button); // Track this button as initialized\n }\n });\n}\n\n// Auto-initialize if running in a browser environment\nif (typeof window !== 'undefined') {\n initAlert();\n}\n","// Collapse component\nconst initializedElements = new WeakSet();\n\nexport function toggleCollapse(event) {\n const collapseID = event.currentTarget.getAttribute(\"data-dui-target\");\n\n if (collapseID && collapseID.startsWith(\"#\")) {\n const collapseElement = document.querySelector(collapseID);\n const isExpanded =\n event.currentTarget.getAttribute(\"aria-expanded\") === \"true\";\n\n if (collapseElement) {\n // Toggle max-height for collapsible content\n collapseElement.style.maxHeight = isExpanded\n ? \"0\"\n : collapseElement.scrollHeight + \"px\";\n\n // Update aria-expanded attribute\n event.currentTarget.setAttribute(\"aria-expanded\", !isExpanded);\n\n // Toggle rotate-180 class on the icon\n const icon = event.currentTarget.querySelector(\"[data-dui-icon]\");\n if (icon) {\n icon.classList.toggle(\"rotate-180\", !isExpanded);\n }\n }\n }\n}\n\nexport function initCollapse() {\n document\n .querySelectorAll(\"[data-dui-toggle='collapse']\")\n .forEach((button) => {\n if (!initializedElements.has(button)) {\n button.addEventListener(\"click\", toggleCollapse);\n initializedElements.add(button); // Mark as initialized\n }\n });\n}\n\n// Auto-initialize collapsible components in the browser\nif (typeof window !== 'undefined') {\n initCollapse();\n}\n","// Tabs Component\nexport function initTabs() {\n document.querySelectorAll(\".tab-group\").forEach((tabGroup) => {\n const tabList = tabGroup.querySelector(\"[role='tablist']\");\n const tabLinks = tabList.querySelectorAll(\".tab-link\");\n const tabContents = tabGroup.querySelectorAll(\".tab-content\");\n const indicator = tabList.querySelector(\".tab-indicator\");\n const isVertical = tabGroup.getAttribute(\"data-dui-orientation\") === \"vertical\";\n\n function updateIndicator(link) {\n const rect = link.getBoundingClientRect();\n const parentRect = tabList.getBoundingClientRect();\n\n requestAnimationFrame(() => {\n if (isVertical) {\n const offsetY = rect.top - parentRect.top;\n const height = rect.height;\n\n // Apply styles dynamically for vertical orientation\n indicator.style.transform = `translateY(${offsetY}px)`;\n indicator.style.height = `${height}px`;\n } else {\n const offsetX = rect.left - parentRect.left;\n const width = rect.width;\n\n // Apply styles dynamically for horizontal orientation\n indicator.style.transform = `translateX(${offsetX}px)`;\n indicator.style.width = `${width}px`;\n }\n\n // Make the indicator visible\n indicator.classList.remove(\"hidden\");\n indicator.style.opacity = \"1\";\n indicator.style.scale = \"1\";\n });\n }\n\n function activateTab(link) {\n // Deactivate all tabs and hide their content\n tabLinks.forEach((item) => item.classList.remove(\"active\"));\n tabContents.forEach((content) => {\n content.classList.add(\"hidden\");\n content.classList.remove(\"block\");\n });\n\n // Activate the clicked tab\n link.classList.add(\"active\");\n const targetContent = document.getElementById(link.getAttribute(\"data-dui-tab-target\"));\n if (targetContent) {\n targetContent.classList.add(\"block\");\n targetContent.classList.remove(\"hidden\");\n }\n\n // Update the indicator position\n updateIndicator(link);\n }\n\n // Check for the tab with the `active` class and set the indicator initially\n setTimeout(() => {\n const activeLink = tabList.querySelector(\".tab-link.active\");\n if (activeLink) {\n activateTab(activeLink);\n }\n }, 100);\n\n // Initialize click event listeners for each tab\n tabLinks.forEach((link) => {\n link.addEventListener(\"click\", (event) => {\n event.preventDefault(); // Prevent default browser behavior\n activateTab(link); // Activate the clicked tab and update the indicator\n });\n });\n });\n}\n\n// Auto-initialize tabs in the browser\nif (typeof window !== \"undefined\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n initTabs();\n });\n}\n\n\n\n\n\n\n\n\n","// Modal Component\n\nconst initializedModals = new WeakSet();\n\nexport function toggleModal(event) {\n const modalID = event.currentTarget.getAttribute(\"data-dui-target\");\n const modal = document.querySelector(modalID);\n\n if (modal) {\n const isHidden = modal.classList.contains(\"pointer-events-none\");\n modal.classList.toggle(\"opacity-0\", !isHidden);\n\n if (isHidden) {\n modal.classList.remove(\"pointer-events-none\");\n } else {\n setTimeout(() => modal.classList.add(\"pointer-events-none\"), 300);\n }\n\n modal.classList.toggle(\"opacity-100\", isHidden);\n const modalContent = modal.querySelector(isHidden ? \".scale-95\" : \".scale-100\");\n modalContent.classList.toggle(\"scale-95\", !isHidden);\n modalContent.classList.toggle(\"scale-100\", isHidden);\n modal.setAttribute(\"aria-hidden\", !isHidden);\n\n // Add or remove event listener for clicks outside modal content\n if (isHidden) {\n modal.addEventListener(\"click\", closeOnOutsideClick);\n } else {\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n }\n}\n\nexport function closeModal(event) {\n const modal = event.currentTarget.closest(\".fixed\");\n\n if (modal) {\n modal.classList.add(\"opacity-0\");\n modal.classList.remove(\"opacity-100\");\n const modalContent = modal.querySelector(\".scale-100\");\n modalContent.classList.add(\"scale-95\");\n modalContent.classList.remove(\"scale-100\");\n\n setTimeout(() => {\n modal.classList.add(\"pointer-events-none\");\n modal.setAttribute(\"aria-hidden\", \"true\");\n }, 300);\n\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n}\n\nfunction closeOnOutsideClick(event) {\n const modalContent = event.currentTarget.querySelector(\".scale-100, .scale-95\");\n\n if (!modalContent.contains(event.target)) {\n closeModal({ currentTarget: event.currentTarget });\n }\n}\n\nexport function initModal() {\n document.querySelectorAll(\"[data-dui-toggle='modal']\").forEach((trigger) => {\n if (!initializedModals.has(trigger)) {\n trigger.addEventListener(\"click\", toggleModal);\n initializedModals.add(trigger);\n }\n });\n\n document.querySelectorAll(\"[data-dui-dismiss='modal']\").forEach((button) => {\n if (!initializedModals.has(button)) {\n button.addEventListener(\"click\", closeModal);\n initializedModals.add(button);\n }\n });\n}\n\n// Auto-initialize Modals in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n initModal();\n}\n","import { loadPopperJs } from './utils/loadPopper.js';\n\n// Import components\nimport { initDropdowns } from './dropdown/dropdown.js';\nimport { initPopovers, cleanupPopovers } from './popover/popover.js';\nimport { initTooltips, cleanupTooltips } from './tooltip/tooltip.js';\nimport { initAlert } from './alert/alert.js';\nimport { initCollapse } from './collapse/collapse.js';\nimport { initTabs } from './tabs/tabs.js';\nimport { initModal } from './modal/modal.js';\n\n// Export individual components for named imports\nexport {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n cleanupPopovers,\n initTooltips,\n cleanupTooltips,\n initTabs,\n initModal\n};\n\n// Combine all features into a global object for default export\nconst DavidAI = {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n cleanupPopovers,\n initTooltips,\n cleanupTooltips,\n initTabs,\n initModal\n};\n\n// Auto-initialize components in the browser\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n // Initialize Popper-independent components\n initAlert();\n initCollapse();\n initTabs();\n initModal();\n\n // Load Popper.js once, then initialize dependent components\n loadPopperJs()\n .then(() => {\n initDropdowns();\n initPopovers();\n initTooltips();\n })\n .catch((error) => {\n console.error(\"Failed to load Popper.js:\", error);\n });\n\n // Expose DavidAI globally for UMD\n window.DavidAI = DavidAI;\n}\n\nexport default DavidAI;\n"],"names":["popperLoaded","popperReady","loadPopperJs","Promise","resolve","reject","window","Popper","script","document","createElement","src","defer","onload","onerror","Error","head","appendChild","initializedDropdowns","WeakSet","Dropdown","dropdownElement","_classCallCheck","dropdown","button","querySelector","menu","popperInstance","placement","getAttribute","init","_createClass","key","value","_init","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_this","wrap","_callee$","_context","prev","next","createPopper","modifiers","name","options","offset","addEventListener","e","stopPropagation","toggleDropdown","contains","target","closeDropdown","stop","apply","arguments","isExpanded","openDropdown","setAttribute","hidden","classList","remove","update","add","initDropdowns","querySelectorAll","forEach","has","initializedPopovers","activePopovers","initPopovers","trigger","_trigger$nextElementS","popoverClasses","plainContent","isOpenByDefault","hasAttribute","popoverInstance","popoverElement","originalContentElement","contentElement","nextElementSibling","matches","openPopover","className","cloneNode","textContent","console","error","body","push","closePopover","destroy","filter","p","event","cleanupPopovers","_ref","loadAndInitPopovers","_loadAndInitPopovers","initializedTooltips","activeTooltips","initTooltips","title","tooltipClasses","tooltipInstance","tooltipElement","customContentElement","showTooltip","contentClone","warn","hideTooltip","t","cleanupTooltips","loadAndInitTooltips","_loadAndInitTooltips","initializedElements","closeAlert","currentTarget","alert","closest","initAlert","toggleCollapse","collapseID","startsWith","collapseElement","style","maxHeight","scrollHeight","icon","toggle","initCollapse","initTabs","tabGroup","tabList","tabLinks","tabContents","indicator","isVertical","updateIndicator","link","rect","getBoundingClientRect","parentRect","requestAnimationFrame","offsetY","top","height","transform","concat","offsetX","left","width","opacity","scale","activateTab","item","content","targetContent","getElementById","setTimeout","activeLink","preventDefault","initializedModals","toggleModal","modalID","modal","isHidden","modalContent","closeOnOutsideClick","removeEventListener","closeModal","initModal","DavidAI","then"],"mappings":";;;;;;EAAA,IAAIA,YAAY,GAAG,KAAK,CAAC;EACzB,IAAIC,WAAW,GAAG,IAAI,CAAC;;EAEhB,SAASC,YAAYA,GAAG;EAC7B,EAAA,IAAIF,YAAY,EAAE;MAChB,OAAOC,WAAW,CAAC;EACrB,GAAA;IACAD,YAAY,GAAG,IAAI,CAAC;;IAEpBC,WAAW,GAAG,IAAIE,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;MACnD,IAAIC,MAAM,CAACC,MAAM,EAAE;EACjBH,MAAAA,OAAO,CAACE,MAAM,CAACC,MAAM,CAAC,CAAC;EACvB,MAAA,OAAA;EACF,KAAA;EACA,IAAA,IAAIC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC,CAAA;MAC7CF,MAAM,CAACG,GAAG,GAAG,oCAAoC,CAAA;MACjDH,MAAM,CAACI,KAAK,GAAG,IAAI,CAAA;MACnBJ,MAAM,CAACK,MA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ACbM,EAAAA,YAAY,EAAZA,YAAY;EACZ0B,EAAAA,eAAe,EAAfA,eAAe;EACfM,EAAAA,YAAY,EAAZA,YAAY;EACZW,EAAAA,eAAe,EAAfA,eAAe;EACfmB,EAAAA,QAAQ,EAARA,QAAQ;EACRwC,EAAAA,SAAS,EAATA,SAAAA;EACF,EAAC;;EAED;EACA,IAAI,OAAO1K,MAAM,KAAK,WAAW,IAAI,OAAOG,QAAQ,KAAK,WAAW,EAAE;EACpE;EACAoH,EAAAA,SAAS,EAAE,CAAA;EACXU,EAAAA,YAAY,EAAE,CAAA;EACdC,EAAAA,QAAQ,EAAE,CAAA;EACVwC,EAAAA,SAAS,EAAE,CAAA;;EAEX;EACA9K,EAAAA,YAAY,EAAE,CACXgL,IAAI,CAAC,YAAM;EACV9G,IAAAA,aAAa,EAAE,CAAA;EACfM,IAAAA,YAAY,EAAE,CAAA;EACdgC,IAAAA,YAAY,EAAE,CAAA;EAChB,GAAC,CAAC,CAAA,OAAA,CACI,CAAC,UAACd,KAAK,EAAK;EAChBD,IAAAA,OAAO,CAACC,KAAK,CAAC,2BAA2B,EAAEA,KAAK,CAAC,CAAA;EACnD,GAAC,CAAC,CAAA;;EAEJ;IACAtF,MAAM,CAAC2K,OAAO,GAAGA,OAAO,CAAA;EAC1B;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/packages/dist/david-ai.min.js b/packages/dist/david-ai.min.js index e76e64a..e8f6fa5 100644 --- a/packages/dist/david-ai.min.js +++ b/packages/dist/david-ai.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).DavidAI={})}(this,(function(t){"use strict";var e=!1,n=null;function o(t,e){for(var n=0;n=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),q(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;q(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:_(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function u(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var s=new WeakSet,l=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dropdown=e,this.button=this.dropdown.querySelector('[data-dui-toggle="dropdown"]'),this.menu=this.dropdown.querySelector('[data-dui-role="menu"]'),this.popperInstance=null,this.placement=this.dropdown.getAttribute("data-dui-placement")||"bottom-start",this.init()},e=[{key:"init",value:(o=i(c().mark((function t(){var e=this;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r();case 2:this.popperInstance=Popper.createPopper(this.button,this.menu,{placement:this.placement,modifiers:[{name:"offset",options:{offset:[0,5]}}]}),this.button.addEventListener("click",(function(t){t.stopPropagation(),e.toggleDropdown()})),document.addEventListener("click",(function(t){e.dropdown.contains(t.target)||e.closeDropdown()}));case 5:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"toggleDropdown",value:function(){"true"===this.button.getAttribute("aria-expanded")?this.closeDropdown():this.openDropdown()}},{key:"openDropdown",value:function(){this.button.setAttribute("aria-expanded","true"),this.menu.hidden=!1,this.menu.classList.remove("hidden"),this.popperInstance.update()}},{key:"closeDropdown",value:function(){this.button.setAttribute("aria-expanded","false"),this.menu.hidden=!0,this.menu.classList.add("hidden")}}],e&&a(t.prototype,e),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,o}();function d(){document.querySelectorAll(".dropdown").forEach((function(t){s.has(t)||(new l(t),s.add(t))}))}var f=new WeakSet,p=[];function h(){document.querySelectorAll("[data-dui-toggle='popover']").forEach((function(t){var e;if(!f.has(t)){var n=t.getAttribute("data-dui-placement")||"top",r=t.getAttribute("data-dui-popover-class")||"popover-default",o=t.getAttribute("data-dui-content"),i=t.hasAttribute("data-dui-open"),a=null,c=null,u=null,s=null!==(e=t.nextElementSibling)&&void 0!==e&&e.matches("[data-dui-popover-content]")?t.nextElementSibling:null;t.addEventListener("click",(function(e){e.stopPropagation(),a?(a&&(a.destroy(),a=null,u&&u.classList.add("hidden"),c.remove(),c=null),p=p.filter((function(e){return e.trigger!==t}))):l()})),i&&l(),f.add(t)}function l(){if((c=document.createElement("div")).className=r,s)(u=s.cloneNode(!0)).classList.remove("hidden"),c.appendChild(u);else{if(!o)return void console.error("No content provided for popover:",t);c.textContent=o}document.body.appendChild(c),a=Popper.createPopper(t,c,{placement:n,modifiers:[{name:"offset",options:{offset:[0,8]}}]}),p.push({trigger:t,popoverElement:c,popoverInstance:a})}}))}function v(){p.forEach((function(t){var e=t.popoverElement,n=t.popoverInstance;n&&n.destroy(),e&&e.remove()})),p=[]}function y(){return(y=i(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r();case 2:h();case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}"undefined"!=typeof window&&"undefined"!=typeof document&&function(){y.apply(this,arguments)}();var m=new WeakSet,g=[];function w(){document.querySelectorAll("[data-dui-toggle='tooltip']").forEach((function(t){var e;if(!m.has(t)){var n=t.getAttribute("data-dui-title"),r=t.getAttribute("data-dui-placement")||"top",o=t.getAttribute("data-dui-tooltip-class")||"tooltip-default",i=null,a=null,c=null;null!==(e=t.nextElementSibling)&&void 0!==e&&e.matches("[data-dui-tooltip-content]")&&(c=t.nextElementSibling),t.addEventListener("mouseenter",(function(){if((a=document.createElement("div")).className=o,c){var e=c.cloneNode(!0);e.classList.remove("hidden"),a.appendChild(e)}else{if(!n)return void console.warn("No tooltip content provided for:",t);a.textContent=n}document.body.appendChild(a),i=Popper.createPopper(t,a,{placement:r,modifiers:[{name:"offset",options:{offset:[0,8]}}]}),g.push({trigger:t,tooltipElement:a,tooltipInstance:i})})),t.addEventListener("mouseleave",(function(){i&&(i.destroy(),i=null),a&&(a.remove(),a=null),g=g.filter((function(e){return e.trigger!==t}))})),m.add(t)}}))}function b(){g.forEach((function(t){var e=t.tooltipElement,n=t.tooltipInstance;n&&n.destroy(),e&&e.remove()})),g=[]}function L(){return(L=i(c().mark((function t(){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r();case 2:w();case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}"undefined"!=typeof window&&"undefined"!=typeof document&&function(){L.apply(this,arguments)}();var E=new WeakSet;function x(t){var e=t.currentTarget.closest('[role="alert"]');e&&e.remove()}function S(){document.querySelectorAll("[data-dui-dismiss='alert']").forEach((function(t){E.has(t)||(t.addEventListener("click",x),E.add(t))}))}"undefined"!=typeof window&&S();var k=new WeakSet;function A(t){var e=t.currentTarget.getAttribute("data-dui-target");if(e&&e.startsWith("#")){var n=document.querySelector(e),r="true"===t.currentTarget.getAttribute("aria-expanded");if(n){n.style.maxHeight=r?"0":n.scrollHeight+"px",t.currentTarget.setAttribute("aria-expanded",!r);var o=t.currentTarget.querySelector("[data-dui-icon]");o&&o.classList.toggle("rotate-180",!r)}}}function P(){document.querySelectorAll("[data-dui-toggle='collapse']").forEach((function(t){k.has(t)||(t.addEventListener("click",A),k.add(t))}))}function T(){document.querySelectorAll(".tab-group").forEach((function(t){var e=t.querySelector("[role='tablist']"),n=e.querySelectorAll(".tab-link"),r=t.querySelectorAll(".tab-content"),o=e.querySelector(".tab-indicator"),i="vertical"===t.getAttribute("data-dui-orientation");function a(t){n.forEach((function(t){return t.classList.remove("active")})),r.forEach((function(t){t.classList.add("hidden"),t.classList.remove("block")})),t.classList.add("active");var a=document.getElementById(t.getAttribute("data-dui-tab-target"));a&&(a.classList.add("block"),a.classList.remove("hidden")),function(t){var n=t.getBoundingClientRect(),r=e.getBoundingClientRect();requestAnimationFrame((function(){if(i){var t=n.top-r.top,e=n.height;o.style.transform="translateY(".concat(t,"px)"),o.style.height="".concat(e,"px")}else{var a=n.left-r.left,c=n.width;o.style.transform="translateX(".concat(a,"px)"),o.style.width="".concat(c,"px")}o.classList.remove("hidden"),o.style.opacity="1",o.style.scale="1"}))}(t)}setTimeout((function(){var t=e.querySelector(".tab-link.active");t&&a(t)}),100),n.forEach((function(t){t.addEventListener("click",(function(e){e.preventDefault(),a(t)}))}))}))}"undefined"!=typeof window&&P(),"undefined"!=typeof window&&document.addEventListener("DOMContentLoaded",(function(){T()}));var j=new WeakSet;function q(t){var e=t.currentTarget.getAttribute("data-dui-target"),n=document.querySelector(e);if(n){var r=n.classList.contains("pointer-events-none");n.classList.toggle("opacity-0",!r),r?n.classList.remove("pointer-events-none"):setTimeout((function(){return n.classList.add("pointer-events-none")}),300),n.classList.toggle("opacity-100",r);var o=n.querySelector(r?".scale-95":".scale-100");o.classList.toggle("scale-95",!r),o.classList.toggle("scale-100",r),n.setAttribute("aria-hidden",!r),r?n.addEventListener("click",_):n.removeEventListener("click",_)}}function O(t){var e=t.currentTarget.closest(".fixed");if(e){e.classList.add("opacity-0"),e.classList.remove("opacity-100");var n=e.querySelector(".scale-100");n.classList.add("scale-95"),n.classList.remove("scale-100"),setTimeout((function(){e.classList.add("pointer-events-none"),e.setAttribute("aria-hidden","true")}),300),e.removeEventListener("click",_)}}function _(t){t.currentTarget.querySelector(".scale-100, .scale-95").contains(t.target)||O({currentTarget:t.currentTarget})}function N(){document.querySelectorAll("[data-dui-toggle='modal']").forEach((function(t){j.has(t)||(t.addEventListener("click",q),j.add(t))})),document.querySelectorAll("[data-dui-dismiss='modal']").forEach((function(t){j.has(t)||(t.addEventListener("click",O),j.add(t))}))}"undefined"!=typeof window&&"undefined"!=typeof document&&N();var C={initAlert:S,initCollapse:P,initDropdowns:d,initPopovers:h,cleanupPopovers:v,initTooltips:w,cleanupTooltips:b,initTabs:T,initModal:N};"undefined"!=typeof window&&"undefined"!=typeof document&&(S(),P(),T(),N(),r().then((function(){d(),h(),w()})).catch((function(t){console.error("Failed to load Popper.js:",t)})),window.DavidAI=C),t.cleanupPopovers=v,t.cleanupTooltips=b,t.default=C,t.initAlert=S,t.initCollapse=P,t.initDropdowns=d,t.initModal=N,t.initPopovers=h,t.initTabs=T,t.initTooltips=w,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=david-ai.min.js.map diff --git a/packages/dist/david-ai.min.js.map b/packages/dist/david-ai.min.js.map index 8f2605d..fc51390 100644 --- a/packages/dist/david-ai.min.js.map +++ b/packages/dist/david-ai.min.js.map @@ -1 +1 @@ -{"version":3,"file":"david-ai.min.js","sources":["../src/utils/loadPopper.js","../src/dropdown/dropdown.js","../src/popover/popover.js","../src/tooltip/tooltip.js","../src/alert/alert.js","../src/collapse/collapse.js","../src/tabs/tabs.js","../src/modal/modal.js","../src/index.js"],"sourcesContent":["var popperLoaded = false; // Singleton flag to track loading state\nvar popperReady = null; // Promise to handle loading Popper.js once\n\nexport function loadPopperJs() {\n if (popperLoaded) {\n return popperReady; // Return the existing Promise if already loading or loaded\n }\n popperLoaded = true; // Mark Popper.js as being loaded\n\n popperReady = new Promise(function (resolve, reject) {\n if (window.Popper) {\n resolve(window.Popper); // If already loaded globally, resolve immediately\n return;\n }\n var script = document.createElement(\"script\");\n script.src = \"https://unpkg.com/@popperjs/core@2\";\n script.defer = true;\n script.onload = function () {\n window.Popper = window.Popper || window.Popper; // Expose Popper globally\n resolve(window.Popper); // Resolve once Popper.js is loaded\n };\n script.onerror = function () {\n reject(new Error(\"Failed to load Popper.js\"));\n };\n document.head.appendChild(script);\n });\n\n return popperReady;\n}\n","// Dropdown component\nexport class Dropdown {\n constructor(dropdownElement) {\n this.dropdown = dropdownElement;\n this.button = this.dropdown.querySelector('[data-dui-toggle=\"dropdown\"]');\n this.menu = this.dropdown.querySelector('[data-dui-role=\"menu\"]');\n this.popperInstance = null;\n\n // Get placement dynamically or default to 'bottom-start'\n this.placement = this.dropdown.getAttribute(\"data-dui-placement\") || \"bottom-start\";\n\n this.init();\n }\n\n init() {\n // Initialize Popper.js\n this.popperInstance = Popper.createPopper(this.button, this.menu, {\n placement: this.placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 5] } }],\n });\n\n // Check for open attribute\n if (this.dropdown.hasAttribute(\"data-dui-open\")) {\n this.openDropdown();\n }\n\n // Toggle dropdown on button click\n this.button.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n this.toggleDropdown();\n });\n\n // Close dropdown on outside click\n document.addEventListener(\"click\", (e) => {\n if (!this.dropdown.contains(e.target)) {\n this.closeDropdown();\n }\n });\n }\n\n toggleDropdown() {\n const isExpanded = this.button.getAttribute(\"aria-expanded\") === \"true\";\n isExpanded ? this.closeDropdown() : this.openDropdown();\n }\n\n openDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"true\");\n this.menu.hidden = false;\n this.menu.classList.remove(\"hidden\");\n this.popperInstance.update();\n this.closeSiblings();\n }\n\n closeDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"false\");\n this.menu.hidden = true;\n this.menu.classList.add(\"hidden\");\n }\n\n closeSiblings() {\n const siblingMenus = this.dropdown.parentElement.querySelectorAll(\n '[data-dui-role=\"menu\"]:not(.hidden)'\n );\n siblingMenus.forEach((siblingMenu) => {\n if (siblingMenu !== this.menu) {\n siblingMenu.classList.add(\"hidden\");\n siblingMenu.parentElement\n .querySelector('[data-dui-toggle=\"dropdown\"]')\n .setAttribute(\"aria-expanded\", \"false\");\n }\n });\n }\n}\n\nexport function initDropdowns() {\n document.querySelectorAll(\".dropdown\").forEach((dropdownElement) => {\n new Dropdown(dropdownElement);\n });\n}","// Popover component\nexport function initPopovers() {\n const popoverTriggers = document.querySelectorAll(\"[data-dui-toggle='popover']\");\n\n popoverTriggers.forEach(trigger => {\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const popoverClasses = trigger.getAttribute(\"data-dui-popover-class\") || \"popover-default\";\n const plainContent = trigger.getAttribute(\"data-dui-content\");\n const isOpenByDefault = trigger.hasAttribute(\"data-dui-open\");\n\n let popoverInstance = null;\n let popoverElement = null;\n let originalContentElement = null;\n\n // Find content element next to the trigger\n const contentElement = trigger.nextElementSibling?.matches(\"[data-dui-popover-content]\")\n ? trigger.nextElementSibling\n : null;\n\n // Function to open the popover\n function openPopover() {\n popoverElement = document.createElement(\"div\");\n popoverElement.className = popoverClasses;\n\n // Use custom HTML content or plain text\n if (contentElement) {\n originalContentElement = contentElement.cloneNode(true);\n originalContentElement.classList.remove(\"hidden\");\n popoverElement.appendChild(originalContentElement);\n } else if (plainContent) {\n popoverElement.textContent = plainContent;\n } else {\n console.error(\"No content provided for popover:\", trigger);\n return;\n }\n\n document.body.appendChild(popoverElement);\n\n popoverInstance = Popper.createPopper(trigger, popoverElement, {\n placement: placement,\n modifiers: [\n { name: \"offset\", options: { offset: [0, 8] } }\n ],\n });\n\n // Store references for cleanup\n trigger._popoverInstance = popoverInstance;\n trigger._popoverElement = popoverElement;\n }\n\n // Function to close the popover\n function closePopover() {\n if (popoverInstance) {\n popoverInstance.destroy();\n popoverInstance = null;\n\n if (originalContentElement) {\n originalContentElement.classList.add(\"hidden\");\n }\n\n popoverElement.remove();\n popoverElement = null;\n }\n }\n\n // Toggle popover on click\n trigger.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n if (popoverInstance) {\n closePopover();\n } else {\n openPopover();\n }\n });\n\n // Open popover by default if specified\n if (isOpenByDefault) {\n openPopover();\n }\n });\n}\n","// Tooltip component\nexport function initTooltips() {\n const tooltipTriggers = document.querySelectorAll(\"[data-dui-toggle='tooltip']\");\n\n tooltipTriggers.forEach((trigger) => {\n const title = trigger.getAttribute(\"data-dui-title\"); // Plain text content\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const tooltipClasses = trigger.getAttribute(\"data-dui-tooltip-class\") || \"tooltip-default\";\n\n let tooltipInstance = null;\n let tooltipElement = null;\n let customContentElement = null;\n\n // Check for sibling content with custom HTML\n if (trigger.nextElementSibling?.matches(\"[data-dui-tooltip-content]\")) {\n customContentElement = trigger.nextElementSibling;\n }\n\n // Show the tooltip\n function showTooltip() {\n if (tooltipElement) return; // Avoid duplicate tooltips\n\n tooltipElement = document.createElement(\"div\");\n tooltipElement.className = tooltipClasses;\n\n // Use custom HTML content or plain text\n if (customContentElement) {\n const contentClone = customContentElement.cloneNode(true);\n contentClone.classList.remove(\"hidden\");\n tooltipElement.appendChild(contentClone);\n } else if (title) {\n tooltipElement.textContent = title;\n } else {\n console.warn(\"No tooltip content provided for:\", trigger);\n return;\n }\n\n document.body.appendChild(tooltipElement);\n\n // Create Popper.js instance\n tooltipInstance = Popper.createPopper(trigger, tooltipElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n }\n\n // Hide the tooltip\n function hideTooltip() {\n if (tooltipElement && !trigger.classList.contains(\"static-tooltip\")) {\n tooltipInstance.destroy();\n tooltipInstance = null;\n tooltipElement.remove();\n tooltipElement = null;\n }\n }\n\n // Event Listeners\n trigger.addEventListener(\"mouseenter\", showTooltip);\n trigger.addEventListener(\"mouseleave\", hideTooltip);\n\n // Toggle static tooltips on click\n trigger.addEventListener(\"click\", () => {\n if (trigger.classList.contains(\"static-tooltip\")) {\n trigger.classList.remove(\"static-tooltip\");\n hideTooltip();\n } else {\n trigger.classList.add(\"static-tooltip\");\n showTooltip();\n }\n });\n });\n}\n","// src/alert/alert.js\n\nexport function closeAlert(event) {\n const button = event.currentTarget;\n const alert = button.closest('[role=\"alert\"]');\n if (alert) {\n alert.parentNode.removeChild(alert);\n }\n}\n\nexport function initAlert() {\n const dismissButtons = document.querySelectorAll(\"[data-dui-dismiss='alert']\");\n dismissButtons.forEach(button => {\n button.addEventListener(\"click\", closeAlert);\n });\n}\n\n// Auto-initialize if running in a browser environment\nif (typeof window !== 'undefined') {\n initAlert();\n}\n","// Collapse component\nexport function toggleCollapse(event) {\n const collapseID =\n event.currentTarget.getAttribute(\"data-dui-target\")\n\n if (collapseID && collapseID.startsWith(\"#\")) {\n const collapseElement = document.querySelector(collapseID);\n const isExpanded = event.currentTarget.getAttribute(\"aria-expanded\") === \"true\";\n\n if (collapseElement) {\n // Toggle max-height for collapsible content\n collapseElement.style.maxHeight = isExpanded\n ? \"0\"\n : collapseElement.scrollHeight + \"px\";\n\n // Update aria-expanded attribute\n event.currentTarget.setAttribute(\"aria-expanded\", !isExpanded);\n\n // Toggle rotate-180 class on the icon\n const icon = event.currentTarget.querySelector(\"[data-dui-icon]\");\n if (icon) {\n icon.classList.toggle(\"rotate-180\", !isExpanded);\n }\n }\n }\n}\n\nexport function initCollapse() {\n document.querySelectorAll(\"[data-dui-toggle='collapse']\").forEach(button => {\n button.addEventListener(\"click\", toggleCollapse);\n });\n}\n\n// Auto-initialize collapsible components in the browser\nif (typeof window !== 'undefined') {\n initCollapse();\n}\n","// Tabs Component\nexport function initTabs() {\n document.querySelectorAll(\".tab-group\").forEach((tabGroup) => {\n const tabList = tabGroup.querySelector(\"[role='tablist']\");\n const tabLinks = tabList.querySelectorAll(\".tab-link\");\n const tabContents = tabGroup.querySelectorAll(\".tab-content\");\n const indicator = tabList.querySelector(\".tab-indicator\");\n\n const isVertical = tabGroup.getAttribute(\"data-dui-orientation\") === \"vertical\";\n\n // Function to update the indicator position dynamically\n function updateIndicator(link) {\n const rect = link.getBoundingClientRect();\n const parentRect = tabList.getBoundingClientRect();\n\n if (isVertical) {\n // For vertical tabs\n indicator.style.height = `${rect.height}px`;\n indicator.style.transform = `translateY(${rect.top - parentRect.top}px)`;\n } else {\n // For horizontal tabs\n indicator.style.width = `${rect.width}px`;\n indicator.style.transform = `translateX(${rect.left - parentRect.left}px)`;\n }\n }\n\n // Function to handle tab activation\n function activateTab(link) {\n // Deactivate all tabs and hide contents\n tabLinks.forEach((item) => item.classList.remove(\"active\"));\n tabContents.forEach((content) => {\n content.classList.add(\"hidden\");\n content.classList.remove(\"block\");\n });\n\n // Activate the clicked tab\n link.classList.add(\"active\");\n const targetContent = document.getElementById(link.getAttribute(\"data-dui-tab-target\"));\n if (targetContent) {\n targetContent.classList.add(\"block\");\n targetContent.classList.remove(\"hidden\");\n }\n\n // Update the indicator position\n updateIndicator(link);\n }\n\n // Initialize the tabs\n tabLinks.forEach((link) => {\n // If a tab is already active, update the indicator\n if (link.classList.contains(\"active\")) {\n activateTab(link);\n }\n\n // Add click event listener to each tab link\n link.addEventListener(\"click\", (event) => {\n event.preventDefault();\n activateTab(link);\n });\n });\n });\n}\n\n// Auto-initialize tabs in the browser\nif (typeof window !== \"undefined\") {\n initTabs();\n}\n","// Modal Component\n\nexport function toggleModal(event) {\n const modalID = event.currentTarget.getAttribute(\"data-dui-target\");\n const modal = document.querySelector(modalID);\n\n if (modal) {\n const isHidden = modal.classList.contains(\"pointer-events-none\");\n modal.classList.toggle(\"opacity-0\", !isHidden);\n\n if (isHidden) {\n modal.classList.remove(\"pointer-events-none\");\n } else {\n setTimeout(() => modal.classList.add(\"pointer-events-none\"), 300);\n }\n\n modal.classList.toggle(\"opacity-100\", isHidden);\n const modalContent = modal.querySelector(isHidden ? \".scale-95\" : \".scale-100\");\n modalContent.classList.toggle(\"scale-95\", !isHidden);\n modalContent.classList.toggle(\"scale-100\", isHidden);\n modal.setAttribute(\"aria-hidden\", !isHidden);\n\n // Add or remove event listener for clicks outside modal content\n if (isHidden) {\n modal.addEventListener(\"click\", closeOnOutsideClick);\n } else {\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n }\n}\n\nexport function closeModal(event) {\n const modal = event.currentTarget.closest(\".fixed\");\n\n if (modal) {\n modal.classList.add(\"opacity-0\");\n modal.classList.remove(\"opacity-100\");\n const modalContent = modal.querySelector(\".scale-100\");\n modalContent.classList.add(\"scale-95\");\n modalContent.classList.remove(\"scale-100\");\n\n setTimeout(() => {\n modal.classList.add(\"pointer-events-none\");\n modal.setAttribute(\"aria-hidden\", \"true\");\n }, 300);\n\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n}\n\nfunction closeOnOutsideClick(event) {\n const modalContent = event.currentTarget.querySelector(\".scale-100, .scale-95\");\n\n if (!modalContent.contains(event.target)) {\n closeModal({ currentTarget: event.currentTarget });\n }\n}\n\nexport function initModal() {\n document.querySelectorAll(\"[data-dui-toggle='modal']\").forEach((trigger) => {\n trigger.addEventListener(\"click\", toggleModal);\n });\n\n document.querySelectorAll(\"[data-dui-dismiss='modal']\").forEach((button) => {\n button.addEventListener(\"click\", closeModal);\n });\n}\n\n// Auto-initialize Modals in the Browser Environment\nif (typeof window !== \"undefined\") {\n initModal();\n}\n","import { loadPopperJs } from './utils/loadPopper.js';\n\n// Import components\nimport { initDropdowns } from './dropdown/dropdown.js';\nimport { initPopovers } from './popover/popover.js';\nimport { initTooltips } from './tooltip/tooltip.js';\nimport { initAlert } from './alert/alert.js';\nimport { initCollapse } from './collapse/collapse.js';\nimport { initTabs } from './tabs/tabs.js';\nimport { initModal } from './modal/modal.js';\n\n// Export individual components for named imports\nexport {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n initTooltips,\n initTabs,\n initModal\n};\n\n// Combine all features into a global object for default export\nconst DavidAI = {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n initTooltips,\n initTabs,\n initModal\n};\n\n// Auto-initialize components in the browser\nif (typeof window !== \"undefined\") {\n // Initialize Popper-independent components\n initAlert();\n initCollapse();\n initTabs();\n initModal();\n\n // Load Popper.js once, then initialize dependent components\n loadPopperJs()\n .then(() => {\n initDropdowns();\n initPopovers();\n initTooltips();\n })\n .catch((error) => {\n console.error(\"Failed to load Popper.js:\", error);\n });\n\n // Expose DavidAI globally for UMD\n window.DavidAI = DavidAI;\n}\n\nexport default DavidAI;\n"],"names":["popperLoaded","popperReady","Dropdown","dropdownElement","_classCallCheck","this","dropdown","button","querySelector","menu","popperInstance","placement","getAttribute","init","key","value","_this","Popper","createPopper","modifiers","name","options","offset","hasAttribute","openDropdown","addEventListener","e","stopPropagation","toggleDropdown","document","contains","target","closeDropdown","setAttribute","hidden","classList","remove","update","closeSiblings","add","_this2","parentElement","querySelectorAll","forEach","siblingMenu","initDropdowns","initPopovers","trigger","_trigger$nextElementS","popoverClasses","plainContent","isOpenByDefault","popoverInstance","popoverElement","originalContentElement","contentElement","nextElementSibling","matches","openPopover","createElement","className","cloneNode","appendChild","console","error","textContent","body","_popoverInstance","_popoverElement","event","destroy","initTooltips","title","tooltipClasses","tooltipInstance","tooltipElement","customContentElement","showTooltip","contentClone","warn","hideTooltip","closeAlert","alert","currentTarget","closest","parentNode","removeChild","initAlert","toggleCollapse","collapseID","startsWith","collapseElement","isExpanded","style","maxHeight","scrollHeight","icon","toggle","initCollapse","initTabs","tabGroup","tabList","tabLinks","tabContents","indicator","isVertical","activateTab","link","item","content","targetContent","getElementById","rect","getBoundingClientRect","parentRect","height","concat","transform","top","width","left","updateIndicator","preventDefault","toggleModal","modalID","modal","isHidden","setTimeout","modalContent","closeOnOutsideClick","removeEventListener","closeModal","initModal","window","DavidAI","Promise","resolve","reject","script","src","defer","onload","onerror","Error","head","then"],"mappings":"+OAAA,IAAIA,GAAe,EACfC,EAAc,ifCAlB,IAAaC,EAAQ,WAWlB,SAVD,SAAAA,EAAYC,gGAAiBC,MAAAF,GAC3BG,KAAKC,SAAWH,EAChBE,KAAKE,OAASF,KAAKC,SAASE,cAAc,gCAC1CH,KAAKI,KAAOJ,KAAKC,SAASE,cAAc,0BACxCH,KAAKK,eAAiB,KAGtBL,KAAKM,UAAYN,KAAKC,SAASM,aAAa,uBAAyB,e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E,KAEH4F,EAAMK,oBAAoB,QAASD,EACrC,CACF,CAEA,SAASA,EAAoB5D,GACNA,EAAMc,cAAc3E,cAAc,yBAErCsB,SAASuC,EAAMtC,SAC/BoG,EAAW,CAAEhD,cAAed,EAAMc,eAEtC,CAEO,SAASiD,IACdvG,SAASa,iBAAiB,6BAA6BC,SAAQ,SAACI,GAC9DA,EAAQtB,iBAAiB,QAASkG,EACpC,IAEA9F,SAASa,iBAAiB,8BAA8BC,SAAQ,SAACpC,GAC/DA,EAAOkB,iBAAiB,QAAS0G,EACnC,GACF,CHhDsB,oBAAXE,QACT9C,ICeoB,oBAAX8C,QACTnC,IC6BoB,oBAAXmC,QACTlC,ICIoB,oBAAXkC,QACTD,IC/CF,IAAME,EAAU,CACd/C,UAAAA,EACAW,aAAAA,EACArD,cAAAA,EACAC,aAAAA,EACAyB,aAAAA,EACA4B,SAAAA,EACAiC,UAAAA,GAIoB,oBAAXC,SAET9C,IACAW,IACAC,IACAiC,KRnCIpI,EACKC,GAETD,GAAe,EAEfC,EAAc,IAAIsI,SAAQ,SAAUC,EAASC,GAC3C,GAAIJ,OAAOpH,OACTuH,EAAQH,OAAOpH,YADjB,CAIA,IAAIyH,EAAS7G,SAAS8B,cAAc,UACpC+E,EAAOC,IAAM,qCACbD,EAAOE,OAAQ,EACfF,EAAOG,OAAS,WACdR,OAAOpH,OAASoH,OAAOpH,QAAUoH,OAAOpH,OACxCuH,EAAQH,OAAOpH,SAEjByH,EAAOI,QAAU,WACfL,EAAO,IAAIM,MAAM,8BAEnBlH,SAASmH,KAAKlF,YAAY4E,EAX1B,CAYF,MQkBGO,MAAK,WACJpG,IACAC,IACAyB,GACF,IAAE,OACK,SAACP,GACND,QAAQC,MAAM,4BAA6BA,EAC7C,IAGFqE,OAAOC,QAAUA"} \ No newline at end of file +{"version":3,"file":"david-ai.min.js","sources":["../src/utils/loadPopper.js","../src/dropdown/dropdown.js","../src/popover/popover.js","../src/tooltip/tooltip.js","../src/alert/alert.js","../src/collapse/collapse.js","../src/tabs/tabs.js","../src/modal/modal.js","../src/index.js"],"sourcesContent":["var popperLoaded = false; // Singleton flag to track loading state\nvar popperReady = null; // Promise to handle loading Popper.js once\n\nexport function loadPopperJs() {\n if (popperLoaded) {\n return popperReady; // Return the existing Promise if already loading or loaded\n }\n popperLoaded = true; // Mark Popper.js as being loaded\n\n popperReady = new Promise(function (resolve, reject) {\n if (window.Popper) {\n resolve(window.Popper); // If already loaded globally, resolve immediately\n return;\n }\n var script = document.createElement(\"script\");\n script.src = \"https://unpkg.com/@popperjs/core@2\";\n script.defer = true;\n script.onload = function () {\n window.Popper = window.Popper || window.Popper; // Expose Popper globally\n resolve(window.Popper); // Resolve once Popper.js is loaded\n };\n script.onerror = function () {\n reject(new Error(\"Failed to load Popper.js\"));\n };\n document.head.appendChild(script);\n });\n\n return popperReady;\n}\n","// Dropdown component\nimport { loadPopperJs } from '../utils/loadPopper'; // Centralized loader\n\nconst initializedDropdowns = new WeakSet();\n\nexport class Dropdown {\n constructor(dropdownElement) {\n this.dropdown = dropdownElement;\n this.button = this.dropdown.querySelector('[data-dui-toggle=\"dropdown\"]');\n this.menu = this.dropdown.querySelector('[data-dui-role=\"menu\"]');\n this.popperInstance = null;\n\n this.placement = this.dropdown.getAttribute(\"data-dui-placement\") || \"bottom-start\";\n\n this.init();\n }\n\n async init() {\n // Ensure Popper.js is loaded\n await loadPopperJs();\n\n // Initialize Popper.js\n this.popperInstance = Popper.createPopper(this.button, this.menu, {\n placement: this.placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 5] } }],\n });\n\n // Event listeners\n this.button.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n this.toggleDropdown();\n });\n\n document.addEventListener(\"click\", (e) => {\n if (!this.dropdown.contains(e.target)) this.closeDropdown();\n });\n }\n\n toggleDropdown() {\n const isExpanded = this.button.getAttribute(\"aria-expanded\") === \"true\";\n isExpanded ? this.closeDropdown() : this.openDropdown();\n }\n\n openDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"true\");\n this.menu.hidden = false;\n this.menu.classList.remove(\"hidden\");\n this.popperInstance.update();\n }\n\n closeDropdown() {\n this.button.setAttribute(\"aria-expanded\", \"false\");\n this.menu.hidden = true;\n this.menu.classList.add(\"hidden\");\n }\n}\n\nexport function initDropdowns() {\n document.querySelectorAll(\".dropdown\").forEach((dropdownElement) => {\n if (!initializedDropdowns.has(dropdownElement)) {\n new Dropdown(dropdownElement);\n initializedDropdowns.add(dropdownElement);\n }\n });\n}\n","// Popover Component\nimport { loadPopperJs } from '../utils/loadPopper';\n\nconst initializedPopovers = new WeakSet(); // Prevent duplicate initialization\nlet activePopovers = []; // Track active popovers for cleanup\n\nexport function initPopovers() {\n document.querySelectorAll(\"[data-dui-toggle='popover']\").forEach((trigger) => {\n if (initializedPopovers.has(trigger)) return; // Avoid re-initializing\n\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const popoverClasses = trigger.getAttribute(\"data-dui-popover-class\") || \"popover-default\";\n const plainContent = trigger.getAttribute(\"data-dui-content\");\n const isOpenByDefault = trigger.hasAttribute(\"data-dui-open\");\n\n let popoverInstance = null;\n let popoverElement = null;\n let originalContentElement = null;\n\n // Find content element next to the trigger\n const contentElement = trigger.nextElementSibling?.matches(\"[data-dui-popover-content]\")\n ? trigger.nextElementSibling\n : null;\n\n // Function to open the popover\n function openPopover() {\n popoverElement = document.createElement(\"div\");\n popoverElement.className = popoverClasses;\n\n // Use custom HTML content or plain text\n if (contentElement) {\n originalContentElement = contentElement.cloneNode(true);\n originalContentElement.classList.remove(\"hidden\");\n popoverElement.appendChild(originalContentElement);\n } else if (plainContent) {\n popoverElement.textContent = plainContent;\n } else {\n console.error(\"No content provided for popover:\", trigger);\n return;\n }\n\n document.body.appendChild(popoverElement);\n\n popoverInstance = Popper.createPopper(trigger, popoverElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n\n // Track active popovers for cleanup\n activePopovers.push({ trigger, popoverElement, popoverInstance });\n }\n\n // Function to close the popover\n function closePopover() {\n if (popoverInstance) {\n popoverInstance.destroy();\n popoverInstance = null;\n\n if (originalContentElement) {\n originalContentElement.classList.add(\"hidden\");\n }\n\n popoverElement.remove();\n popoverElement = null;\n }\n\n // Remove from active popovers\n activePopovers = activePopovers.filter((p) => p.trigger !== trigger);\n }\n\n // Toggle popover on click\n trigger.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n if (popoverInstance) {\n closePopover();\n } else {\n openPopover();\n }\n });\n\n // Open popover by default if specified\n if (isOpenByDefault) {\n openPopover();\n }\n\n // Mark as initialized\n initializedPopovers.add(trigger);\n });\n}\n\n// Cleanup function to destroy all active popovers\nexport function cleanupPopovers() {\n activePopovers.forEach(({ popoverElement, popoverInstance }) => {\n if (popoverInstance) popoverInstance.destroy();\n if (popoverElement) popoverElement.remove();\n });\n activePopovers = [];\n}\n\n// Combined initialization function\nexport async function loadAndInitPopovers() {\n await loadPopperJs();\n initPopovers();\n}\n\n// Auto-initialize Popovers in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n loadAndInitPopovers();\n}\n","// Tooltip Component\nimport { loadPopperJs } from '../utils/loadPopper';\n\nconst initializedTooltips = new WeakSet(); // Prevent duplicate initialization\nlet activeTooltips = []; // Track active tooltips for cleanup\n\nexport function initTooltips() {\n document.querySelectorAll(\"[data-dui-toggle='tooltip']\").forEach((trigger) => {\n if (initializedTooltips.has(trigger)) return; // Avoid re-initializing\n\n const title = trigger.getAttribute(\"data-dui-title\"); // Plain text content\n const placement = trigger.getAttribute(\"data-dui-placement\") || \"top\";\n const tooltipClasses = trigger.getAttribute(\"data-dui-tooltip-class\") || \"tooltip-default\";\n\n let tooltipInstance = null;\n let tooltipElement = null;\n let customContentElement = null;\n\n // Check for sibling content with custom HTML\n if (trigger.nextElementSibling?.matches(\"[data-dui-tooltip-content]\")) {\n customContentElement = trigger.nextElementSibling;\n }\n\n // Function to show the tooltip\n function showTooltip() {\n tooltipElement = document.createElement(\"div\");\n tooltipElement.className = tooltipClasses;\n\n // Use custom HTML content or plain text\n if (customContentElement) {\n const contentClone = customContentElement.cloneNode(true);\n contentClone.classList.remove(\"hidden\");\n tooltipElement.appendChild(contentClone);\n } else if (title) {\n tooltipElement.textContent = title;\n } else {\n console.warn(\"No tooltip content provided for:\", trigger);\n return;\n }\n\n document.body.appendChild(tooltipElement);\n\n tooltipInstance = Popper.createPopper(trigger, tooltipElement, {\n placement: placement,\n modifiers: [{ name: \"offset\", options: { offset: [0, 8] } }],\n });\n\n // Track active tooltips for cleanup\n activeTooltips.push({ trigger, tooltipElement, tooltipInstance });\n }\n\n // Function to hide the tooltip\n function hideTooltip() {\n if (tooltipInstance) {\n tooltipInstance.destroy();\n tooltipInstance = null;\n }\n\n if (tooltipElement) {\n tooltipElement.remove();\n tooltipElement = null;\n }\n\n // Remove from active tooltips\n activeTooltips = activeTooltips.filter((t) => t.trigger !== trigger);\n }\n\n // Add event listeners for showing and hiding tooltips\n trigger.addEventListener(\"mouseenter\", showTooltip);\n trigger.addEventListener(\"mouseleave\", hideTooltip);\n\n // Mark as initialized\n initializedTooltips.add(trigger);\n });\n}\n\n// Cleanup function to destroy all active tooltips\nexport function cleanupTooltips() {\n activeTooltips.forEach(({ tooltipElement, tooltipInstance }) => {\n if (tooltipInstance) tooltipInstance.destroy();\n if (tooltipElement) tooltipElement.remove();\n });\n activeTooltips = [];\n}\n\n// Combined initialization function\nexport async function loadAndInitTooltips() {\n await loadPopperJs();\n initTooltips();\n}\n\n// Auto-initialize Tooltips in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n loadAndInitTooltips();\n}\n","// src/alert/alert.js\n\nconst initializedElements = new WeakSet();\n\nexport function closeAlert(event) {\n const button = event.currentTarget;\n const alert = button.closest('[role=\"alert\"]');\n if (alert) {\n alert.remove(); // Remove the alert\n }\n}\n\nexport function initAlert() {\n // Attach event listeners only to buttons that haven't been initialized\n document.querySelectorAll(\"[data-dui-dismiss='alert']\").forEach((button) => {\n if (!initializedElements.has(button)) {\n button.addEventListener(\"click\", closeAlert);\n initializedElements.add(button); // Track this button as initialized\n }\n });\n}\n\n// Auto-initialize if running in a browser environment\nif (typeof window !== 'undefined') {\n initAlert();\n}\n","// Collapse component\nconst initializedElements = new WeakSet();\n\nexport function toggleCollapse(event) {\n const collapseID = event.currentTarget.getAttribute(\"data-dui-target\");\n\n if (collapseID && collapseID.startsWith(\"#\")) {\n const collapseElement = document.querySelector(collapseID);\n const isExpanded =\n event.currentTarget.getAttribute(\"aria-expanded\") === \"true\";\n\n if (collapseElement) {\n // Toggle max-height for collapsible content\n collapseElement.style.maxHeight = isExpanded\n ? \"0\"\n : collapseElement.scrollHeight + \"px\";\n\n // Update aria-expanded attribute\n event.currentTarget.setAttribute(\"aria-expanded\", !isExpanded);\n\n // Toggle rotate-180 class on the icon\n const icon = event.currentTarget.querySelector(\"[data-dui-icon]\");\n if (icon) {\n icon.classList.toggle(\"rotate-180\", !isExpanded);\n }\n }\n }\n}\n\nexport function initCollapse() {\n document\n .querySelectorAll(\"[data-dui-toggle='collapse']\")\n .forEach((button) => {\n if (!initializedElements.has(button)) {\n button.addEventListener(\"click\", toggleCollapse);\n initializedElements.add(button); // Mark as initialized\n }\n });\n}\n\n// Auto-initialize collapsible components in the browser\nif (typeof window !== 'undefined') {\n initCollapse();\n}\n","// Tabs Component\nexport function initTabs() {\n document.querySelectorAll(\".tab-group\").forEach((tabGroup) => {\n const tabList = tabGroup.querySelector(\"[role='tablist']\");\n const tabLinks = tabList.querySelectorAll(\".tab-link\");\n const tabContents = tabGroup.querySelectorAll(\".tab-content\");\n const indicator = tabList.querySelector(\".tab-indicator\");\n const isVertical = tabGroup.getAttribute(\"data-dui-orientation\") === \"vertical\";\n\n function updateIndicator(link) {\n const rect = link.getBoundingClientRect();\n const parentRect = tabList.getBoundingClientRect();\n\n requestAnimationFrame(() => {\n if (isVertical) {\n const offsetY = rect.top - parentRect.top;\n const height = rect.height;\n\n // Apply styles dynamically for vertical orientation\n indicator.style.transform = `translateY(${offsetY}px)`;\n indicator.style.height = `${height}px`;\n } else {\n const offsetX = rect.left - parentRect.left;\n const width = rect.width;\n\n // Apply styles dynamically for horizontal orientation\n indicator.style.transform = `translateX(${offsetX}px)`;\n indicator.style.width = `${width}px`;\n }\n\n // Make the indicator visible\n indicator.classList.remove(\"hidden\");\n indicator.style.opacity = \"1\";\n indicator.style.scale = \"1\";\n });\n }\n\n function activateTab(link) {\n // Deactivate all tabs and hide their content\n tabLinks.forEach((item) => item.classList.remove(\"active\"));\n tabContents.forEach((content) => {\n content.classList.add(\"hidden\");\n content.classList.remove(\"block\");\n });\n\n // Activate the clicked tab\n link.classList.add(\"active\");\n const targetContent = document.getElementById(link.getAttribute(\"data-dui-tab-target\"));\n if (targetContent) {\n targetContent.classList.add(\"block\");\n targetContent.classList.remove(\"hidden\");\n }\n\n // Update the indicator position\n updateIndicator(link);\n }\n\n // Check for the tab with the `active` class and set the indicator initially\n setTimeout(() => {\n const activeLink = tabList.querySelector(\".tab-link.active\");\n if (activeLink) {\n activateTab(activeLink);\n }\n }, 100);\n\n // Initialize click event listeners for each tab\n tabLinks.forEach((link) => {\n link.addEventListener(\"click\", (event) => {\n event.preventDefault(); // Prevent default browser behavior\n activateTab(link); // Activate the clicked tab and update the indicator\n });\n });\n });\n}\n\n// Auto-initialize tabs in the browser\nif (typeof window !== \"undefined\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n initTabs();\n });\n}\n\n\n\n\n\n\n\n\n","// Modal Component\n\nconst initializedModals = new WeakSet();\n\nexport function toggleModal(event) {\n const modalID = event.currentTarget.getAttribute(\"data-dui-target\");\n const modal = document.querySelector(modalID);\n\n if (modal) {\n const isHidden = modal.classList.contains(\"pointer-events-none\");\n modal.classList.toggle(\"opacity-0\", !isHidden);\n\n if (isHidden) {\n modal.classList.remove(\"pointer-events-none\");\n } else {\n setTimeout(() => modal.classList.add(\"pointer-events-none\"), 300);\n }\n\n modal.classList.toggle(\"opacity-100\", isHidden);\n const modalContent = modal.querySelector(isHidden ? \".scale-95\" : \".scale-100\");\n modalContent.classList.toggle(\"scale-95\", !isHidden);\n modalContent.classList.toggle(\"scale-100\", isHidden);\n modal.setAttribute(\"aria-hidden\", !isHidden);\n\n // Add or remove event listener for clicks outside modal content\n if (isHidden) {\n modal.addEventListener(\"click\", closeOnOutsideClick);\n } else {\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n }\n}\n\nexport function closeModal(event) {\n const modal = event.currentTarget.closest(\".fixed\");\n\n if (modal) {\n modal.classList.add(\"opacity-0\");\n modal.classList.remove(\"opacity-100\");\n const modalContent = modal.querySelector(\".scale-100\");\n modalContent.classList.add(\"scale-95\");\n modalContent.classList.remove(\"scale-100\");\n\n setTimeout(() => {\n modal.classList.add(\"pointer-events-none\");\n modal.setAttribute(\"aria-hidden\", \"true\");\n }, 300);\n\n modal.removeEventListener(\"click\", closeOnOutsideClick);\n }\n}\n\nfunction closeOnOutsideClick(event) {\n const modalContent = event.currentTarget.querySelector(\".scale-100, .scale-95\");\n\n if (!modalContent.contains(event.target)) {\n closeModal({ currentTarget: event.currentTarget });\n }\n}\n\nexport function initModal() {\n document.querySelectorAll(\"[data-dui-toggle='modal']\").forEach((trigger) => {\n if (!initializedModals.has(trigger)) {\n trigger.addEventListener(\"click\", toggleModal);\n initializedModals.add(trigger);\n }\n });\n\n document.querySelectorAll(\"[data-dui-dismiss='modal']\").forEach((button) => {\n if (!initializedModals.has(button)) {\n button.addEventListener(\"click\", closeModal);\n initializedModals.add(button);\n }\n });\n}\n\n// Auto-initialize Modals in the Browser Environment\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n initModal();\n}\n","import { loadPopperJs } from './utils/loadPopper.js';\n\n// Import components\nimport { initDropdowns } from './dropdown/dropdown.js';\nimport { initPopovers, cleanupPopovers } from './popover/popover.js';\nimport { initTooltips, cleanupTooltips } from './tooltip/tooltip.js';\nimport { initAlert } from './alert/alert.js';\nimport { initCollapse } from './collapse/collapse.js';\nimport { initTabs } from './tabs/tabs.js';\nimport { initModal } from './modal/modal.js';\n\n// Export individual components for named imports\nexport {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n cleanupPopovers,\n initTooltips,\n cleanupTooltips,\n initTabs,\n initModal\n};\n\n// Combine all features into a global object for default export\nconst DavidAI = {\n initAlert,\n initCollapse,\n initDropdowns,\n initPopovers,\n cleanupPopovers,\n initTooltips,\n cleanupTooltips,\n initTabs,\n initModal\n};\n\n// Auto-initialize components in the browser\nif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n // Initialize Popper-independent components\n initAlert();\n initCollapse();\n initTabs();\n initModal();\n\n // Load Popper.js once, then initialize dependent components\n loadPopperJs()\n .then(() => {\n initDropdowns();\n initPopovers();\n initTooltips();\n })\n .catch((error) => {\n console.error(\"Failed to load Popper.js:\", error);\n });\n\n // Expose DavidAI globally for UMD\n window.DavidAI = DavidAI;\n}\n\nexport default DavidAI;\n"],"names":["popperLoaded","popperReady","loadPopperJs","Promise","resolve","reject","window","Popper","script","document","createElement","src","defer","onload","onerror","Error","head","appendChild","initializedDropdowns","WeakSet","Dropdown","dropdownElement","_classCallCheck","this","dropdown","button","querySelector","menu","popperInstance","placement","getAttribute","init","key","value","_init","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_this","wrap","_context","prev","next","createPopper","modifiers","name","options","offset","addEventListener","e","stopPropagation","toggleDropdown","contains","target","closeDropdown","stop","apply","arguments","openDropdown","setAttribute","hidden","classList","remove","update","add","initDropdowns","querySelectorAll","forEach","has","initializedPopovers","activePopovers","initPopovers","trigger","_trigger$nextElementS","popoverClasses","plainContent","isOpenByDefault","hasAttribute","popoverInstance","popoverElement","originalContentElement","contentElement","nextElementSibling","matches","event","destroy","filter","p","openPopover","className","cloneNode","console","error","textContent","body","push","cleanupPopovers","_ref","_loadAndInitPopovers","loadAndInitPopovers","initializedTooltips","activeTooltips","initTooltips","title","tooltipClasses","tooltipInstance","tooltipElement","customContentElement","contentClone","warn","t","cleanupTooltips","_loadAndInitTooltips","loadAndInitTooltips","initializedElements","closeAlert","alert","currentTarget","closest","initAlert","toggleCollapse","collapseID","startsWith","collapseElement","isExpanded","style","maxHeight","scrollHeight","icon","toggle","initCollapse","initTabs","tabGroup","tabList","tabLinks","tabContents","indicator","isVertical","activateTab","link","item","content","targetContent","getElementById","rect","getBoundingClientRect","parentRect","requestAnimationFrame","offsetY","top","height","transform","concat","offsetX","left","width","opacity","scale","updateIndicator","setTimeout","activeLink","preventDefault","initializedModals","toggleModal","modalID","modal","isHidden","modalContent","closeOnOutsideClick","removeEventListener","closeModal","initModal","DavidAI","then"],"mappings":"+OAAA,IAAIA,GAAe,EACfC,EAAc,KAEX,SAASC,IACd,OAAIF,EACKC,GAETD,GAAe,EAEfC,EAAc,IAAIE,SAAQ,SAAUC,EAASC,GAC3C,GAAIC,OAAOC,OACTH,EAAQE,OAAOC,YADjB,CAIA,IAAIC,EAASC,SAASC,cAAc,UACpCF,EAAOG,IAAM,qCACbH,EAAOI,OAAQ,EACfJ,EAAOK,OAAS,WACdP,OAAOC,OAASD,OAAOC,QAAUD,OAAOC,OACxCH,EAAQE,OAAOC,SAEjBC,EAAOM,QAAU,WACfT,EAAO,IAAIU,MAAM,8BAEnBN,SAASO,KAAKC,YAAYT,EAX1B,CAYF,IAGF,+oOCzBA,IAAMU,EAAuB,IAAIC,QAEpBC,EAAQ,WAUlB,SATD,SAAAA,EAAYC,gGAAiBC,MAAAF,GAC3BG,KAAKC,SAAWH,EAChBE,KAAKE,OAASF,KAAKC,SAASE,cAAc,gCAC1CH,KAAKI,KAAOJ,KAAKC,SAASE,cAAc,0BACxCH,KAAKK,eAAiB,KAEtBL,KAAKM,UAAYN,KAAKC,SAASM,aAAa,uBAAyB,eAErEP,KAAKQ,MACP,IAAC,CAAA,CAAAC,IAAA,OAAAC,OAAAC,EAAAC,EAAAC,IAAAC,MAED,SAAAC,IAAA,IAAAC,EAAAhB,KAA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AA,EACAM,aAAAA,EACAS,gBAAAA,EACAoB,SAAAA,EACAwC,UAAAA,GAIoB,oBAAXtK,QAA8C,oBAAbG,WAE1C+G,IACAW,IACAC,IACAwC,IAGA1K,IACG4K,MAAK,WACJ5G,IACAM,IACA+B,GACF,IAAE,OACK,SAACV,GACND,QAAQC,MAAM,4BAA6BA,EAC7C,IAGFvF,OAAOuK,QAAUA"} \ No newline at end of file diff --git a/packages/package.json b/packages/package.json index bedfe03..106b26c 100644 --- a/packages/package.json +++ b/packages/package.json @@ -1,12 +1,16 @@ { "name": "david-ai", - "version": "1.0.0", + "version": "1.0.2", "description": "David UI is a free and open-source collection of customizable, production-ready UI components built with Tailwind CSS", "main": "dist/david-ai.js", "module": "dist/david-ai.esm.js", "browser": "dist/david-ai.js", "unpkg": "dist/david-ai.min.js", "type": "module", + "exports": { + "import": "./dist/david-ai.esm.js", + "require": "./dist/david-ai.js" + }, "files": [ "dist", "src", diff --git a/packages/src/alert/alert.js b/packages/src/alert/alert.js index fc31f15..76e2b55 100644 --- a/packages/src/alert/alert.js +++ b/packages/src/alert/alert.js @@ -1,17 +1,22 @@ // src/alert/alert.js +const initializedElements = new WeakSet(); + export function closeAlert(event) { const button = event.currentTarget; const alert = button.closest('[role="alert"]'); if (alert) { - alert.parentNode.removeChild(alert); + alert.remove(); // Remove the alert } } export function initAlert() { - const dismissButtons = document.querySelectorAll("[data-dui-dismiss='alert']"); - dismissButtons.forEach(button => { - button.addEventListener("click", closeAlert); + // Attach event listeners only to buttons that haven't been initialized + document.querySelectorAll("[data-dui-dismiss='alert']").forEach((button) => { + if (!initializedElements.has(button)) { + button.addEventListener("click", closeAlert); + initializedElements.add(button); // Track this button as initialized + } }); } diff --git a/packages/src/collapse/collapse.js b/packages/src/collapse/collapse.js index 63ebc6a..fdef8c5 100644 --- a/packages/src/collapse/collapse.js +++ b/packages/src/collapse/collapse.js @@ -1,11 +1,13 @@ // Collapse component +const initializedElements = new WeakSet(); + export function toggleCollapse(event) { - const collapseID = - event.currentTarget.getAttribute("data-dui-target") + const collapseID = event.currentTarget.getAttribute("data-dui-target"); if (collapseID && collapseID.startsWith("#")) { const collapseElement = document.querySelector(collapseID); - const isExpanded = event.currentTarget.getAttribute("aria-expanded") === "true"; + const isExpanded = + event.currentTarget.getAttribute("aria-expanded") === "true"; if (collapseElement) { // Toggle max-height for collapsible content @@ -26,9 +28,14 @@ export function toggleCollapse(event) { } export function initCollapse() { - document.querySelectorAll("[data-dui-toggle='collapse']").forEach(button => { - button.addEventListener("click", toggleCollapse); - }); + document + .querySelectorAll("[data-dui-toggle='collapse']") + .forEach((button) => { + if (!initializedElements.has(button)) { + button.addEventListener("click", toggleCollapse); + initializedElements.add(button); // Mark as initialized + } + }); } // Auto-initialize collapsible components in the browser diff --git a/packages/src/dropdown/dropdown.js b/packages/src/dropdown/dropdown.js index 286b78c..ef792e6 100644 --- a/packages/src/dropdown/dropdown.js +++ b/packages/src/dropdown/dropdown.js @@ -1,4 +1,8 @@ // Dropdown component +import { loadPopperJs } from '../utils/loadPopper'; // Centralized loader + +const initializedDropdowns = new WeakSet(); + export class Dropdown { constructor(dropdownElement) { this.dropdown = dropdownElement; @@ -6,35 +10,29 @@ export class Dropdown { this.menu = this.dropdown.querySelector('[data-dui-role="menu"]'); this.popperInstance = null; - // Get placement dynamically or default to 'bottom-start' this.placement = this.dropdown.getAttribute("data-dui-placement") || "bottom-start"; this.init(); } - init() { + async init() { + // Ensure Popper.js is loaded + await loadPopperJs(); + // Initialize Popper.js this.popperInstance = Popper.createPopper(this.button, this.menu, { placement: this.placement, modifiers: [{ name: "offset", options: { offset: [0, 5] } }], }); - // Check for open attribute - if (this.dropdown.hasAttribute("data-dui-open")) { - this.openDropdown(); - } - - // Toggle dropdown on button click + // Event listeners this.button.addEventListener("click", (e) => { e.stopPropagation(); this.toggleDropdown(); }); - // Close dropdown on outside click document.addEventListener("click", (e) => { - if (!this.dropdown.contains(e.target)) { - this.closeDropdown(); - } + if (!this.dropdown.contains(e.target)) this.closeDropdown(); }); } @@ -48,7 +46,6 @@ export class Dropdown { this.menu.hidden = false; this.menu.classList.remove("hidden"); this.popperInstance.update(); - this.closeSiblings(); } closeDropdown() { @@ -56,24 +53,13 @@ export class Dropdown { this.menu.hidden = true; this.menu.classList.add("hidden"); } - - closeSiblings() { - const siblingMenus = this.dropdown.parentElement.querySelectorAll( - '[data-dui-role="menu"]:not(.hidden)' - ); - siblingMenus.forEach((siblingMenu) => { - if (siblingMenu !== this.menu) { - siblingMenu.classList.add("hidden"); - siblingMenu.parentElement - .querySelector('[data-dui-toggle="dropdown"]') - .setAttribute("aria-expanded", "false"); - } - }); - } } export function initDropdowns() { document.querySelectorAll(".dropdown").forEach((dropdownElement) => { - new Dropdown(dropdownElement); + if (!initializedDropdowns.has(dropdownElement)) { + new Dropdown(dropdownElement); + initializedDropdowns.add(dropdownElement); + } }); -} \ No newline at end of file +} diff --git a/packages/src/index.js b/packages/src/index.js index 3f1f74c..861c360 100644 --- a/packages/src/index.js +++ b/packages/src/index.js @@ -2,8 +2,8 @@ import { loadPopperJs } from './utils/loadPopper.js'; // Import components import { initDropdowns } from './dropdown/dropdown.js'; -import { initPopovers } from './popover/popover.js'; -import { initTooltips } from './tooltip/tooltip.js'; +import { initPopovers, cleanupPopovers } from './popover/popover.js'; +import { initTooltips, cleanupTooltips } from './tooltip/tooltip.js'; import { initAlert } from './alert/alert.js'; import { initCollapse } from './collapse/collapse.js'; import { initTabs } from './tabs/tabs.js'; @@ -15,7 +15,9 @@ export { initCollapse, initDropdowns, initPopovers, + cleanupPopovers, initTooltips, + cleanupTooltips, initTabs, initModal }; @@ -26,7 +28,9 @@ const DavidAI = { initCollapse, initDropdowns, initPopovers, + cleanupPopovers, initTooltips, + cleanupTooltips, initTabs, initModal }; diff --git a/packages/src/modal/modal.js b/packages/src/modal/modal.js index 2983848..6449d58 100644 --- a/packages/src/modal/modal.js +++ b/packages/src/modal/modal.js @@ -1,5 +1,7 @@ // Modal Component +const initializedModals = new WeakSet(); + export function toggleModal(event) { const modalID = event.currentTarget.getAttribute("data-dui-target"); const modal = document.querySelector(modalID); @@ -58,15 +60,21 @@ function closeOnOutsideClick(event) { export function initModal() { document.querySelectorAll("[data-dui-toggle='modal']").forEach((trigger) => { - trigger.addEventListener("click", toggleModal); + if (!initializedModals.has(trigger)) { + trigger.addEventListener("click", toggleModal); + initializedModals.add(trigger); + } }); document.querySelectorAll("[data-dui-dismiss='modal']").forEach((button) => { - button.addEventListener("click", closeModal); + if (!initializedModals.has(button)) { + button.addEventListener("click", closeModal); + initializedModals.add(button); + } }); } // Auto-initialize Modals in the Browser Environment -if (typeof window !== "undefined") { +if (typeof window !== "undefined" && typeof document !== "undefined") { initModal(); } diff --git a/packages/src/popover/popover.js b/packages/src/popover/popover.js index e8e7b43..5408d31 100644 --- a/packages/src/popover/popover.js +++ b/packages/src/popover/popover.js @@ -1,8 +1,13 @@ -// Popover component +// Popover Component +import { loadPopperJs } from '../utils/loadPopper'; + +const initializedPopovers = new WeakSet(); // Prevent duplicate initialization +let activePopovers = []; // Track active popovers for cleanup + export function initPopovers() { - const popoverTriggers = document.querySelectorAll("[data-dui-toggle='popover']"); + document.querySelectorAll("[data-dui-toggle='popover']").forEach((trigger) => { + if (initializedPopovers.has(trigger)) return; // Avoid re-initializing - popoverTriggers.forEach(trigger => { const placement = trigger.getAttribute("data-dui-placement") || "top"; const popoverClasses = trigger.getAttribute("data-dui-popover-class") || "popover-default"; const plainContent = trigger.getAttribute("data-dui-content"); @@ -38,14 +43,11 @@ export function initPopovers() { popoverInstance = Popper.createPopper(trigger, popoverElement, { placement: placement, - modifiers: [ - { name: "offset", options: { offset: [0, 8] } } - ], + modifiers: [{ name: "offset", options: { offset: [0, 8] } }], }); - // Store references for cleanup - trigger._popoverInstance = popoverInstance; - trigger._popoverElement = popoverElement; + // Track active popovers for cleanup + activePopovers.push({ trigger, popoverElement, popoverInstance }); } // Function to close the popover @@ -61,6 +63,9 @@ export function initPopovers() { popoverElement.remove(); popoverElement = null; } + + // Remove from active popovers + activePopovers = activePopovers.filter((p) => p.trigger !== trigger); } // Toggle popover on click @@ -77,5 +82,28 @@ export function initPopovers() { if (isOpenByDefault) { openPopover(); } + + // Mark as initialized + initializedPopovers.add(trigger); }); } + +// Cleanup function to destroy all active popovers +export function cleanupPopovers() { + activePopovers.forEach(({ popoverElement, popoverInstance }) => { + if (popoverInstance) popoverInstance.destroy(); + if (popoverElement) popoverElement.remove(); + }); + activePopovers = []; +} + +// Combined initialization function +export async function loadAndInitPopovers() { + await loadPopperJs(); + initPopovers(); +} + +// Auto-initialize Popovers in the Browser Environment +if (typeof window !== "undefined" && typeof document !== "undefined") { + loadAndInitPopovers(); +} diff --git a/packages/src/tabs/tabs.js b/packages/src/tabs/tabs.js index b4fe2ef..606982c 100644 --- a/packages/src/tabs/tabs.js +++ b/packages/src/tabs/tabs.js @@ -5,28 +5,38 @@ export function initTabs() { const tabLinks = tabList.querySelectorAll(".tab-link"); const tabContents = tabGroup.querySelectorAll(".tab-content"); const indicator = tabList.querySelector(".tab-indicator"); - const isVertical = tabGroup.getAttribute("data-dui-orientation") === "vertical"; - // Function to update the indicator position dynamically function updateIndicator(link) { const rect = link.getBoundingClientRect(); const parentRect = tabList.getBoundingClientRect(); - if (isVertical) { - // For vertical tabs - indicator.style.height = `${rect.height}px`; - indicator.style.transform = `translateY(${rect.top - parentRect.top}px)`; - } else { - // For horizontal tabs - indicator.style.width = `${rect.width}px`; - indicator.style.transform = `translateX(${rect.left - parentRect.left}px)`; - } + requestAnimationFrame(() => { + if (isVertical) { + const offsetY = rect.top - parentRect.top; + const height = rect.height; + + // Apply styles dynamically for vertical orientation + indicator.style.transform = `translateY(${offsetY}px)`; + indicator.style.height = `${height}px`; + } else { + const offsetX = rect.left - parentRect.left; + const width = rect.width; + + // Apply styles dynamically for horizontal orientation + indicator.style.transform = `translateX(${offsetX}px)`; + indicator.style.width = `${width}px`; + } + + // Make the indicator visible + indicator.classList.remove("hidden"); + indicator.style.opacity = "1"; + indicator.style.scale = "1"; + }); } - // Function to handle tab activation function activateTab(link) { - // Deactivate all tabs and hide contents + // Deactivate all tabs and hide their content tabLinks.forEach((item) => item.classList.remove("active")); tabContents.forEach((content) => { content.classList.add("hidden"); @@ -45,17 +55,19 @@ export function initTabs() { updateIndicator(link); } - // Initialize the tabs - tabLinks.forEach((link) => { - // If a tab is already active, update the indicator - if (link.classList.contains("active")) { - activateTab(link); + // Check for the tab with the `active` class and set the indicator initially + setTimeout(() => { + const activeLink = tabList.querySelector(".tab-link.active"); + if (activeLink) { + activateTab(activeLink); } + }, 100); - // Add click event listener to each tab link + // Initialize click event listeners for each tab + tabLinks.forEach((link) => { link.addEventListener("click", (event) => { - event.preventDefault(); - activateTab(link); + event.preventDefault(); // Prevent default browser behavior + activateTab(link); // Activate the clicked tab and update the indicator }); }); }); @@ -63,5 +75,15 @@ export function initTabs() { // Auto-initialize tabs in the browser if (typeof window !== "undefined") { - initTabs(); + document.addEventListener("DOMContentLoaded", () => { + initTabs(); + }); } + + + + + + + + diff --git a/packages/src/tooltip/tooltip.js b/packages/src/tooltip/tooltip.js index 6151518..99854a5 100644 --- a/packages/src/tooltip/tooltip.js +++ b/packages/src/tooltip/tooltip.js @@ -1,8 +1,13 @@ -// Tooltip component +// Tooltip Component +import { loadPopperJs } from '../utils/loadPopper'; + +const initializedTooltips = new WeakSet(); // Prevent duplicate initialization +let activeTooltips = []; // Track active tooltips for cleanup + export function initTooltips() { - const tooltipTriggers = document.querySelectorAll("[data-dui-toggle='tooltip']"); + document.querySelectorAll("[data-dui-toggle='tooltip']").forEach((trigger) => { + if (initializedTooltips.has(trigger)) return; // Avoid re-initializing - tooltipTriggers.forEach((trigger) => { const title = trigger.getAttribute("data-dui-title"); // Plain text content const placement = trigger.getAttribute("data-dui-placement") || "top"; const tooltipClasses = trigger.getAttribute("data-dui-tooltip-class") || "tooltip-default"; @@ -16,10 +21,8 @@ export function initTooltips() { customContentElement = trigger.nextElementSibling; } - // Show the tooltip + // Function to show the tooltip function showTooltip() { - if (tooltipElement) return; // Avoid duplicate tooltips - tooltipElement = document.createElement("div"); tooltipElement.className = tooltipClasses; @@ -37,36 +40,56 @@ export function initTooltips() { document.body.appendChild(tooltipElement); - // Create Popper.js instance tooltipInstance = Popper.createPopper(trigger, tooltipElement, { placement: placement, modifiers: [{ name: "offset", options: { offset: [0, 8] } }], }); + + // Track active tooltips for cleanup + activeTooltips.push({ trigger, tooltipElement, tooltipInstance }); } - // Hide the tooltip + // Function to hide the tooltip function hideTooltip() { - if (tooltipElement && !trigger.classList.contains("static-tooltip")) { + if (tooltipInstance) { tooltipInstance.destroy(); tooltipInstance = null; + } + + if (tooltipElement) { tooltipElement.remove(); tooltipElement = null; } + + // Remove from active tooltips + activeTooltips = activeTooltips.filter((t) => t.trigger !== trigger); } - // Event Listeners + // Add event listeners for showing and hiding tooltips trigger.addEventListener("mouseenter", showTooltip); trigger.addEventListener("mouseleave", hideTooltip); - // Toggle static tooltips on click - trigger.addEventListener("click", () => { - if (trigger.classList.contains("static-tooltip")) { - trigger.classList.remove("static-tooltip"); - hideTooltip(); - } else { - trigger.classList.add("static-tooltip"); - showTooltip(); - } - }); + // Mark as initialized + initializedTooltips.add(trigger); + }); +} + +// Cleanup function to destroy all active tooltips +export function cleanupTooltips() { + activeTooltips.forEach(({ tooltipElement, tooltipInstance }) => { + if (tooltipInstance) tooltipInstance.destroy(); + if (tooltipElement) tooltipElement.remove(); }); + activeTooltips = []; +} + +// Combined initialization function +export async function loadAndInitTooltips() { + await loadPopperJs(); + initTooltips(); +} + +// Auto-initialize Tooltips in the Browser Environment +if (typeof window !== "undefined" && typeof document !== "undefined") { + loadAndInitTooltips(); }