@fiscozen/input 0.1.3 → 0.1.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiscozen/input",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Design System Input component",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -9,7 +9,8 @@
9
9
  "peerDependencies": {
10
10
  "tailwindcss": "^3.4.1",
11
11
  "vue": "^3.4.13",
12
- "@fiscozen/icons": "^0.1.0"
12
+ "@fiscozen/composables": "^0.1.15",
13
+ "@fiscozen/icons": "^0.1.9"
13
14
  },
14
15
  "devDependencies": {
15
16
  "@rushstack/eslint-patch": "^1.3.3",
@@ -28,8 +29,8 @@
28
29
  "vitest": "^1.2.0",
29
30
  "vue-tsc": "^1.8.25",
30
31
  "@fiscozen/tsconfig": "^0.1.0",
31
- "@fiscozen/eslint-config": "^0.1.0",
32
- "@fiscozen/prettier-config": "^0.1.0"
32
+ "@fiscozen/prettier-config": "^0.1.0",
33
+ "@fiscozen/eslint-config": "^0.1.0"
33
34
  },
34
35
  "license": "MIT",
35
36
  "scripts": {
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <FzInput
3
+ ref="fzInputRef"
4
+ v-bind="props"
5
+ :model-value="model"
6
+ ></FzInput>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import {onMounted, ref} from 'vue'
11
+ import FzInput from './FzInput.vue'
12
+ import {FzInputProps} from './types'
13
+ import {useCurrency} from '@fiscozen/composables'
14
+
15
+ const fzInputRef = ref();
16
+ const props = defineProps<Omit<FzInputProps, 'type'>>();
17
+ const {inputRef} = useCurrency();
18
+
19
+ onMounted(() => {
20
+ inputRef.value = fzInputRef.value.inputRef
21
+ })
22
+ const model = defineModel()
23
+
24
+ </script>
package/src/FzInput.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="w-full flex flex-col gap-8">
2
+ <div class="fz-input w-full flex flex-col gap-8">
3
3
  <label :class="['text-sm', computedLabelClass]" :for="uniqueId">
4
4
  {{ label }}{{ required ? " *" : "" }}
5
5
  </label>
@@ -0,0 +1,37 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { mount } from "@vue/test-utils";
3
+ import { FzCurrencyInput } from "..";
4
+
5
+ describe.concurrent("FzCurrencyInput", () => {
6
+ it('renders floating numbers as currency', async () => {
7
+ const val = 1234.56
8
+
9
+ const wrapper = mount(FzCurrencyInput, {
10
+ props: {
11
+ label: "Label",
12
+ modelValue: val,
13
+ 'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e})
14
+ },
15
+ });
16
+
17
+ const inputElement = wrapper.find('input')
18
+ await inputElement.setValue(val)
19
+ await inputElement.trigger('blur')
20
+ expect(inputElement.element.value).toBe('1.234,56')
21
+ })
22
+ it('should not allow inputs other than digits and separators', async () => {
23
+ const wrapper = mount(FzCurrencyInput, {
24
+ props: {
25
+ label: "Label",
26
+ 'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e})
27
+ },
28
+ });
29
+
30
+ const inputElement = wrapper.find('input')
31
+ await inputElement.setValue('as12.3')
32
+ await inputElement.trigger('input')
33
+ expect(inputElement.element.value).toBe('12.3')
34
+ await inputElement.trigger('blur')
35
+ expect(inputElement.element.value).toBe('12,30')
36
+ })
37
+ });
package/src/index.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { default as FzInput } from "./FzInput.vue";
2
+ export { default as FzCurrencyInput } from "./FzCurrencyInput.vue";
3
+
2
4
  export type * from "./types";
package/src/types.ts CHANGED
@@ -65,4 +65,6 @@ type FzInputProps = {
65
65
 
66
66
  };
67
67
 
68
- export { FzInputProps };
68
+ type FzCurrencyInputProps = Omit<FzInputProps, 'type'>
69
+
70
+ export { FzInputProps, FzCurrencyInputProps };