@draftbit/core 47.0.1-0e56b5.2 → 47.0.1-2f600c.2

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 (81) hide show
  1. package/lib/commonjs/components/AspectRatio.js +17 -1
  2. package/lib/commonjs/components/Button.js +24 -33
  3. package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +1 -2
  4. package/lib/commonjs/components/Checkbox/CheckboxRow.js +1 -2
  5. package/lib/commonjs/components/DeprecatedButton.js +127 -0
  6. package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -2
  7. package/lib/commonjs/components/Picker/Picker.js +4 -3
  8. package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
  9. package/lib/commonjs/components/Pressable.js +12 -23
  10. package/lib/commonjs/components/Touchable.js +13 -24
  11. package/lib/commonjs/components/Touchable.web.js +9 -0
  12. package/lib/commonjs/constants.js +1 -1
  13. package/lib/commonjs/mappings/Button.js +11 -1
  14. package/lib/commonjs/mappings/{Pressable.js → Touchable.js} +18 -10
  15. package/lib/module/components/Accordion/AccordionItem.js +25 -4
  16. package/lib/module/components/AnimatedCircularProgress.js +13 -1
  17. package/lib/module/components/Button.js +18 -27
  18. package/lib/module/components/Checkbox/Checkbox.js +3 -4
  19. package/lib/module/components/Checkbox/CheckboxGroupRow.js +25 -7
  20. package/lib/module/components/Checkbox/CheckboxRow.js +25 -8
  21. package/lib/module/components/DeprecatedButton.js +117 -0
  22. package/lib/module/components/DeprecatedCardWrapper.js +20 -3
  23. package/lib/module/components/NumberInput.js +12 -3
  24. package/lib/module/components/Picker/Picker.js +4 -3
  25. package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
  26. package/lib/module/components/Portal/Portal.js +2 -6
  27. package/lib/module/components/Pressable.js +11 -21
  28. package/lib/module/components/ProgressBar.js +39 -7
  29. package/lib/module/components/Switch.js +21 -10
  30. package/lib/module/components/Touchable.js +12 -22
  31. package/lib/module/components/Touchable.web.js +2 -0
  32. package/lib/module/constants.js +1 -0
  33. package/lib/module/mappings/Button.js +11 -1
  34. package/lib/module/mappings/{Pressable.js → Touchable.js} +19 -11
  35. package/lib/typescript/src/components/Button.d.ts +0 -2
  36. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  37. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +1 -1
  38. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  39. package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
  40. package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
  41. package/lib/typescript/src/components/DeprecatedButton.d.ts +54 -0
  42. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -0
  43. package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +1 -1
  44. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  45. package/lib/typescript/src/components/Pressable.d.ts +2 -4
  46. package/lib/typescript/src/components/Pressable.d.ts.map +1 -1
  47. package/lib/typescript/src/components/Touchable.d.ts +2 -4
  48. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  49. package/lib/typescript/src/components/Touchable.web.d.ts +3 -0
  50. package/lib/typescript/src/components/Touchable.web.d.ts.map +1 -0
  51. package/lib/typescript/src/mappings/Button.d.ts +1 -1
  52. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  53. package/lib/typescript/src/mappings/{Pressable.d.ts → Touchable.d.ts} +1 -1
  54. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -0
  55. package/package.json +3 -3
  56. package/src/components/Button.js +18 -22
  57. package/src/components/Button.tsx +19 -40
  58. package/src/components/Checkbox/Checkbox.tsx +2 -2
  59. package/src/components/Checkbox/CheckboxGroupRow.js +2 -3
  60. package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
  61. package/src/components/Checkbox/CheckboxRow.js +2 -3
  62. package/src/components/Checkbox/CheckboxRow.tsx +3 -3
  63. package/src/components/DeprecatedButton.js +83 -0
  64. package/src/components/DeprecatedButton.tsx +190 -0
  65. package/src/components/DeprecatedCardWrapper.js +2 -2
  66. package/src/components/DeprecatedCardWrapper.tsx +4 -3
  67. package/src/components/Picker/Picker.js +4 -3
  68. package/src/components/Picker/Picker.tsx +4 -4
  69. package/src/components/Picker/PickerComponent.ios.js +1 -1
  70. package/src/components/Picker/PickerComponent.ios.tsx +1 -1
  71. package/src/components/Pressable.js +10 -15
  72. package/src/components/Pressable.tsx +11 -28
  73. package/src/components/Touchable.js +11 -16
  74. package/src/components/Touchable.tsx +13 -34
  75. package/src/components/Touchable.web.js +2 -0
  76. package/src/components/Touchable.web.tsx +3 -0
  77. package/src/mappings/Button.js +11 -1
  78. package/src/mappings/Button.ts +11 -1
  79. package/src/mappings/{Pressable.js → Touchable.js} +19 -11
  80. package/src/mappings/{Pressable.ts → Touchable.ts} +19 -12
  81. package/lib/typescript/src/mappings/Pressable.d.ts.map +0 -1
