@draftbit/core 43.4.11-ba6514.0 → 43.4.11-ca8fc3.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.
Files changed (58) hide show
  1. package/lib/commonjs/components/ActionSheet/ActionSheetCancel.js.map +1 -1
  2. package/lib/commonjs/components/Card.js.map +1 -1
  3. package/lib/commonjs/components/CircleImage.js +3 -17
  4. package/lib/commonjs/components/CircleImage.js.map +1 -1
  5. package/lib/commonjs/components/DeprecatedButton.js +4 -19
  6. package/lib/commonjs/components/DeprecatedButton.js.map +1 -1
  7. package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -14
  8. package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
  9. package/lib/commonjs/components/DeprecatedFAB.js +4 -20
  10. package/lib/commonjs/components/DeprecatedFAB.js.map +1 -1
  11. package/lib/commonjs/components/Elevation.js +14 -3
  12. package/lib/commonjs/components/Elevation.js.map +1 -1
  13. package/lib/commonjs/components/NumberInput.js +17 -15
  14. package/lib/commonjs/components/NumberInput.js.map +1 -1
  15. package/lib/commonjs/components/Picker/PickerComponent.ios.js +10 -30
  16. package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -1
  17. package/lib/commonjs/components/Portal/Portal.js.map +1 -1
  18. package/lib/commonjs/components/Portal/PortalHost.js.map +1 -1
  19. package/lib/commonjs/components/RadioButton/context.js +1 -1
  20. package/lib/commonjs/components/RadioButton/context.js.map +1 -1
  21. package/lib/commonjs/components/Slider.js +5 -22
  22. package/lib/commonjs/components/Slider.js.map +1 -1
  23. package/lib/commonjs/components/StarRating.js +5 -23
  24. package/lib/commonjs/components/StarRating.js.map +1 -1
  25. package/lib/commonjs/components/TextField.js +7 -23
  26. package/lib/commonjs/components/TextField.js.map +1 -1
  27. package/lib/commonjs/hooks.js.map +1 -1
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/commonjs/mappings/AvatarEdit.js.map +1 -1
  30. package/lib/commonjs/mappings/FlatList.js.map +1 -1
  31. package/lib/commonjs/mappings/Icon.js +3 -1
  32. package/lib/commonjs/mappings/Icon.js.map +1 -1
  33. package/lib/commonjs/mappings/KeyboardAwareScrollView.js +48 -0
  34. package/lib/commonjs/mappings/KeyboardAwareScrollView.js.map +1 -0
  35. package/lib/commonjs/mappings/Modal.js.map +1 -1
  36. package/lib/commonjs/mappings/RowBodyIcon.js.map +1 -1
  37. package/lib/commonjs/mappings/Surface.js.map +1 -1
  38. package/lib/commonjs/mappings/Switch.js.map +1 -1
  39. package/lib/commonjs/styles/fonts.js.map +1 -1
  40. package/lib/commonjs/styles/overlay.js.map +1 -1
  41. package/lib/commonjs/theming.js.map +1 -1
  42. package/lib/module/components/NumberInput.js +17 -15
  43. package/lib/module/components/NumberInput.js.map +1 -1
  44. package/lib/module/components/Picker/PickerTypes.js.map +1 -1
  45. package/lib/module/components/Typography.js.map +1 -1
  46. package/lib/module/mappings/Icon.js +3 -1
  47. package/lib/module/mappings/Icon.js.map +1 -1
  48. package/lib/module/mappings/KeyboardAwareScrollView.js +39 -0
  49. package/lib/module/mappings/KeyboardAwareScrollView.js.map +1 -0
  50. package/lib/typescript/src/mappings/Icon.d.ts +1 -1
  51. package/lib/typescript/src/mappings/KeyboardAwareScrollView.d.ts +82 -0
  52. package/package.json +2 -2
  53. package/src/components/NumberInput.js +14 -13
  54. package/src/components/NumberInput.tsx +31 -16
  55. package/src/mappings/Icon.js +4 -1
  56. package/src/mappings/Icon.ts +4 -1
  57. package/src/mappings/KeyboardAwareScrollView.js +38 -0
  58. package/src/mappings/KeyboardAwareScrollView.ts +48 -0
