@fiscozen/input 2.0.0 → 3.0.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,20 +1,20 @@
1
1
  {
2
2
  "name": "@fiscozen/input",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Design System Input component",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
7
7
  "keywords": [],
8
8
  "author": "Cristian Barraco",
9
9
  "dependencies": {
10
- "@fiscozen/alert": "2.0.0",
11
- "@fiscozen/button": "2.0.0",
12
- "@fiscozen/composables": "1.0.2"
10
+ "@fiscozen/alert": "3.0.0",
11
+ "@fiscozen/button": "3.0.0",
12
+ "@fiscozen/composables": "1.0.3"
13
13
  },
14
14
  "peerDependencies": {
15
15
  "tailwindcss": "^3.4.1",
16
16
  "vue": "^3.4.13",
17
- "@fiscozen/icons": "^0.2.0"
17
+ "@fiscozen/icons": "^1.0.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@rushstack/eslint-patch": "^1.3.3",
@@ -734,12 +734,11 @@ describe('FzCurrencyInput', () => {
734
734
  const inputElement = wrapper.find('input')
735
735
  await inputElement.trigger('blur')
736
736
  await new Promise((resolve) => window.setTimeout(resolve, 100))
737
- // Should be formatted with thousand separators
738
- // Note: decimals are truncated to maximumFractionDigits (2), so 89 becomes 88 (truncated, not rounded)
739
- expect(inputElement.element.value).toBe('1.234.567,88')
740
- // Verify the numeric value in v-model is correct (truncated to 2 decimals)
737
+ // Should be formatted with thousand separators and preserve original decimals
738
+ expect(inputElement.element.value).toBe('1.234.567,89')
739
+ // Verify the numeric value in v-model is correct
741
740
  expect(typeof modelValue).toBe('number')
742
- expect(modelValue).toBeCloseTo(1234567.88, 2)
741
+ expect(modelValue).toBeCloseTo(1234567.89, 2)
743
742
 
744
743
  consoleSpy.mockRestore()
745
744
  })
@@ -1523,6 +1522,71 @@ describe('FzCurrencyInput', () => {
1523
1522
  expect(wrapper.props('modelValue')).toBe(1)
1524
1523
  })
1525
1524
  })
1525
+
1526
+ describe('Floating-point precision (regression)', () => {
1527
+ it.each([
1528
+ ['40,30', 40.3, '40,30'],
1529
+ ['40,20', 40.2, '40,20'],
1530
+ ['40,40', 40.4, '40,40'],
1531
+ ['299,96', 299.96, '299,96'],
1532
+ ['0,30', 0.3, '0,30'],
1533
+ ['10,30', 10.3, '10,30'],
1534
+ ['99,99', 99.99, '99,99'],
1535
+ ])('should preserve "%s" without floating-point drift', async (input, expectedModel, expectedDisplay) => {
1536
+ let modelValue: number | string | undefined = undefined
1537
+ let wrapper: ReturnType<typeof mount> | null = null
1538
+ wrapper = mount(FzCurrencyInput, {
1539
+ props: {
1540
+ label: 'Label',
1541
+ modelValue,
1542
+ 'onUpdate:modelValue': (e) => {
1543
+ modelValue = e as number
1544
+ if (wrapper) wrapper.setProps({ modelValue })
1545
+ },
1546
+ },
1547
+ })
1548
+
1549
+ const inputElement = wrapper.find('input')
1550
+
1551
+ // Focus, type the value, blur
1552
+ await inputElement.trigger('focus')
1553
+ await inputElement.setValue(input)
1554
+ await wrapper.vm.$nextTick()
1555
+ await inputElement.trigger('blur')
1556
+ await new Promise((resolve) => window.setTimeout(resolve, 100))
1557
+
1558
+ expect(wrapper.props('modelValue')).toBe(expectedModel)
1559
+ expect(inputElement.element.value).toBe(expectedDisplay)
1560
+ })
1561
+
1562
+ it.each([
1563
+ [40.3, '40,30'],
1564
+ [40.2, '40,20'],
1565
+ [40.4, '40,40'],
1566
+ [299.96, '299,96'],
1567
+ [1234567.89, '1.234.567,89'],
1568
+ ])('should display correct raw value on focus for v-model %f', async (numericValue, expectedRaw) => {
1569
+ const wrapper = mount(FzCurrencyInput, {
1570
+ props: {
1571
+ label: 'Label',
1572
+ modelValue: numericValue,
1573
+ 'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }),
1574
+ },
1575
+ })
1576
+
1577
+ await wrapper.vm.$nextTick()
1578
+ await new Promise((resolve) => window.setTimeout(resolve, 100))
1579
+
1580
+ const inputElement = wrapper.find('input')
1581
+
1582
+ // Focus to see raw value (without thousand separators)
1583
+ await inputElement.trigger('focus')
1584
+ await wrapper.vm.$nextTick()
1585
+
1586
+ const rawExpected = expectedRaw.replace(/\./g, '')
1587
+ expect(inputElement.element.value).toBe(rawExpected)
1588
+ })
1589
+ })
1526
1590
  })
1527
1591
  })
1528
1592