@draftbit/core 47.0.1-ed6e56.2 → 47.1.1-1b33f0.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 (127) hide show
  1. package/lib/commonjs/components/Button.js +3 -3
  2. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -3
  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/DatePicker/DatePicker.js +0 -1
  6. package/lib/commonjs/components/DatePicker/DatePickerComponent.js +9 -3
  7. package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js +1 -0
  8. package/lib/commonjs/components/DeprecatedButton.js +3 -27
  9. package/lib/commonjs/components/DeprecatedFAB.js +1 -2
  10. package/lib/commonjs/components/Pressable.js +37 -0
  11. package/lib/commonjs/components/Swiper/Swiper.js +2 -0
  12. package/lib/commonjs/components/Touchable.js +8 -3
  13. package/lib/commonjs/index.js +7 -0
  14. package/lib/commonjs/mappings/Button.js +39 -10
  15. package/lib/commonjs/mappings/DatePicker.js +1 -1
  16. package/lib/commonjs/mappings/FlashList.js +51 -2
  17. package/lib/commonjs/mappings/FlatList.js +13 -0
  18. package/lib/commonjs/mappings/ScrollView.js +2 -0
  19. package/lib/commonjs/mappings/Swiper.js +2 -0
  20. package/lib/commonjs/mappings/TextField.js +2 -2
  21. package/lib/commonjs/mappings/Touchable.js +47 -7
  22. package/lib/module/components/Button.js +3 -3
  23. package/lib/module/components/Checkbox/Checkbox.js +2 -3
  24. package/lib/module/components/Checkbox/CheckboxGroupRow.js +2 -3
  25. package/lib/module/components/Checkbox/CheckboxRow.js +2 -3
  26. package/lib/module/components/DatePicker/DatePicker.js +0 -1
  27. package/lib/module/components/DatePicker/DatePickerComponent.js +9 -3
  28. package/lib/module/components/DatePicker/DatePickerComponent.web.js +1 -0
  29. package/lib/module/components/DeprecatedButton.js +4 -28
  30. package/lib/module/components/DeprecatedFAB.js +2 -3
  31. package/lib/module/components/Pressable.js +30 -0
  32. package/lib/module/components/Swiper/Swiper.js +2 -0
  33. package/lib/module/components/Touchable.js +8 -3
  34. package/lib/module/index.js +1 -0
  35. package/lib/module/mappings/Button.js +40 -11
  36. package/lib/module/mappings/DatePicker.js +1 -1
  37. package/lib/module/mappings/FlashList.js +52 -3
  38. package/lib/module/mappings/FlatList.js +14 -1
  39. package/lib/module/mappings/ScrollView.js +3 -1
  40. package/lib/module/mappings/Swiper.js +3 -1
  41. package/lib/module/mappings/TextField.js +2 -2
  42. package/lib/module/mappings/Touchable.js +49 -9
  43. package/lib/typescript/src/components/Button.d.ts.map +1 -1
  44. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
  45. package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
  46. package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
  47. package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
  48. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts.map +1 -1
  49. package/lib/typescript/src/components/DatePicker/DatePickerComponent.d.ts.map +1 -1
  50. package/lib/typescript/src/components/DatePicker/DatePickerComponent.web.d.ts.map +1 -1
  51. package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts +0 -2
  52. package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts.map +1 -1
  53. package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
  54. package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -1
  55. package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
  56. package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
  57. package/lib/typescript/src/components/Pressable.d.ts +10 -0
  58. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  59. package/lib/typescript/src/components/Swiper/Swiper.d.ts +2 -1
  60. package/lib/typescript/src/components/Swiper/Swiper.d.ts.map +1 -1
  61. package/lib/typescript/src/components/Touchable.d.ts +5 -6
  62. package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
  63. package/lib/typescript/src/index.d.ts +1 -0
  64. package/lib/typescript/src/index.d.ts.map +1 -1
  65. package/lib/typescript/src/mappings/Button.d.ts +113 -4
  66. package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
  67. package/lib/typescript/src/mappings/DatePicker.d.ts +1 -1
  68. package/lib/typescript/src/mappings/FlashList.d.ts +123 -2
  69. package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
  70. package/lib/typescript/src/mappings/FlatList.d.ts +43 -0
  71. package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
  72. package/lib/typescript/src/mappings/ScrollView.d.ts +11 -0
  73. package/lib/typescript/src/mappings/ScrollView.d.ts.map +1 -1
  74. package/lib/typescript/src/mappings/Swiper.d.ts +11 -0
  75. package/lib/typescript/src/mappings/Swiper.d.ts.map +1 -1
  76. package/lib/typescript/src/mappings/Touchable.d.ts +59 -5
  77. package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
  78. package/package.json +6 -6
  79. package/src/components/Button.js +3 -3
  80. package/src/components/Button.tsx +14 -4
  81. package/src/components/Checkbox/Checkbox.js +2 -3
  82. package/src/components/Checkbox/Checkbox.tsx +5 -7
  83. package/src/components/Checkbox/CheckboxGroupRow.js +2 -3
  84. package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
  85. package/src/components/Checkbox/CheckboxRow.js +2 -3
  86. package/src/components/Checkbox/CheckboxRow.tsx +3 -3
  87. package/src/components/DatePicker/DatePicker.js +1 -1
  88. package/src/components/DatePicker/DatePicker.tsx +0 -1
  89. package/src/components/DatePicker/DatePickerComponent.js +5 -3
  90. package/src/components/DatePicker/DatePickerComponent.tsx +11 -3
  91. package/src/components/DatePicker/DatePickerComponent.web.js +1 -1
  92. package/src/components/DatePicker/DatePickerComponent.web.tsx +1 -0
  93. package/src/components/DatePicker/DatePickerComponentType.ts +0 -9
  94. package/src/components/DeprecatedButton.js +4 -16
  95. package/src/components/DeprecatedButton.tsx +7 -31
  96. package/src/components/DeprecatedFAB.js +2 -3
  97. package/src/components/DeprecatedFAB.tsx +5 -5
  98. package/src/components/Pressable.js +12 -0
  99. package/src/components/Pressable.tsx +44 -0
  100. package/src/components/Swiper/Swiper.js +2 -2
  101. package/src/components/Swiper/Swiper.tsx +3 -0
  102. package/src/components/Touchable.js +3 -3
  103. package/src/components/Touchable.tsx +11 -7
  104. package/src/index.js +1 -0
  105. package/src/index.tsx +1 -0
  106. package/src/mappings/Button.js +39 -10
  107. package/src/mappings/Button.ts +41 -10
  108. package/src/mappings/DatePicker.js +1 -1
  109. package/src/mappings/DatePicker.ts +1 -1
  110. package/src/mappings/FlashList.js +83 -31
  111. package/src/mappings/FlashList.ts +87 -30
  112. package/src/mappings/FlatList.js +14 -1
  113. package/src/mappings/FlatList.ts +17 -0
  114. package/src/mappings/ScrollView.js +3 -1
  115. package/src/mappings/ScrollView.ts +4 -0
  116. package/src/mappings/Swiper.js +3 -1
  117. package/src/mappings/Swiper.ts +4 -0
  118. package/src/mappings/TextField.js +2 -2
  119. package/src/mappings/TextField.ts +2 -2
  120. package/src/mappings/Touchable.js +50 -7
  121. package/src/mappings/Touchable.ts +53 -6
  122. package/lib/commonjs/components/DatePicker/DatePickerInput.js +0 -133
  123. package/lib/module/components/DatePicker/DatePickerInput.js +0 -123
  124. package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts +0 -18
  125. package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts.map +0 -1
  126. package/src/components/DatePicker/DatePickerInput.js +0 -97
  127. package/src/components/DatePicker/DatePickerInput.tsx +0 -195
