@tecsinapse/react-native-kit 3.0.0 → 3.3.1

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.
Files changed (35) hide show
  1. package/dist/cjs/components/molecules/DatePicker/DatePicker.js +30 -2
  2. package/dist/cjs/components/molecules/DateTimePicker/DateTimePicker.js +10 -4
  3. package/dist/cjs/components/molecules/DateTimePickerSelector/DateTimePickerSelector.js +90 -0
  4. package/dist/cjs/components/molecules/DateTimePickerSelector/styled.js +32 -0
  5. package/dist/cjs/components/molecules/ScrollableSelector/ScrollableSelector.js +146 -0
  6. package/dist/cjs/components/molecules/ScrollableSelector/components/DateBlock.js +97 -0
  7. package/dist/cjs/components/molecules/ScrollableSelector/styled.js +49 -0
  8. package/dist/cjs/components/molecules/Select/styled.js +4 -19
  9. package/dist/cjs/index.js +2 -2
  10. package/dist/esm/components/molecules/DatePicker/DatePicker.js +31 -3
  11. package/dist/esm/components/molecules/DateTimePicker/DateTimePicker.js +11 -5
  12. package/dist/esm/components/molecules/DateTimePickerSelector/DateTimePickerSelector.js +69 -0
  13. package/dist/esm/components/molecules/DateTimePickerSelector/styled.js +27 -0
  14. package/dist/esm/components/molecules/ScrollableSelector/ScrollableSelector.js +144 -0
  15. package/dist/esm/components/molecules/ScrollableSelector/components/DateBlock.js +95 -0
  16. package/dist/esm/components/molecules/ScrollableSelector/styled.js +44 -0
  17. package/dist/esm/components/molecules/Select/styled.js +5 -20
  18. package/dist/esm/index.js +1 -1
  19. package/dist/types/components/atoms/Modal/useLazyModalManager.d.ts +2 -2
  20. package/dist/types/components/molecules/DatePicker/DatePicker.d.ts +1 -1
  21. package/dist/types/components/molecules/DateTimePickerSelector/DateTimePickerSelector.d.ts +5 -0
  22. package/dist/types/components/molecules/DateTimePickerSelector/index.d.ts +1 -0
  23. package/dist/types/components/molecules/DateTimePickerSelector/styled.d.ts +23 -0
  24. package/dist/types/components/molecules/ScrollableSelector/ScrollableSelector.d.ts +15 -0
  25. package/dist/types/components/molecules/ScrollableSelector/components/DateBlock.d.ts +19 -0
  26. package/dist/types/components/molecules/ScrollableSelector/components/index.d.ts +1 -0
  27. package/dist/types/components/molecules/ScrollableSelector/index.d.ts +1 -0
  28. package/dist/types/components/molecules/ScrollableSelector/styled.d.ts +57 -0
  29. package/dist/types/components/molecules/Select/styled.d.ts +1 -20
  30. package/dist/types/index.d.ts +1 -1
  31. package/package.json +4 -4
  32. package/dist/cjs/components/molecules/DateTimeSelector/DateTimeSelector.js +0 -22
  33. package/dist/esm/components/molecules/DateTimeSelector/DateTimeSelector.js +0 -20
  34. package/dist/types/components/molecules/DateTimeSelector/DateTimeSelector.d.ts +0 -3
  35. package/dist/types/components/molecules/DateTimeSelector/index.d.ts +0 -1
