@hunter-industries/hunter-components 0.0.89 → 0.0.91

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.
@@ -2809,7 +2809,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2809
2809
  id: {},
2810
2810
  selected: {},
2811
2811
  variant: {},
2812
- showClearButton: { type: Boolean }
2812
+ showClearButton: { type: Boolean },
2813
+ listMaxHeight: {}
2813
2814
  },
2814
2815
  emits: ["selectOption"],
2815
2816
  setup(__props, { emit: __emit }) {
@@ -2820,9 +2821,18 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2820
2821
  const listOptions = computed(
2821
2822
  () => props.options.filter((item) => !item.placeholder) || []
2822
2823
  );
2823
- const handleSelectedOption = (option) => {
2824
+ const resolvedMaxHeight = computed(() => props.listMaxHeight ?? 244);
2825
+ const scrollStyle = computed(() => {
2826
+ if (!isScrollable.value)
2827
+ return void 0;
2828
+ return {
2829
+ maxHeight: `${resolvedMaxHeight.value}px`,
2830
+ overflowY: "auto"
2831
+ };
2832
+ });
2833
+ function handleSelectedOption(option) {
2824
2834
  emit("selectOption", option);
2825
- };
2835
+ }
2826
2836
  return (_ctx, _cache) => {
2827
2837
  return openBlock(), createElementBlock("div", {
2828
2838
  id: `dropdown-list-${_ctx.id}`,
@@ -2832,7 +2842,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2832
2842
  createElementVNode("div", _hoisted_2$6, [
2833
2843
  createElementVNode("ol", {
2834
2844
  ref: "dropdown",
2835
- class: normalizeClass(["hunter-dropdown-ol", isScrollable.value && "max-h-44 overflow-y-auto"])
2845
+ class: "hunter-dropdown-ol",
2846
+ style: normalizeStyle(scrollStyle.value)
2836
2847
  }, [
2837
2848
  (openBlock(true), createElementBlock(Fragment, null, renderList(listOptions.value, (item) => {
2838
2849
  return openBlock(), createElementBlock("li", {
@@ -2857,13 +2868,13 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2857
2868
  onClick: _cache[0] || (_cache[0] = ($event) => handleSelectedOption({ id: null, name: null }))
2858
2869
  }, " Clear Selection ")) : createCommentVNode("", true)
2859
2870
  ])
2860
- ], 2)
2871
+ ], 4)
2861
2872
  ])
2862
2873
  ], 10, _hoisted_1$8);
2863
2874
  };
2864
2875
  }
2865
2876
  });
2866
- const DropdownList = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-fee97d10"]]);
2877
+ const DropdownList = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-ce8d21c1"]]);
2867
2878
  const _sfc_main$c = /* @__PURE__ */ defineComponent({
2868
2879
  __name: "DropdownListWithFilter",
2869
2880
  props: {
@@ -3074,7 +3085,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3074
3085
  dropdownClassName: {},
3075
3086
  disabled: { type: Boolean },
3076
3087
  scrollable: { type: Boolean },
3077
- showClearButton: { type: Boolean }
3088
+ showClearButton: { type: Boolean },
3089
+ listMaxHeight: {}
3078
3090
  },
3079
3091
  emits: ["selectOption"],
3080
3092
  setup(__props, { emit: __emit }) {
@@ -3092,11 +3104,11 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3092
3104
  const collapsed = ref(true);
3093
3105
  const selectedItem = ref();
3094
3106
  const dropdownButtonText = ref(
3095
- props.defaultText || props.placeholderText || props.options[0].name
3107
+ props.defaultText || props.placeholderText || ""
3096
3108
  );
3097
3109
  watch(collapsed, (value) => {
3098
3110
  if (value === false) {
3099
- return document.addEventListener("click", handleOutsideClick);
3111
+ document.addEventListener("click", handleOutsideClick);
3100
3112
  } else {
3101
3113
  document.removeEventListener("click", handleOutsideClick);
3102
3114
  }
@@ -3109,34 +3121,35 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3109
3121
  const toggleDropdown = () => {
3110
3122
  collapsed.value = !collapsed.value;
3111
3123
  };
3112
- const handleSelectedOption = (item) => {
3113
- var _a;
3124
+ function handleSelectedOption(item) {
3114
3125
  selectedItem.value = item;
3115
- if (item.name === null && item.id === null) {
3116
- dropdownButtonText.value = props.placeholderText || ((_a = props.options[0]) == null ? void 0 : _a.name);
3126
+ if ((item == null ? void 0 : item.name) === null && (item == null ? void 0 : item.id) === null) {
3127
+ dropdownButtonText.value = props.placeholderText || "";
3117
3128
  emit("selectOption", { id: null, name: null });
3118
- return dropdownButtonText.value;
3129
+ return;
3119
3130
  }
3120
- dropdownButtonText.value = item.name;
3131
+ dropdownButtonText.value = (item == null ? void 0 : item.name) ?? "";
3121
3132
  setTimeout(() => {
3122
3133
  collapsed.value = true;
3123
3134
  }, 300);
3124
3135
  emit("selectOption", item);
3125
- return dropdownButtonText.value;
3126
- };
3127
- const handleOutsideClick = (e) => {
3136
+ }
3137
+ function handleClearSelection() {
3138
+ selectedItem.value = null;
3139
+ dropdownButtonText.value = props.placeholderText || "";
3140
+ emit("selectOption", { id: null, name: null });
3141
+ collapsed.value = true;
3142
+ }
3143
+ function handleOutsideClick(e) {
3128
3144
  var _a;
3129
3145
  const target = e.target;
3130
3146
  const btn = (_a = dropdownButton == null ? void 0 : dropdownButton.value) == null ? void 0 : _a.buttonEl;
3131
3147
  if (!target || !btn || (target == null ? void 0 : target.id) !== (btn == null ? void 0 : btn.id)) {
3132
3148
  collapsed.value = true;
3133
3149
  }
3134
- };
3150
+ }
3135
3151
  onBeforeUnmount(() => {
3136
- return document.removeEventListener(
3137
- "click",
3138
- (e) => handleOutsideClick(e)
3139
- );
3152
+ document.removeEventListener("click", handleOutsideClick);
3140
3153
  });
3141
3154
  return (_ctx, _cache) => {
3142
3155
  var _a;
@@ -3171,14 +3184,16 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3171
3184
  variant: ((_a = _ctx.variant) == null ? void 0 : _a.includes("small")) ? "small" : "default",
3172
3185
  "show-clear-button": _ctx.showClearButton,
3173
3186
  scrollable: _ctx.scrollable,
3174
- onSelectOption: handleSelectedOption
3175
- }, null, 8, ["options", "option-key", "collapsed", "selected", "variant", "show-clear-button", "scrollable"])
3187
+ "list-max-height": _ctx.listMaxHeight,
3188
+ onSelectOption: handleSelectedOption,
3189
+ onClearSelection: handleClearSelection
3190
+ }, null, 8, ["options", "option-key", "collapsed", "selected", "variant", "show-clear-button", "scrollable", "list-max-height"])
3176
3191
  ], 8, _hoisted_1$5)
3177
3192
  ], 2);
