ui icon indicating copy to clipboard operation
ui copied to clipboard

[UInput] Currency input

Open hamonCordova opened this issue 1 year ago • 6 comments

Description

There is a lot of opened/closed issues that we requested currency input. There is same answer everytime, "have you tried this [...]?". There isn't libs that works with UInput!

If there is a way to achive this, please show us a working example or add this feature, please.

Additional context

No response

hamonCordova avatar Apr 22 '24 21:04 hamonCordova

Hello

Could you link some of the issues you are talking about and give more context on your request?

DarioRega avatar Apr 23 '24 08:04 DarioRega

@hamonCordova

There is same answer everytime, "have you tried this [...]?".

You didn't provide any valuable information what you already have tried, so yes this will always be the first response, because people who are willing to help need context!

There isn't libs that works with UInput!

This took me literally 5mins to get UInput hacked together with a random used mask-input library, here v-maska

admin-2

import { vMaska } from 'maska';

export default defineNuxtPlugin(({ vueApp }) => {
  vueApp.directive('maska', vMaska);
});
<script lang="ts" setup>
const currency = ref(13.37);
</script>

<template>
  <div class="m-5 space-y-4">
    <h1>Currency with Maska</h1>
    <UFormGroup label="Currency" name="currency" class="max-w-[200px]">
      <UInput
        v-model="currency"
        v-maska
        data-maska="##.##"
        icon="i-heroicons-currency-dollar"
      />
    </UFormGroup>
  </div>
</template>

fen89 avatar Apr 30 '24 06:04 fen89

Sorry, but this isn't a currency input, this is only a masked input accepting 4 numbers. ASAP i will post a reproduction.

@hamonCordova

There is same answer everytime, "have you tried this [...]?".

You didn't provide any valuable information what you already have tried, so yes this will always be the first response, because people who are willing to help need context!

There isn't libs that works with UInput!

This took me literally 5mins to get UInput hacked together with a random used mask-input library, here v-maska

admin-2 admin-2

import { vMaska } from 'maska';

export default defineNuxtPlugin(({ vueApp }) => {
  vueApp.directive('maska', vMaska);
});
<script lang="ts" setup>
const currency = ref(13.37);
</script>

<template>
  <div class="m-5 space-y-4">
    <h1>Currency with Maska</h1>
    <UFormGroup label="Currency" name="currency" class="max-w-[200px]">
      <UInput
        v-model="currency"
        v-maska
        data-maska="##.##"
        icon="i-heroicons-currency-dollar"
      />
    </UFormGroup>
  </div>
</template>

hamonCordova avatar May 06 '24 17:05 hamonCordova

As i promise, here is a reproduction. You can see, with the HTML native input, works great, but with the UInput (inside UForm or not) it doest work, throwing errors on cosole. I tested with v-money3

Reproduction

@noook can you give some answer? I apreciate any kind of help or other currency lib suggestion.

hamonCordova avatar May 17 '24 13:05 hamonCordova

~Oh I understand. What's happening is that the directive is bound to the wrapper div and not the input itself. This is the reason why it is currently not working.~

Update: I just noticed the previous example with v-maska and it works so that might not be the reason, even though I'm not sure inheritAttrs also inherits from directives. Maybe v-maska intelligently finds the closes input instead of naively binding the directive to the current element

noook avatar May 17 '24 15:05 noook

~Oh I understand. What's happening is that the directive is bound to the wrapper div and not the input itself. This is the reason why it is currently not working.~

Update: I just noticed the previous example with v-maska and it works so that might not be the reason, even though I'm not sure inheritAttrs also inherits from directives. Maybe v-maska intelligently finds the closes input instead of naively binding the directive to the current element

Thanks. I seems to be a v-money3 problem. @noook do you have some other lib suggestion?

hamonCordova avatar May 17 '24 16:05 hamonCordova