@@ -1,9 +1,7 @@
1
- import React, { useCallback } from "react";
1
+ import React from "react";
2
2
  import {
3
3
  Pressable as NativePressable,
4
4
  PressableProps,
5
- PressableStateCallbackType,
6
- StyleProp,
7
5
  ViewStyle,
8
6
  } from "react-native";
9
7
 
@@ -15,50 +13,35 @@ type Props = {
15
13
  onLongPress?: () => void;
16
14
  delayLongPress?: number;
17
15
  hitSlop?: number;
18
- pressRetentionOffset?: number;
19
16
  activeOpacity?: number;
20
17
  disabledOpacity?: number;
21
18
  } & PressableProps;
22
19
 
23
- export type StyleType = (
24
- state: PressableStateCallbackType
25
- ) => StyleProp<ViewStyle>;
26
-
27
20
  export default function Pressable({
28
21
  children,
29
22
  disabled,
30
23
  onPress,
31
- onLongPress,
32
- hitSlop,
33
- delayLongPress,
34
24
  activeOpacity,
35
25
  disabledOpacity,
26
+ delayLongPress,
27
+ hitSlop,
36
28
  style,
37
29
  ...props
38
30
  }: Props) {
39
- const getOpacity = useCallback(
40
- (pressed: boolean) => {
41
- if (disabled) {
42
- return disabledOpacity;
43
- } else {
44
- if (pressed) return activeOpacity;
45
- else return 1;
46
- }
47
- },
48
- [activeOpacity, disabled, disabledOpacity]
49
- );
50
- const _style = useCallback<StyleType>(
51
- ({ pressed }) => [style as ViewStyle, { opacity: getOpacity(pressed) }],
52
- [getOpacity, style]
53
- );
54
31
  return (
55
32
  <NativePressable
56
33
  onPress={onPress}
57
- onLongPress={onLongPress}
58
34
  disabled={disabled}
59
35
  delayLongPress={delayLongPress ? delayLongPress : 500}
60
36
  hitSlop={hitSlop ? hitSlop : 8}
61
- style={_style}
37
+ style={({ pressed }) => {
38
+ return [
39
+ {
40
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
41
+ },
42
+ style,
43
+ ];
44
+ }}
62
45
  {...props}
63
46
  >
64
47
  {children}
@@ -1,17 +1,12 @@
1
- import React, { useCallback } from "react";
2
- import { Pressable, } from "react-native";
3
- export default function Touchable({ children, disabled, onPress, onLongPress, hitSlop, delayLongPress, activeOpacity, disabledOpacity, style, ...props }) {
4
- const getOpacity = useCallback((pressed) => {
5
- if (disabled) {
6
- return disabledOpacity;
7
- }
8
- else {
9
- if (pressed)
10
- return activeOpacity;
11
- else
12
- return 1;
13
- }
14
- }, [activeOpacity, disabled, disabledOpacity]);
15
- const _style = useCallback(({ pressed }) => [style, { opacity: getOpacity(pressed) }], [getOpacity, style]);
16
- return (React.createElement(Pressable, { onPress: onPress, onLongPress: onLongPress, disabled: disabled, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: _style, ...props }, children));
1
+ import React from "react";
2
+ import { Pressable } from "react-native";
3
+ export default function Touchable({ children, disabled, onPress, activeOpacity, disabledOpacity, delayLongPress, hitSlop, style, ...props }) {
4
+ return (React.createElement(Pressable, { disabled: disabled, onPress: onPress, delayLongPress: delayLongPress ? delayLongPress : 500, hitSlop: hitSlop ? hitSlop : 8, style: ({ pressed }) => {
5
+ return [
6
+ {
7
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
8
+ },
9
+ style,
10
+ ];
11
+ }, ...props }, children));
17
12
  }
@@ -1,11 +1,5 @@
1
- import React, { useCallback } from "react";
2
- import {
3
- Pressable,
4
- PressableProps,
5
- PressableStateCallbackType,
6
- StyleProp,
7
- ViewStyle,
8
- } from "react-native";
1
+ import React from "react";
2
+ import { Pressable, PressableProps, ViewStyle } from "react-native";
9
3
 
10
4
  type Props = {
11
5
  disabled?: boolean;
@@ -15,50 +9,35 @@ type Props = {
15
9
  onLongPress?: () => void;
16
10
  delayLongPress?: number;
17
11
  hitSlop?: number;
18
- pressRetentionOffset?: number;
19
12
  activeOpacity?: number;
20
13
  disabledOpacity?: number;
21
14
  } & PressableProps;
22
15
 
23
- export type StyleType = (
24
- state: PressableStateCallbackType
25
- ) => StyleProp<ViewStyle>;
26
-
27
16
  export default function Touchable({
28
17
  children,
29
18
  disabled,
30
19
  onPress,
31
- onLongPress,
32
- hitSlop,
33
- delayLongPress,
34
20
  activeOpacity,
35
21
  disabledOpacity,
22
+ delayLongPress,
23
+ hitSlop,
36
24
  style,
37
25
  ...props
38
26
  }: Props) {
39
- const getOpacity = useCallback(
40
- (pressed: boolean) => {
41
- if (disabled) {
42
- return disabledOpacity;
43
- } else {
44
- if (pressed) return activeOpacity;
45
- else return 1;
46
- }
47
- },
48
- [activeOpacity, disabled, disabledOpacity]
49
- );
50
- const _style = useCallback<StyleType>(
51
- ({ pressed }) => [style as ViewStyle, { opacity: getOpacity(pressed) }],
52
- [getOpacity, style]
53
- );
54
27
  return (
55
28
  <Pressable
56
- onPress={onPress}
57
- onLongPress={onLongPress}
58
29
  disabled={disabled}
30
+ onPress={onPress}
59
31
  delayLongPress={delayLongPress ? delayLongPress : 500}
60
32
  hitSlop={hitSlop ? hitSlop : 8}
61
- style={_style}
33
+ style={({ pressed }) => {
34
+ return [
35
+ {
36
+ opacity: pressed ? activeOpacity : disabled ? disabledOpacity : 1,
37
+ },
38
+ style,
39
+ ];
40
+ }}
62
41
  {...props}
63
42
  >
64
43
  {children}
@@ -0,0 +1,2 @@
1
+ import { TouchableOpacity } from "react-native";
2
+ export default TouchableOpacity;
@@ -0,0 +1,3 @@
1
+ import { TouchableOpacity } from "react-native";
2
+
3
+ export default TouchableOpacity;
@@ -17,11 +17,21 @@ const SEED_DATA_PROPS = {
17
17
  activeOpacity: createStaticNumberProp({
18
18
  label: "Active Opacity",
19
19
  description: "Opacity of the button when active.",
20
+ defaultValue: 0.8,
21
+ min: 0,
22
+ max: 1,
23
+ step: 0.01,
24
+ precision: 2,
20
25
  required: false,
21
26
  }),
22
27
  disabledOpacity: createStaticNumberProp({
23
28
  label: "Disabled Opacity",
24
29
  description: "Opacity of the button when disabled.",
30
+ defaultValue: 0.8,
31
+ min: 0,
32
+ max: 1,
33
+ step: 0.01,
34
+ precision: 2,
25
35
  required: false,
26
36
  }),
27
37
  delayLongPress: createStaticNumberProp({
@@ -50,9 +60,9 @@ export const SEED_DATA = [
50
60
  StylesPanelSections.Effects,
51
61
  ],
52
62
  layout: {
53
- backgroundColor: "transparent",
54
63
  borderRadius: 8,
55
64
  fontFamily: "system-700",
65
+ backgroundColor: "transparent",
56
66
  borderWidth: 1,
57
67
  textAlign: "center",
58
68
  },
@@ -28,11 +28,21 @@ const SEED_DATA_PROPS = {
28
28
  activeOpacity: createStaticNumberProp({
29
29
  label: "Active Opacity",
30
30
  description: "Opacity of the button when active.",
31
+ defaultValue: 0.8,
32
+ min: 0,
33
+ max: 1,
34
+ step: 0.01,
35
+ precision: 2,
31
36
  required: false,
32
37
  }),
33
38
  disabledOpacity: createStaticNumberProp({
34
39
  label: "Disabled Opacity",
35
40
  description: "Opacity of the button when disabled.",
41
+ defaultValue: 0.8,
42
+ min: 0,
43
+ max: 1,
44
+ step: 0.01,
45
+ precision: 2,
36
46
  required: false,
37
47
  }),
38
48
  delayLongPress: createStaticNumberProp({
@@ -64,9 +74,9 @@ export const SEED_DATA = [
64
74
  StylesPanelSections.Effects,
65
75
  ],
66
76
  layout: {
67
- backgroundColor: "transparent",
68
77
  borderRadius: 8,
69
78
  fontFamily: "system-700",
79
+ backgroundColor: "transparent",
70
80
  borderWidth: 1,
71
81
  textAlign: "center",
72
82
  },
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, createActionProp, Triggers, createNumberProp, StylesPanelSections, GROUPS, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createActionProp, Triggers, createStaticNumberProp, StylesPanelSections, } from "@draftbit/types";
2
2
  const SEED_DATA_PROPS = {
3
3
  stylesPanelSections: [
4
4
  StylesPanelSections.Size,
@@ -10,27 +10,35 @@ const SEED_DATA_PROPS = {
10
10
  props: {
11
11
  onPress: createActionProp(),
12
12
  onLongPress: createActionProp(),
13
- activeOpacity: createNumberProp({
13
+ activeOpacity: createStaticNumberProp({
14
14
  label: "Active Opacity",
15
15
  description: "The opacity when the button is pressed.",
16
16
  defaultValue: 0.8,
17
- group: GROUPS.basic,
17
+ min: 0,
18
+ max: 1,
19
+ step: 0.01,
20
+ precision: 2,
21
+ required: false,
18
22
  }),
19
- disabledOpacity: createNumberProp({
23
+ disabledOpacity: createStaticNumberProp({
20
24
  label: "Disabled Opacity",
21
25
  description: "The opacity when the button is disabled.",
22
26
  defaultValue: 0.8,
23
- group: GROUPS.basic,
27
+ min: 0,
28
+ max: 1,
29
+ step: 0.01,
30
+ precision: 2,
31
+ required: false,
24
32
  }),
25
- delayLongPress: createNumberProp({
33
+ delayLongPress: createStaticNumberProp({
26
34
  label: "Delay Long Press",
27
35
  description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
28
- group: GROUPS.basic,
36
+ required: false,
29
37
  }),
30
- hitSlop: createNumberProp({
38
+ hitSlop: createStaticNumberProp({
31
39
  label: "Hit Slop",
32
40
  description: "Sets additional distance outside of element in which a press can be detected.",
33
- group: GROUPS.basic,
41
+ required: false,
34
42
  }),
35
43
  },
36
44
  };
@@ -39,14 +47,14 @@ export const SEED_DATA = [
39
47
  name: "Touchable",
40
48
  tag: "Touchable",
41
49
  description: "An interactive view with no styles",
42
- category: COMPONENT_TYPES.button,
50
+ category: COMPONENT_TYPES.deprecated,
43
51
  ...SEED_DATA_PROPS,
44
52
  },
45
53
  {
46
54
  name: "Pressable",
47
55
  tag: "Pressable",
48
56
  description: "An interactive view with no styles",
49
- category: COMPONENT_TYPES.deprecated,
57
+ category: COMPONENT_TYPES.button,
50
58
  ...SEED_DATA_PROPS,
51
59
  },
52
60
  ];
@@ -2,9 +2,8 @@ import {
2
2
  COMPONENT_TYPES,
3
3
  createActionProp,
4
4
  Triggers,
5
- createNumberProp,
5
+ createStaticNumberProp,
6
6
  StylesPanelSections,
7
- GROUPS,
8
7
  } from "@draftbit/types";
9
8
 
10
9
  const SEED_DATA_PROPS = {
@@ -18,29 +17,37 @@ const SEED_DATA_PROPS = {
18
17
  props: {
19
18
  onPress: createActionProp(),
20
19
  onLongPress: createActionProp(),
21
- activeOpacity: createNumberProp({
20
+ activeOpacity: createStaticNumberProp({
22
21
  label: "Active Opacity",
23
22
  description: "The opacity when the button is pressed.",
24
23
  defaultValue: 0.8,
25
- group: GROUPS.basic,
24
+ min: 0,
25
+ max: 1,
26
+ step: 0.01,
27
+ precision: 2,
28
+ required: false,
26
29
  }),
27
- disabledOpacity: createNumberProp({
30
+ disabledOpacity: createStaticNumberProp({
28
31
  label: "Disabled Opacity",
29
32
  description: "The opacity when the button is disabled.",
30
33
  defaultValue: 0.8,
31
- group: GROUPS.basic,
34
+ min: 0,
35
+ max: 1,
36
+ step: 0.01,
37
+ precision: 2,
38
+ required: false,
32
39
  }),
33
- delayLongPress: createNumberProp({
40
+ delayLongPress: createStaticNumberProp({
34
41
  label: "Delay Long Press",
35
42
  description:
36
43
  "Duration (in milliseconds) from onPressIn before onLongPress is called.",
37
- group: GROUPS.basic,
44
+ required: false,
38
45
  }),
39
- hitSlop: createNumberProp({
46
+ hitSlop: createStaticNumberProp({
40
47
  label: "Hit Slop",
41
48
  description:
42
49
  "Sets additional distance outside of element in which a press can be detected.",
43
- group: GROUPS.basic,
50
+ required: false,
44
51
  }),
45
52
  },
46
53
  };
@@ -50,14 +57,14 @@ export const SEED_DATA = [
50
57
  name: "Touchable",
51
58
  tag: "Touchable",
52
59
  description: "An interactive view with no styles",
53
- category: COMPONENT_TYPES.button,
60
+ category: COMPONENT_TYPES.deprecated,
54
61
  ...SEED_DATA_PROPS,
55
62
  },
56
63
  {
57
64
  name: "Pressable",
58
65
  tag: "Pressable",
59
66
  description: "An interactive view with no styles",
60
- category: COMPONENT_TYPES.deprecated,
67
+ category: COMPONENT_TYPES.button,
61
68
  ...SEED_DATA_PROPS,
62
69
  },
63
70
  ];
@@ -1 +0,0 @@
1
- {"version":3,"file":"Pressable.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Pressable.ts"],"names":[],"mappings":"AA+CA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAerB,CAAC"}