1.0.4 • Published 7 months ago

@ossph/use-money v1.0.4

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

💸 Use Money 💰

Installation

Install the @ossph/use-money package using npm or yarn:

npm install @ossph/use-money

or

yarn add @ossph/use-money

Money Component

Importing the Component

To use the Money component, import it as follows:

import { Money } from '@ossph/use-money';

Example Usage

Use the Money component in your Vue templates as follows:

<template>
  <div>
    <Money :input="123456.78" />
  </div>
</template>

<script>
import { Money } from '@ossph/use-money';

export default {
  components: {
    Money
  }
};
</script>

Props API

The Money component accepts the following props:

Prop NameTypeDefaultDescription
inputNumber/StringThe input money value to be formatted.
symbolString'$'The currency symbol.
symbolStylesObject{}CSS styles for the currency symbol.
symbolClassesArray[]CSS classes for the currency symbol.
textStyleObject{}CSS styles for the text.
showSymbolBooleanWhether to show the currency symbol.
showFractionalBooleanWhether to show the fractional part of the money value.

Money Composable

Importing the Composable

To use the useMoney composable, import it as follows:

import { useMoney } from '@ossph/use-money';

Example Usage

Use the useMoney composable in your Vue composition functions as follows:

<template>
  <div>
    <p>Formatted Money Value: {{ formattedMoney }}</p>
  </div>
</template>

<script>
import { useMoney } from '@ossph/use-money';

export default {
  setup() {
    const { moneyValue } = useMoney(123456.78);
    
    return {
      formattedMoney: moneyValue
    };
  }
};
</script>

Composable API

The useMoney composable takes the following parameters:

Prop NameTypeDefaultDescription
valueNumber/StringThe input money value to be formatted.
optionsObject{ showFractional: true, showSymbol: true, symbol: '$' }Formatting options for money value.
showFractionalBooleantrueWhether to show the fractional part of the money value.
showSymbolBooleantrueWhether to show the currency symbol.
symbolString'$'The currency symbol.

It returns an object with the following properties:

PropertyTypeDescription
moneyValueStringThe formatted integer part of the money value.
moneyFractionalStringThe original fractional part.
moneySymbolStringThe currency symbol.
moneyConcatenatedStringThe concatenated value with the currency symbol.
1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago