@draftbit/core 43.4.8 → 43.4.11-0e8ceb.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/lib/commonjs/components/Accordion/AccordionGroup.js +2 -2
- package/lib/commonjs/components/Accordion/AccordionGroup.js.map +1 -1
- package/lib/commonjs/components/Elevation.js +14 -3
- package/lib/commonjs/components/Elevation.js.map +1 -1
- package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
- package/lib/commonjs/components/NumberInput.js +15 -17
- package/lib/commonjs/components/NumberInput.js.map +1 -1
- package/lib/commonjs/components/TextField.js +8 -5
- package/lib/commonjs/components/TextField.js.map +1 -1
- package/lib/commonjs/mappings/Icon.js +3 -1
- package/lib/commonjs/mappings/Icon.js.map +1 -1
- package/lib/commonjs/mappings/KeyboardAwareScrollView.js +48 -0
- package/lib/commonjs/mappings/KeyboardAwareScrollView.js.map +1 -0
- package/lib/commonjs/mappings/RowBodyIcon.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageIcon.js.map +1 -1
- package/lib/module/components/Accordion/AccordionGroup.js +2 -2
- package/lib/module/components/Accordion/AccordionGroup.js.map +1 -1
- package/lib/module/components/NumberInput.js +15 -17
- package/lib/module/components/NumberInput.js.map +1 -1
- package/lib/module/components/Stepper.js.map +1 -1
- package/lib/module/components/TextField.js +8 -5
- package/lib/module/components/TextField.js.map +1 -1
- package/lib/module/mappings/Icon.js +3 -1
- package/lib/module/mappings/Icon.js.map +1 -1
- package/lib/module/mappings/KeyboardAwareScrollView.js +39 -0
- package/lib/module/mappings/KeyboardAwareScrollView.js.map +1 -0
- package/lib/typescript/src/mappings/Icon.d.ts +1 -1
- package/lib/typescript/src/mappings/KeyboardAwareScrollView.d.ts +82 -0
- package/package.json +3 -3
- package/src/components/Accordion/AccordionGroup.js +1 -1
- package/src/components/Accordion/AccordionGroup.tsx +1 -1
- package/src/components/NumberInput.js +13 -14
- package/src/components/NumberInput.tsx +16 -31
- package/src/components/TextField.js +5 -4
- package/src/components/TextField.tsx +6 -5
- package/src/mappings/Icon.js +4 -1
- package/src/mappings/Icon.ts +4 -1
- package/src/mappings/KeyboardAwareScrollView.js +38 -0
- package/src/mappings/KeyboardAwareScrollView.ts +48 -0
|
@@ -2,7 +2,8 @@ import React, { useEffect, useState } from "react";
|
|
|
2
2
|
import { TextInput } from "react-native";
|
|
3
3
|
import { isString, isNumber, isNaN } from "lodash";
|
|
4
4
|
const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
5
|
-
const
|
|
5
|
+
const [currentStringNumberValue, setCurrentStringNumberValue] = useState("0");
|
|
6
|
+
const formatValueToStringNumber = (valueToFormat) => {
|
|
6
7
|
if (valueToFormat != null) {
|
|
7
8
|
if (isString(valueToFormat) && valueToFormat !== "") {
|
|
8
9
|
if (/^0[1-9]$/.test(valueToFormat)) {
|
|
@@ -11,7 +12,7 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
|
11
12
|
else if (/^[+-]?([0-9]+\.?[0-9]*|\.[0-9]+)$/.test(valueToFormat)) {
|
|
12
13
|
return valueToFormat;
|
|
13
14
|
}
|
|
14
|
-
else
|
|
15
|
+
else {
|
|
15
16
|
return currentStringNumberValue;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -21,25 +22,23 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
|
21
22
|
}
|
|
22
23
|
return "0";
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
-
const handleChangeText = (newValue) => {
|
|
26
|
-
const newStringNumberValue = formatValueToStringNumber(newValue, currentStringNumberValue);
|
|
27
|
-
const number = parseFloat(newStringNumberValue);
|
|
28
|
-
setCurrentStringNumberValue(newStringNumberValue);
|
|
29
|
-
onChangeText?.(number);
|
|
30
|
-
};
|
|
31
|
-
/* set currentStringNumberValue directly to defaultValue if it exists on load
|
|
32
|
-
( no need to use TextInput's defaultValue because its value is always controlled & set ) */
|
|
25
|
+
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
33
26
|
useEffect(() => {
|
|
34
|
-
const defaultStringNumberValue = formatValueToStringNumber(defaultValue
|
|
27
|
+
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
35
28
|
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
36
29
|
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
37
30
|
}
|
|
38
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
32
|
}, []);
|
|
40
|
-
|
|
33
|
+
const handleChangeText = (newValue) => {
|
|
34
|
+
const newStringNumberValue = formatValueToStringNumber(newValue);
|
|
35
|
+
const number = parseFloat(newStringNumberValue);
|
|
36
|
+
setCurrentStringNumberValue(newStringNumberValue);
|
|
37
|
+
onChangeText?.(number);
|
|
38
|
+
};
|
|
39
|
+
// run handleChangeText with value prop only when value prop changes (and first render to reset currentStringNumberValue)
|
|
41
40
|
useEffect(() => {
|
|
42
|
-
const nextStringNumberValue = formatValueToStringNumber(value
|
|
41
|
+
const nextStringNumberValue = formatValueToStringNumber(value);
|
|
43
42
|
if (currentStringNumberValue !== nextStringNumberValue) {
|
|
44
43
|
handleChangeText(nextStringNumberValue);
|
|
45
44
|
}
|
|
@@ -14,17 +14,16 @@ const NumberInput: FC<Props> = ({
|
|
|
14
14
|
defaultValue,
|
|
15
15
|
...props
|
|
16
16
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
) => {
|
|
17
|
+
const [currentStringNumberValue, setCurrentStringNumberValue] = useState("0");
|
|
18
|
+
|
|
19
|
+
const formatValueToStringNumber = (valueToFormat?: number | string) => {
|
|
21
20
|
if (valueToFormat != null) {
|
|
22
21
|
if (isString(valueToFormat) && valueToFormat !== "") {
|
|
23
22
|
if (/^0[1-9]$/.test(valueToFormat)) {
|
|
24
23
|
return valueToFormat.slice(1);
|
|
25
24
|
} else if (/^[+-]?([0-9]+\.?[0-9]*|\.[0-9]+)$/.test(valueToFormat)) {
|
|
26
25
|
return valueToFormat;
|
|
27
|
-
} else
|
|
26
|
+
} else {
|
|
28
27
|
return currentStringNumberValue;
|
|
29
28
|
}
|
|
30
29
|
} else if (isNumber(valueToFormat) && !isNaN(valueToFormat)) {
|
|
@@ -35,28 +34,9 @@ const NumberInput: FC<Props> = ({
|
|
|
35
34
|
return "0";
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
formatValueToStringNumber(value)
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const handleChangeText = (newValue: string) => {
|
|
43
|
-
const newStringNumberValue = formatValueToStringNumber(
|
|
44
|
-
newValue,
|
|
45
|
-
currentStringNumberValue
|
|
46
|
-
);
|
|
47
|
-
const number = parseFloat(newStringNumberValue);
|
|
48
|
-
|
|
49
|
-
setCurrentStringNumberValue(newStringNumberValue);
|
|
50
|
-
onChangeText?.(number);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/* set currentStringNumberValue directly to defaultValue if it exists on load
|
|
54
|
-
( no need to use TextInput's defaultValue because its value is always controlled & set ) */
|
|
37
|
+
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
55
38
|
useEffect(() => {
|
|
56
|
-
const defaultStringNumberValue = formatValueToStringNumber(
|
|
57
|
-
defaultValue,
|
|
58
|
-
currentStringNumberValue
|
|
59
|
-
);
|
|
39
|
+
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
60
40
|
|
|
61
41
|
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
62
42
|
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
@@ -64,12 +44,17 @@ const NumberInput: FC<Props> = ({
|
|
|
64
44
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
45
|
}, []);
|
|
66
46
|
|
|
67
|
-
|
|
47
|
+
const handleChangeText = (newValue: string) => {
|
|
48
|
+
const newStringNumberValue = formatValueToStringNumber(newValue);
|
|
49
|
+
const number = parseFloat(newStringNumberValue);
|
|
50
|
+
|
|
51
|
+
setCurrentStringNumberValue(newStringNumberValue);
|
|
52
|
+
onChangeText?.(number);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// run handleChangeText with value prop only when value prop changes (and first render to reset currentStringNumberValue)
|
|
68
56
|
useEffect(() => {
|
|
69
|
-
const nextStringNumberValue = formatValueToStringNumber(
|
|
70
|
-
value,
|
|
71
|
-
currentStringNumberValue
|
|
72
|
-
);
|
|
57
|
+
const nextStringNumberValue = formatValueToStringNumber(value);
|
|
73
58
|
|
|
74
59
|
if (currentStringNumberValue !== nextStringNumberValue) {
|
|
75
60
|
handleChangeText(nextStringNumberValue);
|
|
@@ -231,6 +231,7 @@ class TextField extends React.Component {
|
|
|
231
231
|
: leftIconMode === "outset"
|
|
232
232
|
? 16
|
|
233
233
|
: 0,
|
|
234
|
+
marginLeft: leftIconMode === "inset" && type === "solid" ? 16 : 0,
|
|
234
235
|
};
|
|
235
236
|
const labelStyle = {
|
|
236
237
|
...typography.subtitle1,
|
|
@@ -355,10 +356,10 @@ class TextField extends React.Component {
|
|
|
355
356
|
opacity: hasActiveOutline ? this.state.labeled : 1,
|
|
356
357
|
},
|
|
357
358
|
], numberOfLines: 1 }, label))) : null,
|
|
358
|
-
leftIconName && leftIconMode === "inset" ? (React.createElement(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
359
|
+
leftIconName && leftIconMode === "inset" ? (React.createElement(View, { style: {
|
|
360
|
+
justifyContent: type === "solid" ? "center" : undefined,
|
|
361
|
+
} },
|
|
362
|
+
React.createElement(Icon, { ...leftIconProps, style: leftIconStyle }))) : null,
|
|
362
363
|
render({
|
|
363
364
|
ref: (c) => {
|
|
364
365
|
this._root = c;
|
|
@@ -359,6 +359,7 @@ class TextField extends React.Component<Props, State> {
|
|
|
359
359
|
: leftIconMode === "outset"
|
|
360
360
|
? 16
|
|
361
361
|
: 0,
|
|
362
|
+
marginLeft: leftIconMode === "inset" && type === "solid" ? 16 : 0,
|
|
362
363
|
};
|
|
363
364
|
|
|
364
365
|
const labelStyle = {
|
|
@@ -536,13 +537,13 @@ class TextField extends React.Component<Props, State> {
|
|
|
536
537
|
) : null}
|
|
537
538
|
|
|
538
539
|
{leftIconName && leftIconMode === "inset" ? (
|
|
539
|
-
<
|
|
540
|
-
{...leftIconProps}
|
|
540
|
+
<View
|
|
541
541
|
style={{
|
|
542
|
-
|
|
543
|
-
marginLeft: type === "solid" ? 16 : 0,
|
|
542
|
+
justifyContent: type === "solid" ? "center" : undefined,
|
|
544
543
|
}}
|
|
545
|
-
|
|
544
|
+
>
|
|
545
|
+
<Icon {...leftIconProps} style={leftIconStyle} />
|
|
546
|
+
</View>
|
|
546
547
|
) : null}
|
|
547
548
|
|
|
548
549
|
{render({
|
package/src/mappings/Icon.js
CHANGED
package/src/mappings/Icon.ts
CHANGED
|
@@ -13,7 +13,10 @@ export const SEED_DATA = {
|
|
|
13
13
|
category: COMPONENT_TYPES.basic,
|
|
14
14
|
layout: {},
|
|
15
15
|
props: {
|
|
16
|
-
name:
|
|
16
|
+
name: {
|
|
17
|
+
...createIconProp(),
|
|
18
|
+
group: GROUPS.data,
|
|
19
|
+
},
|
|
17
20
|
color: createColorProp(),
|
|
18
21
|
size: createNumberProp({
|
|
19
22
|
group: GROUPS.basic,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { COMPONENT_TYPES, createStaticBoolProp, createStaticNumberProp, } from "@draftbit/types";
|
|
2
|
+
export const SEED_DATA = {
|
|
3
|
+
name: "Keyboard Aware Scroll View",
|
|
4
|
+
tag: "KeyboardAwareScrollView",
|
|
5
|
+
description: "View that moves pushes the content when virtual keyboard is open.",
|
|
6
|
+
category: COMPONENT_TYPES.layout,
|
|
7
|
+
layout: {},
|
|
8
|
+
props: {
|
|
9
|
+
viewIsInsideTabBar: createStaticBoolProp({
|
|
10
|
+
label: "View Is Inside TabBar",
|
|
11
|
+
description: "Adds an extra offset that represents the TabBarIOS height.",
|
|
12
|
+
}),
|
|
13
|
+
enableAutomaticScroll: createStaticBoolProp({
|
|
14
|
+
label: "Enable Automatic Scroll",
|
|
15
|
+
description: "When focus in TextInput will scroll the position, default is enabled",
|
|
16
|
+
}),
|
|
17
|
+
extraHeight: createStaticNumberProp({
|
|
18
|
+
label: "Extra Height",
|
|
19
|
+
description: "Adds an extra offset when focusing the TextInputs",
|
|
20
|
+
}),
|
|
21
|
+
extraScrollHeight: createStaticNumberProp({
|
|
22
|
+
label: "Extra Scroll Height",
|
|
23
|
+
description: "Adds an extra offset to the keyboard. Useful if you want to stick elements above the keyboard",
|
|
24
|
+
}),
|
|
25
|
+
enableResetScrollToCoords: createStaticBoolProp({
|
|
26
|
+
label: "Enable Reset Scroll To Coordinates",
|
|
27
|
+
description: "Lets the user enable or disable automatic resetScrollToCoords",
|
|
28
|
+
}),
|
|
29
|
+
keyboardOpeningTime: createStaticNumberProp({
|
|
30
|
+
label: "Keyboard Opening Time",
|
|
31
|
+
description: "Sets the delay time before scrolling to new position, default is 250",
|
|
32
|
+
}),
|
|
33
|
+
enableOnAndroid: createStaticBoolProp({
|
|
34
|
+
label: "Enable On Android",
|
|
35
|
+
description: "Enable Android Support",
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
createStaticBoolProp,
|
|
4
|
+
createStaticNumberProp,
|
|
5
|
+
} from "@draftbit/types";
|
|
6
|
+
|
|
7
|
+
export const SEED_DATA = {
|
|
8
|
+
name: "Keyboard Aware Scroll View",
|
|
9
|
+
tag: "KeyboardAwareScrollView",
|
|
10
|
+
description:
|
|
11
|
+
"View that moves pushes the content when virtual keyboard is open.",
|
|
12
|
+
category: COMPONENT_TYPES.layout,
|
|
13
|
+
layout: {},
|
|
14
|
+
props: {
|
|
15
|
+
viewIsInsideTabBar: createStaticBoolProp({
|
|
16
|
+
label: "View Is Inside TabBar",
|
|
17
|
+
description: "Adds an extra offset that represents the TabBarIOS height.",
|
|
18
|
+
}),
|
|
19
|
+
enableAutomaticScroll: createStaticBoolProp({
|
|
20
|
+
label: "Enable Automatic Scroll",
|
|
21
|
+
description:
|
|
22
|
+
"When focus in TextInput will scroll the position, default is enabled",
|
|
23
|
+
}),
|
|
24
|
+
extraHeight: createStaticNumberProp({
|
|
25
|
+
label: "Extra Height",
|
|
26
|
+
description: "Adds an extra offset when focusing the TextInputs",
|
|
27
|
+
}),
|
|
28
|
+
extraScrollHeight: createStaticNumberProp({
|
|
29
|
+
label: "Extra Scroll Height",
|
|
30
|
+
description:
|
|
31
|
+
"Adds an extra offset to the keyboard. Useful if you want to stick elements above the keyboard",
|
|
32
|
+
}),
|
|
33
|
+
enableResetScrollToCoords: createStaticBoolProp({
|
|
34
|
+
label: "Enable Reset Scroll To Coordinates",
|
|
35
|
+
description:
|
|
36
|
+
"Lets the user enable or disable automatic resetScrollToCoords",
|
|
37
|
+
}),
|
|
38
|
+
keyboardOpeningTime: createStaticNumberProp({
|
|
39
|
+
label: "Keyboard Opening Time",
|
|
40
|
+
description:
|
|
41
|
+
"Sets the delay time before scrolling to new position, default is 250",
|
|
42
|
+
}),
|
|
43
|
+
enableOnAndroid: createStaticBoolProp({
|
|
44
|
+
label: "Enable On Android",
|
|
45
|
+
description: "Enable Android Support",
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
};
|