index.mjs 746 B

123456789101112131415161718192021222324
  1. import { shallowRef, ref, computed } from 'vue';
  2. import { useResizeObserver } from '@vueuse/core';
  3. function useCalcInputWidth() {
  4. const calculatorRef = shallowRef();
  5. const calculatorWidth = ref(0);
  6. const MINIMUM_INPUT_WIDTH = 11;
  7. const inputStyle = computed(() => ({
  8. minWidth: `${Math.max(calculatorWidth.value, MINIMUM_INPUT_WIDTH)}px`
  9. }));
  10. const resetCalculatorWidth = () => {
  11. var _a, _b;
  12. calculatorWidth.value = (_b = (_a = calculatorRef.value) == null ? void 0 : _a.getBoundingClientRect().width) != null ? _b : 0;
  13. };
  14. useResizeObserver(calculatorRef, resetCalculatorWidth);
  15. return {
  16. calculatorRef,
  17. calculatorWidth,
  18. inputStyle
  19. };
  20. }
  21. export { useCalcInputWidth };
  22. //# sourceMappingURL=index.mjs.map