@code-coaching/vuetiful 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ import { DirectiveBinding } from 'vue';
2
+ interface HTMLElementWithClickOutsideHandler extends HTMLElement {
3
+ _clickOutsideHandler?: (event: MouseEvent) => void;
4
+ }
5
+ declare const clickOutsideGroup: {
6
+ mounted(el: HTMLElementWithClickOutsideHandler, binding: DirectiveBinding): void;
7
+ beforeUnmount(el: HTMLElementWithClickOutsideHandler): void;
8
+ };
9
+ export default clickOutsideGroup;
@@ -0,0 +1,9 @@
1
+ import { DirectiveBinding } from 'vue';
2
+ interface HTMLElementWithClickOutsideHandler extends HTMLElement {
3
+ _clickOutsideHandler?: (event: MouseEvent) => void;
4
+ }
5
+ declare const clickOutside: {
6
+ mounted(el: HTMLElementWithClickOutsideHandler, binding: DirectiveBinding): void;
7
+ beforeUnmount(el: HTMLElementWithClickOutsideHandler): void;
8
+ };
9
+ export default clickOutside;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,4 @@
1
+ import vClickOutside from './click-outside';
2
+ import vClickOutsideGroup from './click-outside-group';
1
3
  import vClipboard from './clipboard';
2
- export { vClipboard };
4
+ export { vClickOutside, vClickOutsideGroup, vClipboard };
@@ -50071,7 +50071,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
50071
50071
  ]),
50072
50072
  _: 1
50073
50073
  }, 8, ["class"]),
50074
- showPopup.value ? (openBlock(), createElementBlock("div", {
50074
+ showPopup.value ? withDirectives((openBlock(), createElementBlock("div", {
50075
50075
  key: 0,
50076
50076
  class: normalizeClass(["vuetiful-theme-switcher__popup absolute z-10 mt-1 space-y-4 p-4 shadow-xl rounded-container-token", `${__props.background} ${__props.text} ${__props.widthPopup} ${__props.classList}`])
50077
50077
  }, [
@@ -50095,7 +50095,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
50095
50095
  }, 1032, ["class", "onClick"]);
50096
50096
  }), 128))
50097
50097
  ], 2)
50098
- ], 2)) : createCommentVNode("", true)
50098
+ ], 2)), [
50099
+ [unref(clickOutsideGroup), {
50100
+ elementsInGroup: [".vuetiful-theme-switcher__button"],
50101
+ callback: () => showPopup.value = false
50102
+ }]
50103
+ ]) : createCommentVNode("", true)
50099
50104
  ]);
50100
50105
  };
50101
50106
  }
@@ -50440,6 +50445,48 @@ ${generateColorCSS(theme)}
50440
50445
  registerTheme
50441
50446
  };
50442
50447
  };
