@tecsinapse/react-web-kit 1.14.0 → 1.15.0
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.15.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.14.0...@tecsinapse/react-web-kit@1.15.0) (2022-02-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* formatWithMask util. Refactoring on useNumberMask and useStringMask hooks. ([76920f6](https://github.com/tecsinapse/design-system/commit/76920f62fb8cf9070b9b2e477dc720e9b7b24077))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [1.14.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.13.0...@tecsinapse/react-web-kit@1.14.0) (2022-02-09)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/react-web-kit",
|
|
3
3
|
"description": "TecSinapse React components",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.15.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@emotion/native": "^11.0.0",
|
|
15
15
|
"@emotion/react": "^11.4.1",
|
|
16
16
|
"@emotion/styled": "^11.3.0",
|
|
17
|
-
"@tecsinapse/react-core": "^1.
|
|
17
|
+
"@tecsinapse/react-core": "^1.14.0",
|
|
18
18
|
"@types/react-native": "^0.64.4",
|
|
19
19
|
"react-native-vector-icons": "^8.1.0",
|
|
20
20
|
"react-transition-group": "^4.4.2"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"react-dom": ">=16.8.0",
|
|
34
34
|
"react-native-web": "^0.17.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "fb1d3b3bfa028174ef30ee2c9387a04c81699c3f"
|
|
37
37
|
}
|
|
@@ -2,6 +2,8 @@ import { action } from '@storybook/addon-actions';
|
|
|
2
2
|
import { Story } from '@storybook/react';
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
4
|
import Input, { InputWebProps } from './Input';
|
|
5
|
+
import { Masks } from '@tecsinapse/react-core/src';
|
|
6
|
+
import { CurrencyOptions } from '@tecsinapse/react-core/src/components/atoms/Input/hooks/useNumberMask';
|
|
5
7
|
|
|
6
8
|
export default {
|
|
7
9
|
title: 'Hybrid/Input',
|
|
@@ -37,3 +39,72 @@ Base.args = {
|
|
|
37
39
|
disabled: false,
|
|
38
40
|
label: 'Login',
|
|
39
41
|
};
|
|
42
|
+
|
|
43
|
+
const TemplateStringMask: Story<InputWebProps> = args => {
|
|
44
|
+
const [value, setValue] = useState<string>('');
|
|
45
|
+
|
|
46
|
+
const onChange = text => {
|
|
47
|
+
setValue(text);
|
|
48
|
+
if (args.onChange) {
|
|
49
|
+
args.onChange(text);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Input
|
|
55
|
+
{...args}
|
|
56
|
+
label={args.label}
|
|
57
|
+
value={value}
|
|
58
|
+
onChange={onChange}
|
|
59
|
+
placeholder={args.placeholder}
|
|
60
|
+
mask={Masks.COMBINED_PHONE}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const StringMask = TemplateStringMask.bind({});
|
|
66
|
+
|
|
67
|
+
StringMask.args = {
|
|
68
|
+
onChange: value => action('onChange')(value),
|
|
69
|
+
placeholder: 'Type your phone',
|
|
70
|
+
disabled: false,
|
|
71
|
+
label: 'Phone',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const TemplateNumberMask: Story<InputWebProps> = args => {
|
|
75
|
+
const [value, setValue] = useState<number>(1200.2);
|
|
76
|
+
|
|
77
|
+
const onChange = text => {
|
|
78
|
+
setValue(text);
|
|
79
|
+
if (args.onChange) {
|
|
80
|
+
args.onChange(text);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const numberMaskExample: CurrencyOptions = {
|
|
85
|
+
symbol: 'R$ ',
|
|
86
|
+
separator: '.',
|
|
87
|
+
decimal: ',',
|
|
88
|
+
precision: 2,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Input
|
|
93
|
+
{...args}
|
|
94
|
+
label={args.label}
|
|
95
|
+
value={value}
|
|
96
|
+
onChange={onChange}
|
|
97
|
+
placeholder={args.placeholder}
|
|
98
|
+
mask={numberMaskExample}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const NumberMask = TemplateNumberMask.bind({});
|
|
104
|
+
|
|
105
|
+
NumberMask.args = {
|
|
106
|
+
onChange: value => action('onChange')(value),
|
|
107
|
+
placeholder: 'Type the price in R$',
|
|
108
|
+
disabled: false,
|
|
109
|
+
label: 'Price',
|
|
110
|
+
};
|