@@ -13,17 +13,45 @@ var styled = require('./styled.js');
13
13
  const DatePicker = ({
14
14
  locale,
15
15
  onChange,
16
+ value,
17
+ type,
16
18
  ...rest
17
19
  }) => {
18
20
  const modal = useLazyModalManager.useLazyModalManager();
19
- const handleChange = (value) => {
20
- onChange?.(value);
21
+ const handleChange = (value2) => {
22
+ onChange?.(value2);
21
23
  modal.requestUpdate();
22
24
  };
25
+ const getYear = React.useMemo(() => {
26
+ if (value) {
27
+ if (type === "range") {
28
+ if (value.lowest !== void 0)
29
+ return new Date(value.lowest).getFullYear();
30
+ } else {
31
+ return new Date(value).getFullYear();
32
+ }
33
+ }
34
+ return void 0;
35
+ }, [value]);
36
+ const getMonth = React.useMemo(() => {
37
+ if (value) {
38
+ if (type === "range") {
39
+ if (value.lowest !== void 0)
40
+ return new Date(value.lowest).getMonth();
41
+ } else {
42
+ return new Date(value).getMonth();
43
+ }
44
+ }
45
+ return void 0;
46
+ }, [value]);
23
47
  return /* @__PURE__ */ React.createElement(
24
48
  reactCore.DatePicker,
25
49
  {
26
50
  ...rest,
51
+ value,
52
+ month: getMonth,
53
+ year: getYear,
54
+ type,
27
55
  TextComponent: Text,
28
56
  CalendarComponent: Calendar.Calendar,
29
57
  locale: locale ?? date.getLocale(),
@@ -7,7 +7,7 @@ require('react-native');
7
7
  var BaseModalView = require('../../atoms/Modal/ui/BaseModalView.js');
8
8
  var useLazyModalManager = require('../../atoms/Modal/useLazyModalManager.js');
9
9
  var Text = require('../../atoms/Text/Text.js');
10
- var DateTimeSelector = require('../DateTimeSelector/DateTimeSelector.js');
10
+ var DateTimePickerSelector = require('../DateTimePickerSelector/DateTimePickerSelector.js');
11
11
 
12
12
  const DateTimePicker = ({
13
13
  locale,
@@ -19,10 +19,16 @@ const DateTimePicker = ({
19
19
  {
20
20
  ...rest,
21
21
  TextComponent: Text,
22
- DateTimeSelectorComponent: DateTimeSelector.DateTimeSelector,
22
+ DateTimeSelectorComponent: (props) => /* @__PURE__ */ React.createElement(
23
+ reactCore.ControlledDateTimeSelector,
24
+ {
25
+ SelectorComponent: DateTimePickerSelector,
26
+ ...props
27
+ }
28
+ ),
23
29
  locale: locale ?? date.getLocale(),
24
- requestShowSelector: () => modal.show(),
25
- requestCloseSelector: () => modal.close(),
30
+ requestShowSelector: modal.show,
31
+ requestCloseSelector: modal.close,
26
32
  renderSelector: (selector, blur) => modal.sync(/* @__PURE__ */ React.createElement(NativeModal, { onClose: blur }, selector))
27
33
  }
28
34
  );
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var Button = require('../../atoms/Button/Button.js');
5
+ var reactCore = require('@tecsinapse/react-core');
6
+ var Text = require('../../atoms/Text/Text.js');
7
+ var ScrollableSelector = require('../ScrollableSelector/ScrollableSelector.js');
8
+ var Calendar = require('../Calendar/Calendar.js');
9
+ var styled = require('./styled.js');
10
+ var date = require('../../../utils/date.js');
11
+
12
+ function _interopNamespaceDefault(e) {
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
30
+
31
+ const DateTimePickerSelector = ({
32
+ TextComponent = Text,
33
+ currentMode,
34
+ handlePressBack,
35
+ modalTitle,
36
+ isDate,
37
+ date: date$1,
38
+ handleCalendarChange,
39
+ isMonth,
40
+ setDate,
41
+ handlePressConfirm,
42
+ confirmButtonText,
43
+ locale,
44
+ yearLabel,
45
+ monthLabel,
46
+ hourLabel,
47
+ minuteLabel,
48
+ ...rest
49
+ }) => {
50
+ return /* @__PURE__ */ React__namespace.createElement(styled.Root, { ...rest }, /* @__PURE__ */ React__namespace.createElement(styled.Header, null, currentMode === 1 && /* @__PURE__ */ React__namespace.createElement(styled.BackButton, { onPress: handlePressBack }, /* @__PURE__ */ React__namespace.createElement(
51
+ reactCore.Icon,
52
+ {
53
+ type: "material-community",
54
+ name: "chevron-left",
55
+ size: "mega",
56
+ colorVariant: "secondary"
57
+ }
58
+ )), /* @__PURE__ */ React__namespace.createElement(TextComponent, { typography: "base", colorVariant: "secondary" }, modalTitle)), isDate ? /* @__PURE__ */ React__namespace.createElement(
59
+ Calendar.Calendar,
60
+ {
61
+ type: "day",
62
+ value: date$1,
63
+ onChange: handleCalendarChange,
64
+ year: date$1.getFullYear(),
65
+ month: date$1.getMonth()
66
+ }
67
+ ) : isMonth ? /* @__PURE__ */ React__namespace.createElement(styled.Content, null, /* @__PURE__ */ React__namespace.createElement(
68
+ ScrollableSelector,
69
+ {
70
+ onChange: setDate,
71
+ value: date$1,
72
+ yearLabel,
73
+ monthLabel,
74
+ format: "MM-yyyy",
75
+ locale: locale ?? date.getLocale()
76
+ }
77
+ )) : /* @__PURE__ */ React__namespace.createElement(styled.Content, null, /* @__PURE__ */ React__namespace.createElement(
78
+ ScrollableSelector,
79
+ {
80
+ onChange: setDate,
81
+ value: date$1,
82
+ hourLabel,
83
+ minuteLabel,
84
+ format: "HH-mm",
85
+ locale: locale ?? date.getLocale()
86
+ }
87
+ )), /* @__PURE__ */ React__namespace.createElement(Button.Button, { color: "primary", onPress: handlePressConfirm }, /* @__PURE__ */ React__namespace.createElement(TextComponent, { fontWeight: "bold", fontColor: "light" }, confirmButtonText || "OK")));
88
+ };
89
+
90
+ module.exports = DateTimePickerSelector;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var styled = require('@emotion/native');
4
+ var reactCore = require('@tecsinapse/react-core');
5
+
6
+ const Root = styled.View`
7
+ position: relative;
8
+ background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};
9
+ `;
10
+ const Content = styled.View`
11
+ flex-direction: row;
12
+ justify-content: space-between;
13
+ margin-top: ${({ theme }) => theme.spacing.deca};
14
+ margin-bottom: ${({ theme }) => theme.spacing.deca};
15
+ `;
16
+ const BackButton = styled(reactCore.PressableSurface)`
17
+ border-radius: ${({ theme }) => theme.borderRadius.mili};
18
+ padding: ${({ theme }) => theme.spacing.micro};
19
+ margin-right: ${({ theme }) => theme.spacing.mili};
20
+ aspect-ratio: 1;
21
+ `;
22
+ const Header = styled.View`
23
+ flex-direction: row;
24
+ align-items: center;
25
+ margin-top: ${({ theme }) => theme.spacing.mili};
26
+ margin-bottom: ${({ theme }) => theme.spacing.mili};
27
+ `;
28
+
29
+ exports.BackButton = BackButton;
30
+ exports.Content = Content;
31
+ exports.Header = Header;
32
+ exports.Root = Root;
@@ -0,0 +1,146 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var reactNative = require('react-native');
5
+ var Text = require('../../atoms/Text/Text.js');
6
+ var styled = require('./styled.js');
7
+ var DateBlock = require('./components/DateBlock.js');
8
+ var date = require('../../../utils/date.js');
9
+
10
+ const ScrollableSelector = ({
11
+ value,
12
+ onChange,
13
+ height,
14
+ width,
15
+ fontSize,
16
+ textColor,
17
+ startYear,
18
+ endYear,
19
+ markColor,
20
+ markHeight,
21
+ markWidth,
22
+ format,
23
+ monthLabel,
24
+ yearLabel,
25
+ hourLabel,
26
+ minuteLabel,
27
+ TextComponent = Text,
28
+ locale = date.getLocale()
29
+ }) => {
30
+ const date = React.useMemo(() => value ?? /* @__PURE__ */ new Date(), [value]);
31
+ const [months, setMonths] = React.useState([]);
32
+ const [years, setYears] = React.useState([]);
33
+ const [hour, setHour] = React.useState([]);
34
+ const [minutes, setMinutes] = React.useState([]);
35
+ React.useEffect(() => {
36
+ const end = endYear || (/* @__PURE__ */ new Date()).getFullYear();
37
+ const start = !startYear || startYear > end ? end - 100 : startYear;
38
+ const _months = [...Array(12)].map((_, index) => index + 1);
39
+ const _years = [...Array(end - start + 1)].map((_, index) => start + index);
40
+ const _hour = [...Array(24)].map((_, index) => index);
41
+ const _minutes = [...Array(60)].map((_, index) => index);
42
+ setMonths(_months);
43
+ setYears(_years);
44
+ setHour(_hour);
45
+ setMinutes(_minutes);
46
+ }, []);
47
+ const pickerHeight = Math.round(
48
+ height ?? reactNative.Dimensions.get("window").height / 3.5
49
+ );
50
+ const pickerWidth = width ?? "100%";
51
+ const changeHandle = React.useCallback(
52
+ (type, digit) => {
53
+ switch (type) {
54
+ case "month":
55
+ date.setMonth(digit - 1);
56
+ break;
57
+ case "year":
58
+ date.setFullYear(digit);
59
+ break;
60
+ case "hour":
61
+ date.setHours(digit);
62
+ break;
63
+ case "minutes":
64
+ date.setMinutes(digit);
65
+ }
66
+ onChange?.(date);
67
+ },
68
+ [date]
69
+ );
70
+ const getOrder = React.useCallback(() => {
71
+ return (format || "dd-MM-yyyy").split("-").map((type, index) => {
72
+ switch (type) {
73
+ case "MM":
74
+ return {
75
+ name: "month",
76
+ digits: months,
77
+ value: date.getMonth() + 1
78
+ };
79
+ case "yyyy":
80
+ return { name: "year", digits: years, value: date.getFullYear() };
81
+ case "HH":
82
+ return { name: "hour", digits: hour, value: date.getHours() };
83
+ case "mm":
84
+ return {
85
+ name: "minutes",
86
+ digits: minutes,
87
+ value: date.getMinutes()
88
+ };
89
+ default:
90
+ return {
91
+ name: ["day", "month", "year", "hour", "minutes"][index],
92
+ digits: [months, years, hour, minutes][index],
93
+ value: [
94
+ date.getDate(),
95
+ date.getMonth() + 1,
96
+ date.getFullYear(),
97
+ date.getHours(),
98
+ date.getMinutes()
99
+ ][index]
100
+ };
101
+ }
102
+ });
103
+ }, [format, date, months, years, hour, minutes]);
104
+ return /* @__PURE__ */ React.createElement(reactNative.View, { style: { flexDirection: "column", width: "100%" } }, /* @__PURE__ */ React.createElement(styled.BlockLabels, null, format === "MM-yyyy" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TextComponent, null, monthLabel), /* @__PURE__ */ React.createElement(TextComponent, null, yearLabel)) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TextComponent, null, hourLabel), /* @__PURE__ */ React.createElement(TextComponent, null, minuteLabel))), /* @__PURE__ */ React.createElement(
105
+ reactNative.View,
106
+ {
107
+ style: [styles.picker, { height: pickerHeight, width: pickerWidth }]
108
+ },
109
+ getOrder().map((el, index) => {
110
+ return /* @__PURE__ */ React.createElement(
111
+ DateBlock,
112
+ {
113
+ date: value ?? /* @__PURE__ */ new Date(),
114
+ digits: el.digits,
115
+ value: el.value,
116
+ onChange: changeHandle,
117
+ height: pickerHeight,
118
+ fontSize: fontSize ?? 22,
119
+ textColor,
120
+ markColor,
121
+ markHeight,
122
+ markWidth: markWidth ?? 70,
123
+ type: el.name,
124
+ key: index,
125
+ locale
126
+ }
127
+ );
128
+ })
129
+ ));
130
+ };
131
+ const styles = reactNative.StyleSheet.create({
132
+ picker: {
133
+ flexDirection: "row",
134
+ width: "100%"
135
+ },
136
+ digit: {
137
+ fontSize: 20,
138
+ textAlign: "center"
139
+ },
140
+ gradient: {
141
+ position: "absolute",
142
+ width: "100%"
143
+ }
144
+ });
145
+
146
+ module.exports = ScrollableSelector;
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var reactNative = require('react-native');
5
+ var styled = require('../styled.js');
6
+ var dateFns = require('date-fns');
7
+
8
+ const DateBlock = ({
9
+ value,
10
+ digits,
11
+ type,
12
+ onChange,
13
+ height = 170,
14
+ fontSize,
15
+ textColor,
16
+ markColor,
17
+ markHeight,
18
+ markWidth,
19
+ TextComponent = reactNative.Text,
20
+ locale
21
+ }) => {
22
+ const months = [...Array(12)].map(
23
+ (_, index) => dateFns.format((/* @__PURE__ */ new Date()).setMonth(index), "MMM", { locale })
24
+ );
25
+ const dHeight = Math.round(height / 4);
26
+ const mHeight = markHeight ?? Math.min(dHeight, 65);
27
+ const mWidth = markWidth ?? 70;
28
+ const offsets = digits.map((_, index) => index * dHeight);
29
+ const scrollRef = React.useRef(null);
30
+ const snapScrollToIndex = (index) => {
31
+ scrollRef?.current?.scrollTo({ y: dHeight * index, animated: true });
32
+ };
33
+ React.useEffect(() => {
34
+ snapScrollToIndex(value - digits[0]);
35
+ }, [scrollRef.current]);
36
+ const handleMomentumScrollEnd = ({ nativeEvent }) => {
37
+ const digit = Math.round(nativeEvent.contentOffset.y / dHeight + digits[0]);
38
+ onChange(type, digit);
39
+ };
40
+ const getDisplayedValue = (granularity) => (value2) => {
41
+ if (granularity === "month") {
42
+ return months[value2 - 1];
43
+ } else {
44
+ return value2.toString().padStart(2, "0");
45
+ }
46
+ };
47
+ return /* @__PURE__ */ React.createElement(styled.Block, null, /* @__PURE__ */ React.createElement(
48
+ styled.Mark,
49
+ {
50
+ markTop: (height - mHeight) / 2,
51
+ markColor: markColor ?? "rgba(0, 0, 0, 0.05)",
52
+ markHeight: 24,
53
+ markWidth: mWidth
54
+ }
55
+ ), /* @__PURE__ */ React.createElement(
56
+ styled.StyledScrollView,
57
+ {
58
+ ref: scrollRef,
59
+ snapToOffsets: offsets,
60
+ decelerationRate: "fast",
61
+ showsVerticalScrollIndicator: false,
62
+ scrollEventThrottle: 0,
63
+ onMomentumScrollEnd: handleMomentumScrollEnd,
64
+ fadingEdgeLength: 300
65
+ },
66
+ digits.map((value2, index) => {
67
+ return /* @__PURE__ */ React.createElement(
68
+ reactNative.TouchableOpacity,
69
+ {
70
+ key: index,
71
+ onPress: () => {
72
+ onChange(type, digits[index]);
73
+ snapScrollToIndex(index);
74
+ }
75
+ },
76
+ /* @__PURE__ */ React.createElement(
77
+ TextComponent,
78
+ {
79
+ style: {
80
+ textAlign: "center",
81
+ fontSize: fontSize || 22,
82
+ color: textColor || "#000000",
83
+ marginBottom: index === digits.length - 1 ? height / 2 - dHeight / 2 : 0,
84
+ marginTop: index === 0 ? height / 2 - dHeight / 2 : 0,
85
+ lineHeight: dHeight,
86
+ height: dHeight,
87
+ textTransform: "capitalize"
88
+ }
89
+ },
90
+ getDisplayedValue(type)(value2)
91
+ )
92
+ );
93
+ })
94
+ ));
95
+ };
96
+
97
+ module.exports = DateBlock;
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var styled = require('@emotion/native');
4
+ var reactNative = require('react-native');
5
+
6
+ styled.View`
7
+ flex-direction: row;
8
+ width: 100%;
9
+ `;
10
+ const Block = styled.View`
11
+ flex: 1;
12
+ align-items: center;
13
+ justify-content: center;
14
+ flex-direction: row;
15
+ height: 100%;
16
+ `;
17
+ const BlockLabels = styled.View`
18
+ flex-direction: row;
19
+ width: 100%;
20
+ justify-content: space-around;
21
+ margin-bottom: 10px;
22
+ `;
23
+ styled.ScrollView`
24
+ width: 100%;
25
+ `;
26
+ styled.Text`
27
+ font-size: ${({ fontSize }) => `${fontSize}px`};
28
+ text-align: center;
29
+ color: #000000;
30
+ margin-bottom: ${({ marginBottom }) => `${marginBottom}px`};
31
+ margin-top: ${({ marginTop }) => `${marginTop}px`};
32
+ line-height: ${({ lineHeight }) => `${lineHeight}px`};
33
+ height: ${({ height }) => `${height}px`};
34
+ `;
35
+ const Mark = styled.View`
36
+ position: absolute;
37
+ border-radius: 10px;
38
+ background-color: ${({ theme }) => theme.color.primary.light};
39
+ height: ${({ markHeight }) => `${markHeight}px`};
40
+ width: ${({ markWidth }) => `${markWidth}px`};
41
+ `;
42
+ const StyledScrollView = styled(reactNative.ScrollView)`
43
+ width: 100%;
44
+ `;
45
+
46
+ exports.Block = Block;
47
+ exports.BlockLabels = BlockLabels;
48
+ exports.Mark = Mark;
49
+ exports.StyledScrollView = StyledScrollView;
@@ -3,7 +3,6 @@
3
3
  var styled = require('@emotion/native');
4
4
  var reactCore = require('@tecsinapse/react-core');
5
5
  var reactNative = require('react-native');
6
- var Input = require('../../atoms/Input/Input.js');
7
6
  var Text = require('../../atoms/Text/Text.js');
8
7
 
9
8
  const getStyledModal = (safeTop = 0) => {
@@ -19,15 +18,6 @@ const StyledSelectionText = styled(Text)(
19
18
  ${reactCore.disabledInputStyles(props)};
20
19
  `
21
20
  );
22
- styled(reactNative.View)`
23
- aspect-ratio: 1;
24
- height: 100%;
25
- `;
26
- styled(
27
- reactCore.PressableSurface
28
- )`
29
- width: 100%;
30
- `;
31
21
  styled(reactNative.View)`
32
22
  position: relative;
33
23
  width: 100%;
@@ -38,22 +28,17 @@ styled(reactNative.View)`
38
28
  padding: ${({ theme }) => theme.spacing.deca};
39
29
  height: ${reactCore.RFValueStr("75px")};
40
30
  `;
41
- styled(reactCore.Button)`
42
- aspect-ratio: 1;
43
- height: 100%;
44
- `;
45
31
  const SearchBarContainer = styled(reactNative.View)`
46
32
  padding: ${({ theme }) => theme.spacing.deca};
47
33
  position: relative;
48
34
  `;
49
- styled(Input)`
50
- margin-bottom: ${({ theme }) => theme.spacing.deca};
51
- `;
52
35
  const ListItem = styled(reactCore.PressableSurface)`
53
36
  border-bottom-width: ${reactCore.RFValueStr("1px")};
54
37
  border-color: ${({ theme }) => theme.color.secondary.light};
55
- padding-vertical: ${({ theme }) => theme.spacing.mili};
56
- padding-horizontal: ${({ theme }) => theme.spacing.deca};
38
+ padding-top: ${({ theme }) => theme.spacing.mili};
39
+ padding-bottom: ${({ theme }) => theme.spacing.mili};
40
+ padding-left: ${({ theme }) => theme.spacing.deca};
41
+ padding-right: ${({ theme }) => theme.spacing.deca};
57
42
  `;
58
43
  const ModalFooter = styled(reactNative.View)`
59
44
  width: 100%;
package/dist/cjs/index.js CHANGED
@@ -26,7 +26,7 @@ var TextArea = require('./components/atoms/TextArea/TextArea.js');
26
26
  var Calendar = require('./components/molecules/Calendar/Calendar.js');
27
27
  var DatePicker = require('./components/molecules/DatePicker/DatePicker.js');
28
28
  var DateTimePicker = require('./components/molecules/DateTimePicker/DateTimePicker.js');
29
- var DateTimeSelector = require('./components/molecules/DateTimeSelector/DateTimeSelector.js');
29
+ var DateTimePickerSelector = require('./components/molecules/DateTimePickerSelector/DateTimePickerSelector.js');
30
30
  var IconTextButton = require('./components/molecules/IconTextButton/IconTextButton.js');
31
31
  var InputPassword = require('./components/molecules/InputPassword/InputPassword.js');
32
32
  var LabeledSwitch = require('./components/molecules/LabeledSwitch/LabeledSwitch.js');
@@ -62,7 +62,7 @@ exports.TextArea = TextArea;
62
62
  exports.Calendar = Calendar.Calendar;
63
63
  exports.DatePicker = DatePicker.DatePicker;
64
64
  exports.DateTimePicker = DateTimePicker.DateTimePicker;
65
- exports.DateTimeSelector = DateTimeSelector.DateTimeSelector;
65
+ exports.DateTimePickerSelector = DateTimePickerSelector;
66
66
  exports.IconTextButton = IconTextButton;
67
67
  exports.InputPassword = InputPassword;
68
68
  exports.LabeledSwitch = LabeledSwitch;
@@ -1,5 +1,5 @@
1
1
  import { DatePicker as DatePicker$1 } from '@tecsinapse/react-core';
2
- import React__default from 'react';
2
+ import React__default, { useMemo } from 'react';
3
3
  import { getLocale } from '../../../utils/date.js';
4
4
  import 'react-native';
5
5
  import { ModalView } from '../../atoms/Modal/ui/BaseModalView.js';
@@ -11,17 +11,45 @@ import { CalendarBoxContent } from './styled.js';
11
11
  const DatePicker = ({
12
12
  locale,
13
13
  onChange,
14
+ value,
15
+ type,
14
16
  ...rest
15
17
  }) => {
16
18
  const modal = useLazyModalManager();
17
- const handleChange = (value) => {
18
- onChange?.(value);
19
+ const handleChange = (value2) => {
20
+ onChange?.(value2);
19
21
  modal.requestUpdate();
20
22
  };
23
+ const getYear = useMemo(() => {
24
+ if (value) {
25
+ if (type === "range") {
26
+ if (value.lowest !== void 0)
27
+ return new Date(value.lowest).getFullYear();
28
+ } else {
29
+ return new Date(value).getFullYear();
30
+ }
31
+ }
32
+ return void 0;
33
+ }, [value]);
34
+ const getMonth = useMemo(() => {
35
+ if (value) {
36
+ if (type === "range") {
37
+ if (value.lowest !== void 0)
38
+ return new Date(value.lowest).getMonth();
39
+ } else {
40
+ return new Date(value).getMonth();
41
+ }
42
+ }
43
+ return void 0;
44
+ }, [value]);
21
45
  return /* @__PURE__ */ React__default.createElement(
22
46
  DatePicker$1,
23
47
  {
24
48
  ...rest,
49
+ value,
50
+ month: getMonth,
51
+ year: getYear,
52
+ type,
25
53
  TextComponent: Text,
26
54
  CalendarComponent: Calendar,
27
55
  locale: locale ?? getLocale(),
@@ -1,11 +1,11 @@
1
- import { DateTimePicker as DateTimePicker$1 } from '@tecsinapse/react-core';
1
+ import { DateTimePicker as DateTimePicker$1, ControlledDateTimeSelector } from '@tecsinapse/react-core';
2
2
  import React__default from 'react';
3
3
  import { getLocale } from '../../../utils/date.js';
4
4
  import 'react-native';
5
5
  import { ModalView } from '../../atoms/Modal/ui/BaseModalView.js';
6
6
  import { useLazyModalManager } from '../../atoms/Modal/useLazyModalManager.js';
7
7
  import Text from '../../atoms/Text/Text.js';
8
- import { DateTimeSelector } from '../DateTimeSelector/DateTimeSelector.js';
8
+ import DateTimePickerSelector from '../DateTimePickerSelector/DateTimePickerSelector.js';
9
9
 
10
10
  const DateTimePicker = ({
11
11
  locale,
@@ -17,10 +17,16 @@ const DateTimePicker = ({
17
17
  {
18
18
  ...rest,
19
19
  TextComponent: Text,
20
- DateTimeSelectorComponent: DateTimeSelector,
20
+ DateTimeSelectorComponent: (props) => /* @__PURE__ */ React__default.createElement(
21
+ ControlledDateTimeSelector,
22
+ {
23
+ SelectorComponent: DateTimePickerSelector,
24
+ ...props
25
+ }
26
+ ),
21
27
  locale: locale ?? getLocale(),
22
- requestShowSelector: () => modal.show(),
23
- requestCloseSelector: () => modal.close(),
28
+ requestShowSelector: modal.show,
29
+ requestCloseSelector: modal.close,
24
30
  renderSelector: (selector, blur) => modal.sync(/* @__PURE__ */ React__default.createElement(NativeModal, { onClose: blur }, selector))
25
31
  }
26
32
  );