index.mjs 764 B

1234567891011121314151617181920212223
  1. import { MINIMUM_INPUT_WIDTH } from "../../constants/form.mjs";
  2. import { useResizeObserver } from "@vueuse/core";
  3. import { computed, ref, shallowRef } from "vue";
  4. //#region ../../packages/hooks/use-calc-input-width/index.ts
  5. function useCalcInputWidth() {
  6. const calculatorRef = shallowRef();
  7. const calculatorWidth = ref(0);
  8. const inputStyle = computed(() => ({ minWidth: `${Math.max(calculatorWidth.value, MINIMUM_INPUT_WIDTH)}px` }));
  9. const resetCalculatorWidth = () => {
  10. calculatorWidth.value = calculatorRef.value?.getBoundingClientRect().width ?? 0;
  11. };
  12. useResizeObserver(calculatorRef, resetCalculatorWidth);
  13. return {
  14. calculatorRef,
  15. calculatorWidth,
  16. inputStyle
  17. };
  18. }
  19. //#endregion
  20. export { useCalcInputWidth };
  21. //# sourceMappingURL=index.mjs.map