@draftbit/core 42.1.3 → 42.1.6-f67332.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/Divider.js +18 -5
- package/lib/commonjs/components/Divider.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +4 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js +4 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +2 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/components/Switch.js +4 -70
- package/lib/commonjs/components/Switch.js.map +1 -1
- package/lib/commonjs/mappings/Switch.js +79 -0
- package/lib/commonjs/mappings/Switch.js.map +1 -0
- package/lib/module/components/Accordion/AccordionItem.js +5 -18
- package/lib/module/components/Accordion/AccordionItem.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +4 -1
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.web.js +4 -1
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/Switch.js +13 -92
- package/lib/module/components/Switch.js.map +1 -1
- package/lib/module/components/Touchable.web.js.map +1 -1
- package/lib/module/mappings/Switch.js +70 -0
- package/lib/module/mappings/Switch.js.map +1 -0
- package/lib/typescript/src/components/Switch.d.ts +0 -155
- package/package.json +2 -2
- package/src/components/Picker/PickerComponent.android.js +4 -1
- package/src/components/Picker/PickerComponent.android.tsx +6 -1
- package/src/components/Picker/PickerComponent.web.js +4 -1
- package/src/components/Picker/PickerComponent.web.tsx +6 -1
- package/src/components/RadioButton/RadioButtonRow.js +1 -0
- package/src/components/RadioButton/RadioButtonRow.tsx +1 -0
- package/src/components/Switch.js +3 -72
- package/src/components/Switch.tsx +3 -83
- package/src/mappings/Switch.js +81 -0
|
@@ -40,6 +40,9 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
40
40
|
"marginBottom",
|
|
41
41
|
"marginLeft",
|
|
42
42
|
]);
|
|
43
|
+
const selectedLabel = selectedValue &&
|
|
44
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
45
|
+
selectedValue);
|
|
43
46
|
return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
|
|
44
47
|
React.createElement(View, null,
|
|
45
48
|
React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: (value, index) => onValueChange(value.toString(), index), style: {
|
|
@@ -51,7 +54,7 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
51
54
|
bottom: 0,
|
|
52
55
|
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
|
|
53
56
|
React.createElement(View, { pointerEvents: "none" },
|
|
54
|
-
React.createElement(TextField, { ...props, value:
|
|
57
|
+
React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
|
|
55
58
|
// @ts-ignore
|
|
56
59
|
ref: textField, disabled: disabled,
|
|
57
60
|
// @ts-expect-error
|
|
@@ -61,6 +61,11 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
61
61
|
"marginLeft",
|
|
62
62
|
]);
|
|
63
63
|
|
|
64
|
+
const selectedLabel =
|
|
65
|
+
selectedValue &&
|
|
66
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
67
|
+
selectedValue);
|
|
68
|
+
|
|
64
69
|
return (
|
|
65
70
|
<Touchable
|
|
66
71
|
disabled={disabled}
|
|
@@ -90,7 +95,7 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
90
95
|
<View pointerEvents="none">
|
|
91
96
|
<TextField
|
|
92
97
|
{...props}
|
|
93
|
-
value={
|
|
98
|
+
value={selectedLabel}
|
|
94
99
|
placeholder={placeholder}
|
|
95
100
|
// @ts-ignore
|
|
96
101
|
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
@@ -39,6 +39,9 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
39
39
|
"marginBottom",
|
|
40
40
|
"marginLeft",
|
|
41
41
|
]);
|
|
42
|
+
const selectedLabel = selectedValue &&
|
|
43
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
44
|
+
selectedValue);
|
|
42
45
|
return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },
|
|
43
46
|
React.createElement(View, null,
|
|
44
47
|
React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: (value, index) => onValueChange(value.toString(), index), style: {
|
|
@@ -51,7 +54,7 @@ const Picker = ({ style, options, placeholder, selectedValue, disabled = false,
|
|
|
51
54
|
bottom: 0,
|
|
52
55
|
} }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),
|
|
53
56
|
React.createElement(View, { pointerEvents: "none" },
|
|
54
|
-
React.createElement(TextField, { ...props, value:
|
|
57
|
+
React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder,
|
|
55
58
|
// @ts-ignore
|
|
56
59
|
ref: textField, disabled: disabled,
|
|
57
60
|
// @ts-expect-error
|
|
@@ -60,6 +60,11 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
60
60
|
"marginLeft",
|
|
61
61
|
]);
|
|
62
62
|
|
|
63
|
+
const selectedLabel =
|
|
64
|
+
selectedValue &&
|
|
65
|
+
(options.find((opt) => opt.value === selectedValue)?.label ??
|
|
66
|
+
selectedValue);
|
|
67
|
+
|
|
63
68
|
return (
|
|
64
69
|
<Touchable
|
|
65
70
|
disabled={disabled}
|
|
@@ -90,7 +95,7 @@ const Picker: React.FC<PickerComponentProps> = ({
|
|
|
90
95
|
<View pointerEvents="none">
|
|
91
96
|
<TextField
|
|
92
97
|
{...props}
|
|
93
|
-
value={
|
|
98
|
+
value={selectedLabel}
|
|
94
99
|
placeholder={placeholder}
|
|
95
100
|
// @ts-ignore
|
|
96
101
|
ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
package/src/components/Switch.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { Switch as NativeSwitch, } from "react-native";
|
|
3
3
|
import { withTheme } from "../theming";
|
|
4
4
|
import FormRow from "./FormRow";
|
|
5
|
-
import {
|
|
5
|
+
import { RowDirection } from "@draftbit/types";
|
|
6
6
|
import { usePrevious } from "../hooks";
|
|
7
7
|
function Switch({ value = false, initialValue, disabled, onValueChange, activeTrackColor, inactiveTrackColor, activeThumbColor, inactiveThumbColor, theme, style, ...rest }) {
|
|
8
8
|
const activeTrackThemeColor = activeTrackColor || theme.colors.primary;
|
|
@@ -55,74 +55,5 @@ function Row({ label = "Label", direction = RowDirection.Row, style, value = fal
|
|
|
55
55
|
const SwitchRow = withTheme(Row);
|
|
56
56
|
export { SwitchRow };
|
|
57
57
|
export default withTheme(Switch);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
name: "Switch",
|
|
62
|
-
tag: "Switch",
|
|
63
|
-
category: COMPONENT_TYPES.input,
|
|
64
|
-
layout: {},
|
|
65
|
-
triggers: SEED_DATA_TRIGGERS,
|
|
66
|
-
props: {
|
|
67
|
-
disabled: createBoolProp({
|
|
68
|
-
label: "Disabled",
|
|
69
|
-
description: "Boolean to handle disabling the switch",
|
|
70
|
-
}),
|
|
71
|
-
fieldName: createFieldNameProp({
|
|
72
|
-
handlerPropName: "onValueChange",
|
|
73
|
-
valuePropName: "value",
|
|
74
|
-
defaultValue: "switchValue",
|
|
75
|
-
}),
|
|
76
|
-
activeTrackColor: createColorProp({
|
|
77
|
-
label: "Active Track Color",
|
|
78
|
-
}),
|
|
79
|
-
inactiveTrackColor: createColorProp({
|
|
80
|
-
label: "Inactive Track Color",
|
|
81
|
-
}),
|
|
82
|
-
activeThumbColor: createColorProp({
|
|
83
|
-
label: "Active Thumb Color",
|
|
84
|
-
}),
|
|
85
|
-
inactiveThumbColor: createColorProp({
|
|
86
|
-
label: "Inactive Thumb Color",
|
|
87
|
-
}),
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: "Switch Row",
|
|
92
|
-
tag: "SwitchRow",
|
|
93
|
-
category: COMPONENT_TYPES.input,
|
|
94
|
-
layout: {},
|
|
95
|
-
triggers: SEED_DATA_TRIGGERS,
|
|
96
|
-
props: {
|
|
97
|
-
label: createTextProp({
|
|
98
|
-
label: "Label",
|
|
99
|
-
description: "Label to show with the checkbox",
|
|
100
|
-
required: true,
|
|
101
|
-
defaultValue: "First Option",
|
|
102
|
-
}),
|
|
103
|
-
direction: createRowDirectionProp(),
|
|
104
|
-
disabled: createBoolProp({
|
|
105
|
-
label: "Disabled",
|
|
106
|
-
description: "Boolean to handle disabling the switch",
|
|
107
|
-
group: GROUPS.data,
|
|
108
|
-
}),
|
|
109
|
-
fieldName: createFieldNameProp({
|
|
110
|
-
handlerPropName: "onValueChange",
|
|
111
|
-
valuePropName: "value",
|
|
112
|
-
defaultValue: "switchValue",
|
|
113
|
-
}),
|
|
114
|
-
activeTrackColor: createColorProp({
|
|
115
|
-
label: "Active Track Color",
|
|
116
|
-
}),
|
|
117
|
-
inactiveTrackColor: createColorProp({
|
|
118
|
-
label: "Inactive Track Color",
|
|
119
|
-
}),
|
|
120
|
-
activeThumbColor: createColorProp({
|
|
121
|
-
label: "Active Thumb Color",
|
|
122
|
-
}),
|
|
123
|
-
inactiveThumbColor: createColorProp({
|
|
124
|
-
label: "Inactive Thumb Color",
|
|
125
|
-
}),
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
];
|
|
58
|
+
/* README: SEED_DATA lives inside mappings/Switch.js since there were weird issues taking place with sourceMaps being
|
|
59
|
+
* generated */
|
|
@@ -7,17 +7,7 @@ import {
|
|
|
7
7
|
} from "react-native";
|
|
8
8
|
import { withTheme } from "../theming";
|
|
9
9
|
import FormRow from "./FormRow";
|
|
10
|
-
import {
|
|
11
|
-
COMPONENT_TYPES,
|
|
12
|
-
GROUPS,
|
|
13
|
-
createBoolProp,
|
|
14
|
-
createColorProp,
|
|
15
|
-
createFieldNameProp,
|
|
16
|
-
createTextProp,
|
|
17
|
-
createRowDirectionProp,
|
|
18
|
-
RowDirection,
|
|
19
|
-
Triggers,
|
|
20
|
-
} from "@draftbit/types";
|
|
10
|
+
import { RowDirection } from "@draftbit/types";
|
|
21
11
|
import type { Theme } from "../styles/DefaultTheme";
|
|
22
12
|
import { usePrevious } from "../hooks";
|
|
23
13
|
|
|
@@ -153,77 +143,7 @@ function Row({
|
|
|
153
143
|
|
|
154
144
|
const SwitchRow = withTheme(Row);
|
|
155
145
|
export { SwitchRow };
|
|
156
|
-
|
|
157
146
|
export default withTheme(Switch);
|
|
158
147
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
name: "Switch",
|
|
163
|
-
tag: "Switch",
|
|
164
|
-
category: COMPONENT_TYPES.input,
|
|
165
|
-
layout: {},
|
|
166
|
-
triggers: SEED_DATA_TRIGGERS,
|
|
167
|
-
props: {
|
|
168
|
-
disabled: createBoolProp({
|
|
169
|
-
label: "Disabled",
|
|
170
|
-
description: "Boolean to handle disabling the switch",
|
|
171
|
-
}),
|
|
172
|
-
fieldName: createFieldNameProp({
|
|
173
|
-
handlerPropName: "onValueChange",
|
|
174
|
-
valuePropName: "value",
|
|
175
|
-
defaultValue: "switchValue",
|
|
176
|
-
}),
|
|
177
|
-
activeTrackColor: createColorProp({
|
|
178
|
-
label: "Active Track Color",
|
|
179
|
-
}),
|
|
180
|
-
inactiveTrackColor: createColorProp({
|
|
181
|
-
label: "Inactive Track Color",
|
|
182
|
-
}),
|
|
183
|
-
activeThumbColor: createColorProp({
|
|
184
|
-
label: "Active Thumb Color",
|
|
185
|
-
}),
|
|
186
|
-
inactiveThumbColor: createColorProp({
|
|
187
|
-
label: "Inactive Thumb Color",
|
|
188
|
-
}),
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: "Switch Row",
|
|
193
|
-
tag: "SwitchRow",
|
|
194
|
-
category: COMPONENT_TYPES.input,
|
|
195
|
-
layout: {},
|
|
196
|
-
triggers: SEED_DATA_TRIGGERS,
|
|
197
|
-
props: {
|
|
198
|
-
label: createTextProp({
|
|
199
|
-
label: "Label",
|
|
200
|
-
description: "Label to show with the checkbox",
|
|
201
|
-
required: true,
|
|
202
|
-
defaultValue: "First Option",
|
|
203
|
-
}),
|
|
204
|
-
direction: createRowDirectionProp(),
|
|
205
|
-
disabled: createBoolProp({
|
|
206
|
-
label: "Disabled",
|
|
207
|
-
description: "Boolean to handle disabling the switch",
|
|
208
|
-
group: GROUPS.data,
|
|
209
|
-
}),
|
|
210
|
-
fieldName: createFieldNameProp({
|
|
211
|
-
handlerPropName: "onValueChange",
|
|
212
|
-
valuePropName: "value",
|
|
213
|
-
defaultValue: "switchValue",
|
|
214
|
-
}),
|
|
215
|
-
activeTrackColor: createColorProp({
|
|
216
|
-
label: "Active Track Color",
|
|
217
|
-
}),
|
|
218
|
-
inactiveTrackColor: createColorProp({
|
|
219
|
-
label: "Inactive Track Color",
|
|
220
|
-
}),
|
|
221
|
-
activeThumbColor: createColorProp({
|
|
222
|
-
label: "Active Thumb Color",
|
|
223
|
-
}),
|
|
224
|
-
inactiveThumbColor: createColorProp({
|
|
225
|
-
label: "Inactive Thumb Color",
|
|
226
|
-
}),
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
];
|
|
148
|
+
/* README: SEED_DATA lives inside mappings/Switch.js since there were weird issues taking place with sourceMaps being
|
|
149
|
+
* generated */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_TYPES,
|
|
3
|
+
GROUPS,
|
|
4
|
+
createBoolProp,
|
|
5
|
+
createColorProp,
|
|
6
|
+
createFieldNameProp,
|
|
7
|
+
createTextProp,
|
|
8
|
+
createRowDirectionProp,
|
|
9
|
+
Triggers,
|
|
10
|
+
} from "@draftbit/types";
|
|
11
|
+
const SEED_DATA_TRIGGERS = [Triggers.OnValueChange];
|
|
12
|
+
export const SEED_DATA = [
|
|
13
|
+
{
|
|
14
|
+
name: "Switch",
|
|
15
|
+
tag: "Switch",
|
|
16
|
+
category: COMPONENT_TYPES.input,
|
|
17
|
+
layout: {},
|
|
18
|
+
triggers: SEED_DATA_TRIGGERS,
|
|
19
|
+
props: {
|
|
20
|
+
disabled: createBoolProp({
|
|
21
|
+
label: "Disabled",
|
|
22
|
+
description: "Boolean to handle disabling the switch",
|
|
23
|
+
}),
|
|
24
|
+
fieldName: createFieldNameProp({
|
|
25
|
+
handlerPropName: "onValueChange",
|
|
26
|
+
valuePropName: "value",
|
|
27
|
+
defaultValue: "switchValue",
|
|
28
|
+
}),
|
|
29
|
+
activeTrackColor: createColorProp({
|
|
30
|
+
label: "Active Track Color",
|
|
31
|
+
}),
|
|
32
|
+
inactiveTrackColor: createColorProp({
|
|
33
|
+
label: "Inactive Track Color",
|
|
34
|
+
}),
|
|
35
|
+
activeThumbColor: createColorProp({
|
|
36
|
+
label: "Active Thumb Color",
|
|
37
|
+
}),
|
|
38
|
+
inactiveThumbColor: createColorProp({
|
|
39
|
+
label: "Inactive Thumb Color",
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "Switch Row",
|
|
45
|
+
tag: "SwitchRow",
|
|
46
|
+
category: COMPONENT_TYPES.input,
|
|
47
|
+
layout: {},
|
|
48
|
+
triggers: SEED_DATA_TRIGGERS,
|
|
49
|
+
props: {
|
|
50
|
+
label: createTextProp({
|
|
51
|
+
label: "Label",
|
|
52
|
+
description: "Label to show with the checkbox",
|
|
53
|
+
required: true,
|
|
54
|
+
defaultValue: "First Option",
|
|
55
|
+
}),
|
|
56
|
+
direction: createRowDirectionProp(),
|
|
57
|
+
disabled: createBoolProp({
|
|
58
|
+
label: "Disabled",
|
|
59
|
+
description: "Boolean to handle disabling the switch",
|
|
60
|
+
group: GROUPS.data,
|
|
61
|
+
}),
|
|
62
|
+
fieldName: createFieldNameProp({
|
|
63
|
+
handlerPropName: "onValueChange",
|
|
64
|
+
valuePropName: "value",
|
|
65
|
+
defaultValue: "switchValue",
|
|
66
|
+
}),
|
|
67
|
+
activeTrackColor: createColorProp({
|
|
68
|
+
label: "Active Track Color",
|
|
69
|
+
}),
|
|
70
|
+
inactiveTrackColor: createColorProp({
|
|
71
|
+
label: "Inactive Track Color",
|
|
72
|
+
}),
|
|
73
|
+
activeThumbColor: createColorProp({
|
|
74
|
+
label: "Active Thumb Color",
|
|
75
|
+
}),
|
|
76
|
+
inactiveThumbColor: createColorProp({
|
|
77
|
+
label: "Inactive Thumb Color",
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
];
|