@draftbit/core 47.0.1-ed6e56.2 → 47.1.1-2bc708.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.
- package/lib/commonjs/components/Button.js +3 -3
- package/lib/commonjs/components/Checkbox/Checkbox.js +1 -3
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +1 -2
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +1 -2
- package/lib/commonjs/components/DatePicker/DatePicker.js +0 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponent.js +9 -3
- package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js +1 -0
- package/lib/commonjs/components/DeprecatedButton.js +3 -27
- package/lib/commonjs/components/DeprecatedFAB.js +1 -2
- package/lib/commonjs/components/Pressable.js +37 -0
- package/lib/commonjs/components/Swiper/Swiper.js +2 -0
- package/lib/commonjs/components/Touchable.js +8 -3
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/mappings/Button.js +39 -10
- package/lib/commonjs/mappings/DatePicker.js +1 -1
- package/lib/commonjs/mappings/FlashList.js +55 -2
- package/lib/commonjs/mappings/FlatList.js +13 -0
- package/lib/commonjs/mappings/Swiper.js +2 -0
- package/lib/commonjs/mappings/TextField.js +2 -2
- package/lib/commonjs/mappings/Touchable.js +47 -7
- package/lib/module/components/Button.js +3 -3
- package/lib/module/components/Checkbox/Checkbox.js +2 -3
- package/lib/module/components/Checkbox/CheckboxGroupRow.js +2 -3
- package/lib/module/components/Checkbox/CheckboxRow.js +2 -3
- package/lib/module/components/DatePicker/DatePicker.js +0 -1
- package/lib/module/components/DatePicker/DatePickerComponent.js +9 -3
- package/lib/module/components/DatePicker/DatePickerComponent.web.js +1 -0
- package/lib/module/components/DeprecatedButton.js +4 -28
- package/lib/module/components/DeprecatedFAB.js +2 -3
- package/lib/module/components/Pressable.js +30 -0
- package/lib/module/components/Swiper/Swiper.js +2 -0
- package/lib/module/components/Touchable.js +8 -3
- package/lib/module/constants.js +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/mappings/Button.js +40 -11
- package/lib/module/mappings/DatePicker.js +1 -1
- package/lib/module/mappings/FlashList.js +56 -3
- package/lib/module/mappings/FlatList.js +14 -1
- package/lib/module/mappings/Swiper.js +3 -1
- package/lib/module/mappings/TextField.js +2 -2
- package/lib/module/mappings/Touchable.js +49 -9
- 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/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
- 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/DatePickerComponent.web.d.ts.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts +0 -2
- package/lib/typescript/src/components/DatePicker/DatePickerComponentType.d.ts.map +1 -1
- package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
- package/lib/typescript/src/components/DeprecatedButton.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/Pressable.d.ts +10 -0
- package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/Swiper/Swiper.d.ts +2 -1
- package/lib/typescript/src/components/Swiper/Swiper.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable.d.ts +5 -6
- package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Button.d.ts +113 -4
- package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
- package/lib/typescript/src/mappings/DatePicker.d.ts +1 -1
- package/lib/typescript/src/mappings/FlashList.d.ts +134 -2
- package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
- package/lib/typescript/src/mappings/FlatList.d.ts +43 -0
- package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Swiper.d.ts +11 -0
- package/lib/typescript/src/mappings/Swiper.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Touchable.d.ts +59 -5
- package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/components/Button.js +3 -3
- package/src/components/Button.tsx +14 -4
- package/src/components/Checkbox/Checkbox.js +2 -3
- package/src/components/Checkbox/Checkbox.tsx +5 -7
- package/src/components/Checkbox/CheckboxGroupRow.js +2 -3
- package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
- package/src/components/Checkbox/CheckboxRow.js +2 -3
- package/src/components/Checkbox/CheckboxRow.tsx +3 -3
- package/src/components/DatePicker/DatePicker.js +1 -1
- package/src/components/DatePicker/DatePicker.tsx +0 -1
- package/src/components/DatePicker/DatePickerComponent.js +5 -3
- package/src/components/DatePicker/DatePickerComponent.tsx +11 -3
- package/src/components/DatePicker/DatePickerComponent.web.js +1 -1
- package/src/components/DatePicker/DatePickerComponent.web.tsx +1 -0
- package/src/components/DatePicker/DatePickerComponentType.ts +0 -9
- package/src/components/DeprecatedButton.js +4 -16
- package/src/components/DeprecatedButton.tsx +7 -31
- package/src/components/DeprecatedFAB.js +2 -3
- package/src/components/DeprecatedFAB.tsx +5 -5
- package/src/components/Pressable.js +12 -0
- package/src/components/Pressable.tsx +44 -0
- package/src/components/Swiper/Swiper.js +2 -2
- package/src/components/Swiper/Swiper.tsx +3 -0
- package/src/components/Touchable.js +3 -3
- package/src/components/Touchable.tsx +11 -7
- package/src/index.js +1 -0
- package/src/index.tsx +1 -0
- package/src/mappings/Button.js +39 -10
- package/src/mappings/Button.ts +41 -10
- package/src/mappings/DatePicker.js +1 -1
- package/src/mappings/DatePicker.ts +1 -1
- package/src/mappings/FlashList.js +87 -31
- package/src/mappings/FlashList.ts +92 -30
- package/src/mappings/FlatList.js +14 -1
- package/src/mappings/FlatList.ts +17 -0
- package/src/mappings/Swiper.js +3 -1
- package/src/mappings/Swiper.ts +4 -0
- package/src/mappings/TextField.js +2 -2
- package/src/mappings/TextField.ts +2 -2
- package/src/mappings/Touchable.js +50 -7
- package/src/mappings/Touchable.ts +53 -6
- package/lib/commonjs/components/DatePicker/DatePickerInput.js +0 -133
- package/lib/module/components/DatePicker/DatePickerInput.js +0 -123
- package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts +0 -18
- package/lib/typescript/src/components/DatePicker/DatePickerInput.d.ts.map +0 -1
- package/src/components/DatePicker/DatePickerInput.js +0 -97
- package/src/components/DatePicker/DatePickerInput.tsx +0 -195
package/src/mappings/FlatList.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createNumColumnsType, createStaticBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, } from "@draftbit/types";
|
|
1
|
+
import { COMPONENT_TYPES, createNumColumnsType, createStaticBoolProp, CONTAINER_COMPONENT_STYLES_SECTIONS, Triggers, createActionProp, createStaticNumberProp, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
3
|
name: "List",
|
|
4
4
|
tag: "FlatList",
|
|
@@ -8,7 +8,10 @@ export const SEED_DATA = {
|
|
|
8
8
|
layout: {
|
|
9
9
|
flex: 1,
|
|
10
10
|
},
|
|
11
|
+
triggers: [Triggers.OnRefresh, Triggers.OnEndReached],
|
|
11
12
|
props: {
|
|
13
|
+
onRefresh: createActionProp(),
|
|
14
|
+
onEndReached: createActionProp(),
|
|
12
15
|
horizontal: createStaticBoolProp({
|
|
13
16
|
label: "Horizontal",
|
|
14
17
|
description: "Render list horizontally",
|
|
@@ -20,5 +23,15 @@ export const SEED_DATA = {
|
|
|
20
23
|
numColumns: createNumColumnsType({
|
|
21
24
|
editable: true,
|
|
22
25
|
}),
|
|
26
|
+
initialNumToRender: createStaticNumberProp({
|
|
27
|
+
label: "Initial Num To Render",
|
|
28
|
+
description: "How many items to render in the initial batch",
|
|
29
|
+
defaultValue: null,
|
|
30
|
+
}),
|
|
31
|
+
onEndReachedThreshold: createStaticNumberProp({
|
|
32
|
+
label: "End Reached Threshold",
|
|
33
|
+
description: "How far from the end (in units of visible length of the list) the bottom edge of the list must be from the end of the content to trigger the onEndReached callback. Thus a value of 0.5 will trigger onEndReached when the end of the content is within half the visible length of the list.",
|
|
34
|
+
defaultValue: 0.5,
|
|
35
|
+
}),
|
|
23
36
|
},
|
|
24
37
|
};
|
package/src/mappings/FlatList.ts
CHANGED
|
@@ -3,6 +3,9 @@ import {
|
|
|
3
3
|
createNumColumnsType,
|
|
4
4
|
createStaticBoolProp,
|
|
5
5
|
CONTAINER_COMPONENT_STYLES_SECTIONS,
|
|
6
|
+
Triggers,
|
|
7
|
+
createActionProp,
|
|
8
|
+
createStaticNumberProp,
|
|
6
9
|
} from "@draftbit/types";
|
|
7
10
|
|
|
8
11
|
export const SEED_DATA = {
|
|
@@ -14,7 +17,10 @@ export const SEED_DATA = {
|
|
|
14
17
|
layout: {
|
|
15
18
|
flex: 1,
|
|
16
19
|
},
|
|
20
|
+
triggers: [Triggers.OnRefresh, Triggers.OnEndReached],
|
|
17
21
|
props: {
|
|
22
|
+
onRefresh: createActionProp(),
|
|
23
|
+
onEndReached: createActionProp(),
|
|
18
24
|
horizontal: createStaticBoolProp({
|
|
19
25
|
label: "Horizontal",
|
|
20
26
|
description: "Render list horizontally",
|
|
@@ -26,5 +32,16 @@ export const SEED_DATA = {
|
|
|
26
32
|
numColumns: createNumColumnsType({
|
|
27
33
|
editable: true,
|
|
28
34
|
}),
|
|
35
|
+
initialNumToRender: createStaticNumberProp({
|
|
36
|
+
label: "Initial Num To Render",
|
|
37
|
+
description: "How many items to render in the initial batch",
|
|
38
|
+
defaultValue: null,
|
|
39
|
+
}),
|
|
40
|
+
onEndReachedThreshold: createStaticNumberProp({
|
|
41
|
+
label: "End Reached Threshold",
|
|
42
|
+
description:
|
|
43
|
+
"How far from the end (in units of visible length of the list) the bottom edge of the list must be from the end of the content to trigger the onEndReached callback. Thus a value of 0.5 will trigger onEndReached when the end of the content is within half the visible length of the list.",
|
|
44
|
+
defaultValue: 0.5,
|
|
45
|
+
}),
|
|
29
46
|
},
|
|
30
47
|
};
|
package/src/mappings/Swiper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createBoolProp, createNumberProp, createTextProp, createColorProp, GROUPS, } from "@draftbit/types";
|
|
1
|
+
import { COMPONENT_TYPES, createBoolProp, createNumberProp, createTextProp, createColorProp, GROUPS, Triggers, createActionProp, } from "@draftbit/types";
|
|
2
2
|
export const SEED_DATA = {
|
|
3
3
|
name: "Swiper",
|
|
4
4
|
tag: "Swiper",
|
|
@@ -8,7 +8,9 @@ export const SEED_DATA = {
|
|
|
8
8
|
height: 300,
|
|
9
9
|
width: "100%",
|
|
10
10
|
},
|
|
11
|
+
triggers: [Triggers.OnIndexChanged],
|
|
11
12
|
props: {
|
|
13
|
+
onIndexChanged: createActionProp(),
|
|
12
14
|
from: createNumberProp({
|
|
13
15
|
group: GROUPS.basic,
|
|
14
16
|
label: "Initial Slide",
|
package/src/mappings/Swiper.ts
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
createTextProp,
|
|
6
6
|
createColorProp,
|
|
7
7
|
GROUPS,
|
|
8
|
+
Triggers,
|
|
9
|
+
createActionProp,
|
|
8
10
|
} from "@draftbit/types";
|
|
9
11
|
|
|
10
12
|
export const SEED_DATA = {
|
|
@@ -16,7 +18,9 @@ export const SEED_DATA = {
|
|
|
16
18
|
height: 300,
|
|
17
19
|
width: "100%",
|
|
18
20
|
},
|
|
21
|
+
triggers: [Triggers.OnIndexChanged],
|
|
19
22
|
props: {
|
|
23
|
+
onIndexChanged: createActionProp(),
|
|
20
24
|
from: createNumberProp({
|
|
21
25
|
group: GROUPS.basic,
|
|
22
26
|
label: "Initial Slide",
|
|
@@ -306,7 +306,7 @@ export const SEED_DATA = [
|
|
|
306
306
|
...SEED_DATA_PROPS,
|
|
307
307
|
type: {
|
|
308
308
|
label: "Appearance",
|
|
309
|
-
description: "Type of
|
|
309
|
+
description: "Type of Field",
|
|
310
310
|
formType: FORM_TYPES.flatArray,
|
|
311
311
|
propType: PROP_TYPES.STRING,
|
|
312
312
|
defaultValue: "solid",
|
|
@@ -357,7 +357,7 @@ export const SEED_DATA = [
|
|
|
357
357
|
...SEED_DATA_PROPS,
|
|
358
358
|
type: {
|
|
359
359
|
label: "Appearance",
|
|
360
|
-
description: "Type of
|
|
360
|
+
description: "Type of Field",
|
|
361
361
|
formType: FORM_TYPES.flatArray,
|
|
362
362
|
propType: PROP_TYPES.STRING,
|
|
363
363
|
defaultValue: "solid",
|
|
@@ -328,7 +328,7 @@ export const SEED_DATA = [
|
|
|
328
328
|
...SEED_DATA_PROPS,
|
|
329
329
|
type: {
|
|
330
330
|
label: "Appearance",
|
|
331
|
-
description: "Type of
|
|
331
|
+
description: "Type of Field",
|
|
332
332
|
formType: FORM_TYPES.flatArray,
|
|
333
333
|
propType: PROP_TYPES.STRING,
|
|
334
334
|
defaultValue: "solid",
|
|
@@ -380,7 +380,7 @@ export const SEED_DATA = [
|
|
|
380
380
|
...SEED_DATA_PROPS,
|
|
381
381
|
type: {
|
|
382
382
|
label: "Appearance",
|
|
383
|
-
description: "Type of
|
|
383
|
+
description: "Type of Field",
|
|
384
384
|
formType: FORM_TYPES.flatArray,
|
|
385
385
|
propType: PROP_TYPES.STRING,
|
|
386
386
|
defaultValue: "solid",
|
|
@@ -1,17 +1,60 @@
|
|
|
1
|
-
import { COMPONENT_TYPES, createActionProp, Triggers, StylesPanelSections, } from "@draftbit/types";
|
|
2
|
-
|
|
3
|
-
name: "Touchable",
|
|
4
|
-
tag: "Touchable",
|
|
5
|
-
description: "Simple button with no styles",
|
|
6
|
-
category: COMPONENT_TYPES.button,
|
|
1
|
+
import { COMPONENT_TYPES, createActionProp, Triggers, createStaticNumberProp, StylesPanelSections, } from "@draftbit/types";
|
|
2
|
+
const SEED_DATA_PROPS = {
|
|
7
3
|
stylesPanelSections: [
|
|
8
4
|
StylesPanelSections.Size,
|
|
9
5
|
StylesPanelSections.Margins,
|
|
10
6
|
StylesPanelSections.Borders,
|
|
11
7
|
],
|
|
12
8
|
layout: {},
|
|
13
|
-
triggers: [Triggers.OnPress],
|
|
9
|
+
triggers: [Triggers.OnPress, Triggers.OnLongPress],
|
|
14
10
|
props: {
|
|
15
11
|
onPress: createActionProp(),
|
|
12
|
+
onLongPress: createActionProp(),
|
|
13
|
+
activeOpacity: createStaticNumberProp({
|
|
14
|
+
label: "Active Opacity",
|
|
15
|
+
description: "The opacity when the button is pressed.",
|
|
16
|
+
defaultValue: 0.8,
|
|
17
|
+
min: 0,
|
|
18
|
+
max: 1,
|
|
19
|
+
step: 0.01,
|
|
20
|
+
precision: 2,
|
|
21
|
+
required: false,
|
|
22
|
+
}),
|
|
23
|
+
disabledOpacity: createStaticNumberProp({
|
|
24
|
+
label: "Disabled Opacity",
|
|
25
|
+
description: "The opacity when the button is disabled.",
|
|
26
|
+
defaultValue: 0.8,
|
|
27
|
+
min: 0,
|
|
28
|
+
max: 1,
|
|
29
|
+
step: 0.01,
|
|
30
|
+
precision: 2,
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
delayLongPress: createStaticNumberProp({
|
|
34
|
+
label: "Delay Long Press",
|
|
35
|
+
description: "Duration (in milliseconds) from onPressIn before onLongPress is called.",
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
hitSlop: createStaticNumberProp({
|
|
39
|
+
label: "Hit Slop",
|
|
40
|
+
description: "Sets additional distance outside of element in which a press can be detected.",
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
16
43
|
},
|
|
17
44
|
};
|
|
45
|
+
export const SEED_DATA = [
|
|
46
|
+
{
|
|
47
|
+
name: "Touchable",
|
|
48
|
+
tag: "Touchable",
|
|
49
|
+
description: "An interactive view with no styles",
|
|
50
|
+
category: COMPONENT_TYPES.button,
|
|
51
|
+
...SEED_DATA_PROPS,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "Pressable",
|
|
55
|
+
tag: "Pressable",
|
|
56
|
+
description: "An interactive view with no styles",
|
|
57
|
+
category: COMPONENT_TYPES.button,
|
|
58
|
+
...SEED_DATA_PROPS,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
@@ -2,22 +2,69 @@ import {
|
|
|
2
2
|
COMPONENT_TYPES,
|
|
3
3
|
createActionProp,
|
|
4
4
|
Triggers,
|
|
5
|
+
createStaticNumberProp,
|
|
5
6
|
StylesPanelSections,
|
|
6
7
|
} from "@draftbit/types";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
name: "Touchable",
|
|
10
|
-
tag: "Touchable",
|
|
11
|
-
description: "Simple button with no styles",
|
|
12
|
-
category: COMPONENT_TYPES.button,
|
|
9
|
+
const SEED_DATA_PROPS = {
|
|
13
10
|
stylesPanelSections: [
|
|
14
11
|
StylesPanelSections.Size,
|
|
15
12
|
StylesPanelSections.Margins,
|
|
16
13
|
StylesPanelSections.Borders,
|
|
17
14
|
],
|
|
18
15
|
layout: {},
|
|
19
|
-
triggers: [Triggers.OnPress],
|
|
16
|
+
triggers: [Triggers.OnPress, Triggers.OnLongPress],
|
|
20
17
|
props: {
|
|
21
18
|
onPress: createActionProp(),
|
|
19
|
+
onLongPress: createActionProp(),
|
|
20
|
+
activeOpacity: createStaticNumberProp({
|
|
21
|
+
label: "Active Opacity",
|
|
22
|
+
description: "The opacity when the button is pressed.",
|
|
23
|
+
defaultValue: 0.8,
|
|
24
|
+
min: 0,
|
|
25
|
+
max: 1,
|
|
26
|
+
step: 0.01,
|
|
27
|
+
precision: 2,
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
disabledOpacity: createStaticNumberProp({
|
|
31
|
+
label: "Disabled Opacity",
|
|
32
|
+
description: "The opacity when the button is disabled.",
|
|
33
|
+
defaultValue: 0.8,
|
|
34
|
+
min: 0,
|
|
35
|
+
max: 1,
|
|
36
|
+
step: 0.01,
|
|
37
|
+
precision: 2,
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
delayLongPress: createStaticNumberProp({
|
|
41
|
+
label: "Delay Long Press",
|
|
42
|
+
description:
|
|
43
|
+
"Duration (in milliseconds) from onPressIn before onLongPress is called.",
|
|
44
|
+
required: false,
|
|
45
|
+
}),
|
|
46
|
+
hitSlop: createStaticNumberProp({
|
|
47
|
+
label: "Hit Slop",
|
|
48
|
+
description:
|
|
49
|
+
"Sets additional distance outside of element in which a press can be detected.",
|
|
50
|
+
required: false,
|
|
51
|
+
}),
|
|
22
52
|
},
|
|
23
53
|
};
|
|
54
|
+
|
|
55
|
+
export const SEED_DATA = [
|
|
56
|
+
{
|
|
57
|
+
name: "Touchable",
|
|
58
|
+
tag: "Touchable",
|
|
59
|
+
description: "An interactive view with no styles",
|
|
60
|
+
category: COMPONENT_TYPES.button,
|
|
61
|
+
...SEED_DATA_PROPS,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "Pressable",
|
|
65
|
+
tag: "Pressable",
|
|
66
|
+
description: "An interactive view with no styles",
|
|
67
|
+
category: COMPONENT_TYPES.button,
|
|
68
|
+
...SEED_DATA_PROPS,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
10
|
-
var _dateformat = _interopRequireDefault(require("dateformat"));
|
|
11
|
-
var _Portal = _interopRequireDefault(require("../Portal/Portal"));
|
|
12
|
-
var _Touchable = _interopRequireDefault(require("../Touchable"));
|
|
13
|
-
var _DatePickerComponent = _interopRequireDefault(require("./DatePickerComponent"));
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
|
-
const MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
19
|
-
const DatePickerInput = _ref => {
|
|
20
|
-
let {
|
|
21
|
-
style,
|
|
22
|
-
date,
|
|
23
|
-
onDateChange = () => {},
|
|
24
|
-
defaultValue,
|
|
25
|
-
disabled = false,
|
|
26
|
-
mode = "date",
|
|
27
|
-
format,
|
|
28
|
-
androidDisplay = "default",
|
|
29
|
-
iosDisplay = "default",
|
|
30
|
-
webDisplay = "dialog",
|
|
31
|
-
placeholder,
|
|
32
|
-
...props
|
|
33
|
-
} = _ref;
|
|
34
|
-
const [value, setValue] = React.useState(date || defaultValue);
|
|
35
|
-
React.useEffect(() => {
|
|
36
|
-
if (defaultValue != null) {
|
|
37
|
-
setValue(defaultValue);
|
|
38
|
-
}
|
|
39
|
-
}, [defaultValue]);
|
|
40
|
-
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
41
|
-
const [focused, setFocused] = React.useState(false);
|
|
42
|
-
const getValidDate = () => {
|
|
43
|
-
if (!value) {
|
|
44
|
-
return new Date();
|
|
45
|
-
}
|
|
46
|
-
return typeof (value === null || value === void 0 ? void 0 : value.getMonth) === "function" ? value : new Date();
|
|
47
|
-
};
|
|
48
|
-
const formatDate = () => {
|
|
49
|
-
if (!value) return "";
|
|
50
|
-
let newDate = getValidDate();
|
|
51
|
-
if (format) return (0, _dateformat.default)(newDate, format);
|
|
52
|
-
if (mode === "time") {
|
|
53
|
-
return "".concat(newDate.toLocaleTimeString());
|
|
54
|
-
}
|
|
55
|
-
if (mode === "datetime") {
|
|
56
|
-
return "".concat(newDate.toLocaleString());
|
|
57
|
-
}
|
|
58
|
-
return "".concat(MONTHS[newDate.getMonth()], " ").concat(newDate.getDate(), ", ").concat(newDate.getFullYear());
|
|
59
|
-
};
|
|
60
|
-
const toggleVisibility = async () => {
|
|
61
|
-
setPickerVisible(!pickerVisible);
|
|
62
|
-
focused ? _handleBlur() : _handleFocus();
|
|
63
|
-
};
|
|
64
|
-
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
65
|
-
React.useEffect(() => {
|
|
66
|
-
setValue(date);
|
|
67
|
-
}, [date]);
|
|
68
|
-
const _handleFocus = () => {
|
|
69
|
-
if (disabled) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
setFocused(true);
|
|
73
|
-
};
|
|
74
|
-
const _handleBlur = () => {
|
|
75
|
-
if (disabled) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
setFocused(false);
|
|
79
|
-
};
|
|
80
|
-
return /*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_Touchable.default, {
|
|
81
|
-
disabled: disabled,
|
|
82
|
-
onPress: toggleVisibility
|
|
83
|
-
}, /*#__PURE__*/React.createElement(_reactNative.TextInput, _extends({
|
|
84
|
-
value: formatDate(),
|
|
85
|
-
placeholder: placeholder,
|
|
86
|
-
editable: !disabled,
|
|
87
|
-
onFocus: _handleFocus,
|
|
88
|
-
onBlur: _handleBlur,
|
|
89
|
-
style: style
|
|
90
|
-
}, props))), pickerVisible && /*#__PURE__*/React.createElement(_Portal.default, null, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
91
|
-
style: {
|
|
92
|
-
paddingTop: insets.top,
|
|
93
|
-
paddingBottom: insets.bottom,
|
|
94
|
-
paddingLeft: insets.left,
|
|
95
|
-
paddingRight: insets.right
|
|
96
|
-
}
|
|
97
|
-
}, _reactNative.Platform.OS === "web" && /*#__PURE__*/React.createElement(_DatePickerComponent.default, {
|
|
98
|
-
value: getValidDate(),
|
|
99
|
-
mode: mode,
|
|
100
|
-
isVisible: pickerVisible,
|
|
101
|
-
toggleVisibility: toggleVisibility,
|
|
102
|
-
onChange: (_event, data) => {
|
|
103
|
-
toggleVisibility();
|
|
104
|
-
setValue(data);
|
|
105
|
-
onDateChange(data);
|
|
106
|
-
}
|
|
107
|
-
}), _reactNative.Platform.OS === "ios" && /*#__PURE__*/React.createElement(_DatePickerComponent.default, {
|
|
108
|
-
value: getValidDate(),
|
|
109
|
-
mode: mode,
|
|
110
|
-
displayMode: iosDisplay,
|
|
111
|
-
isVisible: pickerVisible,
|
|
112
|
-
toggleVisibility: toggleVisibility,
|
|
113
|
-
onChange: (_event, data) => {
|
|
114
|
-
toggleVisibility();
|
|
115
|
-
setValue(data);
|
|
116
|
-
onDateChange(data);
|
|
117
|
-
}
|
|
118
|
-
}), _reactNative.Platform.OS === "android" && /*#__PURE__*/React.createElement(_DatePickerComponent.default, {
|
|
119
|
-
value: getValidDate(),
|
|
120
|
-
mode: mode,
|
|
121
|
-
variant: webDisplay,
|
|
122
|
-
displayMode: androidDisplay,
|
|
123
|
-
isVisible: pickerVisible,
|
|
124
|
-
toggleVisibility: toggleVisibility,
|
|
125
|
-
onChange: (_event, data) => {
|
|
126
|
-
toggleVisibility();
|
|
127
|
-
setValue(data);
|
|
128
|
-
onDateChange(data);
|
|
129
|
-
}
|
|
130
|
-
}))));
|
|
131
|
-
};
|
|
132
|
-
var _default = DatePickerInput;
|
|
133
|
-
exports.default = _default;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { View, TextInput, Platform } from "react-native";
|
|
4
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
-
import dateFormat from "dateformat";
|
|
6
|
-
import Portal from "../Portal/Portal";
|
|
7
|
-
import Touchable from "../Touchable";
|
|
8
|
-
import DateTimePicker from "./DatePickerComponent";
|
|
9
|
-
const MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
10
|
-
const DatePickerInput = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
style,
|
|
13
|
-
date,
|
|
14
|
-
onDateChange = () => {},
|
|
15
|
-
defaultValue,
|
|
16
|
-
disabled = false,
|
|
17
|
-
mode = "date",
|
|
18
|
-
format,
|
|
19
|
-
androidDisplay = "default",
|
|
20
|
-
iosDisplay = "default",
|
|
21
|
-
webDisplay = "dialog",
|
|
22
|
-
placeholder,
|
|
23
|
-
...props
|
|
24
|
-
} = _ref;
|
|
25
|
-
const [value, setValue] = React.useState(date || defaultValue);
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
if (defaultValue != null) {
|
|
28
|
-
setValue(defaultValue);
|
|
29
|
-
}
|
|
30
|
-
}, [defaultValue]);
|
|
31
|
-
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
32
|
-
const [focused, setFocused] = React.useState(false);
|
|
33
|
-
const getValidDate = () => {
|
|
34
|
-
if (!value) {
|
|
35
|
-
return new Date();
|
|
36
|
-
}
|
|
37
|
-
return typeof (value === null || value === void 0 ? void 0 : value.getMonth) === "function" ? value : new Date();
|
|
38
|
-
};
|
|
39
|
-
const formatDate = () => {
|
|
40
|
-
if (!value) return "";
|
|
41
|
-
let newDate = getValidDate();
|
|
42
|
-
if (format) return dateFormat(newDate, format);
|
|
43
|
-
if (mode === "time") {
|
|
44
|
-
return "".concat(newDate.toLocaleTimeString());
|
|
45
|
-
}
|
|
46
|
-
if (mode === "datetime") {
|
|
47
|
-
return "".concat(newDate.toLocaleString());
|
|
48
|
-
}
|
|
49
|
-
return "".concat(MONTHS[newDate.getMonth()], " ").concat(newDate.getDate(), ", ").concat(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 /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Touchable, {
|
|
72
|
-
disabled: disabled,
|
|
73
|
-
onPress: toggleVisibility
|
|
74
|
-
}, /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
75
|
-
value: formatDate(),
|
|
76
|
-
placeholder: placeholder,
|
|
77
|
-
editable: !disabled,
|
|
78
|
-
onFocus: _handleFocus,
|
|
79
|
-
onBlur: _handleBlur,
|
|
80
|
-
style: style
|
|
81
|
-
}, props))), pickerVisible && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(View, {
|
|
82
|
-
style: {
|
|
83
|
-
paddingTop: insets.top,
|
|
84
|
-
paddingBottom: insets.bottom,
|
|
85
|
-
paddingLeft: insets.left,
|
|
86
|
-
paddingRight: insets.right
|
|
87
|
-
}
|
|
88
|
-
}, Platform.OS === "web" && /*#__PURE__*/React.createElement(DateTimePicker, {
|
|
89
|
-
value: getValidDate(),
|
|
90
|
-
mode: mode,
|
|
91
|
-
isVisible: pickerVisible,
|
|
92
|
-
toggleVisibility: toggleVisibility,
|
|
93
|
-
onChange: (_event, data) => {
|
|
94
|
-
toggleVisibility();
|
|
95
|
-
setValue(data);
|
|
96
|
-
onDateChange(data);
|
|
97
|
-
}
|
|
98
|
-
}), Platform.OS === "ios" && /*#__PURE__*/React.createElement(DateTimePicker, {
|
|
99
|
-
value: getValidDate(),
|
|
100
|
-
mode: mode,
|
|
101
|
-
displayMode: iosDisplay,
|
|
102
|
-
isVisible: pickerVisible,
|
|
103
|
-
toggleVisibility: toggleVisibility,
|
|
104
|
-
onChange: (_event, data) => {
|
|
105
|
-
toggleVisibility();
|
|
106
|
-
setValue(data);
|
|
107
|
-
onDateChange(data);
|
|
108
|
-
}
|
|
109
|
-
}), Platform.OS === "android" && /*#__PURE__*/React.createElement(DateTimePicker, {
|
|
110
|
-
value: getValidDate(),
|
|
111
|
-
mode: mode,
|
|
112
|
-
variant: webDisplay,
|
|
113
|
-
displayMode: androidDisplay,
|
|
114
|
-
isVisible: pickerVisible,
|
|
115
|
-
toggleVisibility: toggleVisibility,
|
|
116
|
-
onChange: (_event, data) => {
|
|
117
|
-
toggleVisibility();
|
|
118
|
-
setValue(data);
|
|
119
|
-
onDateChange(data);
|
|
120
|
-
}
|
|
121
|
-
}))));
|
|
122
|
-
};
|
|
123
|
-
export default DatePickerInput;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle, TextInputProps } from "react-native";
|
|
3
|
-
declare type Props = {
|
|
4
|
-
style?: StyleProp<ViewStyle>;
|
|
5
|
-
date?: Date;
|
|
6
|
-
format?: string;
|
|
7
|
-
onDateChange?: (data?: Date) => void;
|
|
8
|
-
defaultValue?: Date;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
mode?: "date" | "time" | "datetime";
|
|
11
|
-
androidDisplay: "default" | "spinner" | "calendar" | "clock";
|
|
12
|
-
iosDisplay: "default" | "spinner" | "compact" | "inline";
|
|
13
|
-
webDisplay: "dialog" | "inline";
|
|
14
|
-
placeholder?: string;
|
|
15
|
-
} & TextInputProps;
|
|
16
|
-
declare const DatePickerInput: React.FC<React.PropsWithChildren<Props>>;
|
|
17
|
-
export default DatePickerInput;
|
|
18
|
-
//# sourceMappingURL=DatePickerInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/DatePicker/DatePickerInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,SAAS,EACT,SAAS,EACT,cAAc,EAGf,MAAM,cAAc,CAAC;AAQtB,aAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IACpC,cAAc,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;IAC7D,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACzD,UAAU,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,cAAc,CAAC;AAiBnB,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAmJ7D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -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;
|