@@ -0,0 +1,82 @@
1
+ export declare const SEED_DATA: {
2
+ name: string;
3
+ tag: string;
4
+ description: string;
5
+ category: string;
6
+ layout: {};
7
+ props: {
8
+ viewIsInsideTabBar: {
9
+ label: string;
10
+ description: string;
11
+ formType: string;
12
+ propType: string;
13
+ defaultValue: boolean;
14
+ editable: boolean;
15
+ required: boolean;
16
+ group: string;
17
+ };
18
+ enableAutomaticScroll: {
19
+ label: string;
20
+ description: string;
21
+ formType: string;
22
+ propType: string;
23
+ defaultValue: boolean;
24
+ editable: boolean;
25
+ required: boolean;
26
+ group: string;
27
+ };
28
+ extraHeight: {
29
+ label: string;
30
+ description: string;
31
+ formType: string;
32
+ propType: string;
33
+ group: string;
34
+ defaultValue: null;
35
+ editable: boolean;
36
+ required: boolean;
37
+ step: number;
38
+ };
39
+ extraScrollHeight: {
40
+ label: string;
41
+ description: string;
42
+ formType: string;
43
+ propType: string;
44
+ group: string;
45
+ defaultValue: null;
46
+ editable: boolean;
47
+ required: boolean;
48
+ step: number;
49
+ };
50
+ enableResetScrollToCoords: {
51
+ label: string;
52
+ description: string;
53
+ formType: string;
54
+ propType: string;
55
+ defaultValue: boolean;
56
+ editable: boolean;
57
+ required: boolean;
58
+ group: string;
59
+ };
60
+ keyboardOpeningTime: {
61
+ label: string;
62
+ description: string;
63
+ formType: string;
64
+ propType: string;
65
+ group: string;
66
+ defaultValue: null;
67
+ editable: boolean;
68
+ required: boolean;
69
+ step: number;
70
+ };
71
+ enableOnAndroid: {
72
+ label: string;
73
+ description: string;
74
+ formType: string;
75
+ propType: string;
76
+ defaultValue: boolean;
77
+ editable: boolean;
78
+ required: boolean;
79
+ group: string;
80
+ };
81
+ };
82
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "43.4.11-ba6514.0+ba6514a2",
3
+ "version": "43.4.11-ca8fc3.1+ca8fc360",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -80,5 +80,5 @@
80
80
  ]
81
81
  ]
82
82
  },
83
- "gitHead": "ba6514a22d03e7d7de755c12b83d115c78c146c4"
83
+ "gitHead": "ca8fc360a04be664d5b932ba3bdb8a0616f8ef58"
84
84
  }
