@fiscozen/input 0.1.3 → 0.1.5-beta.1

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.5-beta.1",
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.20-beta.1",
13
+ "@fiscozen/icons": "^0.1.9"
13
14
  },
14
15
  "devDependencies": {
15
16
  "@rushstack/eslint-patch": "^1.3.3",
@@ -27,9 +28,9 @@
27
28
  "vite-plugin-dts": "^3.8.3",
28
29
  "vitest": "^1.2.0",
29
30
  "vue-tsc": "^1.8.25",
30
- "@fiscozen/tsconfig": "^0.1.0",
31
31
  "@fiscozen/eslint-config": "^0.1.0",
32
- "@fiscozen/prettier-config": "^0.1.0"
32
+ "@fiscozen/prettier-config": "^0.1.0",
33
+ "@fiscozen/tsconfig": "^0.1.0"
33
34
  },
34
35
  "license": "MIT",
35
36
  "scripts": {
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <FzInput ref="fzInputRef" v-bind="props" type="text"></FzInput>
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { onMounted, ref } from "vue";
7
+ import FzInput from "./FzInput.vue";
8
+ import { FzInputProps } from "./types";
9
+ import { useCurrency } from "@fiscozen/composables";
10
+
11
+ const fzInputRef = ref();
12
+ const props = defineProps<Omit<FzInputProps, "type" | "modelValue">>();
13
+ const { inputRef } = useCurrency();
14
+
15
+ defineEmits(["update:amount"]);
16
+
17
+ onMounted(() => {
18
+ inputRef.value = fzInputRef.value.inputRef;
19
+ });
20
+ const model = defineModel("amount");
21
+ </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>
@@ -92,11 +92,11 @@ const {
92
92
  containerWidth,
93
93
  } = useInputStyle(props, containerRef);
94
94
 
95
- const emit = defineEmits(['input', 'focus']);
95
+ const emit = defineEmits(["input", "focus"]);
96
96
  defineExpose({
97
97
  inputRef,
98
- containerRef
99
- })
98
+ containerRef,
99
+ });
100
100
  </script>
101
101
 
102
102
  <style scoped></style>
@@ -0,0 +1,42 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { flushPromises, mount } from "@vue/test-utils";
3
+ import { FzCurrencyInput } from "..";
4
+ import {ref} from 'vue'
5
+
6
+ describe.concurrent("FzCurrencyInput", () => {
7
+ it("renders floating numbers as currency", async () => {
8
+
9
+ const wrapper = mount(FzCurrencyInput, {
10
+ props: {
11
+ label: "Label",
12
+ amount: 1234.56,
13
+ "onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
14
+ },
15
+ });
16
+
17
+ const inputElement = wrapper.find("input");
18
+ await inputElement.trigger("blur");
19
+ // flushPromises doesn't seem to be enoughsince the implementation
20
+ // of the composable uses setTimeout itself
21
+ await new Promise((resolve) => window.setTimeout(resolve, 100));
22
+ expect(inputElement.element.value).toBe("1234,56");
23
+ });
24
+ it("should not allow inputs other than digits and separators", async () => {
25
+ const wrapper = mount(FzCurrencyInput, {
26
+ props: {
27
+ label: "Label",
28
+ amount: '',
29
+ "onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
30
+ },
31
+ });
32
+
33
+ const inputElement = wrapper.find("input");
34
+ await inputElement.setValue("as12.3");
35
+ await inputElement.trigger("input");
36
+ await new Promise((resolve) => window.setTimeout(resolve, 100));
37
+ expect(inputElement.element.value).toBe("12.3");
38
+ await inputElement.trigger("blur");
39
+ await new Promise((resolve) => window.setTimeout(resolve, 100));
40
+ expect(inputElement.element.value).toBe("12,30");
41
+ });
42
+ });
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
@@ -62,7 +62,8 @@ type FzInputProps = {
62
62
  * native readonly input value
63
63
  */
64
64
  readonly?: boolean;
65
-
66
65
  };
67
66
 
68
- export { FzInputProps };
67
+ type FzCurrencyInputProps = Omit<FzInputProps, "type">;
68
+
69
+ export { FzInputProps, FzCurrencyInputProps };