3178
3193
  };
3179
3194
  }
3180
3195
  });
3181
- const Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-d0720735"]]);
3196
+ const Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-257d9ae4"]]);
3182
3197
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3183
3198
  __name: "ButtonDropdownColors",
3184
3199
  props: {
@@ -3376,7 +3391,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3376
3391
  }
3377
3392
  });
3378
3393
  const FormInput = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-7719e3d0"]]);
3379
- const _withScopeId = (n) => (pushScopeId("data-v-d49ef131"), n = n(), popScopeId(), n);
3394
+ const _withScopeId = (n) => (pushScopeId("data-v-26606b3a"), n = n(), popScopeId(), n);
3380
3395
  const _hoisted_1$3 = { class: "unit-selection-container" };
3381
3396
  const _hoisted_2$2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "font-medium" }, "Units", -1));
3382
3397
  const _hoisted_3$1 = { class: "unit-selection" };
@@ -3401,7 +3416,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3401
3416
  submitButtonText: {},
3402
3417
  cancelButtonText: {},
3403
3418
  showCancelButton: { type: Boolean },
3404
- successSubmitButtonDisabled: { type: Boolean }
3419
+ successSubmitButtonDisabled: { type: Boolean },
3420
+ focusOnFirstInput: { type: Boolean }
3405
3421
  },
3406
3422
  emits: ["cancelSubmit", "submitForm"],
3407
3423
  setup(__props, { emit: __emit }) {
@@ -3414,6 +3430,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3414
3430
  } = toRefs(props);
3415
3431
  const status = ref(props.submitStatus);
3416
3432
  const formInputs = ref(props.inputs);
3433
+ const form = ref();
3417
3434
  const unit = ref("en");
3418
3435
  const emit = __emit;
3419
3436
  const canSubmit = computed(() => {
@@ -3516,6 +3533,11 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3516
3533
  handleFormSubmit(e);
3517
3534
  }
3518
3535
  });
3536
+ if (props.focusOnFirstInput) {
3537
+ if (form.value && form.value[0]) {
3538
+ form.value[0].focus();
3539
+ }
3540
+ }
3519
3541
  });
3520
3542
  onBeforeUnmount(() => {
3521
3543
  document.removeEventListener("keydown", (e) => {
@@ -3533,7 +3555,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3533
3555
  return openBlock(), createElementBlock("form", {
3534
3556
  class: "hunter-component hunter-form",
3535
3557
  onSubmit: withModifiers(handleFormSubmit, ["prevent"]),
3536
- novalidate: ""
3558
+ novalidate: "",
3559
+ ref_key: "form",
3560
+ ref: form
3537
3561
  }, [
3538
3562
  (openBlock(true), createElementBlock(Fragment, null, renderList(formInputs.value, (input, index2) => {
3539
3563
  return openBlock(), createBlock(FormInput, mergeProps({
@@ -3596,11 +3620,11 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3596
3620
  type: "submit"
3597
3621
  }), null, 16, ["class", "status", "disabled"])
3598
3622
  ])
3599
- ], 32);
3623
+ ], 544);
3600
3624
  };
3601
3625
  }
3602
3626
  });
3603
- const index = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-d49ef131"]]);
3627
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-26606b3a"]]);
3604
3628
  const _hoisted_1$2 = ["href"];
3605
3629
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3606
3630
  __name: "Link",