@@ -2,8 +2,7 @@ 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 [currentStringNumberValue, setCurrentStringNumberValue] = useState("0");
6
- const formatValueToStringNumber = (valueToFormat) => {
5
+ const formatValueToStringNumber = (valueToFormat, currentStringNumberValue) => {
7
6
  if (valueToFormat != null) {
8
7
  if (isString(valueToFormat) && valueToFormat !== "") {
9
8
  if (/^0[1-9]$/.test(valueToFormat)) {
@@ -12,7 +11,7 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
12
11
  else if (/^[+-]?([0-9]+\.?[0-9]*|\.[0-9]+)$/.test(valueToFormat)) {
13
12
  return valueToFormat;
14
13
  }
15
- else {
14
+ else if (currentStringNumberValue) {
16
15
  return currentStringNumberValue;
17
16
  }
18
17
  }
@@ -22,23 +21,25 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
22
21
  }
23
22
  return "0";
24
23
  };
25
- // set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
24
+ const [currentStringNumberValue, setCurrentStringNumberValue] = useState(formatValueToStringNumber("0"));
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 ) */
26
33
  useEffect(() => {
27
- const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
34
+ const defaultStringNumberValue = formatValueToStringNumber(defaultValue, currentStringNumberValue);
28
35
  if (currentStringNumberValue !== defaultStringNumberValue) {
29
36
  setCurrentStringNumberValue(defaultStringNumberValue);
30
37
  }
31
38
  // eslint-disable-next-line react-hooks/exhaustive-deps
32
39
  }, []);
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)
40
+ // set new (or original) value if different from current (or initialized "0") value
40
41
  useEffect(() => {
41
- const nextStringNumberValue = formatValueToStringNumber(value);
42
+ const nextStringNumberValue = formatValueToStringNumber(value, currentStringNumberValue);
42
43
  if (currentStringNumberValue !== nextStringNumberValue) {
43
44
  handleChangeText(nextStringNumberValue);
44
45
  }
@@ -14,16 +14,17 @@ const NumberInput: FC<Props> = ({
14
14
  defaultValue,
15
15
  ...props
16
16
  }) => {
17
- const [currentStringNumberValue, setCurrentStringNumberValue] = useState("0");
18
-
19
- const formatValueToStringNumber = (valueToFormat?: number | string) => {
17
+ const formatValueToStringNumber = (
18
+ valueToFormat?: number | string,
19
+ currentStringNumberValue?: string
20
+ ) => {
20
21
  if (valueToFormat != null) {
21
22
  if (isString(valueToFormat) && valueToFormat !== "") {
22
23
  if (/^0[1-9]$/.test(valueToFormat)) {
23
24
  return valueToFormat.slice(1);
24
25
  } else if (/^[+-]?([0-9]+\.?[0-9]*|\.[0-9]+)$/.test(valueToFormat)) {
25
26
  return valueToFormat;
26
- } else {
27
+ } else if (currentStringNumberValue) {
27
28
  return currentStringNumberValue;
28
29
  }
29
30
  } else if (isNumber(valueToFormat) && !isNaN(valueToFormat)) {
@@ -34,27 +35,41 @@ const NumberInput: FC<Props> = ({
34
35
  return "0";
35
36
  };
36
37
 
37
- // set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
38
- useEffect(() => {
39
- const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
40
-
41
- if (currentStringNumberValue !== defaultStringNumberValue) {
42
- setCurrentStringNumberValue(defaultStringNumberValue);
43
- }
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
- }, []);
38
+ const [currentStringNumberValue, setCurrentStringNumberValue] = useState(
39
+ formatValueToStringNumber("0")
40
+ );
46
41
 
47
42
  const handleChangeText = (newValue: string) => {
48
- const newStringNumberValue = formatValueToStringNumber(newValue);
43
+ const newStringNumberValue = formatValueToStringNumber(
44
+ newValue,
45
+ currentStringNumberValue
46
+ );
49
47
  const number = parseFloat(newStringNumberValue);
50
48
 
51
49
  setCurrentStringNumberValue(newStringNumberValue);
52
50
  onChangeText?.(number);
53
51
  };
54
52
 
55
- // run handleChangeText with value prop only when value prop changes (and first render to reset currentStringNumberValue)
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 ) */
55
+ useEffect(() => {
56
+ const defaultStringNumberValue = formatValueToStringNumber(
57
+ defaultValue,
58
+ currentStringNumberValue
59
+ );
60
+
61
+ if (currentStringNumberValue !== defaultStringNumberValue) {
62
+ setCurrentStringNumberValue(defaultStringNumberValue);
63
+ }
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
65
+ }, []);
66
+
67
+ // set new (or original) value if different from current (or initialized "0") value
56
68
  useEffect(() => {
57
- const nextStringNumberValue = formatValueToStringNumber(value);
69
+ const nextStringNumberValue = formatValueToStringNumber(
70
+ value,
71
+ currentStringNumberValue
72
+ );
58
73
 
59
74
  if (currentStringNumberValue !== nextStringNumberValue) {
60
75
  handleChangeText(nextStringNumberValue);
@@ -6,7 +6,10 @@ export const SEED_DATA = {
6
6
  category: COMPONENT_TYPES.basic,
7
7
  layout: {},
8
8
  props: {
9
- name: createIconProp(),
9
+ name: {
10
+ ...createIconProp(),
11
+ group: GROUPS.data,
12
+ },
10
13
  color: createColorProp(),
11
14
  size: createNumberProp({
12
15
  group: GROUPS.basic,
@@ -13,7 +13,10 @@ export const SEED_DATA = {
13
13
  category: COMPONENT_TYPES.basic,
14
14
  layout: {},
15
15
  props: {
16
- name: createIconProp(),
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
+ };