@hunter-industries/hunter-components 0.0.103 → 0.0.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { createElementBlock, openBlock, createElementVNode, createStaticVNode, defineComponent, toRefs, computed, ref, createBlock, createCommentVNode, resolveDynamicComponent, mergeProps, normalizeStyle, normalizeClass, renderSlot, toDisplayString, unref, createVNode, createTextVNode, watchEffect, withDirectives, vShow, withCtx, vModelCheckbox, Fragment, renderList, watch, onBeforeUnmount, withModifiers, onMounted, vModelRadio, pushScopeId, popScopeId, vModelText, useCssVars } from "vue";
1
+ import { createElementBlock, openBlock, createElementVNode, createStaticVNode, defineComponent, toRefs, computed, ref, createBlock, createCommentVNode, resolveDynamicComponent, mergeProps, normalizeStyle, normalizeClass, renderSlot, toDisplayString, unref, createVNode, createTextVNode, watchEffect, withDirectives, vShow, withCtx, vModelCheckbox, Fragment, renderList, watch, onMounted, onBeforeUnmount, withModifiers, vModelRadio, pushScopeId, popScopeId, vModelText, useCssVars } from "vue";
2
2
  const _hoisted_1$28 = {
3
3
  xmlns: "http://www.w3.org/2000/svg",
4
4
  fill: "currentColor",
@@ -3271,6 +3271,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
3271
3271
  }
3272
3272
  });
3273
3273
  const _hoisted_1$6 = ["id"];
3274
+ const DROPDOWN_OPEN_EVENT = "hunter:dropdown-open";
3274
3275
  const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3275
3276
  __name: "Dropdown",
3276
3277
  props: {
@@ -3318,9 +3319,31 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3318
3319
  collapsed.value = true;
3319
3320
  }
3320
3321
  });
3322
+ onMounted(() => {
3323
+ window.addEventListener(
3324
+ DROPDOWN_OPEN_EVENT,
3325
+ handleOtherDropdownOpen
3326
+ );
3327
+ });
3321
3328
  const toggleDropdown = () => {
3329
+ const wasCollapsed = collapsed.value;
3322
3330
  collapsed.value = !collapsed.value;
3331
+ if (wasCollapsed === true && collapsed.value === false) {
3332
+ window.dispatchEvent(
3333
+ new CustomEvent(DROPDOWN_OPEN_EVENT, {
3334
+ detail: { dropdownId: dropdownId.value }
3335
+ })
3336
+ );
3337
+ }
3323
3338
  };
3339
+ function handleOtherDropdownOpen(e) {
3340
+ var _a;
3341
+ const openedId = (_a = e.detail) == null ? void 0 : _a.dropdownId;
3342
+ if (!openedId) return;
3343
+ if (openedId !== dropdownId.value) {
3344
+ collapsed.value = true;
3345
+ }
3346
+ }
3324
3347
  function handleSelectedOption(item) {
3325
3348
  selectedItem.value = item;
3326
3349
  if ((item == null ? void 0 : item.name) === null && (item == null ? void 0 : item.id) === null) {
@@ -3341,15 +3364,19 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3341
3364
  collapsed.value = true;
3342
3365
  }
3343
3366
  function handleOutsideClick(e) {
3344
- var _a;
3345
3367
  const target = e.target;
3346
- const btn = (_a = dropdownButton == null ? void 0 : dropdownButton.value) == null ? void 0 : _a.buttonEl;
3347
- if (!target || !btn || (target == null ? void 0 : target.id) !== (btn == null ? void 0 : btn.id)) {
3368
+ const root = dropdownWithButton.value;
3369
+ if (!root || !target) return;
3370
+ if (!root.contains(target)) {
3348
3371
  collapsed.value = true;
3349
3372
  }
3350
3373
  }
3351
3374
  onBeforeUnmount(() => {
3352
3375
  document.removeEventListener("click", handleOutsideClick);
3376
+ window.removeEventListener(
3377
+ DROPDOWN_OPEN_EVENT,
3378
+ handleOtherDropdownOpen
3379
+ );
3353
3380
  });
3354
3381
  return (_ctx, _cache) => {
3355
3382
  return openBlock(), createElementBlock("div", {
@@ -3392,7 +3419,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3392
3419
  };
3393
3420
  }
3394
3421
  });
3395
- const Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-c575183f"]]);
3422
+ const Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-2791a8b6"]]);
3396
3423
  const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3397
3424
  __name: "ButtonDropdownColors",
3398
3425
  props: {