50448
+ const clickOutside = {
50449
+ mounted(el, binding) {
50450
+ const clickOutsideHandler = (event) => {
50451
+ if (!el.contains(event.target)) {
50452
+ binding.value();
50453
+ }
50454
+ };
50455
+ document.addEventListener("click", clickOutsideHandler);
50456
+ el._clickOutsideHandler = clickOutsideHandler;
50457
+ },
50458
+ beforeUnmount(el) {
50459
+ if (el._clickOutsideHandler) {
50460
+ document.removeEventListener("click", el._clickOutsideHandler);
50461
+ delete el._clickOutsideHandler;
50462
+ }
50463
+ }
50464
+ };
50465
+ const clickOutsideGroup = {
50466
+ mounted(el, binding) {
50467
+ const { elementsInGroup = [], callback } = binding.value;
50468
+ const elementsToIgnore = elementsInGroup.map((selector) => {
50469
+ const allElements = document.querySelectorAll(selector);
50470
+ const elements = Array.from(allElements);
50471
+ return elements;
50472
+ });
50473
+ const allElementsToIgnore = elementsToIgnore.flat();
50474
+ const clickOutsideHandler = (event) => {
50475
+ const clickedIgnoreElement = allElementsToIgnore.some((el2) => el2 == null ? void 0 : el2.contains(event.target));
50476
+ if (!el.contains(event.target) && !clickedIgnoreElement) {
50477
+ callback();
50478
+ }
50479
+ };
50480
+ document.addEventListener("click", clickOutsideHandler);
50481
+ el._clickOutsideHandler = clickOutsideHandler;
50482
+ },
50483
+ beforeUnmount(el) {
50484
+ if (el._clickOutsideHandler) {
50485
+ document.removeEventListener("click", el._clickOutsideHandler);
50486
+ delete el._clickOutsideHandler;
50487
+ }
50488
+ }
50489
+ };
50443
50490
  const clipboard = (el, binding) => {
50444
50491
  el.addEventListener("click", () => {
50445
50492
  navigator.clipboard.writeText(binding.value);
@@ -50451,4 +50498,4 @@ function install(app) {
50451
50498
  }
50452
50499
  }
50453
50500
  var index = { install };
50454
- export { _sfc_main as ThemeSwitcher, _sfc_main$8 as VAccordion, VAccordionItem, VAlert, _sfc_main$y as VAvatar, _sfc_main$x as VBadge, _sfc_main$w as VButton, _sfc_main$5 as VCard, _sfc_main$4 as VCardBody, _sfc_main$3 as VCardFooter, _sfc_main$2 as VCardHeader, _sfc_main$v as VChip, _sfc_main$1 as VCodeBlock, _sfc_main$l as VDrawer, VLightSwitch, _sfc_main$d as VListbox, VListboxButton, _sfc_main$c as VListboxItem, _sfc_main$f as VListboxItems, _sfc_main$e as VListboxLabel, VPreview, _sfc_main$t as VRadioDescription, _sfc_main$s as VRadioGroup, _sfc_main$r as VRadioItem, _sfc_main$q as VRadioLabel, _sfc_main$j as VRail, _sfc_main$i as VRailTile, _sfc_main$h as VShell, _sfc_main$p as VSwitch, _sfc_main$o as VSwitchDescription, _sfc_main$n as VSwitchGroup, _sfc_main$m as VSwitchLabel, _sfc_main$b as VTab, _sfc_main$a as VTabPanel, _sfc_main$9 as VTabs, index as default, useColors, useDarkMode, useDrawer, useHighlight, usePlatform, useRail, useSettings, useTheme, clipboard as vClipboard };
50501
+ export { _sfc_main as ThemeSwitcher, _sfc_main$8 as VAccordion, VAccordionItem, VAlert, _sfc_main$y as VAvatar, _sfc_main$x as VBadge, _sfc_main$w as VButton, _sfc_main$5 as VCard, _sfc_main$4 as VCardBody, _sfc_main$3 as VCardFooter, _sfc_main$2 as VCardHeader, _sfc_main$v as VChip, _sfc_main$1 as VCodeBlock, _sfc_main$l as VDrawer, VLightSwitch, _sfc_main$d as VListbox, VListboxButton, _sfc_main$c as VListboxItem, _sfc_main$f as VListboxItems, _sfc_main$e as VListboxLabel, VPreview, _sfc_main$t as VRadioDescription, _sfc_main$s as VRadioGroup, _sfc_main$r as VRadioItem, _sfc_main$q as VRadioLabel, _sfc_main$j as VRail, _sfc_main$i as VRailTile, _sfc_main$h as VShell, _sfc_main$p as VSwitch, _sfc_main$o as VSwitchDescription, _sfc_main$n as VSwitchGroup, _sfc_main$m as VSwitchLabel, _sfc_main$b as VTab, _sfc_main$a as VTabPanel, _sfc_main$9 as VTabs, index as default, useColors, useDarkMode, useDrawer, useHighlight, usePlatform, useRail, useSettings, useTheme, clickOutside as vClickOutside, clickOutsideGroup as vClickOutsideGroup, clipboard as vClipboard };