@draftbit/core 42.3.3-fdd04d.0 → 42.4.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/Checkbox/Checkbox.js +13 -2
- package/lib/commonjs/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +2 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/commonjs/components/FieldSearchBarFull.js +16 -3
- package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +16 -2
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +7 -2
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/components/Slider.js +13 -2
- package/lib/commonjs/components/Slider.js.map +1 -1
- package/lib/commonjs/components/StarRating.js +2 -1
- package/lib/commonjs/components/StarRating.js.map +1 -1
- package/lib/commonjs/components/Stepper.js +5 -1
- package/lib/commonjs/components/Stepper.js.map +1 -1
- package/lib/commonjs/components/Swiper/Swiper.js +1 -33
- package/lib/commonjs/components/Swiper/Swiper.js.map +1 -1
- package/lib/commonjs/components/Switch.js +3 -0
- package/lib/commonjs/components/Switch.js.map +1 -1
- package/lib/commonjs/components/TextField.js +4 -1
- package/lib/commonjs/components/TextField.js.map +1 -1
- package/lib/commonjs/components/TextInput.js +1 -1
- package/lib/commonjs/components/TextInput.js.map +1 -1
- package/lib/commonjs/components/ToggleButton.js +13 -2
- package/lib/commonjs/components/ToggleButton.js.map +1 -1
- package/lib/module/components/Checkbox/Checkbox.js +13 -2
- package/lib/module/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +2 -1
- package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/components/DatePicker/DatePickerComponent.web.js.map +1 -1
- package/lib/module/components/FieldSearchBarFull.js +16 -3
- package/lib/module/components/FieldSearchBarFull.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +16 -2
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonGroup.js +7 -2
- package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/module/components/Slider.js +13 -2
- package/lib/module/components/Slider.js.map +1 -1
- package/lib/module/components/StarRating.js +2 -1
- package/lib/module/components/StarRating.js.map +1 -1
- package/lib/module/components/Stepper.js +5 -1
- package/lib/module/components/Stepper.js.map +1 -1
- package/lib/module/components/Swiper/Swiper.js +2 -34
- package/lib/module/components/Swiper/Swiper.js.map +1 -1
- package/lib/module/components/Switch.js +3 -0
- package/lib/module/components/Switch.js.map +1 -1
- package/lib/module/components/TextField.js +4 -1
- package/lib/module/components/TextField.js.map +1 -1
- package/lib/module/components/TextInput.js +1 -1
- package/lib/module/components/TextInput.js.map +1 -1
- package/lib/module/components/ToggleButton.js +13 -2
- package/lib/module/components/ToggleButton.js.map +1 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +1 -0
- package/lib/typescript/src/components/DatePicker/DatePicker.d.ts +1 -0
- package/lib/typescript/src/components/FieldSearchBarFull.d.ts +3 -2
- package/lib/typescript/src/components/Picker/Picker.d.ts +1 -1
- package/lib/typescript/src/components/Picker/PickerTypes.d.ts +2 -1
- package/lib/typescript/src/components/RadioButton/RadioButtonGroup.d.ts +2 -1
- package/lib/typescript/src/components/Slider.d.ts +4 -1
- package/lib/typescript/src/components/StarRating.d.ts +1 -0
- package/lib/typescript/src/components/Stepper.d.ts +1 -0
- package/lib/typescript/src/components/Swiper/Swiper.d.ts +1 -45
- package/lib/typescript/src/components/TextField.d.ts +1 -0
- package/lib/typescript/src/components/TextInput.d.ts +1 -1
- package/lib/typescript/src/components/ToggleButton.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/Checkbox/Checkbox.js +13 -3
- package/src/components/Checkbox/Checkbox.tsx +22 -3
- package/src/components/DatePicker/DatePicker.js +2 -2
- package/src/components/DatePicker/DatePicker.tsx +4 -2
- package/src/components/FieldSearchBarFull.js +12 -2
- package/src/components/FieldSearchBarFull.tsx +22 -5
- package/src/components/Picker/Picker.js +12 -2
- package/src/components/Picker/Picker.tsx +19 -3
- package/src/components/Picker/PickerTypes.ts +3 -2
- package/src/components/RadioButton/RadioButtonGroup.js +10 -2
- package/src/components/RadioButton/RadioButtonGroup.tsx +19 -3
- package/src/components/Slider.js +11 -3
- package/src/components/Slider.tsx +18 -3
- package/src/components/StarRating.js +2 -2
- package/src/components/StarRating.tsx +5 -1
- package/src/components/Stepper.js +5 -2
- package/src/components/Stepper.tsx +10 -2
- package/src/components/Swiper/Swiper.js +2 -20
- package/src/components/Swiper/Swiper.tsx +0 -27
- package/src/components/Switch.js +3 -0
- package/src/components/Switch.tsx +5 -0
- package/src/components/TextField.js +5 -1
- package/src/components/TextField.tsx +5 -1
- package/src/components/TextInput.js +1 -1
- package/src/components/TextInput.tsx +2 -2
- package/src/components/ToggleButton.js +10 -2
- package/src/components/ToggleButton.tsx +18 -3
|
@@ -25,7 +25,11 @@ class TextField extends React.Component {
|
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
componentDidMount() {
|
|
28
|
-
if (this.props.
|
|
28
|
+
if (this.props.defaultValue) {
|
|
29
|
+
this._handleChangeText(this.props.defaultValue);
|
|
30
|
+
}
|
|
31
|
+
else if (this.props.initialValue) {
|
|
32
|
+
// deprecated
|
|
29
33
|
this._handleChangeText(this.props.initialValue);
|
|
30
34
|
}
|
|
31
35
|
if (this.props.placeholder) {
|
|
@@ -41,6 +41,7 @@ const ICON_SIZE = 24;
|
|
|
41
41
|
export type Props = {
|
|
42
42
|
type?: "solid" | "underline";
|
|
43
43
|
initialValue?: string;
|
|
44
|
+
defaultValue?: string;
|
|
44
45
|
disabled?: boolean;
|
|
45
46
|
label?: string;
|
|
46
47
|
error?: boolean;
|
|
@@ -94,7 +95,10 @@ class TextField extends React.Component<Props, State> {
|
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
componentDidMount() {
|
|
97
|
-
if (this.props.
|
|
98
|
+
if (this.props.defaultValue) {
|
|
99
|
+
this._handleChangeText(this.props.defaultValue);
|
|
100
|
+
} else if (this.props.initialValue) {
|
|
101
|
+
// deprecated
|
|
98
102
|
this._handleChangeText(this.props.initialValue);
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -4,7 +4,7 @@ import { usePrevious } from "../hooks";
|
|
|
4
4
|
const TextInput = ({ initialValue, onChangeText, ...props }) => {
|
|
5
5
|
const previousInitialValue = usePrevious(initialValue);
|
|
6
6
|
React.useEffect(() => {
|
|
7
|
-
if (initialValue !== previousInitialValue) {
|
|
7
|
+
if (initialValue !== previousInitialValue && onChangeText) {
|
|
8
8
|
onChangeText(initialValue);
|
|
9
9
|
}
|
|
10
10
|
}, [initialValue, previousInitialValue, onChangeText]);
|
|
@@ -4,7 +4,7 @@ import { usePrevious } from "../hooks";
|
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
initialValue?: string;
|
|
7
|
-
onChangeText
|
|
7
|
+
onChangeText?: (value?: string) => void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const TextInput: React.FC<Props> = ({
|
|
@@ -14,7 +14,7 @@ const TextInput: React.FC<Props> = ({
|
|
|
14
14
|
}) => {
|
|
15
15
|
const previousInitialValue = usePrevious(initialValue);
|
|
16
16
|
React.useEffect(() => {
|
|
17
|
-
if (initialValue !== previousInitialValue) {
|
|
17
|
+
if (initialValue !== previousInitialValue && onChangeText) {
|
|
18
18
|
onChangeText(initialValue);
|
|
19
19
|
}
|
|
20
20
|
}, [initialValue, previousInitialValue, onChangeText]);
|
|
@@ -5,14 +5,22 @@ import { StyleSheet } from "react-native";
|
|
|
5
5
|
import IconButton from "./IconButton";
|
|
6
6
|
import { COMPONENT_TYPES, createIconProp, createBoolProp, createColorProp, createStaticNumberProp, createFieldNameProp, createIconSizeProp, createActionProp, Triggers, } from "@draftbit/types";
|
|
7
7
|
import { usePrevious } from "../hooks";
|
|
8
|
-
const ToggleButton = ({ Icon, icon, toggled = false, onPress = () => { }, initialValue, disabled = false, color = "primary", colorSecondary = "surface", borderColor = "divider", iconSize = 25, width = 50, height = 50, theme: { colors }, style, ...rest }) => {
|
|
8
|
+
const ToggleButton = ({ Icon, icon, toggled = false, onPress = () => { }, initialValue, defaultValue, disabled = false, color = "primary", colorSecondary = "surface", borderColor = "divider", iconSize = 25, width = 50, height = 50, theme: { colors }, style, ...rest }) => {
|
|
9
|
+
const [internalValue, setIntervalValue] = React.useState(toggled || defaultValue || false);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
setIntervalValue(toggled);
|
|
12
|
+
}, [toggled]);
|
|
9
13
|
const previousInitialValue = usePrevious(initialValue);
|
|
10
14
|
React.useEffect(() => {
|
|
11
15
|
if (initialValue !== previousInitialValue) {
|
|
12
16
|
onPress(initialValue);
|
|
13
17
|
}
|
|
14
18
|
}, [initialValue, previousInitialValue, onPress]);
|
|
15
|
-
|
|
19
|
+
const handlePress = () => {
|
|
20
|
+
setIntervalValue(!toggled);
|
|
21
|
+
onPress(!toggled);
|
|
22
|
+
};
|
|
23
|
+
return (React.createElement(IconButton, { Icon: Icon, icon: icon, size: iconSize, color: internalValue ? colors[color] : colors[colorSecondary], onPress: handlePress, disabled: disabled, style: [
|
|
16
24
|
styles.mainContainer,
|
|
17
25
|
{
|
|
18
26
|
width,
|
|
@@ -22,7 +22,8 @@ type Props = {
|
|
|
22
22
|
icon: string;
|
|
23
23
|
toggled?: boolean;
|
|
24
24
|
onPress?: (toggled: boolean) => void;
|
|
25
|
-
initialValue?: boolean;
|
|
25
|
+
initialValue?: boolean; // deprecated
|
|
26
|
+
defaultValue?: boolean;
|
|
26
27
|
disabled?: boolean;
|
|
27
28
|
color?: colorTypes;
|
|
28
29
|
colorSecondary?: colorTypes;
|
|
@@ -40,6 +41,7 @@ const ToggleButton: React.FC<Props> = ({
|
|
|
40
41
|
toggled = false,
|
|
41
42
|
onPress = () => {},
|
|
42
43
|
initialValue,
|
|
44
|
+
defaultValue,
|
|
43
45
|
disabled = false,
|
|
44
46
|
color = "primary",
|
|
45
47
|
colorSecondary = "surface",
|
|
@@ -51,6 +53,14 @@ const ToggleButton: React.FC<Props> = ({
|
|
|
51
53
|
style,
|
|
52
54
|
...rest
|
|
53
55
|
}) => {
|
|
56
|
+
const [internalValue, setIntervalValue] = React.useState<boolean>(
|
|
57
|
+
toggled || defaultValue || false
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
setIntervalValue(toggled);
|
|
62
|
+
}, [toggled]);
|
|
63
|
+
|
|
54
64
|
const previousInitialValue = usePrevious(initialValue);
|
|
55
65
|
React.useEffect(() => {
|
|
56
66
|
if (initialValue !== previousInitialValue) {
|
|
@@ -58,13 +68,18 @@ const ToggleButton: React.FC<Props> = ({
|
|
|
58
68
|
}
|
|
59
69
|
}, [initialValue, previousInitialValue, onPress]);
|
|
60
70
|
|
|
71
|
+
const handlePress = () => {
|
|
72
|
+
setIntervalValue(!toggled);
|
|
73
|
+
onPress(!toggled);
|
|
74
|
+
};
|
|
75
|
+
|
|
61
76
|
return (
|
|
62
77
|
<IconButton
|
|
63
78
|
Icon={Icon}
|
|
64
79
|
icon={icon}
|
|
65
80
|
size={iconSize}
|
|
66
|
-
color={
|
|
67
|
-
onPress={
|
|
81
|
+
color={internalValue ? colors[color] : colors[colorSecondary]}
|
|
82
|
+
onPress={handlePress}
|
|
68
83
|
disabled={disabled}
|
|
69
84
|
style={[
|
|
70
85
|
styles.mainContainer,
|