@hunter-industries/hunter-components 0.0.102 → 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",
@@ -1255,11 +1255,11 @@ const _hoisted_1$Z = {
1255
1255
  fill: "none"
1256
1256
  };
1257
1257
  const _hoisted_2$V = /* @__PURE__ */ createStaticVNode('<circle cx="16" cy="16" r="15.625" fill="#fff" opacity=".8"></circle><path fill="#68aee0" d="M18.859 27.5v-23h6.64v23z"></path><path fill="#3A2F26" d="M20.756 27.501v-23h2.846v23z"></path><path fill="#68aee0" d="M20.76 19.91H2.5v-6.64h18.26z"></path><path fill="#3A2F26" d="M20.761 18.012H2.501v-2.846h18.26z"></path>', 5);
1258
- const _hoisted_7$2 = [
1258
+ const _hoisted_7$1 = [
1259
1259
  _hoisted_2$V
1260
1260
  ];
1261
1261
  function render$J(_ctx, _cache) {
1262
- return openBlock(), createElementBlock("svg", _hoisted_1$Z, [..._hoisted_7$2]);
1262
+ return openBlock(), createElementBlock("svg", _hoisted_1$Z, [..._hoisted_7$1]);
1263
1263
  }
1264
1264
  const __vite_glob_0_75 = { render: render$J };
1265
1265
  const _hoisted_1$Y = {
@@ -2745,8 +2745,8 @@ const _hoisted_3$8 = {
2745
2745
  const _hoisted_4$7 = ["src", "alt"];
2746
2746
  const _hoisted_5$4 = { class: "hc__card__text" };
2747
2747
  const _hoisted_6$2 = { class: "hc__card__text__description" };
2748
- const _hoisted_7$1 = { class: "card-description-body-wrapper" };
2749
- const _hoisted_8$1 = { class: "description" };
2748
+ const _hoisted_7 = { class: "card-description-body-wrapper" };
2749
+ const _hoisted_8 = { class: "description" };
2750
2750
  const _hoisted_9 = {
2751
2751
  key: 0,
2752
2752
  class: "hc__card__buttons float2"
@@ -2815,8 +2815,8 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2815
2815
  createElementVNode("div", {
2816
2816
  class: normalizeClass(["hc__card__text__title", "uppercase"])
2817
2817
  }, toDisplayString(_ctx.title), 1),
2818
- createElementVNode("div", _hoisted_7$1, [
2819
- createElementVNode("div", _hoisted_8$1, [
2818
+ createElementVNode("div", _hoisted_7, [
2819
+ createElementVNode("div", _hoisted_8, [
2820
2820
  !_ctx.hideToggleButton ? (openBlock(), createElementBlock("div", _hoisted_9, [
2821
2821
  withDirectives(createVNode(unref(_sfc_main$l), {
2822
2822
  variant: "icon-primary",
@@ -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: {
@@ -4152,17 +4179,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
4152
4179
  }
4153
4180
  });
4154
4181
  const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-603385ac"]]);
4155
- const _hoisted_1 = { class: "slider-and-single-unit-container" };
4156
- const _hoisted_2 = { class: "slider-with-descriptions" };
4157
- const _hoisted_3 = { class: "slider-container" };
4158
- const _hoisted_4 = {
4182
+ const _hoisted_1 = { class: "slider-with-descriptions" };
4183
+ const _hoisted_2 = ["min", "max"];
4184
+ const _hoisted_3 = {
4159
4185
  class: "ticks",
4160
4186
  "aria-hidden": "true"
4161
4187
  };
4162
- const _hoisted_5 = { class: "text-under-slider" };
4163
- const _hoisted_6 = { class: "text" };
4164
- const _hoisted_7 = { class: "title" };
4165
- const _hoisted_8 = {
4188
+ const _hoisted_4 = { class: "text-under-slider" };
4189
+ const _hoisted_5 = { class: "title" };
4190
+ const _hoisted_6 = {
4166
4191
  key: 0,
4167
4192
  class: "unit-text"
4168
4193
  };
@@ -4179,16 +4204,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4179
4204
  text: {},
4180
4205
  tickEvery: { default: 2 },
4181
4206
  showSelection: { type: Boolean, default: true },
4182
- unit: { default: '"' }
4207
+ unit: { default: '"' },
4208
+ maxCharacterSize: { default: "3ch" },
4209
+ locked: { type: Boolean, default: false }
4183
4210
  },
4184
4211
  emits: ["change", "input"],
4185
4212
  setup(__props, { emit: __emit }) {
4186
4213
  useCssVars((_ctx) => ({
4187
- "32a6fe14": primaryColor,
4188
- "05354dbc": secondaryColor,
4189
- "e10d3100": thumbColor,
4190
- "49449f78": thumbSize
4214
+ "0f62f7dc": unref(primaryColor),
4215
+ "c9ebfe2c": unref(secondaryColor),
4216
+ "660d9970": unref(thumbColor),
4217
+ "875d6908": unref(thumbSize),
4218
+ "6dccefa1": unref(maxCharacterSize)
4191
4219
  }));
4220
+ const props = __props;
4192
4221
  const {
4193
4222
  min,
4194
4223
  max,
@@ -4199,45 +4228,50 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4199
4228
  thumbSize,
4200
4229
  tickEvery,
4201
4230
  showSelection,
4202
- unit
4203
- } = __props;
4231
+ unit,
4232
+ maxCharacterSize
4233
+ } = props;
4204
4234
  const emit = __emit;
4205
4235
  const minN = computed(() => Number(min));
4206
4236
  const maxN = computed(() => Number(max));
4207
4237
  const defN = computed(() => Number(def));
4208
4238
  const slider = ref(null);
4209
4239
  const sliderValue = ref(defN.value);
4210
- const tickCount = computed(
4211
- () => Math.floor(max - min) + 1
4212
- );
4240
+ const tickCount = computed(() => Math.floor(max - min) + 1);
4213
4241
  function calcValue(val) {
4214
- const el = slider.value;
4215
- if (!el) return;
4216
- const hi = Number(el.max || maxN.value);
4217
- const lo = Number(el.min || minN.value);
4218
- const pct = (val - lo) / (hi - lo) * 100;
4219
- el.style.background = `linear-gradient(to right, ${primaryColor} ${pct}%, ${secondaryColor} ${pct}%)`;
4220
4242
  emit("input", val);
4221
4243
  }
4244
+ const sliderBackground = computed(() => {
4245
+ if (props.locked) return "";
4246
+ const hi = maxN.value;
4247
+ const lo = minN.value;
4248
+ const pct = (sliderValue.value - lo) / (hi - lo) * 100;
4249
+ return `linear-gradient(to right, ${primaryColor} ${pct}%, ${secondaryColor} ${pct}%)`;
4250
+ });
4222
4251
  onMounted(() => {
4223
4252
  calcValue(sliderValue.value);
4224
4253
  });
4225
4254
  return (_ctx, _cache) => {
4226
- return openBlock(), createElementBlock("div", _hoisted_1, [
4227
- createElementVNode("div", _hoisted_2, [
4228
- createElementVNode("div", _hoisted_3, [
4255
+ return openBlock(), createElementBlock("div", {
4256
+ class: normalizeClass(["slider-and-single-unit-container", { "locked": _ctx.locked }])
4257
+ }, [
4258
+ createElementVNode("div", _hoisted_1, [
4259
+ createElementVNode("div", {
4260
+ class: "slider-container",
4261
+ style: normalizeStyle({ "--track-color": sliderBackground.value })
4262
+ }, [
4229
4263
  withDirectives(createElementVNode("input", {
4230
4264
  type: "range",
4231
- min,
4232
- max,
4265
+ min: unref(min),
4266
+ max: unref(max),
4233
4267
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => sliderValue.value = $event),
4234
4268
  class: "slider block w-full",
4235
4269
  id: "range",
4236
4270
  ref_key: "slider",
4237
4271
  ref: slider,
4238
- onInput: _cache[1] || (_cache[1] = ($event) => calcValue(sliderValue.value)),
4272
+ onInput: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("input", sliderValue.value)),
4239
4273
  onChange: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("change", sliderValue.value))
4240
- }, null, 544), [
4274
+ }, null, 40, _hoisted_2), [
4241
4275
  [
4242
4276
  vModelText,
4243
4277
  sliderValue.value,
@@ -4245,34 +4279,36 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4245
4279
  { number: true }
4246
4280
  ]
4247
4281
  ]),
4248
- createElementVNode("div", _hoisted_4, [
4282
+ createElementVNode("div", _hoisted_3, [
4249
4283
  (openBlock(true), createElementBlock(Fragment, null, renderList(tickCount.value, (i) => {
4250
4284
  return openBlock(), createElementBlock("span", {
4251
4285
  key: i,
4252
4286
  class: normalizeClass(["tick", {
4253
- hide: (i - 1) % tickEvery !== 0,
4254
- passed: +min + (i - 1) < +sliderValue.value,
4255
- active: +min + (i - 1) === +sliderValue.value
4287
+ hide: (i - 1) % unref(tickEvery) !== 0,
4288
+ passed: +unref(min) + (i - 1) < +sliderValue.value
4256
4289
  }])
4257
4290
  }, null, 2);
4258
4291
  }), 128))
4259
4292
  ])
4260
- ]),
4261
- createElementVNode("div", _hoisted_5, [
4293
+ ], 4),
4294
+ createElementVNode("div", _hoisted_4, [
4262
4295
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.text, (item, _) => {
4263
- return openBlock(), createElementBlock("div", _hoisted_6, [
4264
- createElementVNode("div", _hoisted_7, toDisplayString(item.title), 1),
4296
+ return openBlock(), createElementBlock("div", {
4297
+ key: (item == null ? void 0 : item.title) ?? _,
4298
+ class: "text"
4299
+ }, [
4300
+ createElementVNode("div", _hoisted_5, toDisplayString(item.title), 1),
4265
4301
  createElementVNode("div", null, toDisplayString(item == null ? void 0 : item.description), 1)
4266
4302
  ]);
4267
- }), 256))
4303
+ }), 128))
4268
4304
  ])
4269
4305
  ]),
4270
- showSelection ? (openBlock(), createElementBlock("div", _hoisted_8, toDisplayString(`${sliderValue.value}${unit}`), 1)) : createCommentVNode("", true)
4271
- ]);
4306
+ unref(showSelection) ? (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString(`${sliderValue.value}${unref(unit)}`), 1)) : createCommentVNode("", true)
4307
+ ], 2);
4272
4308
  };
4273
4309
  }
4274
4310
  });
4275
- const Slider = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b87d7551"]]);
4311
+ const Slider = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2eab50c9"]]);
4276
4312
  export {
4277
4313
  _sfc_main$l as HunterButton,
4278
4314
  ButtonIcon as HunterButtonIcon,