@@ -1,97 +0,0 @@
1
- import * as React from "react";
2
- import { View, TextInput, Platform, } from "react-native";
3
- import { useSafeAreaInsets } from "react-native-safe-area-context";
4
- import dateFormat from "dateformat";
5
- import Portal from "../Portal/Portal";
6
- import Touchable from "../Touchable";
7
- import DateTimePicker from "./DatePickerComponent";
8
- const MONTHS = [
9
- "January",
10
- "February",
11
- "March",
12
- "April",
13
- "May",
14
- "June",
15
- "July",
16
- "August",
17
- "September",
18
- "October",
19
- "November",
20
- "December",
21
- ];
22
- const DatePickerInput = ({ style, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, androidDisplay = "default", iosDisplay = "default", webDisplay = "dialog", placeholder, ...props }) => {
23
- const [value, setValue] = React.useState(date || defaultValue);
24
- React.useEffect(() => {
25
- if (defaultValue != null) {
26
- setValue(defaultValue);
27
- }
28
- }, [defaultValue]);
29
- const [pickerVisible, setPickerVisible] = React.useState(false);
30
- const [focused, setFocused] = React.useState(false);
31
- const getValidDate = () => {
32
- if (!value) {
33
- return new Date();
34
- }
35
- return typeof (value === null || value === void 0 ? void 0 : value.getMonth) === "function" ? value : new Date();
36
- };
37
- const formatDate = () => {
38
- if (!value)
39
- return "";
40
- let newDate = getValidDate();
41
- if (format)
42
- return dateFormat(newDate, format);
43
- if (mode === "time") {
44
- return `${newDate.toLocaleTimeString()}`;
45
- }
46
- if (mode === "datetime") {
47
- return `${newDate.toLocaleString()}`;
48
- }
49
- return `${MONTHS[newDate.getMonth()]} ${newDate.getDate()}, ${newDate.getFullYear()}`;
50
- };
51
- const toggleVisibility = async () => {
52
- setPickerVisible(!pickerVisible);
53
- focused ? _handleBlur() : _handleFocus();
54
- };
55
- const insets = useSafeAreaInsets();
56
- React.useEffect(() => {
57
- setValue(date);
58
- }, [date]);
59
- const _handleFocus = () => {
60
- if (disabled) {
61
- return;
62
- }
63
- setFocused(true);
64
- };
65
- const _handleBlur = () => {
66
- if (disabled) {
67
- return;
68
- }
69
- setFocused(false);
70
- };
71
- return (React.createElement(View, null,
72
- React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility },
73
- React.createElement(TextInput, { value: formatDate(), placeholder: placeholder, editable: !disabled, onFocus: _handleFocus, onBlur: _handleBlur, style: style, ...props })),
74
- pickerVisible && (React.createElement(Portal, null,
75
- React.createElement(View, { style: {
76
- paddingTop: insets.top,
77
- paddingBottom: insets.bottom,
78
- paddingLeft: insets.left,
79
- paddingRight: insets.right,
80
- } },
81
- Platform.OS === "web" && (React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
82
- toggleVisibility();
83
- setValue(data);
84
- onDateChange(data);
85
- } })),
86
- Platform.OS === "ios" && (React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, displayMode: iosDisplay, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
87
- toggleVisibility();
88
- setValue(data);
89
- onDateChange(data);
90
- } })),
91
- Platform.OS === "android" && (React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, variant: webDisplay, displayMode: androidDisplay, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
92
- toggleVisibility();
93
- setValue(data);
94
- onDateChange(data);
95
- } })))))));
96
- };
97
- export default DatePickerInput;
@@ -1,195 +0,0 @@
1
- import * as React from "react";
2
- import {
3
- View,
4
- StyleProp,
5
- ViewStyle,
6
- TextInputProps,
7
- TextInput,
8
- Platform,
9
- } from "react-native";
10
- import { useSafeAreaInsets } from "react-native-safe-area-context";
11
-
12
- import dateFormat from "dateformat";
13
- import Portal from "../Portal/Portal";
14
- import Touchable from "../Touchable";
15
- import DateTimePicker from "./DatePickerComponent";
16
-
17
- type Props = {
18
- style?: StyleProp<ViewStyle>;
19
- date?: Date;
20
- format?: string;
21
- onDateChange?: (data?: Date) => void;
22
- defaultValue?: Date;
23
- disabled?: boolean;
24
- mode?: "date" | "time" | "datetime";
25
- androidDisplay: "default" | "spinner" | "calendar" | "clock";
26
- iosDisplay: "default" | "spinner" | "compact" | "inline";
27
- webDisplay: "dialog" | "inline";
28
- placeholder?: string;
29
- } & TextInputProps;
30
-
31
- const MONTHS = [
32
- "January",
33
- "February",
34
- "March",
35
- "April",
36
- "May",
37
- "June",
38
- "July",
39
- "August",
40
- "September",
41
- "October",
42
- "November",
43
- "December",
44
- ];
45
-
46
- const DatePickerInput: React.FC<React.PropsWithChildren<Props>> = ({
47
- style,
48
- date,
49
- onDateChange = () => {},
50
- defaultValue,
51
- disabled = false,
52
- mode = "date",
53
- format,
54
- androidDisplay = "default",
55
- iosDisplay = "default",
56
- webDisplay = "dialog",
57
- placeholder,
58
- ...props
59
- }) => {
60
- const [value, setValue] = React.useState<any>(date || defaultValue);
61
-
62
- React.useEffect(() => {
63
- if (defaultValue != null) {
64
- setValue(defaultValue);
65
- }
66
- }, [defaultValue]);
67
-
68
- const [pickerVisible, setPickerVisible] = React.useState(false);
69
- const [focused, setFocused] = React.useState<boolean>(false);
70
-
71
- const getValidDate = (): Date => {
72
- if (!value) {
73
- return new Date();
74
- }
75
- return typeof value?.getMonth === "function" ? value : new Date();
76
- };
77
-
78
- const formatDate = (): string => {
79
- if (!value) return "";
80
- let newDate = getValidDate();
81
-
82
- if (format) return dateFormat(newDate, format);
83
-
84
- if (mode === "time") {
85
- return `${newDate.toLocaleTimeString()}`;
86
- }
87
-
88
- if (mode === "datetime") {
89
- return `${newDate.toLocaleString()}`;
90
- }
91
-
92
- return `${
93
- MONTHS[newDate.getMonth()]
94
- } ${newDate.getDate()}, ${newDate.getFullYear()}`;
95
- };
96
-
97
- const toggleVisibility = async () => {
98
- setPickerVisible(!pickerVisible);
99
- focused ? _handleBlur() : _handleFocus();
100
- };
101
-
102
- const insets = useSafeAreaInsets();
103
-
104
- React.useEffect(() => {
105
- setValue(date);
106
- }, [date]);
107
-
108
- const _handleFocus = () => {
109
- if (disabled) {
110
- return;
111
- }
112
-
113
- setFocused(true);
114
- };
115
-
116
- const _handleBlur = () => {
117
- if (disabled) {
118
- return;
119
- }
120
- setFocused(false);
121
- };
122
-
123
- return (
124
- <View>
125
- <Touchable disabled={disabled} onPress={toggleVisibility}>
126
- <TextInput
127
- value={formatDate()}
128
- placeholder={placeholder}
129
- editable={!disabled}
130
- onFocus={_handleFocus}
131
- onBlur={_handleBlur}
132
- style={style}
133
- {...props}
134
- />
135
- </Touchable>
136
- {pickerVisible && (
137
- <Portal>
138
- <View
139
- style={{
140
- paddingTop: insets.top,
141
- paddingBottom: insets.bottom,
142
- paddingLeft: insets.left,
143
- paddingRight: insets.right,
144
- }}
145
- >
146
- {Platform.OS === "web" && (
147
- <DateTimePicker
148
- value={getValidDate()}
149
- mode={mode}
150
- isVisible={pickerVisible}
151
- toggleVisibility={toggleVisibility}
152
- onChange={(_event: any, data: any) => {
153
- toggleVisibility();
154
- setValue(data);
155
- onDateChange(data);
156
- }}
157
- />
158
- )}
159
- {Platform.OS === "ios" && (
160
- <DateTimePicker
161
- value={getValidDate()}
162
- mode={mode}
163
- displayMode={iosDisplay}
164
- isVisible={pickerVisible}
165
- toggleVisibility={toggleVisibility}
166
- onChange={(_event: any, data: any) => {
167
- toggleVisibility();
168
- setValue(data);
169
- onDateChange(data);
170
- }}
171
- />
172
- )}
173
- {Platform.OS === "android" && (
174
- <DateTimePicker
175
- value={getValidDate()}
176
- mode={mode}
177
- variant={webDisplay}
178
- displayMode={androidDisplay}
179
- isVisible={pickerVisible}
180
- toggleVisibility={toggleVisibility}
181
- onChange={(_event: any, data: any) => {
182
- toggleVisibility();
183
- setValue(data);
184
- onDateChange(data);
185
- }}
186
- />
187
- )}
188
- </View>
189
- </Portal>
190
- )}
191
- </View>
192
- );
193
- };
194
-
195
- export default DatePickerInput;