@draftbit/core 46.5.2-13b65f.2 → 46.5.2-5f6e91.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.
- package/lib/commonjs/components/Button.js +15 -27
- package/lib/commonjs/components/CardBlock.js +13 -4
- package/lib/commonjs/components/CardContainerRating.js +13 -4
- package/lib/commonjs/components/CardContainerShortImage.js +15 -4
- package/lib/commonjs/components/Carousel.js +30 -8
- package/lib/commonjs/components/Checkbox/Checkbox.js +3 -1
- package/lib/commonjs/components/Checkbox/CheckboxGroup.js +17 -2
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +23 -6
- package/lib/commonjs/components/CircleImage.js +15 -1
- package/lib/commonjs/components/CircularProgress.js +26 -8
- package/lib/commonjs/components/DatePicker/DatePicker.js +4 -0
- package/lib/commonjs/components/DatePicker/DatePickerComponent.js +6 -0
- package/lib/commonjs/components/DeprecatedButton.js +151 -0
- package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -2
- package/lib/commonjs/components/DeprecatedFAB.js +2 -1
- package/lib/commonjs/components/Elevation.js +14 -2
- package/lib/commonjs/components/FieldSearchBarFull.js +1 -2
- package/lib/commonjs/components/FormRow.js +16 -2
- package/lib/commonjs/components/IconButton.js +19 -4
- package/lib/commonjs/components/Image.js +17 -2
- package/lib/commonjs/components/Layout.js +40 -19
- package/lib/commonjs/components/Picker/Picker.js +13 -7
- package/lib/commonjs/components/Picker/PickerComponent.android.js +20 -3
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +38 -13
- package/lib/commonjs/components/Portal/PortalConsumer.js +22 -7
- package/lib/commonjs/components/Portal/PortalHost.js +44 -15
- package/lib/commonjs/components/ProgressBar.js +37 -7
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +23 -5
- package/lib/commonjs/components/Slider.js +21 -4
- package/lib/commonjs/components/Surface.js +14 -2
- package/lib/commonjs/components/Switch.js +19 -10
- package/lib/commonjs/components/Text.js +50 -4
- package/lib/commonjs/components/Touchable.js +27 -28
- package/lib/commonjs/components/Touchable.web.js +9 -0
- package/lib/commonjs/constants.js +1 -1
- package/lib/commonjs/hooks.js +1 -2
- package/lib/commonjs/mappings/Button.js +10 -13
- package/lib/commonjs/mappings/Touchable.js +20 -0
- package/lib/commonjs/styles/overlay.js +1 -3
- package/lib/module/components/AnimatedCircularProgress.js +13 -1
- package/lib/module/components/Button.js +9 -21
- package/lib/module/components/CardContainer.js +14 -4
- package/lib/module/components/Checkbox/Checkbox.js +3 -2
- package/lib/module/components/Checkbox/CheckboxGroupRow.js +24 -5
- package/lib/module/components/Checkbox/CheckboxRow.js +24 -6
- package/lib/module/components/Checkbox/context.js +1 -1
- package/lib/module/components/CircleImage.js +16 -1
- package/lib/module/components/DatePicker/DatePicker.js +4 -0
- package/lib/module/components/DatePicker/DatePickerComponent.js +6 -0
- package/lib/module/components/DeprecatedButton.js +141 -0
- package/lib/module/components/DeprecatedCardWrapper.js +2 -2
- package/lib/module/components/DeprecatedFAB.js +25 -4
- package/lib/module/components/Divider.js +18 -1
- package/lib/module/components/Elevation.js +14 -2
- package/lib/module/components/IconButton.js +21 -4
- package/lib/module/components/Layout.js +42 -21
- package/lib/module/components/Picker/Picker.js +4 -3
- package/lib/module/components/Picker/PickerComponent.ios.js +1 -1
- package/lib/module/components/Picker/PickerComponent.web.js +21 -3
- package/lib/module/components/Portal/PortalHost.js +45 -15
- package/lib/module/components/Portal/PortalManager.js +33 -7
- package/lib/module/components/ProgressBar.js +39 -7
- package/lib/module/components/RadioButton/RadioButtonFieldGroup.js +10 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +24 -5
- package/lib/module/components/ScreenContainer.js +21 -4
- package/lib/module/components/Slider.js +21 -4
- package/lib/module/components/StepIndicator.js +58 -18
- package/lib/module/components/Surface.js +15 -1
- package/lib/module/components/TextField.js +78 -28
- package/lib/module/components/ToggleButton.js +16 -2
- package/lib/module/components/Touchable.js +10 -25
- package/lib/module/components/Touchable.web.js +2 -0
- package/lib/module/constants.js +1 -2
- package/lib/module/hooks.js +1 -2
- package/lib/module/index.js +1 -3
- package/lib/module/mappings/Button.js +11 -14
- package/lib/module/mappings/FieldSearchBarFull.js +4 -1
- package/lib/module/mappings/StarRating.js +7 -2
- package/lib/module/mappings/Touchable.js +13 -0
- package/lib/module/styles/overlay.js +1 -3
- package/lib/typescript/src/components/Button.d.ts +0 -2
- package/lib/typescript/src/components/Button.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePicker.d.ts +2 -0
- package/lib/typescript/src/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePickerComponent.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts +2 -0
- package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts.map +1 -1
- package/lib/typescript/src/components/DeprecatedButton.d.ts +54 -0
- package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -0
- package/lib/typescript/src/components/DeprecatedCardWrapper.d.ts.map +1 -1
- package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
- package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable.d.ts +2 -9
- package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable.web.d.ts +3 -0
- package/lib/typescript/src/components/Touchable.web.d.ts.map +1 -0
- package/lib/typescript/src/mappings/Button.d.ts +4 -113
- package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Touchable.d.ts +22 -0
- package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Button.js +11 -18
- package/src/components/Button.tsx +11 -45
- package/src/components/Checkbox/Checkbox.js +3 -2
- package/src/components/Checkbox/Checkbox.tsx +7 -5
- package/src/components/DatePicker/DatePicker.js +2 -2
- package/src/components/DatePicker/DatePicker.tsx +6 -0
- package/src/components/DatePicker/DatePickerComponent.js +3 -3
- package/src/components/DatePicker/DatePickerComponent.tsx +6 -0
- package/src/components/DatePicker/DatePickerComponentType.ts +2 -0
- package/src/components/DeprecatedButton.js +95 -0
- package/src/components/DeprecatedButton.tsx +214 -0
- package/src/components/DeprecatedCardWrapper.js +2 -2
- package/src/components/DeprecatedCardWrapper.tsx +4 -3
- package/src/components/DeprecatedFAB.js +3 -2
- package/src/components/DeprecatedFAB.tsx +5 -5
- package/src/components/Picker/Picker.js +4 -3
- package/src/components/Picker/Picker.tsx +4 -4
- package/src/components/Picker/PickerComponent.ios.js +1 -1
- package/src/components/Picker/PickerComponent.ios.tsx +1 -1
- package/src/components/Touchable.js +11 -16
- package/src/components/Touchable.tsx +11 -42
- package/src/components/Touchable.web.js +2 -0
- package/src/components/Touchable.web.tsx +3 -0
- package/src/mappings/Button.js +10 -13
- package/src/mappings/Button.ts +10 -13
- package/src/mappings/Touchable.js +17 -0
- package/src/mappings/Touchable.ts +23 -0
- package/lib/commonjs/components/Pressable.js +0 -48
- package/lib/commonjs/mappings/Pressable.js +0 -34
- package/lib/module/components/Pressable.js +0 -40
- package/lib/module/mappings/Pressable.js +0 -27
- package/lib/typescript/src/components/Pressable.d.ts +0 -18
- package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
- package/lib/typescript/src/mappings/Pressable.d.ts +0 -76
- package/lib/typescript/src/mappings/Pressable.d.ts.map +0 -1
- package/src/components/Pressable.js +0 -17
- package/src/components/Pressable.tsx +0 -67
- package/src/mappings/Pressable.js +0 -34
- package/src/mappings/Pressable.ts +0 -42
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const SEED_DATA: {
|
|
2
|
+
name: string;
|
|
3
|
+
tag: string;
|
|
4
|
+
description: string;
|
|
5
|
+
category: string;
|
|
6
|
+
stylesPanelSections: string[];
|
|
7
|
+
layout: {};
|
|
8
|
+
triggers: string[];
|
|
9
|
+
props: {
|
|
10
|
+
onPress: {
|
|
11
|
+
label: string;
|
|
12
|
+
description: string;
|
|
13
|
+
editable: boolean;
|
|
14
|
+
required: boolean;
|
|
15
|
+
formType: string;
|
|
16
|
+
propType: string;
|
|
17
|
+
defaultValue: null;
|
|
18
|
+
group: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=Touchable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Touchable.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Touchable.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAerB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "46.5.2-
|
|
3
|
+
"version": "46.5.2-5f6e91.0+5f6e919f",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^46.5.
|
|
44
|
+
"@draftbit/types": "^46.5.1",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
47
|
"@react-native-community/slider": "4.2.3",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
]
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "5f6e919f90653f6a093791d248baed3a1dbe31a2"
|
|
95
95
|
}
|
package/src/components/Button.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { Text, Pressable, Platform, StyleSheet, ActivityIndicator, } from "react-native";
|
|
3
3
|
import { withTheme } from "../theming";
|
|
4
4
|
const CONSTANTS = {
|
|
@@ -7,7 +7,7 @@ const CONSTANTS = {
|
|
|
7
7
|
padding: 8,
|
|
8
8
|
icon: 24,
|
|
9
9
|
};
|
|
10
|
-
function Base({ Icon, icon, title, onPress,
|
|
10
|
+
function Base({ Icon, icon, title, onPress, loading, disabled, style, ...props }) {
|
|
11
11
|
const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...buttonStyles } = StyleSheet.flatten(style || {});
|
|
12
12
|
const titleStyles = {
|
|
13
13
|
color,
|
|
@@ -28,22 +28,15 @@ function Base({ Icon, icon, title, onPress, onLongPress, activeOpacity, disabled
|
|
|
28
28
|
if (textAlign === "right") {
|
|
29
29
|
buttonStyles.justifyContent = "flex-end";
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}, [activeOpacity, disabled, disabledOpacity]);
|
|
42
|
-
const _style = useCallback(({ pressed }) => [
|
|
43
|
-
buttonStyles,
|
|
44
|
-
{ opacity: getOpacity(pressed) },
|
|
45
|
-
], [getOpacity, buttonStyles]);
|
|
46
|
-
return (React.createElement(Pressable, { onPress: onPress, onLongPress: onLongPress, disabled: disabled || loading, style: (styles.base, _style), ...props },
|
|
31
|
+
return (React.createElement(Pressable, { onPress: onPress, disabled: disabled || loading, style: ({ pressed }) => {
|
|
32
|
+
return [
|
|
33
|
+
styles.base,
|
|
34
|
+
{
|
|
35
|
+
opacity: pressed || disabled ? 0.75 : 1,
|
|
36
|
+
},
|
|
37
|
+
buttonStyles,
|
|
38
|
+
];
|
|
39
|
+
}, ...props },
|
|
47
40
|
loading ? (React.createElement(ActivityIndicator, { size: "small", color: color, style: styles.loading })) : null,
|
|
48
41
|
icon && !loading ? (React.createElement(Icon, { name: icon, color: color, style: styles.icon, size: CONSTANTS.icon })) : null,
|
|
49
42
|
React.createElement(Text, { style: titleStyles }, title)));
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import {
|
|
3
3
|
Text,
|
|
4
4
|
Pressable,
|
|
5
|
-
PressableProps,
|
|
6
|
-
PressableStateCallbackType,
|
|
7
5
|
Platform,
|
|
8
6
|
StyleSheet,
|
|
9
|
-
StyleProp,
|
|
10
7
|
TextStyle,
|
|
11
|
-
|
|
8
|
+
PressableProps,
|
|
12
9
|
ActivityIndicator,
|
|
13
10
|
} from "react-native";
|
|
14
11
|
|
|
@@ -30,12 +27,6 @@ type BaseProps = {
|
|
|
30
27
|
loading: boolean;
|
|
31
28
|
style?: TextStyle;
|
|
32
29
|
onPress: () => void;
|
|
33
|
-
onLongPress?: () => void;
|
|
34
|
-
activeOpacity?: number;
|
|
35
|
-
disabledOpacity?: number;
|
|
36
|
-
delayLongPress?: number;
|
|
37
|
-
hitSlop?: number;
|
|
38
|
-
pressRetentionOffset?: number;
|
|
39
30
|
icon?: string;
|
|
40
31
|
} & PressableProps &
|
|
41
32
|
IconSlot;
|
|
@@ -46,29 +37,16 @@ type Props = {
|
|
|
46
37
|
loading: boolean;
|
|
47
38
|
style?: TextStyle;
|
|
48
39
|
onPress: () => void;
|
|
49
|
-
onLongPress?: () => void;
|
|
50
|
-
activeOpacity?: number;
|
|
51
|
-
disabledOpacity?: number;
|
|
52
|
-
delayLongPress?: number;
|
|
53
|
-
hitSlop?: number;
|
|
54
|
-
pressRetentionOffset?: number;
|
|
55
40
|
icon?: string;
|
|
56
41
|
theme: Theme;
|
|
57
42
|
} & PressableProps &
|
|
58
43
|
IconSlot;
|
|
59
44
|
|
|
60
|
-
export type StyleType = (
|
|
61
|
-
state: PressableStateCallbackType
|
|
62
|
-
) => StyleProp<ViewStyle>;
|
|
63
|
-
|
|
64
45
|
function Base({
|
|
65
46
|
Icon,
|
|
66
47
|
icon,
|
|
67
48
|
title,
|
|
68
49
|
onPress,
|
|
69
|
-
onLongPress,
|
|
70
|
-
activeOpacity,
|
|
71
|
-
disabledOpacity,
|
|
72
50
|
loading,
|
|
73
51
|
disabled,
|
|
74
52
|
style,
|
|
@@ -111,31 +89,19 @@ function Base({
|
|
|
111
89
|
buttonStyles.justifyContent = "flex-end";
|
|
112
90
|
}
|
|
113
91
|
|
|
114
|
-
const getOpacity = useCallback(
|
|
115
|
-
(pressed: boolean) => {
|
|
116
|
-
if (disabled) {
|
|
117
|
-
return disabledOpacity;
|
|
118
|
-
} else {
|
|
119
|
-
if (pressed) return activeOpacity;
|
|
120
|
-
else return 1;
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
[activeOpacity, disabled, disabledOpacity]
|
|
124
|
-
);
|
|
125
|
-
const _style = useCallback<StyleType>(
|
|
126
|
-
({ pressed }) => [
|
|
127
|
-
buttonStyles as ViewStyle,
|
|
128
|
-
{ opacity: getOpacity(pressed) },
|
|
129
|
-
],
|
|
130
|
-
[getOpacity, buttonStyles]
|
|
131
|
-
);
|
|
132
|
-
|
|
133
92
|
return (
|
|
134
93
|
<Pressable
|
|
135
94
|
onPress={onPress}
|
|
136
|
-
onLongPress={onLongPress}
|
|
137
95
|
disabled={disabled || loading}
|
|
138
|
-
style={(
|
|
96
|
+
style={({ pressed }) => {
|
|
97
|
+
return [
|
|
98
|
+
styles.base,
|
|
99
|
+
{
|
|
100
|
+
opacity: pressed || disabled ? 0.75 : 1,
|
|
101
|
+
},
|
|
102
|
+
buttonStyles,
|
|
103
|
+
];
|
|
104
|
+
}}
|
|
139
105
|
{...props}
|
|
140
106
|
>
|
|
141
107
|
{loading ? (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet,
|
|
2
|
+
import { View, StyleSheet, } from "react-native";
|
|
3
3
|
import { useTheme } from "../../theming";
|
|
4
|
+
import Touchable from "../Touchable";
|
|
4
5
|
import { usePrevious } from "../../hooks";
|
|
5
6
|
const Checkbox = ({ Icon, status, disabled = false, onPress, onCheck, onUncheck, color, uncheckedColor, defaultValue, checkedIcon = "MaterialCommunityIcons/checkbox-marked", uncheckedIcon = "MaterialCommunityIcons/checkbox-blank-outline", size = 24, style, ...rest }) => {
|
|
6
7
|
const [internalValue, setInternalValue] = React.useState(status || defaultValue || false);
|
|
@@ -32,7 +33,7 @@ const Checkbox = ({ Icon, status, disabled = false, onPress, onCheck, onUncheck,
|
|
|
32
33
|
onUncheck === null || onUncheck === void 0 ? void 0 : onUncheck();
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
|
-
return (React.createElement(
|
|
36
|
+
return (React.createElement(Touchable, { ...rest, onPress: handlePress, disabled: disabled, accessibilityState: { disabled }, accessibilityRole: "button", accessibilityLiveRegion: "polite", style: [styles.container, style, { width: size, height: size }] },
|
|
36
37
|
React.createElement(Icon, { style: styles.icon, name: internalValue ? checkedIcon : uncheckedIcon, size: size, color: checkboxColor }),
|
|
37
38
|
React.createElement(View, { style: [StyleSheet.absoluteFill, styles.fillContainer] },
|
|
38
39
|
React.createElement(View, { style: [
|
|
@@ -2,14 +2,14 @@ import * as React from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
5
|
+
TouchableHighlightProps,
|
|
5
6
|
StyleProp,
|
|
6
7
|
ViewStyle,
|
|
7
|
-
Pressable,
|
|
8
|
-
PressableProps,
|
|
9
8
|
} from "react-native";
|
|
10
9
|
import { useTheme } from "../../theming";
|
|
11
10
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
12
11
|
|
|
12
|
+
import Touchable from "../Touchable";
|
|
13
13
|
import { usePrevious } from "../../hooks";
|
|
14
14
|
|
|
15
15
|
export interface CheckboxProps {
|
|
@@ -27,7 +27,9 @@ export interface CheckboxProps {
|
|
|
27
27
|
style?: StyleProp<ViewStyle>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const Checkbox: React.FC<
|
|
30
|
+
const Checkbox: React.FC<
|
|
31
|
+
CheckboxProps & TouchableHighlightProps & IconSlot
|
|
32
|
+
> = ({
|
|
31
33
|
Icon,
|
|
32
34
|
status,
|
|
33
35
|
disabled = false,
|
|
@@ -85,7 +87,7 @@ const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
|
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
return (
|
|
88
|
-
<
|
|
90
|
+
<Touchable
|
|
89
91
|
{...rest}
|
|
90
92
|
onPress={handlePress}
|
|
91
93
|
disabled={disabled}
|
|
@@ -109,7 +111,7 @@ const Checkbox: React.FC<CheckboxProps & PressableProps & IconSlot> = ({
|
|
|
109
111
|
]}
|
|
110
112
|
/>
|
|
111
113
|
</View>
|
|
112
|
-
</
|
|
114
|
+
</Touchable>
|
|
113
115
|
);
|
|
114
116
|
};
|
|
115
117
|
|
|
@@ -25,7 +25,7 @@ const MONTHS = [
|
|
|
25
25
|
"November",
|
|
26
26
|
"December",
|
|
27
27
|
];
|
|
28
|
-
const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, labelSize, labelColor, placeholder, borderColor: inputBorderColor, borderColorActive: inputBorderColorActive, ...props }) => {
|
|
28
|
+
const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, labelSize, labelColor, placeholder, borderColor: inputBorderColor, borderColorActive: inputBorderColorActive, pickerAccentColor, pickerTextColor, ...props }) => {
|
|
29
29
|
const [value, setValue] = React.useState(date || defaultValue);
|
|
30
30
|
React.useEffect(() => {
|
|
31
31
|
if (defaultValue != null) {
|
|
@@ -333,7 +333,7 @@ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disab
|
|
|
333
333
|
paddingRight: insets.right,
|
|
334
334
|
},
|
|
335
335
|
] },
|
|
336
|
-
React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
|
|
336
|
+
React.createElement(DateTimePicker, { accentColor: pickerAccentColor, textColor: pickerTextColor, value: getValidDate(), mode: mode, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
|
|
337
337
|
toggleVisibility();
|
|
338
338
|
setValue(data);
|
|
339
339
|
onDateChange(data);
|
|
@@ -55,6 +55,8 @@ type Props = {
|
|
|
55
55
|
rightIconName?: string;
|
|
56
56
|
borderColor?: string;
|
|
57
57
|
borderColorActive?: string;
|
|
58
|
+
pickerTextColor?: string;
|
|
59
|
+
pickerAccentColor?: string;
|
|
58
60
|
} & IconSlot &
|
|
59
61
|
TextInputProps;
|
|
60
62
|
|
|
@@ -93,6 +95,8 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
93
95
|
placeholder,
|
|
94
96
|
borderColor: inputBorderColor,
|
|
95
97
|
borderColorActive: inputBorderColorActive,
|
|
98
|
+
pickerAccentColor,
|
|
99
|
+
pickerTextColor,
|
|
96
100
|
...props
|
|
97
101
|
}) => {
|
|
98
102
|
const [value, setValue] = React.useState<any>(date || defaultValue);
|
|
@@ -513,6 +517,8 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
513
517
|
]}
|
|
514
518
|
>
|
|
515
519
|
<DateTimePicker
|
|
520
|
+
accentColor={pickerAccentColor}
|
|
521
|
+
textColor={pickerTextColor}
|
|
516
522
|
value={getValidDate()}
|
|
517
523
|
mode={mode}
|
|
518
524
|
isVisible={pickerVisible}
|
|
@@ -2,12 +2,12 @@ import React from "react";
|
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
3
|
import DateTimePicker from "@react-native-community/datetimepicker";
|
|
4
4
|
import DateTimePickerModal from "react-native-modal-datetime-picker";
|
|
5
|
-
const DatePickerComponent = ({ value, onChange, mode, toggleVisibility, }) => {
|
|
6
|
-
return Platform.OS === "ios" || Platform.OS === "android" ? (React.createElement(DateTimePickerModal, { date: value, mode: mode, isVisible: true, display: Platform.OS === "ios" ? "spinner" : "default", onCancel: () => {
|
|
5
|
+
const DatePickerComponent = ({ value, onChange, textColor, accentColor, mode, toggleVisibility, }) => {
|
|
6
|
+
return Platform.OS === "ios" || Platform.OS === "android" ? (React.createElement(DateTimePickerModal, { date: value, mode: mode, textColor: textColor, accentColor: accentColor, isVisible: true, display: Platform.OS === "ios" ? "spinner" : "default", onCancel: () => {
|
|
7
7
|
console.log("Picker cancelled before selecting anything.");
|
|
8
8
|
toggleVisibility();
|
|
9
9
|
}, onConfirm: (data) => {
|
|
10
10
|
onChange(null, data);
|
|
11
|
-
} })) : (React.createElement(DateTimePicker, { value: value, mode: mode, onChange: onChange, display: "default" }));
|
|
11
|
+
} })) : (React.createElement(DateTimePicker, { value: value, mode: mode, textColor: textColor, accentColor: accentColor, onChange: onChange, display: "default" }));
|
|
12
12
|
};
|
|
13
13
|
export default DatePickerComponent;
|
|
@@ -7,6 +7,8 @@ import { DatePickerComponentProps as Props } from "./DatePickerComponentType";
|
|
|
7
7
|
const DatePickerComponent: React.FC<React.PropsWithChildren<Props>> = ({
|
|
8
8
|
value,
|
|
9
9
|
onChange,
|
|
10
|
+
textColor,
|
|
11
|
+
accentColor,
|
|
10
12
|
mode,
|
|
11
13
|
toggleVisibility,
|
|
12
14
|
}) => {
|
|
@@ -14,6 +16,8 @@ const DatePickerComponent: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
14
16
|
<DateTimePickerModal
|
|
15
17
|
date={value}
|
|
16
18
|
mode={mode}
|
|
19
|
+
textColor={textColor}
|
|
20
|
+
accentColor={accentColor}
|
|
17
21
|
isVisible={true}
|
|
18
22
|
display={Platform.OS === "ios" ? "spinner" : "default"}
|
|
19
23
|
onCancel={() => {
|
|
@@ -28,6 +32,8 @@ const DatePickerComponent: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
28
32
|
<DateTimePicker
|
|
29
33
|
value={value}
|
|
30
34
|
mode={mode}
|
|
35
|
+
textColor={textColor}
|
|
36
|
+
accentColor={accentColor}
|
|
31
37
|
onChange={onChange}
|
|
32
38
|
display={"default"}
|
|
33
39
|
/>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ActivityIndicator, View, Text, StyleSheet, } from "react-native";
|
|
3
|
+
import color from "color";
|
|
4
|
+
import Config from "./Config";
|
|
5
|
+
import Touchable from "./Touchable";
|
|
6
|
+
import Elevation from "./Elevation";
|
|
7
|
+
import { withTheme } from "../theming";
|
|
8
|
+
const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
|
|
9
|
+
let backgroundColor, borderColor, textColor, borderWidth;
|
|
10
|
+
const buttonColor = colorOverride || colors.primary;
|
|
11
|
+
if (type === "solid") {
|
|
12
|
+
backgroundColor = buttonColor;
|
|
13
|
+
if (disabled) {
|
|
14
|
+
textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
textColor = labelColor || colors.surface;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
backgroundColor = "transparent";
|
|
22
|
+
if (disabled) {
|
|
23
|
+
textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
textColor = labelColor || buttonColor;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (type === "outline") {
|
|
30
|
+
if (disabled) {
|
|
31
|
+
borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
borderColor = buttonColor;
|
|
35
|
+
}
|
|
36
|
+
borderWidth = StyleSheet.hairlineWidth;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
borderColor = "transparent";
|
|
40
|
+
borderWidth = 0;
|
|
41
|
+
}
|
|
42
|
+
const buttonStyle = {
|
|
43
|
+
backgroundColor,
|
|
44
|
+
borderColor,
|
|
45
|
+
borderWidth,
|
|
46
|
+
borderRadius: roundness,
|
|
47
|
+
};
|
|
48
|
+
const textStyle = {
|
|
49
|
+
textAlign: "center",
|
|
50
|
+
color: textColor,
|
|
51
|
+
marginVertical: 16,
|
|
52
|
+
marginHorizontal: 16,
|
|
53
|
+
};
|
|
54
|
+
const iconStyle = [
|
|
55
|
+
styles.icon,
|
|
56
|
+
{
|
|
57
|
+
marginLeft: 16,
|
|
58
|
+
marginRight: -8,
|
|
59
|
+
width: Config.buttonIconSize,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
const { margin, marginEnd, marginTop, marginLeft, marginRight, marginBottom, marginHorizontal, marginVertical, ...innerStyles } = StyleSheet.flatten(style || {});
|
|
63
|
+
const margins = {
|
|
64
|
+
margin,
|
|
65
|
+
marginEnd,
|
|
66
|
+
marginTop,
|
|
67
|
+
marginLeft,
|
|
68
|
+
marginRight,
|
|
69
|
+
marginBottom,
|
|
70
|
+
marginHorizontal,
|
|
71
|
+
marginVertical,
|
|
72
|
+
};
|
|
73
|
+
return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch", ...margins } },
|
|
74
|
+
React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle, innerStyles] },
|
|
75
|
+
React.createElement(View, { style: styles.content },
|
|
76
|
+
icon && loading !== true ? (React.createElement(View, { style: iconStyle },
|
|
77
|
+
React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
|
|
78
|
+
loading ? (React.createElement(ActivityIndicator, { size: "small", color: textColor, style: iconStyle })) : null,
|
|
79
|
+
React.createElement(Text, { numberOfLines: 1, style: [textStyle, typography.button] }, children)))));
|
|
80
|
+
};
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
button: {
|
|
83
|
+
minWidth: 64,
|
|
84
|
+
borderStyle: "solid",
|
|
85
|
+
},
|
|
86
|
+
content: {
|
|
87
|
+
flexDirection: "row",
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
justifyContent: "center",
|
|
90
|
+
},
|
|
91
|
+
icon: {
|
|
92
|
+
width: Config.buttonIconSize,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
export default withTheme(Button);
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
TouchableHighlightProps,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
TextStyle,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import color from "color";
|
|
13
|
+
import Config from "./Config";
|
|
14
|
+
import Touchable from "./Touchable";
|
|
15
|
+
import Elevation from "./Elevation";
|
|
16
|
+
import { withTheme } from "../theming";
|
|
17
|
+
|
|
18
|
+
import type { Theme } from "../styles/DefaultTheme";
|
|
19
|
+
import type { IconSlot } from "../interfaces/Icon";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A button is component that the user can press to trigger an action.
|
|
23
|
+
*
|
|
24
|
+
* <div class="screenshots">
|
|
25
|
+
* <figure>
|
|
26
|
+
* <img src="screenshots/button-1.png" />
|
|
27
|
+
* <figcaption>Text button</figcaption>
|
|
28
|
+
* </figure>
|
|
29
|
+
* <figure>
|
|
30
|
+
* <img src="screenshots/button-2.png" />
|
|
31
|
+
* <figcaption>Outlined button</figcaption>
|
|
32
|
+
* </figure>
|
|
33
|
+
* <figure>
|
|
34
|
+
* <img src="screenshots/button-3.png" />
|
|
35
|
+
* <figcaption>Contained button</figcaption>
|
|
36
|
+
* </figure>
|
|
37
|
+
* </div>
|
|
38
|
+
*
|
|
39
|
+
* ## Usage
|
|
40
|
+
* ```js
|
|
41
|
+
* import * as React from 'react';
|
|
42
|
+
* import { Button } from '@draftbit/ui';
|
|
43
|
+
*
|
|
44
|
+
* const MyComponent = () => (
|
|
45
|
+
* <Button icon="add-a-photo" type="solid" onPress={() => console.log('Pressed')}>
|
|
46
|
+
* Press me
|
|
47
|
+
* </Button>
|
|
48
|
+
* );
|
|
49
|
+
*
|
|
50
|
+
* export default MyComponent;
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
type Props = {
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
type?: "solid" | "outline" | "text";
|
|
57
|
+
loading?: boolean;
|
|
58
|
+
icon?: string;
|
|
59
|
+
labelColor?: string;
|
|
60
|
+
color?: string;
|
|
61
|
+
children?: React.ReactNode;
|
|
62
|
+
onPress: () => void;
|
|
63
|
+
elevation?: number;
|
|
64
|
+
style?: StyleProp<ViewStyle>;
|
|
65
|
+
theme: Theme;
|
|
66
|
+
} & TouchableHighlightProps &
|
|
67
|
+
IconSlot;
|
|
68
|
+
|
|
69
|
+
const Button: React.FC<React.PropsWithChildren<Props>> = ({
|
|
70
|
+
Icon,
|
|
71
|
+
icon,
|
|
72
|
+
disabled = false,
|
|
73
|
+
type = "solid",
|
|
74
|
+
loading = false,
|
|
75
|
+
labelColor,
|
|
76
|
+
color: colorOverride,
|
|
77
|
+
children,
|
|
78
|
+
onPress,
|
|
79
|
+
elevation = 0,
|
|
80
|
+
style,
|
|
81
|
+
theme: { colors, disabledOpacity, roundness, typography },
|
|
82
|
+
...rest
|
|
83
|
+
}) => {
|
|
84
|
+
let backgroundColor, borderColor, textColor, borderWidth;
|
|
85
|
+
const buttonColor = colorOverride || colors.primary;
|
|
86
|
+
|
|
87
|
+
if (type === "solid") {
|
|
88
|
+
backgroundColor = buttonColor;
|
|
89
|
+
|
|
90
|
+
if (disabled) {
|
|
91
|
+
textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
92
|
+
} else {
|
|
93
|
+
textColor = labelColor || colors.surface;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
backgroundColor = "transparent";
|
|
97
|
+
|
|
98
|
+
if (disabled) {
|
|
99
|
+
textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
100
|
+
} else {
|
|
101
|
+
textColor = labelColor || buttonColor;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (type === "outline") {
|
|
106
|
+
if (disabled) {
|
|
107
|
+
borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
108
|
+
} else {
|
|
109
|
+
borderColor = buttonColor;
|
|
110
|
+
}
|
|
111
|
+
borderWidth = StyleSheet.hairlineWidth;
|
|
112
|
+
} else {
|
|
113
|
+
borderColor = "transparent";
|
|
114
|
+
borderWidth = 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const buttonStyle = {
|
|
118
|
+
backgroundColor,
|
|
119
|
+
borderColor,
|
|
120
|
+
borderWidth,
|
|
121
|
+
borderRadius: roundness,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const textStyle: StyleProp<TextStyle> = {
|
|
125
|
+
textAlign: "center",
|
|
126
|
+
color: textColor,
|
|
127
|
+
marginVertical: 16,
|
|
128
|
+
marginHorizontal: 16,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const iconStyle = [
|
|
132
|
+
styles.icon,
|
|
133
|
+
{
|
|
134
|
+
marginLeft: 16,
|
|
135
|
+
marginRight: -8,
|
|
136
|
+
width: Config.buttonIconSize,
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
const {
|
|
141
|
+
margin,
|
|
142
|
+
marginEnd,
|
|
143
|
+
marginTop,
|
|
144
|
+
marginLeft,
|
|
145
|
+
marginRight,
|
|
146
|
+
marginBottom,
|
|
147
|
+
marginHorizontal,
|
|
148
|
+
marginVertical,
|
|
149
|
+
...innerStyles
|
|
150
|
+
} = StyleSheet.flatten(style || {});
|
|
151
|
+
|
|
152
|
+
const margins = {
|
|
153
|
+
margin,
|
|
154
|
+
marginEnd,
|
|
155
|
+
marginTop,
|
|
156
|
+
marginLeft,
|
|
157
|
+
marginRight,
|
|
158
|
+
marginBottom,
|
|
159
|
+
marginHorizontal,
|
|
160
|
+
marginVertical,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Elevation style={{ elevation, alignSelf: "stretch", ...margins }}>
|
|
165
|
+
<Touchable
|
|
166
|
+
{...rest}
|
|
167
|
+
onPress={onPress}
|
|
168
|
+
accessibilityState={{ disabled }}
|
|
169
|
+
accessibilityRole="button"
|
|
170
|
+
disabled={disabled || loading}
|
|
171
|
+
style={[styles.button, buttonStyle, innerStyles]}
|
|
172
|
+
>
|
|
173
|
+
<View style={styles.content}>
|
|
174
|
+
{icon && loading !== true ? (
|
|
175
|
+
<View style={iconStyle}>
|
|
176
|
+
<Icon
|
|
177
|
+
name={icon}
|
|
178
|
+
size={Config.buttonIconSize}
|
|
179
|
+
color={textColor}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
182
|
+
) : null}
|
|
183
|
+
{loading ? (
|
|
184
|
+
<ActivityIndicator
|
|
185
|
+
size="small"
|
|
186
|
+
color={textColor}
|
|
187
|
+
style={iconStyle}
|
|
188
|
+
/>
|
|
189
|
+
) : null}
|
|
190
|
+
<Text numberOfLines={1} style={[textStyle, typography.button]}>
|
|
191
|
+
{children}
|
|
192
|
+
</Text>
|
|
193
|
+
</View>
|
|
194
|
+
</Touchable>
|
|
195
|
+
</Elevation>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const styles = StyleSheet.create({
|
|
200
|
+
button: {
|
|
201
|
+
minWidth: 64,
|
|
202
|
+
borderStyle: "solid",
|
|
203
|
+
},
|
|
204
|
+
content: {
|
|
205
|
+
flexDirection: "row",
|
|
206
|
+
alignItems: "center",
|
|
207
|
+
justifyContent: "center",
|
|
208
|
+
},
|
|
209
|
+
icon: {
|
|
210
|
+
width: Config.buttonIconSize,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
export default withTheme(Button);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { withTheme } from "../theming";
|
|
3
|
-
import
|
|
3
|
+
import Touchable from "./Touchable";
|
|
4
4
|
const getWidth = (numColumns) => {
|
|
5
5
|
switch (numColumns) {
|
|
6
6
|
case 1:
|
|
@@ -13,6 +13,6 @@ const getWidth = (numColumns) => {
|
|
|
13
13
|
};
|
|
14
14
|
const Card = ({ numColumns = 3, children, onPress, style, ...rest }) => {
|
|
15
15
|
const width = getWidth(numColumns);
|
|
16
|
-
return (React.createElement(
|
|
16
|
+
return (React.createElement(Touchable, { disabled: !onPress, onPress: onPress, style: [style, { width }], ...rest }, children));
|
|
17
17
|
};
|
|
18
18
|
export default withTheme(Card);
|