@tecsinapse/react-core 3.0.0 → 3.3.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/dist/cjs/components/atoms/GroupButton/styled.js +1 -1
- package/dist/cjs/components/atoms/Tag/styled.js +2 -2
- package/dist/cjs/components/molecules/Calendar/Calendar.js +91 -39
- package/dist/cjs/components/molecules/Calendar/components/MemoizedYearCard.js +32 -0
- package/dist/cjs/components/molecules/Calendar/components/SelectYear.js +67 -0
- package/dist/cjs/components/molecules/Calendar/styled.js +45 -36
- package/dist/cjs/components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.js +78 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/utils/masks.js +1 -0
- package/dist/esm/components/atoms/GroupButton/styled.js +1 -1
- package/dist/esm/components/atoms/Tag/styled.js +2 -2
- package/dist/esm/components/molecules/Calendar/Calendar.js +93 -40
- package/dist/esm/components/molecules/Calendar/components/MemoizedYearCard.js +30 -0
- package/dist/esm/components/molecules/Calendar/components/SelectYear.js +65 -0
- package/dist/esm/components/molecules/Calendar/styled.js +45 -37
- package/dist/esm/components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.js +57 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/masks.js +1 -0
- package/dist/types/components/molecules/Calendar/Calendar.d.ts +3 -1
- package/dist/types/components/molecules/Calendar/components/MemoizedYearCard.d.ts +10 -0
- package/dist/types/components/molecules/Calendar/components/SelectYear.d.ts +12 -0
- package/dist/types/components/molecules/Calendar/components/index.d.ts +2 -0
- package/dist/types/components/molecules/Calendar/styled.d.ts +10 -2
- package/dist/types/components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.d.ts +20 -0
- package/dist/types/components/molecules/ControlledDateTimeSelector/index.d.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/utils/masks.d.ts +1 -0
- package/package.json +3 -3
|
@@ -99,7 +99,7 @@ const StyledOption = styled.View`
|
|
|
99
99
|
`;
|
|
100
100
|
const StyledDivider = styled.View`
|
|
101
101
|
width: ${({ theme }) => theme.borderWidth.pico};
|
|
102
|
-
background-color: ${({ theme }) => theme.color.secondary.light};
|
|
102
|
+
background-color: ${({ theme }) => theme.color.secondary.light};
|
|
103
103
|
`;
|
|
104
104
|
const StyledPressable = styled(StyledPressableBase)(
|
|
105
105
|
(props) => styled.css`
|
|
@@ -13,8 +13,8 @@ const backgroundColorTag = ({
|
|
|
13
13
|
backgroundColorTone,
|
|
14
14
|
backgroundColorVariant
|
|
15
15
|
}) => styled.css`
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
background-color: ${theme?.color[backgroundColorTone][backgroundColorVariant]};
|
|
17
|
+
`;
|
|
18
18
|
const defaultVariant = ({ theme, variant }) => variant === "default" && styled.css`
|
|
19
19
|
border-radius: ${theme.borderRadius.mili};
|
|
20
20
|
padding: ${theme.spacing.micro} ${theme.spacing.centi};
|
|
@@ -8,6 +8,7 @@ var Text = require('../../atoms/Text/Text.js');
|
|
|
8
8
|
var styled = require('./styled.js');
|
|
9
9
|
var Weekdays = require('./components/Weekdays.js');
|
|
10
10
|
var MonthWeek = require('./components/MonthWeek.js');
|
|
11
|
+
var SelectYear = require('./components/SelectYear.js');
|
|
11
12
|
|
|
12
13
|
function _interopNamespaceDefault(e) {
|
|
13
14
|
var n = Object.create(null);
|
|
@@ -46,6 +47,7 @@ function Calendar({
|
|
|
46
47
|
type,
|
|
47
48
|
onChange,
|
|
48
49
|
locale,
|
|
50
|
+
selectYearProps,
|
|
49
51
|
...rest
|
|
50
52
|
}) {
|
|
51
53
|
const _referenceDate = React__namespace.useMemo(
|
|
@@ -53,6 +55,8 @@ function Calendar({
|
|
|
53
55
|
[_year, _month]
|
|
54
56
|
);
|
|
55
57
|
const [referenceDate, setReferenceDate] = React__namespace.useState(_referenceDate);
|
|
58
|
+
const [showSelectYear, setShowSelectYear] = React__namespace.useState(false);
|
|
59
|
+
const calendarHeightRef = React.useRef(0);
|
|
56
60
|
const startingWeekDay = React__namespace.useMemo(
|
|
57
61
|
() => dayOfWeekFromWeekStart(
|
|
58
62
|
referenceDate.getDay(),
|
|
@@ -71,12 +75,15 @@ function Calendar({
|
|
|
71
75
|
[TextComponent]
|
|
72
76
|
);
|
|
73
77
|
const calendar = React__namespace.useMemo(
|
|
74
|
-
() => [...Array(
|
|
75
|
-
(week) => [...Array(7).keys()].map(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
() => [...Array(6).keys()].map(
|
|
79
|
+
(week) => [...Array(7).keys()].map((weekDayIndex) => {
|
|
80
|
+
let addDays = 6 * week + week + weekDayIndex - startingWeekDay;
|
|
81
|
+
if (weeksInMonth == 5 && startingWeekDay == 0)
|
|
82
|
+
addDays -= 7;
|
|
83
|
+
return dateFns.add(referenceDate, {
|
|
84
|
+
days: addDays
|
|
85
|
+
});
|
|
86
|
+
})
|
|
80
87
|
),
|
|
81
88
|
[weeksInMonth, startingWeekDay, referenceDate]
|
|
82
89
|
);
|
|
@@ -86,16 +93,37 @@ function Calendar({
|
|
|
86
93
|
const handlePressPrev = React__namespace.useCallback(() => {
|
|
87
94
|
setReferenceDate(dateFns.add(referenceDate, { months: -1 }));
|
|
88
95
|
}, [referenceDate, setReferenceDate]);
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
const handlePressSelectYear = React__namespace.useCallback(() => {
|
|
97
|
+
setShowSelectYear((prevState) => !prevState);
|
|
98
|
+
}, [setShowSelectYear]);
|
|
99
|
+
const handleSelectYear = React__namespace.useCallback(
|
|
100
|
+
(year) => {
|
|
101
|
+
const referenceDateYear = referenceDate.getFullYear();
|
|
102
|
+
const addYears = year - referenceDateYear;
|
|
103
|
+
setReferenceDate(dateFns.add(referenceDate, { years: addYears }));
|
|
104
|
+
setShowSelectYear(false);
|
|
105
|
+
},
|
|
106
|
+
[referenceDate]
|
|
107
|
+
);
|
|
108
|
+
return /* @__PURE__ */ React__namespace.createElement(reactNative.View, { ...rest }, /* @__PURE__ */ React__namespace.createElement(styled.TitleContainer, null, /* @__PURE__ */ React__namespace.createElement(
|
|
109
|
+
styled.Control,
|
|
91
110
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
onPress: handlePressPrev,
|
|
112
|
+
align: "start",
|
|
113
|
+
disabled: showSelectYear,
|
|
114
|
+
isLeft: true
|
|
115
|
+
},
|
|
116
|
+
/* @__PURE__ */ React__namespace.createElement(
|
|
117
|
+
Icon,
|
|
118
|
+
{
|
|
119
|
+
name: "chevron-left",
|
|
120
|
+
type: "material-community",
|
|
121
|
+
size: "kilo",
|
|
122
|
+
colorVariant: "secondary",
|
|
123
|
+
colorTone: "medium"
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
), /* @__PURE__ */ React__namespace.createElement(reactNative.TouchableOpacity, { onPress: handlePressSelectYear }, /* @__PURE__ */ React__namespace.createElement(
|
|
99
127
|
Capitalized,
|
|
100
128
|
{
|
|
101
129
|
colorVariant: "secondary",
|
|
@@ -103,34 +131,58 @@ function Calendar({
|
|
|
103
131
|
fontWeight: "bold"
|
|
104
132
|
},
|
|
105
133
|
dateFns.format(referenceDate, "MMMM yyyy", { locale })
|
|
106
|
-
), /* @__PURE__ */ React__namespace.createElement(
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
name: "chevron-right",
|
|
110
|
-
type: "material-community",
|
|
111
|
-
size: "kilo",
|
|
112
|
-
colorVariant: "secondary",
|
|
113
|
-
colorTone: "medium"
|
|
114
|
-
}
|
|
115
|
-
))), /* @__PURE__ */ React__namespace.createElement(styled.Content, null, /* @__PURE__ */ React__namespace.createElement(
|
|
116
|
-
Weekdays,
|
|
134
|
+
)), /* @__PURE__ */ React__namespace.createElement(
|
|
135
|
+
styled.Control,
|
|
117
136
|
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
onPress: handlePressNext,
|
|
138
|
+
align: "end",
|
|
139
|
+
disabled: showSelectYear,
|
|
140
|
+
isRight: true
|
|
141
|
+
},
|
|
142
|
+
/* @__PURE__ */ React__namespace.createElement(
|
|
143
|
+
Icon,
|
|
144
|
+
{
|
|
145
|
+
name: "chevron-right",
|
|
146
|
+
type: "material-community",
|
|
147
|
+
size: "kilo",
|
|
148
|
+
colorVariant: "secondary",
|
|
149
|
+
colorTone: "medium"
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
)), showSelectYear ? /* @__PURE__ */ React__namespace.createElement(styled.Content, { height: calendarHeightRef.current }, /* @__PURE__ */ React__namespace.createElement(
|
|
153
|
+
SelectYear,
|
|
124
154
|
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
value,
|
|
128
|
-
key: `week-${index}`,
|
|
129
|
-
onChange,
|
|
155
|
+
currentYear: referenceDate.getFullYear(),
|
|
156
|
+
onSelectYear: handleSelectYear,
|
|
130
157
|
TextComponent,
|
|
131
|
-
|
|
158
|
+
...selectYearProps
|
|
132
159
|
}
|
|
133
|
-
))
|
|
160
|
+
)) : /* @__PURE__ */ React__namespace.createElement(
|
|
161
|
+
styled.Content,
|
|
162
|
+
{
|
|
163
|
+
onLayout: (e) => calendarHeightRef.current = e.nativeEvent.layout.height
|
|
164
|
+
},
|
|
165
|
+
/* @__PURE__ */ React__namespace.createElement(
|
|
166
|
+
Weekdays,
|
|
167
|
+
{
|
|
168
|
+
locale,
|
|
169
|
+
calendar,
|
|
170
|
+
Capitalized
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
calendar.map((week, index) => /* @__PURE__ */ React__namespace.createElement(
|
|
174
|
+
MonthWeek,
|
|
175
|
+
{
|
|
176
|
+
week,
|
|
177
|
+
type,
|
|
178
|
+
value,
|
|
179
|
+
key: `week-${index}`,
|
|
180
|
+
onChange,
|
|
181
|
+
TextComponent,
|
|
182
|
+
referenceDate
|
|
183
|
+
}
|
|
184
|
+
))
|
|
185
|
+
));
|
|
134
186
|
}
|
|
135
187
|
|
|
136
188
|
module.exports = Calendar;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var styled = require('../styled.js');
|
|
5
|
+
|
|
6
|
+
const MemoizedYearCard = React.memo(
|
|
7
|
+
({
|
|
8
|
+
year,
|
|
9
|
+
isSelected,
|
|
10
|
+
onPress,
|
|
11
|
+
TextComponent
|
|
12
|
+
}) => /* @__PURE__ */ React.createElement(
|
|
13
|
+
styled.YearCard,
|
|
14
|
+
{
|
|
15
|
+
id: String(year),
|
|
16
|
+
key: year,
|
|
17
|
+
isSelected,
|
|
18
|
+
onPress
|
|
19
|
+
},
|
|
20
|
+
/* @__PURE__ */ React.createElement(
|
|
21
|
+
TextComponent,
|
|
22
|
+
{
|
|
23
|
+
colorVariant: isSelected ? "primary" : "secondary",
|
|
24
|
+
colorTone: "xdark",
|
|
25
|
+
typography: "sub"
|
|
26
|
+
},
|
|
27
|
+
year
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
module.exports = MemoizedYearCard;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
var Text = require('../../../atoms/Text/Text.js');
|
|
6
|
+
require('../../../atoms/Input/styled.js');
|
|
7
|
+
require('currency.js');
|
|
8
|
+
require('../../../atoms/Input/InputElement/InputElement.js');
|
|
9
|
+
require('../../../atoms/Input/InputMaskElement/InputMaskElement.js');
|
|
10
|
+
require('../../../atoms/Input/PressableInputContainer/styled.js');
|
|
11
|
+
var ResponsiveFontSize = require('../../../../utils/ResponsiveFontSize.js');
|
|
12
|
+
var useTheme = require('../../../../hooks/useTheme.js');
|
|
13
|
+
var MemoizedYearCard = require('./MemoizedYearCard.js');
|
|
14
|
+
|
|
15
|
+
const SelectYear = ({
|
|
16
|
+
currentYear,
|
|
17
|
+
onSelectYear,
|
|
18
|
+
TextComponent = Text,
|
|
19
|
+
yearsToShow = 100,
|
|
20
|
+
firstYear = 1950,
|
|
21
|
+
numColumns = 4
|
|
22
|
+
}) => {
|
|
23
|
+
const theme = useTheme.useTheme();
|
|
24
|
+
const years = React.useMemo(
|
|
25
|
+
() => Array.from({ length: yearsToShow }, (_, i) => i + firstYear),
|
|
26
|
+
[yearsToShow, firstYear]
|
|
27
|
+
);
|
|
28
|
+
const initialIndex = React.useMemo(() => {
|
|
29
|
+
const index = currentYear % firstYear / numColumns - 2;
|
|
30
|
+
return index < 0 ? 0 : index;
|
|
31
|
+
}, [currentYear, firstYear, numColumns]);
|
|
32
|
+
const yearCardHeight = ResponsiveFontSize.RFValue(Number(theme.typography.base.fontSize.slice(0, -2))) + 2 * ResponsiveFontSize.RFValue(Number(theme.spacing.deca.slice(0, -2)));
|
|
33
|
+
const yearCardsBuilder = React.useCallback(
|
|
34
|
+
(item) => /* @__PURE__ */ React.createElement(
|
|
35
|
+
MemoizedYearCard,
|
|
36
|
+
{
|
|
37
|
+
year: item.item,
|
|
38
|
+
isSelected: currentYear === item.item,
|
|
39
|
+
onPress: () => onSelectYear(item.item),
|
|
40
|
+
TextComponent
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
[currentYear, onSelectYear]
|
|
44
|
+
);
|
|
45
|
+
return /* @__PURE__ */ React.createElement(
|
|
46
|
+
reactNative.FlatList,
|
|
47
|
+
{
|
|
48
|
+
data: years,
|
|
49
|
+
renderItem: yearCardsBuilder,
|
|
50
|
+
keyExtractor: (item) => String(item),
|
|
51
|
+
contentContainerStyle: {
|
|
52
|
+
alignItems: "center"
|
|
53
|
+
},
|
|
54
|
+
numColumns,
|
|
55
|
+
initialScrollIndex: initialIndex,
|
|
56
|
+
getItemLayout: (_, index) => ({
|
|
57
|
+
length: yearCardHeight,
|
|
58
|
+
offset: yearCardHeight * index,
|
|
59
|
+
index
|
|
60
|
+
}),
|
|
61
|
+
fadingEdgeLength: 200
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
var SelectYear$1 = React.memo(SelectYear);
|
|
66
|
+
|
|
67
|
+
module.exports = SelectYear$1;
|
|
@@ -27,6 +27,7 @@ const getCapitalizedTextComponent = (component) => {
|
|
|
27
27
|
const Content = styled.View`
|
|
28
28
|
padding: ${({ theme }) => theme.spacing.deca};
|
|
29
29
|
background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};
|
|
30
|
+
height: ${({ height }) => height ? `${height}px` : "auto"};
|
|
30
31
|
`;
|
|
31
32
|
const Week = styled.View`
|
|
32
33
|
flex-direction: row;
|
|
@@ -40,42 +41,49 @@ const Selected = styled.View`
|
|
|
40
41
|
width: 100%;
|
|
41
42
|
height: 100%;
|
|
42
43
|
`;
|
|
43
|
-
const Cell = styled(PressableSurface)(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
44
|
+
const Cell = styled(PressableSurface)(({
|
|
45
|
+
theme,
|
|
46
|
+
selected,
|
|
47
|
+
highlighted,
|
|
48
|
+
isLineEnd,
|
|
49
|
+
isLineStart,
|
|
50
|
+
isRangeStart,
|
|
51
|
+
isRangeEnd
|
|
52
|
+
}) => {
|
|
53
|
+
const borderRadiusSize = theme.borderRadius.mili;
|
|
54
|
+
const { rightBorderRadius, leftBorderRadius } = {
|
|
55
|
+
rightBorderRadius: selected && !isRangeStart || isLineEnd ? borderRadiusSize : 0,
|
|
56
|
+
leftBorderRadius: selected && !isRangeEnd || isLineStart ? borderRadiusSize : 0
|
|
57
|
+
};
|
|
58
|
+
const borderEffect = highlighted ? 0 : borderRadiusSize;
|
|
59
|
+
const backgroundColor = highlighted ? theme.color.primary.light : "transparent";
|
|
60
|
+
return styled.css`
|
|
61
|
+
${isWeb ? styled.css`
|
|
62
|
+
width: 32px;
|
|
63
|
+
height: 32px;
|
|
64
|
+
` : styled.css`
|
|
65
|
+
aspect-ratio: 1;
|
|
66
|
+
flex: 1;
|
|
67
|
+
`}
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
align-items: center;
|
|
71
|
+
border-radius: ${borderEffect};
|
|
72
|
+
border-top-left-radius: ${leftBorderRadius};
|
|
73
|
+
border-bottom-left-radius: ${leftBorderRadius};
|
|
74
|
+
border-top-right-radius: ${rightBorderRadius};
|
|
75
|
+
border-bottom-right-radius: ${rightBorderRadius};
|
|
76
|
+
background-color: ${backgroundColor};
|
|
77
|
+
`;
|
|
78
|
+
});
|
|
79
|
+
const YearCard = styled(PressableSurface)(
|
|
80
|
+
(props) => styled.css`
|
|
81
|
+
background-color: ${props.isSelected ? props.theme?.color.primary.light : void 0};
|
|
82
|
+
padding: ${props.theme?.spacing.centi};
|
|
83
|
+
border-radius: ${props.theme?.borderRadius.mili};
|
|
84
|
+
margin: ${props.theme?.spacing.mili};
|
|
85
|
+
padding: ${props.theme?.spacing.mili} ${props.theme?.spacing.deca};
|
|
86
|
+
`
|
|
79
87
|
);
|
|
80
88
|
|
|
81
89
|
exports.Cell = Cell;
|
|
@@ -84,4 +92,5 @@ exports.Control = Control;
|
|
|
84
92
|
exports.Selected = Selected;
|
|
85
93
|
exports.TitleContainer = TitleContainer;
|
|
86
94
|
exports.Week = Week;
|
|
95
|
+
exports.YearCard = YearCard;
|
|
87
96
|
exports.getCapitalizedTextComponent = getCapitalizedTextComponent;
|
package/dist/cjs/components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
23
|
+
|
|
24
|
+
const ControlledDateTimeSelector = ({
|
|
25
|
+
SelectorComponent,
|
|
26
|
+
...rest
|
|
27
|
+
}) => {
|
|
28
|
+
const {
|
|
29
|
+
value,
|
|
30
|
+
mode,
|
|
31
|
+
dateModalTitle,
|
|
32
|
+
dateConfirmButtonText,
|
|
33
|
+
timeModalTitle,
|
|
34
|
+
timeConfirmButtonText,
|
|
35
|
+
onChange
|
|
36
|
+
} = rest;
|
|
37
|
+
const [date, setDate] = React__namespace.useState(value || /* @__PURE__ */ new Date());
|
|
38
|
+
const [currentMode, setCurrentMode] = React__namespace.useState(0);
|
|
39
|
+
const isDate = mode === "date" || mode === "datetime" && currentMode === 0;
|
|
40
|
+
const isMonth = mode === "month";
|
|
41
|
+
const modalTitle = isDate || isMonth ? dateModalTitle : timeModalTitle;
|
|
42
|
+
const confirmButtonText = isDate || isMonth ? dateConfirmButtonText : timeConfirmButtonText;
|
|
43
|
+
const handleCalendarChange = (value2) => {
|
|
44
|
+
if (value2 !== void 0) {
|
|
45
|
+
const referenceDate = value2;
|
|
46
|
+
referenceDate.setHours(date.getHours(), date.getMinutes());
|
|
47
|
+
setDate(referenceDate);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const handlePressConfirm = () => {
|
|
51
|
+
if (mode === "datetime" && currentMode === 0) {
|
|
52
|
+
setCurrentMode(1);
|
|
53
|
+
} else {
|
|
54
|
+
onChange?.(date);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handlePressBack = () => {
|
|
58
|
+
setCurrentMode(0);
|
|
59
|
+
};
|
|
60
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
61
|
+
SelectorComponent,
|
|
62
|
+
{
|
|
63
|
+
...rest,
|
|
64
|
+
handlePressBack,
|
|
65
|
+
handlePressConfirm,
|
|
66
|
+
handleCalendarChange,
|
|
67
|
+
confirmButtonText,
|
|
68
|
+
isDate,
|
|
69
|
+
isMonth,
|
|
70
|
+
date,
|
|
71
|
+
setDate,
|
|
72
|
+
currentMode,
|
|
73
|
+
modalTitle
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
module.exports = ControlledDateTimeSelector;
|
package/dist/cjs/index.js
CHANGED
|
@@ -56,6 +56,7 @@ var lightenDarkenColor = require('./utils/lightenDarkenColor.js');
|
|
|
56
56
|
var masks = require('./utils/masks.js');
|
|
57
57
|
var ResponsiveFontSize = require('./utils/ResponsiveFontSize.js');
|
|
58
58
|
var variantComplement = require('./utils/variantComplement.js');
|
|
59
|
+
var ControlledDateTimeSelector = require('./components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.js');
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
|
|
@@ -141,3 +142,4 @@ exports.borderColorVC = variantComplement.borderColorVC;
|
|
|
141
142
|
exports.colorGradationVC = variantComplement.colorGradationVC;
|
|
142
143
|
exports.colorVC = variantComplement.colorVC;
|
|
143
144
|
exports.fontColorVC = variantComplement.fontColorVC;
|
|
145
|
+
exports.ControlledDateTimeSelector = ControlledDateTimeSelector;
|
package/dist/cjs/utils/masks.js
CHANGED
|
@@ -97,7 +97,7 @@ const StyledOption = styled.View`
|
|
|
97
97
|
`;
|
|
98
98
|
const StyledDivider = styled.View`
|
|
99
99
|
width: ${({ theme }) => theme.borderWidth.pico};
|
|
100
|
-
background-color: ${({ theme }) => theme.color.secondary.light};
|
|
100
|
+
background-color: ${({ theme }) => theme.color.secondary.light};
|
|
101
101
|
`;
|
|
102
102
|
const StyledPressable = styled(StyledPressableBase)(
|
|
103
103
|
(props) => css`
|
|
@@ -11,8 +11,8 @@ const backgroundColorTag = ({
|
|
|
11
11
|
backgroundColorTone,
|
|
12
12
|
backgroundColorVariant
|
|
13
13
|
}) => css`
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
background-color: ${theme?.color[backgroundColorTone][backgroundColorVariant]};
|
|
15
|
+
`;
|
|
16
16
|
const defaultVariant = ({ theme, variant }) => variant === "default" && css`
|
|
17
17
|
border-radius: ${theme.borderRadius.mili};
|
|
18
18
|
padding: ${theme.spacing.micro} ${theme.spacing.centi};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { set, getWeeksInMonth, add, format } from 'date-fns';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
4
5
|
import Icon from '../../atoms/Icon/Icon.js';
|
|
5
6
|
import Text from '../../atoms/Text/Text.js';
|
|
6
7
|
import { getCapitalizedTextComponent, TitleContainer, Control, Content } from './styled.js';
|
|
7
8
|
import Weekdays from './components/Weekdays.js';
|
|
8
9
|
import MonthWeek from './components/MonthWeek.js';
|
|
10
|
+
import SelectYear from './components/SelectYear.js';
|
|
9
11
|
|
|
10
12
|
const now = set(/* @__PURE__ */ new Date(), {
|
|
11
13
|
date: 1,
|
|
@@ -25,6 +27,7 @@ function Calendar({
|
|
|
25
27
|
type,
|
|
26
28
|
onChange,
|
|
27
29
|
locale,
|
|
30
|
+
selectYearProps,
|
|
28
31
|
...rest
|
|
29
32
|
}) {
|
|
30
33
|
const _referenceDate = React.useMemo(
|
|
@@ -32,6 +35,8 @@ function Calendar({
|
|
|
32
35
|
[_year, _month]
|
|
33
36
|
);
|
|
34
37
|
const [referenceDate, setReferenceDate] = React.useState(_referenceDate);
|
|
38
|
+
const [showSelectYear, setShowSelectYear] = React.useState(false);
|
|
39
|
+
const calendarHeightRef = useRef(0);
|
|
35
40
|
const startingWeekDay = React.useMemo(
|
|
36
41
|
() => dayOfWeekFromWeekStart(
|
|
37
42
|
referenceDate.getDay(),
|
|
@@ -50,12 +55,15 @@ function Calendar({
|
|
|
50
55
|
[TextComponent]
|
|
51
56
|
);
|
|
52
57
|
const calendar = React.useMemo(
|
|
53
|
-
() => [...Array(
|
|
54
|
-
(week) => [...Array(7).keys()].map(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
() => [...Array(6).keys()].map(
|
|
59
|
+
(week) => [...Array(7).keys()].map((weekDayIndex) => {
|
|
60
|
+
let addDays = 6 * week + week + weekDayIndex - startingWeekDay;
|
|
61
|
+
if (weeksInMonth == 5 && startingWeekDay == 0)
|
|
62
|
+
addDays -= 7;
|
|
63
|
+
return add(referenceDate, {
|
|
64
|
+
days: addDays
|
|
65
|
+
});
|
|
66
|
+
})
|
|
59
67
|
),
|
|
60
68
|
[weeksInMonth, startingWeekDay, referenceDate]
|
|
61
69
|
);
|
|
@@ -65,16 +73,37 @@ function Calendar({
|
|
|
65
73
|
const handlePressPrev = React.useCallback(() => {
|
|
66
74
|
setReferenceDate(add(referenceDate, { months: -1 }));
|
|
67
75
|
}, [referenceDate, setReferenceDate]);
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
const handlePressSelectYear = React.useCallback(() => {
|
|
77
|
+
setShowSelectYear((prevState) => !prevState);
|
|
78
|
+
}, [setShowSelectYear]);
|
|
79
|
+
const handleSelectYear = React.useCallback(
|
|
80
|
+
(year) => {
|
|
81
|
+
const referenceDateYear = referenceDate.getFullYear();
|
|
82
|
+
const addYears = year - referenceDateYear;
|
|
83
|
+
setReferenceDate(add(referenceDate, { years: addYears }));
|
|
84
|
+
setShowSelectYear(false);
|
|
85
|
+
},
|
|
86
|
+
[referenceDate]
|
|
87
|
+
);
|
|
88
|
+
return /* @__PURE__ */ React.createElement(View, { ...rest }, /* @__PURE__ */ React.createElement(TitleContainer, null, /* @__PURE__ */ React.createElement(
|
|
89
|
+
Control,
|
|
70
90
|
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
onPress: handlePressPrev,
|
|
92
|
+
align: "start",
|
|
93
|
+
disabled: showSelectYear,
|
|
94
|
+
isLeft: true
|
|
95
|
+
},
|
|
96
|
+
/* @__PURE__ */ React.createElement(
|
|
97
|
+
Icon,
|
|
98
|
+
{
|
|
99
|
+
name: "chevron-left",
|
|
100
|
+
type: "material-community",
|
|
101
|
+
size: "kilo",
|
|
102
|
+
colorVariant: "secondary",
|
|
103
|
+
colorTone: "medium"
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
), /* @__PURE__ */ React.createElement(TouchableOpacity, { onPress: handlePressSelectYear }, /* @__PURE__ */ React.createElement(
|
|
78
107
|
Capitalized,
|
|
79
108
|
{
|
|
80
109
|
colorVariant: "secondary",
|
|
@@ -82,34 +111,58 @@ function Calendar({
|
|
|
82
111
|
fontWeight: "bold"
|
|
83
112
|
},
|
|
84
113
|
format(referenceDate, "MMMM yyyy", { locale })
|
|
85
|
-
), /* @__PURE__ */ React.createElement(
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
name: "chevron-right",
|
|
89
|
-
type: "material-community",
|
|
90
|
-
size: "kilo",
|
|
91
|
-
colorVariant: "secondary",
|
|
92
|
-
colorTone: "medium"
|
|
93
|
-
}
|
|
94
|
-
))), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(
|
|
95
|
-
Weekdays,
|
|
114
|
+
)), /* @__PURE__ */ React.createElement(
|
|
115
|
+
Control,
|
|
96
116
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
117
|
+
onPress: handlePressNext,
|
|
118
|
+
align: "end",
|
|
119
|
+
disabled: showSelectYear,
|
|
120
|
+
isRight: true
|
|
121
|
+
},
|
|
122
|
+
/* @__PURE__ */ React.createElement(
|
|
123
|
+
Icon,
|
|
124
|
+
{
|
|
125
|
+
name: "chevron-right",
|
|
126
|
+
type: "material-community",
|
|
127
|
+
size: "kilo",
|
|
128
|
+
colorVariant: "secondary",
|
|
129
|
+
colorTone: "medium"
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
)), showSelectYear ? /* @__PURE__ */ React.createElement(Content, { height: calendarHeightRef.current }, /* @__PURE__ */ React.createElement(
|
|
133
|
+
SelectYear,
|
|
103
134
|
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
value,
|
|
107
|
-
key: `week-${index}`,
|
|
108
|
-
onChange,
|
|
135
|
+
currentYear: referenceDate.getFullYear(),
|
|
136
|
+
onSelectYear: handleSelectYear,
|
|
109
137
|
TextComponent,
|
|
110
|
-
|
|
138
|
+
...selectYearProps
|
|
111
139
|
}
|
|
112
|
-
))
|
|
140
|
+
)) : /* @__PURE__ */ React.createElement(
|
|
141
|
+
Content,
|
|
142
|
+
{
|
|
143
|
+
onLayout: (e) => calendarHeightRef.current = e.nativeEvent.layout.height
|
|
144
|
+
},
|
|
145
|
+
/* @__PURE__ */ React.createElement(
|
|
146
|
+
Weekdays,
|
|
147
|
+
{
|
|
148
|
+
locale,
|
|
149
|
+
calendar,
|
|
150
|
+
Capitalized
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
calendar.map((week, index) => /* @__PURE__ */ React.createElement(
|
|
154
|
+
MonthWeek,
|
|
155
|
+
{
|
|
156
|
+
week,
|
|
157
|
+
type,
|
|
158
|
+
value,
|
|
159
|
+
key: `week-${index}`,
|
|
160
|
+
onChange,
|
|
161
|
+
TextComponent,
|
|
162
|
+
referenceDate
|
|
163
|
+
}
|
|
164
|
+
))
|
|
165
|
+
));
|
|
113
166
|
}
|
|
114
167
|
|
|
115
168
|
export { Calendar as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { YearCard } from '../styled.js';
|
|
3
|
+
|
|
4
|
+
const MemoizedYearCard = React__default.memo(
|
|
5
|
+
({
|
|
6
|
+
year,
|
|
7
|
+
isSelected,
|
|
8
|
+
onPress,
|
|
9
|
+
TextComponent
|
|
10
|
+
}) => /* @__PURE__ */ React__default.createElement(
|
|
11
|
+
YearCard,
|
|
12
|
+
{
|
|
13
|
+
id: String(year),
|
|
14
|
+
key: year,
|
|
15
|
+
isSelected,
|
|
16
|
+
onPress
|
|
17
|
+
},
|
|
18
|
+
/* @__PURE__ */ React__default.createElement(
|
|
19
|
+
TextComponent,
|
|
20
|
+
{
|
|
21
|
+
colorVariant: isSelected ? "primary" : "secondary",
|
|
22
|
+
colorTone: "xdark",
|
|
23
|
+
typography: "sub"
|
|
24
|
+
},
|
|
25
|
+
year
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export { MemoizedYearCard as default };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { FlatList } from 'react-native';
|
|
3
|
+
import Text from '../../../atoms/Text/Text.js';
|
|
4
|
+
import '../../../atoms/Input/styled.js';
|
|
5
|
+
import 'currency.js';
|
|
6
|
+
import '../../../atoms/Input/InputElement/InputElement.js';
|
|
7
|
+
import '../../../atoms/Input/InputMaskElement/InputMaskElement.js';
|
|
8
|
+
import '../../../atoms/Input/PressableInputContainer/styled.js';
|
|
9
|
+
import { RFValue } from '../../../../utils/ResponsiveFontSize.js';
|
|
10
|
+
import { useTheme } from '../../../../hooks/useTheme.js';
|
|
11
|
+
import MemoizedYearCard from './MemoizedYearCard.js';
|
|
12
|
+
|
|
13
|
+
const SelectYear = ({
|
|
14
|
+
currentYear,
|
|
15
|
+
onSelectYear,
|
|
16
|
+
TextComponent = Text,
|
|
17
|
+
yearsToShow = 100,
|
|
18
|
+
firstYear = 1950,
|
|
19
|
+
numColumns = 4
|
|
20
|
+
}) => {
|
|
21
|
+
const theme = useTheme();
|
|
22
|
+
const years = React__default.useMemo(
|
|
23
|
+
() => Array.from({ length: yearsToShow }, (_, i) => i + firstYear),
|
|
24
|
+
[yearsToShow, firstYear]
|
|
25
|
+
);
|
|
26
|
+
const initialIndex = React__default.useMemo(() => {
|
|
27
|
+
const index = currentYear % firstYear / numColumns - 2;
|
|
28
|
+
return index < 0 ? 0 : index;
|
|
29
|
+
}, [currentYear, firstYear, numColumns]);
|
|
30
|
+
const yearCardHeight = RFValue(Number(theme.typography.base.fontSize.slice(0, -2))) + 2 * RFValue(Number(theme.spacing.deca.slice(0, -2)));
|
|
31
|
+
const yearCardsBuilder = React__default.useCallback(
|
|
32
|
+
(item) => /* @__PURE__ */ React__default.createElement(
|
|
33
|
+
MemoizedYearCard,
|
|
34
|
+
{
|
|
35
|
+
year: item.item,
|
|
36
|
+
isSelected: currentYear === item.item,
|
|
37
|
+
onPress: () => onSelectYear(item.item),
|
|
38
|
+
TextComponent
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
[currentYear, onSelectYear]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
44
|
+
FlatList,
|
|
45
|
+
{
|
|
46
|
+
data: years,
|
|
47
|
+
renderItem: yearCardsBuilder,
|
|
48
|
+
keyExtractor: (item) => String(item),
|
|
49
|
+
contentContainerStyle: {
|
|
50
|
+
alignItems: "center"
|
|
51
|
+
},
|
|
52
|
+
numColumns,
|
|
53
|
+
initialScrollIndex: initialIndex,
|
|
54
|
+
getItemLayout: (_, index) => ({
|
|
55
|
+
length: yearCardHeight,
|
|
56
|
+
offset: yearCardHeight * index,
|
|
57
|
+
index
|
|
58
|
+
}),
|
|
59
|
+
fadingEdgeLength: 200
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
var SelectYear$1 = React__default.memo(SelectYear);
|
|
64
|
+
|
|
65
|
+
export { SelectYear$1 as default };
|
|
@@ -25,6 +25,7 @@ const getCapitalizedTextComponent = (component) => {
|
|
|
25
25
|
const Content = styled.View`
|
|
26
26
|
padding: ${({ theme }) => theme.spacing.deca};
|
|
27
27
|
background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};
|
|
28
|
+
height: ${({ height }) => height ? `${height}px` : "auto"};
|
|
28
29
|
`;
|
|
29
30
|
const Week = styled.View`
|
|
30
31
|
flex-direction: row;
|
|
@@ -38,42 +39,49 @@ const Selected = styled.View`
|
|
|
38
39
|
width: 100%;
|
|
39
40
|
height: 100%;
|
|
40
41
|
`;
|
|
41
|
-
const Cell = styled(PressableSurface)(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
42
|
+
const Cell = styled(PressableSurface)(({
|
|
43
|
+
theme,
|
|
44
|
+
selected,
|
|
45
|
+
highlighted,
|
|
46
|
+
isLineEnd,
|
|
47
|
+
isLineStart,
|
|
48
|
+
isRangeStart,
|
|
49
|
+
isRangeEnd
|
|
50
|
+
}) => {
|
|
51
|
+
const borderRadiusSize = theme.borderRadius.mili;
|
|
52
|
+
const { rightBorderRadius, leftBorderRadius } = {
|
|
53
|
+
rightBorderRadius: selected && !isRangeStart || isLineEnd ? borderRadiusSize : 0,
|
|
54
|
+
leftBorderRadius: selected && !isRangeEnd || isLineStart ? borderRadiusSize : 0
|
|
55
|
+
};
|
|
56
|
+
const borderEffect = highlighted ? 0 : borderRadiusSize;
|
|
57
|
+
const backgroundColor = highlighted ? theme.color.primary.light : "transparent";
|
|
58
|
+
return css`
|
|
59
|
+
${isWeb ? css`
|
|
60
|
+
width: 32px;
|
|
61
|
+
height: 32px;
|
|
62
|
+
` : css`
|
|
63
|
+
aspect-ratio: 1;
|
|
64
|
+
flex: 1;
|
|
65
|
+
`}
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
align-items: center;
|
|
69
|
+
border-radius: ${borderEffect};
|
|
70
|
+
border-top-left-radius: ${leftBorderRadius};
|
|
71
|
+
border-bottom-left-radius: ${leftBorderRadius};
|
|
72
|
+
border-top-right-radius: ${rightBorderRadius};
|
|
73
|
+
border-bottom-right-radius: ${rightBorderRadius};
|
|
74
|
+
background-color: ${backgroundColor};
|
|
75
|
+
`;
|
|
76
|
+
});
|
|
77
|
+
const YearCard = styled(PressableSurface)(
|
|
78
|
+
(props) => css`
|
|
79
|
+
background-color: ${props.isSelected ? props.theme?.color.primary.light : void 0};
|
|
80
|
+
padding: ${props.theme?.spacing.centi};
|
|
81
|
+
border-radius: ${props.theme?.borderRadius.mili};
|
|
82
|
+
margin: ${props.theme?.spacing.mili};
|
|
83
|
+
padding: ${props.theme?.spacing.mili} ${props.theme?.spacing.deca};
|
|
84
|
+
`
|
|
77
85
|
);
|
|
78
86
|
|
|
79
|
-
export { Cell, Content, Control, Selected, TitleContainer, Week, getCapitalizedTextComponent };
|
|
87
|
+
export { Cell, Content, Control, Selected, TitleContainer, Week, YearCard, getCapitalizedTextComponent };
|
package/dist/esm/components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
const ControlledDateTimeSelector = ({
|
|
4
|
+
SelectorComponent,
|
|
5
|
+
...rest
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
value,
|
|
9
|
+
mode,
|
|
10
|
+
dateModalTitle,
|
|
11
|
+
dateConfirmButtonText,
|
|
12
|
+
timeModalTitle,
|
|
13
|
+
timeConfirmButtonText,
|
|
14
|
+
onChange
|
|
15
|
+
} = rest;
|
|
16
|
+
const [date, setDate] = React.useState(value || /* @__PURE__ */ new Date());
|
|
17
|
+
const [currentMode, setCurrentMode] = React.useState(0);
|
|
18
|
+
const isDate = mode === "date" || mode === "datetime" && currentMode === 0;
|
|
19
|
+
const isMonth = mode === "month";
|
|
20
|
+
const modalTitle = isDate || isMonth ? dateModalTitle : timeModalTitle;
|
|
21
|
+
const confirmButtonText = isDate || isMonth ? dateConfirmButtonText : timeConfirmButtonText;
|
|
22
|
+
const handleCalendarChange = (value2) => {
|
|
23
|
+
if (value2 !== void 0) {
|
|
24
|
+
const referenceDate = value2;
|
|
25
|
+
referenceDate.setHours(date.getHours(), date.getMinutes());
|
|
26
|
+
setDate(referenceDate);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const handlePressConfirm = () => {
|
|
30
|
+
if (mode === "datetime" && currentMode === 0) {
|
|
31
|
+
setCurrentMode(1);
|
|
32
|
+
} else {
|
|
33
|
+
onChange?.(date);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const handlePressBack = () => {
|
|
37
|
+
setCurrentMode(0);
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ React.createElement(
|
|
40
|
+
SelectorComponent,
|
|
41
|
+
{
|
|
42
|
+
...rest,
|
|
43
|
+
handlePressBack,
|
|
44
|
+
handlePressConfirm,
|
|
45
|
+
handleCalendarChange,
|
|
46
|
+
confirmButtonText,
|
|
47
|
+
isDate,
|
|
48
|
+
isMonth,
|
|
49
|
+
date,
|
|
50
|
+
setDate,
|
|
51
|
+
currentMode,
|
|
52
|
+
modalTitle
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { ControlledDateTimeSelector as default };
|
package/dist/esm/index.js
CHANGED
|
@@ -54,3 +54,4 @@ export { lightenDarkenColor } from './utils/lightenDarkenColor.js';
|
|
|
54
54
|
export { Masks } from './utils/masks.js';
|
|
55
55
|
export { RFPercentage, RFValue, RFValueStr } from './utils/ResponsiveFontSize.js';
|
|
56
56
|
export { borderColorGradationVC, borderColorVC, colorGradationVC, colorVC, fontColorVC } from './utils/variantComplement.js';
|
|
57
|
+
export { default as ControlledDateTimeSelector } from './components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.js';
|
package/dist/esm/utils/masks.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
3
|
import { TextProps } from '../../atoms/Text';
|
|
4
|
+
import { SelectYearProps } from './components';
|
|
4
5
|
export type SelectionType = 'range' | 'day';
|
|
5
6
|
export type DateRange = {
|
|
6
7
|
lowest: Date;
|
|
@@ -15,6 +16,7 @@ export interface CalendarProps<T extends SelectionType> extends ViewProps {
|
|
|
15
16
|
type?: T;
|
|
16
17
|
value?: Value<T>;
|
|
17
18
|
locale?: Locale;
|
|
19
|
+
selectYearProps?: Omit<SelectYearProps, 'TextComponent' | 'currentYear' | 'onSelectYear'>;
|
|
18
20
|
}
|
|
19
|
-
declare function Calendar<T extends SelectionType>({ TextComponent, year: _year, month: _month, value, type, onChange, locale, ...rest }: CalendarProps<T>): JSX.Element;
|
|
21
|
+
declare function Calendar<T extends SelectionType>({ TextComponent, year: _year, month: _month, value, type, onChange, locale, selectYearProps, ...rest }: CalendarProps<T>): JSX.Element;
|
|
20
22
|
export default Calendar;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextProps } from '../../../atoms/Text';
|
|
3
|
+
interface MemoizedYearCardProps {
|
|
4
|
+
year: number;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
onPress: () => void;
|
|
7
|
+
TextComponent: React.FC<TextProps>;
|
|
8
|
+
}
|
|
9
|
+
declare const MemoizedYearCard: React.MemoExoticComponent<({ year, isSelected, onPress, TextComponent, }: MemoizedYearCardProps) => JSX.Element>;
|
|
10
|
+
export default MemoizedYearCard;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextProps } from '../../../atoms/Text';
|
|
3
|
+
export interface SelectYearProps {
|
|
4
|
+
currentYear: number;
|
|
5
|
+
onSelectYear: (year: number) => void;
|
|
6
|
+
TextComponent?: React.FC<TextProps>;
|
|
7
|
+
yearsToShow?: number;
|
|
8
|
+
firstYear?: number;
|
|
9
|
+
numColumns?: number;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: React.MemoExoticComponent<({ currentYear, onSelectYear, TextComponent, yearsToShow, firstYear, numColumns, }: SelectYearProps) => JSX.Element>;
|
|
12
|
+
export default _default;
|
|
@@ -3,7 +3,7 @@ import { PressableProps, ViewProps } from 'react-native';
|
|
|
3
3
|
import { TextProps } from '../../atoms/Text';
|
|
4
4
|
interface ButtonBorders {
|
|
5
5
|
isLeft?: boolean;
|
|
6
|
-
|
|
6
|
+
isRight?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const TitleContainer: import("@emotion/native").StyledComponent<ViewProps & {
|
|
9
9
|
theme?: import("@emotion/react").Theme | undefined;
|
|
@@ -24,7 +24,9 @@ export declare const getCapitalizedTextComponent: (component: FC<TextProps>) =>
|
|
|
24
24
|
export declare const Content: import("@emotion/native").StyledComponent<ViewProps & {
|
|
25
25
|
theme?: import("@emotion/react").Theme | undefined;
|
|
26
26
|
as?: import("react").ElementType<any> | undefined;
|
|
27
|
-
} & Partial<import("../../../types/defaults").ThemeProviderProps
|
|
27
|
+
} & Partial<import("../../../types/defaults").ThemeProviderProps> & {
|
|
28
|
+
height?: number | undefined;
|
|
29
|
+
}, {}, {
|
|
28
30
|
ref?: import("react").Ref<import("react-native").View> | undefined;
|
|
29
31
|
}>;
|
|
30
32
|
export declare const Week: import("@emotion/native").StyledComponent<ViewProps & {
|
|
@@ -52,4 +54,10 @@ export declare const Cell: import("@emotion/native").StyledComponent<import("../
|
|
|
52
54
|
isRangeStart: boolean;
|
|
53
55
|
isRangeEnd: boolean;
|
|
54
56
|
}, {}, {}>;
|
|
57
|
+
export declare const YearCard: import("@emotion/native").StyledComponent<import("../../atoms/PressableSurface").PressableSurfaceProps & {
|
|
58
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
59
|
+
as?: import("react").ElementType<any> | undefined;
|
|
60
|
+
} & Partial<import("../../../types/defaults").ThemeProviderProps> & ButtonBorders & {
|
|
61
|
+
isSelected?: boolean | undefined;
|
|
62
|
+
}, {}, {}>;
|
|
55
63
|
export {};
|
package/dist/types/components/molecules/ControlledDateTimeSelector/ControlledDateTimeSelector.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DateTimeSelectorProps } from '../DateTimeSelector';
|
|
3
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
export interface ControlledDateTimeSelectorProps extends DateTimeSelectorProps {
|
|
5
|
+
SelectorComponent: React.FC<ControlledSelectorComponentProps>;
|
|
6
|
+
}
|
|
7
|
+
export interface ControlledSelectorComponentProps {
|
|
8
|
+
date: Date;
|
|
9
|
+
setDate: Dispatch<SetStateAction<Date>>;
|
|
10
|
+
currentMode: number;
|
|
11
|
+
isDate: boolean;
|
|
12
|
+
isMonth: boolean;
|
|
13
|
+
handlePressConfirm: () => void;
|
|
14
|
+
handlePressBack: () => void;
|
|
15
|
+
handleCalendarChange: (value?: Date) => void;
|
|
16
|
+
modalTitle?: string;
|
|
17
|
+
confirmButtonText?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const ControlledDateTimeSelector: React.FC<ControlledDateTimeSelectorProps>;
|
|
20
|
+
export default ControlledDateTimeSelector;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -62,3 +62,5 @@ export * from './styles/light';
|
|
|
62
62
|
export { default as ThemeProvider } from './styles/ThemeProvider';
|
|
63
63
|
export * from './types/defaults';
|
|
64
64
|
export * from './utils';
|
|
65
|
+
export { ControlledDateTimeSelector } from './components/molecules/ControlledDateTimeSelector';
|
|
66
|
+
export type { ControlledDateTimeSelectorProps, ControlledSelectorComponentProps, } from './components/molecules/ControlledDateTimeSelector';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/react-core",
|
|
3
3
|
"description": "TecSinapse hybrid React components",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"dev": "
|
|
13
|
+
"dev": "yarn build:es --watch",
|
|
14
14
|
"build:es": "rollup --config",
|
|
15
15
|
"build:declaration": "tsc --project tsconfig.build.json",
|
|
16
16
|
"build:declaration:watch": "tsc --project tsconfig.build.json --watch",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"react-native": "^0.71.0",
|
|
38
38
|
"react-native-vector-icons": "^9.2.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "755aef933fa22dcbe93c6a93689620d920670928"
|
|
41
41
|
}
|