@factorearth/component-library 3.0.1-alpha.0 → 3.0.2-alpha.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.
|
@@ -5,6 +5,8 @@ interface NumberFieldProps {
|
|
|
5
5
|
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
6
6
|
handleBlur: () => void;
|
|
7
7
|
fromTable?: boolean;
|
|
8
|
+
value: number | undefined;
|
|
9
|
+
placeholder?: string;
|
|
8
10
|
}
|
|
9
|
-
export declare const NumberField: ({ colorPalette, handleChange, handleBlur, fromTable }: NumberFieldProps) => React.JSX.Element;
|
|
11
|
+
export declare const NumberField: ({ colorPalette, handleChange, handleBlur, fromTable, value, placeholder, }: NumberFieldProps) => React.JSX.Element;
|
|
10
12
|
export {};
|
|
@@ -4,7 +4,6 @@ import { FiPlus, FiMinus } from "react-icons/fi";
|
|
|
4
4
|
import { MoreHorizonButton } from "../MoreHorizonButton/MoreHorizonButton";
|
|
5
5
|
const NumberFieldContainer = styled.div `
|
|
6
6
|
display: flex;
|
|
7
|
-
min-width: 180px;
|
|
8
7
|
align-items: center;
|
|
9
8
|
gap: -0.5px;
|
|
10
9
|
`;
|
|
@@ -13,6 +12,7 @@ const NumberInput = styled.input `
|
|
|
13
12
|
justify-content: center;
|
|
14
13
|
align-items: center;
|
|
15
14
|
text-align: center;
|
|
15
|
+
min-width: 180px;
|
|
16
16
|
gap: 10px;
|
|
17
17
|
align-self: stretch;
|
|
18
18
|
color: ${({ color }) => color.text.primary};
|
|
@@ -57,32 +57,36 @@ const IncrementButton = styled.div `
|
|
|
57
57
|
background: ${({ color }) => color.background.primary};
|
|
58
58
|
color: ${({ color }) => color.text.primary};
|
|
59
59
|
`;
|
|
60
|
-
export const NumberField = ({ colorPalette, handleChange, handleBlur, fromTable }) => {
|
|
61
|
-
const [
|
|
60
|
+
export const NumberField = ({ colorPalette, handleChange, handleBlur, fromTable, value, placeholder, }) => {
|
|
61
|
+
const [numberValue, setNumberValue] = useState(value);
|
|
62
62
|
const ref = useRef(null);
|
|
63
63
|
const handleIncrement = () => {
|
|
64
|
-
if (
|
|
65
|
-
|
|
64
|
+
if (numberValue === undefined) {
|
|
65
|
+
setNumberValue(1);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
setNumberValue(numberValue + 1);
|
|
69
69
|
};
|
|
70
70
|
const handleDecrement = () => {
|
|
71
|
-
if (
|
|
72
|
-
|
|
71
|
+
if (numberValue === undefined) {
|
|
72
|
+
setNumberValue(1);
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
setNumberValue(numberValue - 1);
|
|
76
76
|
};
|
|
77
77
|
const handleFocus = () => {
|
|
78
78
|
if (fromTable) {
|
|
79
|
-
ref.current?.scrollIntoView({
|
|
79
|
+
ref.current?.scrollIntoView({
|
|
80
|
+
block: "center",
|
|
81
|
+
behavior: "smooth",
|
|
82
|
+
inline: "center",
|
|
83
|
+
});
|
|
80
84
|
}
|
|
81
85
|
};
|
|
82
86
|
return (React.createElement(NumberFieldContainer, { color: colorPalette },
|
|
83
87
|
React.createElement(DecrementButton, { color: colorPalette, onClick: handleDecrement },
|
|
84
88
|
React.createElement(FiMinus, null)),
|
|
85
|
-
React.createElement(NumberInput, { value: value, onChange: handleChange, onBlur: handleBlur, type: "number", color: colorPalette, ref: ref, onFocus: handleFocus }),
|
|
89
|
+
React.createElement(NumberInput, { value: value, onChange: handleChange, onBlur: handleBlur, type: "number", color: colorPalette, ref: ref, onFocus: handleFocus, placeholder: placeholder }),
|
|
86
90
|
React.createElement(IncrementButton, { color: colorPalette, onClick: handleIncrement },
|
|
87
91
|
React.createElement(FiPlus, null)),
|
|
88
92
|
React.createElement(MoreHorizonButton, { colorPalette: colorPalette })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.js","sourceRoot":"","sources":["../../../lib/Atoms/NumberField/NumberField.tsx"],"names":[],"m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,MAAM,EAAE,QAAQ;aAChB,CAAC,CAAC;QACJ,CAAC;IACF,CAAC,CAAC;IAEF,OAAO,CACN,oBAAC,oBAAoB,IAAC,KAAK,EAAE,YAAY;QACxC,oBAAC,eAAe,IAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe;YAC7D,oBAAC,OAAO,OAAG,CACM;QAClB,oBAAC,WAAW,IACX,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,WAAW,GACvB;QACF,oBAAC,eAAe,IAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe;YAC7D,oBAAC,MAAM,OAAG,CACO;QAClB,oBAAC,iBAAiB,IAAC,YAAY,EAAE,YAAY,GAAI,CAC3B,CACvB,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@factorearth/component-library",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2-alpha.0",
|
|
4
4
|
"description": " A storybook component library for FactorEarth",
|
|
5
5
|
"author": "madtrx <marlin.makori@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/FactorEarth/RecordMiddleware#readme",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"access": "public",
|
|
46
46
|
"registry": "https://registry.npmjs.org/"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "7d8405249afcf1dd23d67ee8a939bf79e5f32e08",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@emotion/react": "^11.13.0",
|
|
51
51
|
"@emotion/styled": "^11.13.0",
|