@draftbit/core 43.4.11-ca8fc3.1 → 43.4.12
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/Accordion/AccordionGroup.js +2 -2
- package/lib/commonjs/components/Accordion/AccordionGroup.js.map +1 -1
- package/lib/commonjs/components/Accordion/AccordionItem.js +5 -21
- package/lib/commonjs/components/Accordion/AccordionItem.js.map +1 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +6 -6
- package/lib/commonjs/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +142 -0
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js.map +1 -0
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +55 -46
- package/lib/commonjs/components/Checkbox/CheckboxRow.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +2 -9
- package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/commonjs/components/Divider.js +13 -3
- package/lib/commonjs/components/Divider.js.map +1 -1
- package/lib/commonjs/components/FAB.js +5 -19
- package/lib/commonjs/components/FAB.js.map +1 -1
- package/lib/commonjs/components/NumberInput.js +15 -17
- package/lib/commonjs/components/NumberInput.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/components/TextField.js +8 -5
- package/lib/commonjs/components/TextField.js.map +1 -1
- package/lib/commonjs/mappings/CheckboxRow.js +25 -6
- package/lib/commonjs/mappings/CheckboxRow.js.map +1 -1
- package/lib/module/components/Accordion/AccordionGroup.js +2 -2
- package/lib/module/components/Accordion/AccordionGroup.js.map +1 -1
- package/lib/module/components/Checkbox/Checkbox.js +6 -6
- package/lib/module/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/module/components/Checkbox/CheckboxGroupRow.js +120 -0
- package/lib/module/components/Checkbox/CheckboxGroupRow.js.map +1 -0
- package/lib/module/components/Checkbox/CheckboxRow.js +53 -46
- package/lib/module/components/Checkbox/CheckboxRow.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +3 -9
- package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/components/NumberInput.js +15 -17
- package/lib/module/components/NumberInput.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.ios.js +29 -10
- package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -1
- package/lib/module/components/Picker/PickerTypes.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/TextField.js +8 -5
- package/lib/module/components/TextField.js.map +1 -1
- package/lib/module/components/Touchable.web.js.map +1 -1
- package/lib/module/components/Typography.js.map +1 -1
- package/lib/module/mappings/CheckboxRow.js +26 -7
- package/lib/module/mappings/CheckboxRow.js.map +1 -1
- package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts +21 -0
- package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts +3 -7
- package/lib/typescript/src/mappings/CheckboxRow.d.ts +50 -9
- package/package.json +2 -2
- package/src/components/Accordion/AccordionGroup.js +1 -1
- package/src/components/Accordion/AccordionGroup.tsx +1 -1
- package/src/components/Checkbox/Checkbox.js +6 -6
- package/src/components/Checkbox/Checkbox.tsx +8 -6
- package/src/components/Checkbox/CheckboxGroupRow.js +77 -0
- package/src/components/Checkbox/CheckboxGroupRow.tsx +152 -0
- package/src/components/Checkbox/CheckboxRow.js +33 -32
- package/src/components/Checkbox/CheckboxRow.tsx +67 -62
- package/src/components/DatePicker/DatePicker.js +2 -4
- package/src/components/DatePicker/DatePicker.tsx +1 -14
- package/src/components/NumberInput.js +13 -14
- package/src/components/NumberInput.tsx +16 -31
- package/src/components/RadioButton/RadioButtonRow.js +1 -1
- package/src/components/RadioButton/RadioButtonRow.tsx +1 -1
- package/src/components/TextField.js +5 -4
- package/src/components/TextField.tsx +6 -5
- package/src/mappings/CheckboxRow.js +26 -7
- package/src/mappings/CheckboxRow.ts +28 -6
|
@@ -2,7 +2,8 @@ import React, { useEffect, useState } from "react";
|
|
|
2
2
|
import { TextInput } from "react-native";
|
|
3
3
|
import { isString, isNumber, isNaN } from "lodash";
|
|
4
4
|
const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
5
|
-
const
|
|
5
|
+
const [currentStringNumberValue, setCurrentStringNumberValue] = useState("0");
|
|
6
|
+
const formatValueToStringNumber = (valueToFormat) => {
|
|
6
7
|
if (valueToFormat != null) {
|
|
7
8
|
if (isString(valueToFormat) && valueToFormat !== "") {
|
|
8
9
|
if (/^0[1-9]$/.test(valueToFormat)) {
|
|
@@ -11,7 +12,7 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
|
11
12
|
else if (/^[+-]?([0-9]+\.?[0-9]*|\.[0-9]+)$/.test(valueToFormat)) {
|
|
12
13
|
return valueToFormat;
|
|
13
14
|
}
|
|
14
|
-
else
|
|
15
|
+
else {
|
|
15
16
|
return currentStringNumberValue;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -21,25 +22,23 @@ const NumberInput = ({ onChangeText, value, defaultValue, ...props }) => {
|
|
|
21
22
|
}
|
|
22
23
|
return "0";
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
-
const handleChangeText = (newValue) => {
|
|
26
|
-
const newStringNumberValue = formatValueToStringNumber(newValue, currentStringNumberValue);
|
|
27
|
-
const number = parseFloat(newStringNumberValue);
|
|
28
|
-
setCurrentStringNumberValue(newStringNumberValue);
|
|
29
|
-
onChangeText?.(number);
|
|
30
|
-
};
|
|
31
|
-
/* set currentStringNumberValue directly to defaultValue if it exists on load
|
|
32
|
-
( no need to use TextInput's defaultValue because its value is always controlled & set ) */
|
|
25
|
+
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
33
26
|
useEffect(() => {
|
|
34
|
-
const defaultStringNumberValue = formatValueToStringNumber(defaultValue
|
|
27
|
+
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
35
28
|
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
36
29
|
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
37
30
|
}
|
|
38
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
32
|
}, []);
|
|
40
|
-
|
|
33
|
+
const handleChangeText = (newValue) => {
|
|
34
|
+
const newStringNumberValue = formatValueToStringNumber(newValue);
|
|
35
|
+
const number = parseFloat(newStringNumberValue);
|
|
36
|
+
setCurrentStringNumberValue(newStringNumberValue);
|
|
37
|
+
onChangeText?.(number);
|
|
38
|
+
};
|
|
39
|
+
// run handleChangeText with value prop only when value prop changes (and first render to reset currentStringNumberValue)
|
|
41
40
|
useEffect(() => {
|
|
42
|
-
const nextStringNumberValue = formatValueToStringNumber(value
|
|
41
|
+
const nextStringNumberValue = formatValueToStringNumber(value);
|
|
43
42
|
if (currentStringNumberValue !== nextStringNumberValue) {
|
|
44
43
|
handleChangeText(nextStringNumberValue);
|
|
45
44
|
}
|
|
@@ -14,17 +14,16 @@ const NumberInput: FC<Props> = ({
|
|
|
14
14
|
defaultValue,
|
|
15
15
|
...props
|
|
16
16
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
) => {
|
|
17
|
+
const [currentStringNumberValue, setCurrentStringNumberValue] = useState("0");
|
|
18
|
+
|
|
19
|
+
const formatValueToStringNumber = (valueToFormat?: number | string) => {
|
|
21
20
|
if (valueToFormat != null) {
|
|
22
21
|
if (isString(valueToFormat) && valueToFormat !== "") {
|
|
23
22
|
if (/^0[1-9]$/.test(valueToFormat)) {
|
|
24
23
|
return valueToFormat.slice(1);
|
|
25
24
|
} else if (/^[+-]?([0-9]+\.?[0-9]*|\.[0-9]+)$/.test(valueToFormat)) {
|
|
26
25
|
return valueToFormat;
|
|
27
|
-
} else
|
|
26
|
+
} else {
|
|
28
27
|
return currentStringNumberValue;
|
|
29
28
|
}
|
|
30
29
|
} else if (isNumber(valueToFormat) && !isNaN(valueToFormat)) {
|
|
@@ -35,28 +34,9 @@ const NumberInput: FC<Props> = ({
|
|
|
35
34
|
return "0";
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
formatValueToStringNumber("0")
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const handleChangeText = (newValue: string) => {
|
|
43
|
-
const newStringNumberValue = formatValueToStringNumber(
|
|
44
|
-
newValue,
|
|
45
|
-
currentStringNumberValue
|
|
46
|
-
);
|
|
47
|
-
const number = parseFloat(newStringNumberValue);
|
|
48
|
-
|
|
49
|
-
setCurrentStringNumberValue(newStringNumberValue);
|
|
50
|
-
onChangeText?.(number);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/* set currentStringNumberValue directly to defaultValue if it exists on load
|
|
54
|
-
( no need to use TextInput's defaultValue because its value is always controlled & set ) */
|
|
37
|
+
// set currentStringNumberValue as defaultValue prop if there is a differnce on first render only
|
|
55
38
|
useEffect(() => {
|
|
56
|
-
const defaultStringNumberValue = formatValueToStringNumber(
|
|
57
|
-
defaultValue,
|
|
58
|
-
currentStringNumberValue
|
|
59
|
-
);
|
|
39
|
+
const defaultStringNumberValue = formatValueToStringNumber(defaultValue);
|
|
60
40
|
|
|
61
41
|
if (currentStringNumberValue !== defaultStringNumberValue) {
|
|
62
42
|
setCurrentStringNumberValue(defaultStringNumberValue);
|
|
@@ -64,12 +44,17 @@ const NumberInput: FC<Props> = ({
|
|
|
64
44
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
45
|
}, []);
|
|
66
46
|
|
|
67
|
-
|
|
47
|
+
const handleChangeText = (newValue: string) => {
|
|
48
|
+
const newStringNumberValue = formatValueToStringNumber(newValue);
|
|
49
|
+
const number = parseFloat(newStringNumberValue);
|
|
50
|
+
|
|
51
|
+
setCurrentStringNumberValue(newStringNumberValue);
|
|
52
|
+
onChangeText?.(number);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// run handleChangeText with value prop only when value prop changes (and first render to reset currentStringNumberValue)
|
|
68
56
|
useEffect(() => {
|
|
69
|
-
const nextStringNumberValue = formatValueToStringNumber(
|
|
70
|
-
value,
|
|
71
|
-
currentStringNumberValue
|
|
72
|
-
);
|
|
57
|
+
const nextStringNumberValue = formatValueToStringNumber(value);
|
|
73
58
|
|
|
74
59
|
if (currentStringNumberValue !== nextStringNumberValue) {
|
|
75
60
|
handleChangeText(nextStringNumberValue);
|
|
@@ -231,6 +231,7 @@ class TextField extends React.Component {
|
|
|
231
231
|
: leftIconMode === "outset"
|
|
232
232
|
? 16
|
|
233
233
|
: 0,
|
|
234
|
+
marginLeft: leftIconMode === "inset" && type === "solid" ? 16 : 0,
|
|
234
235
|
};
|
|
235
236
|
const labelStyle = {
|
|
236
237
|
...typography.subtitle1,
|
|
@@ -355,10 +356,10 @@ class TextField extends React.Component {
|
|
|
355
356
|
opacity: hasActiveOutline ? this.state.labeled : 1,
|
|
356
357
|
},
|
|
357
358
|
], numberOfLines: 1 }, label))) : null,
|
|
358
|
-
leftIconName && leftIconMode === "inset" ? (React.createElement(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
359
|
+
leftIconName && leftIconMode === "inset" ? (React.createElement(View, { style: {
|
|
360
|
+
justifyContent: type === "solid" ? "center" : undefined,
|
|
361
|
+
} },
|
|
362
|
+
React.createElement(Icon, { ...leftIconProps, style: leftIconStyle }))) : null,
|
|
362
363
|
render({
|
|
363
364
|
ref: (c) => {
|
|
364
365
|
this._root = c;
|
|
@@ -359,6 +359,7 @@ class TextField extends React.Component<Props, State> {
|
|
|
359
359
|
: leftIconMode === "outset"
|
|
360
360
|
? 16
|
|
361
361
|
: 0,
|
|
362
|
+
marginLeft: leftIconMode === "inset" && type === "solid" ? 16 : 0,
|
|
362
363
|
};
|
|
363
364
|
|
|
364
365
|
const labelStyle = {
|
|
@@ -536,13 +537,13 @@ class TextField extends React.Component<Props, State> {
|
|
|
536
537
|
) : null}
|
|
537
538
|
|
|
538
539
|
{leftIconName && leftIconMode === "inset" ? (
|
|
539
|
-
<
|
|
540
|
-
{...leftIconProps}
|
|
540
|
+
<View
|
|
541
541
|
style={{
|
|
542
|
-
|
|
543
|
-
marginLeft: type === "solid" ? 16 : 0,
|
|
542
|
+
justifyContent: type === "solid" ? "center" : undefined,
|
|
544
543
|
}}
|
|
545
|
-
|
|
544
|
+
>
|
|
545
|
+
<Icon {...leftIconProps} style={leftIconStyle} />
|
|
546
|
+
</View>
|
|
546
547
|
) : null}
|
|
547
548
|
|
|
548
549
|
{render({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createTextProp, createTextStyle, createRowDirectionProp, createFieldNameProp, COMPONENT_TYPES, Triggers, createColorProp, } from "@draftbit/types";
|
|
1
|
+
import { createBoolProp, createTextProp, createTextStyle, createRowDirectionProp, createFieldNameProp, createIconProp, createStaticNumberProp, COMPONENT_TYPES, Triggers, createColorProp, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
3
|
name: "Checkbox Row",
|
|
4
4
|
tag: "CheckboxRow",
|
|
@@ -6,8 +6,13 @@ export const SEED_DATA = {
|
|
|
6
6
|
layout: {
|
|
7
7
|
minHeight: 50,
|
|
8
8
|
},
|
|
9
|
-
triggers: [Triggers.OnPress],
|
|
9
|
+
triggers: [Triggers.OnPress, Triggers.OnCheck, Triggers.OnUncheck],
|
|
10
10
|
props: {
|
|
11
|
+
fieldName: createFieldNameProp({
|
|
12
|
+
defaultValue: "checkboxRowValue",
|
|
13
|
+
valuePropName: "value",
|
|
14
|
+
handlerPropName: "onPress",
|
|
15
|
+
}),
|
|
11
16
|
label: createTextProp({
|
|
12
17
|
label: "Label",
|
|
13
18
|
description: "Label to show with the checkbox",
|
|
@@ -21,11 +26,6 @@ export const SEED_DATA = {
|
|
|
21
26
|
editable: false,
|
|
22
27
|
}),
|
|
23
28
|
direction: createRowDirectionProp(),
|
|
24
|
-
fieldName: createFieldNameProp({
|
|
25
|
-
defaultValue: "checkboxRowValue",
|
|
26
|
-
valuePropName: "value",
|
|
27
|
-
handlerPropName: "onPress",
|
|
28
|
-
}),
|
|
29
29
|
color: createColorProp({
|
|
30
30
|
description: "Color for the button (used when the checkbox is checked)",
|
|
31
31
|
}),
|
|
@@ -33,5 +33,24 @@ export const SEED_DATA = {
|
|
|
33
33
|
label: "Unselected Color",
|
|
34
34
|
description: "Color for the button when the checkbox is unchecked",
|
|
35
35
|
}),
|
|
36
|
+
disabled: createBoolProp({
|
|
37
|
+
label: "Disabled",
|
|
38
|
+
description: "Whether the checkbox is disabled",
|
|
39
|
+
}),
|
|
40
|
+
size: createStaticNumberProp({
|
|
41
|
+
label: "Size",
|
|
42
|
+
description: "Specifies the size of the icon",
|
|
43
|
+
defaultValue: null,
|
|
44
|
+
}),
|
|
45
|
+
checkedIcon: createIconProp({
|
|
46
|
+
label: "Checked Icon",
|
|
47
|
+
description: 'Icon to show when the checkbox status is "checked"',
|
|
48
|
+
defaultValue: null,
|
|
49
|
+
}),
|
|
50
|
+
uncheckedIcon: createIconProp({
|
|
51
|
+
label: "Unchecked Icon",
|
|
52
|
+
description: 'Icon to show when the checkbox status is "unchecked"',
|
|
53
|
+
defaultValue: null,
|
|
54
|
+
}),
|
|
36
55
|
},
|
|
37
56
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createBoolProp,
|
|
2
3
|
createTextProp,
|
|
3
4
|
createTextStyle,
|
|
4
5
|
createRowDirectionProp,
|
|
5
6
|
createFieldNameProp,
|
|
7
|
+
createIconProp,
|
|
8
|
+
createStaticNumberProp,
|
|
6
9
|
COMPONENT_TYPES,
|
|
7
10
|
Triggers,
|
|
8
11
|
createColorProp,
|
|
@@ -15,8 +18,13 @@ export const SEED_DATA = {
|
|
|
15
18
|
layout: {
|
|
16
19
|
minHeight: 50,
|
|
17
20
|
},
|
|
18
|
-
triggers: [Triggers.OnPress],
|
|
21
|
+
triggers: [Triggers.OnPress, Triggers.OnCheck, Triggers.OnUncheck],
|
|
19
22
|
props: {
|
|
23
|
+
fieldName: createFieldNameProp({
|
|
24
|
+
defaultValue: "checkboxRowValue",
|
|
25
|
+
valuePropName: "value",
|
|
26
|
+
handlerPropName: "onPress",
|
|
27
|
+
}),
|
|
20
28
|
label: createTextProp({
|
|
21
29
|
label: "Label",
|
|
22
30
|
description: "Label to show with the checkbox",
|
|
@@ -30,11 +38,6 @@ export const SEED_DATA = {
|
|
|
30
38
|
editable: false,
|
|
31
39
|
}),
|
|
32
40
|
direction: createRowDirectionProp(),
|
|
33
|
-
fieldName: createFieldNameProp({
|
|
34
|
-
defaultValue: "checkboxRowValue",
|
|
35
|
-
valuePropName: "value",
|
|
36
|
-
handlerPropName: "onPress",
|
|
37
|
-
}),
|
|
38
41
|
color: createColorProp({
|
|
39
42
|
description: "Color for the button (used when the checkbox is checked)",
|
|
40
43
|
}),
|
|
@@ -42,5 +45,24 @@ export const SEED_DATA = {
|
|
|
42
45
|
label: "Unselected Color",
|
|
43
46
|
description: "Color for the button when the checkbox is unchecked",
|
|
44
47
|
}),
|
|
48
|
+
disabled: createBoolProp({
|
|
49
|
+
label: "Disabled",
|
|
50
|
+
description: "Whether the checkbox is disabled",
|
|
51
|
+
}),
|
|
52
|
+
size: createStaticNumberProp({
|
|
53
|
+
label: "Size",
|
|
54
|
+
description: "Specifies the size of the icon",
|
|
55
|
+
defaultValue: null,
|
|
56
|
+
}),
|
|
57
|
+
checkedIcon: createIconProp({
|
|
58
|
+
label: "Checked Icon",
|
|
59
|
+
description: 'Icon to show when the checkbox status is "checked"',
|
|
60
|
+
defaultValue: null,
|
|
61
|
+
}),
|
|
62
|
+
uncheckedIcon: createIconProp({
|
|
63
|
+
label: "Unchecked Icon",
|
|
64
|
+
description: 'Icon to show when the checkbox status is "unchecked"',
|
|
65
|
+
defaultValue: null,
|
|
66
|
+
}),
|
|
45
67
|
},
|
|
46
68
|
};
|