@particle-network/ui-native 0.1.4-beta.0 → 0.1.4-beta.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 (72) hide show
  1. package/dist/components/UXButton/button.types.d.ts +2 -2
  2. package/dist/components/UXCheckbox/checkbox.js +5 -4
  3. package/dist/components/UXHint/index.js +3 -2
  4. package/dist/components/UXListBox/UXListBoxItem.js +3 -2
  5. package/dist/components/UXRadio/radio.js +5 -4
  6. package/dist/components/UXTabs/tab.js +3 -2
  7. package/dist/components/UXTabs/types.d.ts +1 -1
  8. package/dist/components/UXToast/ToastView.js +3 -2
  9. package/dist/components/date-picker/date-button.d.ts +8 -0
  10. package/dist/components/date-picker/date-button.js +21 -0
  11. package/dist/components/date-picker/date-picker.d.ts +3 -0
  12. package/dist/components/date-picker/date-picker.js +117 -0
  13. package/dist/components/date-picker/date-range-picker.d.ts +3 -0
  14. package/dist/components/date-picker/date-range-picker.js +195 -0
  15. package/dist/components/date-picker/date-wheel-picker.d.ts +3 -0
  16. package/dist/components/date-picker/date-wheel-picker.js +121 -0
  17. package/dist/components/date-picker/index.d.ts +3 -0
  18. package/dist/components/date-picker/index.js +2 -0
  19. package/dist/components/date-picker/time-wheel-picker.d.ts +7 -0
  20. package/dist/components/date-picker/time-wheel-picker.js +64 -0
  21. package/dist/components/date-picker/types.d.ts +93 -0
  22. package/dist/components/date-picker/types.js +0 -0
  23. package/dist/components/date-picker/utils.d.ts +6 -0
  24. package/dist/components/date-picker/utils.js +2 -0
  25. package/dist/components/date-picker/wheel-column.d.ts +12 -0
  26. package/dist/components/date-picker/wheel-column.js +152 -0
  27. package/dist/components/index.d.ts +1 -0
  28. package/dist/components/index.js +1 -0
  29. package/dist/components/input/input.js +3 -2
  30. package/dist/components/input/number-input.js +3 -2
  31. package/dist/config/config.street.d.ts +2 -0
  32. package/dist/config/{config.ux.js → config.street.js} +2 -2
  33. package/dist/config/index.d.ts +1 -1
  34. package/dist/config/index.js +2 -2
  35. package/dist/hooks/index.d.ts +2 -0
  36. package/dist/hooks/index.js +2 -0
  37. package/dist/hooks/useI18n.d.ts +5 -0
  38. package/dist/hooks/useI18n.js +7 -0
  39. package/dist/hooks/useLocale.d.ts +8 -0
  40. package/dist/hooks/useLocale.js +9 -0
  41. package/dist/icons/{DotIcon.d.ts → index.d.ts} +1 -2
  42. package/dist/icons/index.js +152 -0
  43. package/dist/icons/types.d.ts +1 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/locales/en.d.ts +35 -0
  47. package/dist/locales/en.js +35 -0
  48. package/dist/locales/index.d.ts +107 -0
  49. package/dist/locales/index.js +12 -0
  50. package/dist/locales/zh.d.ts +2 -0
  51. package/dist/locales/zh.js +35 -0
  52. package/dist/provider/ThemeContext.js +2 -0
  53. package/dist/provider/ThemeProvider.d.ts +4 -2
  54. package/dist/provider/ThemeProvider.js +9 -3
  55. package/dist/types/theme.d.ts +4 -0
  56. package/package.json +6 -4
  57. package/dist/config/config.ux.d.ts +0 -2
  58. package/dist/icons/CheckIcon.d.ts +0 -4
  59. package/dist/icons/CheckIcon.js +0 -20
  60. package/dist/icons/CheckboxOffIcon.d.ts +0 -4
  61. package/dist/icons/CheckboxOffIcon.js +0 -21
  62. package/dist/icons/CheckboxOnIcon.d.ts +0 -4
  63. package/dist/icons/CheckboxOnIcon.js +0 -26
  64. package/dist/icons/CloseIcon.d.ts +0 -4
  65. package/dist/icons/CloseIcon.js +0 -21
  66. package/dist/icons/DotIcon.js +0 -23
  67. package/dist/icons/QuestionIcon.d.ts +0 -4
  68. package/dist/icons/QuestionIcon.js +0 -21
  69. package/dist/icons/RadioOffIcon.d.ts +0 -4
  70. package/dist/icons/RadioOffIcon.js +0 -22
  71. package/dist/icons/RadioOnIcon.d.ts +0 -4
  72. package/dist/icons/RadioOnIcon.js +0 -42
@@ -8,7 +8,7 @@ export interface UXButtonProps extends Omit<UXPressableProps, 'style' | 'disable
8
8
  /**
9
9
  * 按钮尺寸
10
10
  * @default 'md'
11
- * | size | ux-pro | ux |
11
+ * | size | ux | street |
12
12
  * | :----- | :----- | :----- |
13
13
  * | xs | 20 | 36 |
14
14
  * | sm | 24 | 40 |
@@ -16,7 +16,7 @@ export interface UXButtonProps extends Omit<UXPressableProps, 'style' | 'disable
16
16
  * | lg | 44 | 48 |
17
17
  *
18
18
  * fontSize
19
- * | size | ux-pro | ux |
19
+ * | size | ux | street |
20
20
  * | :----- | :----- | :----- |
21
21
  * | xs | 11 | 12 |
22
22
  * | sm | 10 | 14 |
@@ -1,8 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { useMs } from "../../hooks/index.js";
4
- import CheckboxOffIcon from "../../icons/CheckboxOffIcon.js";
5
- import CheckboxOnIcon from "../../icons/CheckboxOnIcon.js";
4
+ import { Icon } from "../../icons/index.js";
6
5
  import { disabledOpacity } from "../../theme/index.js";
7
6
  import { Flex } from "../layout/Flex/index.js";
8
7
  import { Text } from "../Text/index.js";
@@ -62,10 +61,12 @@ const UXCheckbox = ({ size, color, defaultSelected = false, isSelected, children
62
61
  items: "center",
63
62
  ...props,
64
63
  children: [
65
- internalSelected ? /*#__PURE__*/ jsx(CheckboxOnIcon, {
64
+ internalSelected ? /*#__PURE__*/ jsx(Icon, {
65
+ name: "checkboxOn",
66
66
  color: checkboxColor,
67
67
  size: iconSize
68
- }) : /*#__PURE__*/ jsx(CheckboxOffIcon, {
68
+ }) : /*#__PURE__*/ jsx(Icon, {
69
+ name: "checkboxOff",
69
70
  color: "secondary",
70
71
  size: iconSize
71
72
  }),
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { useMs } from "../../hooks/index.js";
4
- import QuestionIcon from "../../icons/QuestionIcon.js";
4
+ import { Icon } from "../../icons/index.js";
5
5
  import { Square } from "../layout/Square.js";
6
6
  import { UXTooltip } from "../UXTooltip/index.js";
7
7
  const UXHint = (props)=>{
@@ -14,7 +14,8 @@ const UXHint = (props)=>{
14
14
  center: true,
15
15
  size: 20,
16
16
  style: style,
17
- children: /*#__PURE__*/ jsx(QuestionIcon, {
17
+ children: /*#__PURE__*/ jsx(Icon, {
18
+ name: "question",
18
19
  color: "secondary",
19
20
  size: ms(14),
20
21
  style: iconStyle
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { useMs } from "../../hooks/index.js";
4
- import CheckIcon from "../../icons/CheckIcon.js";
4
+ import { Icon } from "../../icons/index.js";
5
5
  import { HStack } from "../layout/HStack.js";
6
6
  import { Text } from "../Text/index.js";
7
7
  import { UXTouchableOpacity } from "../UXTouchableOpacity/index.js";
@@ -47,7 +47,8 @@ const UXListBoxItem = ({ value = '', startContent, isDisabled = false, onPress,
47
47
  })
48
48
  ]
49
49
  }),
50
- selectionMode && isSelected ? /*#__PURE__*/ jsx(CheckIcon, {
50
+ selectionMode && isSelected ? /*#__PURE__*/ jsx(Icon, {
51
+ name: "check",
51
52
  size: ms(16),
52
53
  color: "foreground"
53
54
  }) : null
@@ -2,8 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from "react";
3
3
  import { Pressable } from "react-native";
4
4
  import { useMs } from "../../hooks/index.js";
5
- import RadioOffIcon from "../../icons/RadioOffIcon.js";
6
- import RadioOnIcon from "../../icons/RadioOnIcon.js";
5
+ import { Icon } from "../../icons/index.js";
7
6
  import { disabledOpacity } from "../../theme/index.js";
8
7
  import { Flex } from "../layout/Flex/index.js";
9
8
  import { Text } from "../Text/index.js";
@@ -50,10 +49,12 @@ const UXRadio = ({ size, color, children, value, isDisabled, ...props })=>{
50
49
  items: "center",
51
50
  ...props,
52
51
  children: [
53
- isSelected ? /*#__PURE__*/ jsx(RadioOnIcon, {
52
+ isSelected ? /*#__PURE__*/ jsx(Icon, {
53
+ name: "radioOn",
54
54
  color: radioColor,
55
55
  size: iconSize
56
- }) : /*#__PURE__*/ jsx(RadioOffIcon, {
56
+ }) : /*#__PURE__*/ jsx(Icon, {
57
+ name: "radioOff",
57
58
  color: "secondary",
58
59
  size: iconSize
59
60
  }),
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from "react";
3
- import DotIcon from "../../icons/DotIcon.js";
3
+ import { Icon } from "../../icons/index.js";
4
4
  import { Box } from "../layout/Box/index.js";
5
5
  import { HStack } from "../layout/HStack.js";
6
6
  import { Text } from "../Text/index.js";
@@ -42,7 +42,8 @@ const UXTab = ({ tabKey = '', title, icon, style, notification })=>{
42
42
  style: styles.tabText,
43
43
  children: title
44
44
  }),
45
- notification ? /*#__PURE__*/ jsx(DotIcon, {
45
+ notification ? /*#__PURE__*/ jsx(Icon, {
46
+ name: "dot",
46
47
  color: "danger",
47
48
  size: 5,
48
49
  style: {
@@ -13,7 +13,7 @@ export interface UXTabsProps extends HStackProps {
13
13
  * | light | 24 | 30 | 34 |
14
14
  *
15
15
  * variant-text 字号对比
16
- * | text | ux-pro | ux |
16
+ * | text | ux | street |
17
17
  * | ------- | ------ | ----- |
18
18
  * | sm | 12 | 14 |
19
19
  * | md | 14 | 16 |
@@ -6,7 +6,7 @@ import { HStack } from "../layout/HStack.js";
6
6
  import { Text } from "../Text/index.js";
7
7
  import { UXButton } from "../UXButton/index.js";
8
8
  import { useComponentConfig, useTheme } from "../../hooks/index.js";
9
- import CloseIcon from "../../icons/CloseIcon.js";
9
+ import { Icon } from "../../icons/index.js";
10
10
  import { ToastIcon } from "./ToastIcon.js";
11
11
  const ToastView = ({ type, text, props: toastProps })=>{
12
12
  const { btnText, numberOfLines = 4, colorBg, onPress = ()=>null } = toastProps ?? {};
@@ -63,7 +63,8 @@ const ToastView = ({ type, text, props: toastProps })=>{
63
63
  /*#__PURE__*/ jsx(UXButton, {
64
64
  variant: "text",
65
65
  onPress: ()=>react_native_toast_message.hide(),
66
- children: /*#__PURE__*/ jsx(CloseIcon, {
66
+ children: /*#__PURE__*/ jsx(Icon, {
67
+ name: "close",
67
68
  color: colorBg ? 'white' : 'foreground',
68
69
  size: 18
69
70
  })
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { type UXPressableProps } from '../UXPressable';
3
+ interface DateButtonProps extends UXPressableProps {
4
+ isSelected?: boolean;
5
+ text: string;
6
+ }
7
+ declare const DateButton: React.FC<DateButtonProps>;
8
+ export default DateButton;
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Text } from "../Text/index.js";
4
+ import { UXPressable } from "../UXPressable/index.js";
5
+ const DateButton = ({ isSelected, text, ...props })=>/*#__PURE__*/ jsx(UXPressable, {
6
+ fill: true,
7
+ center: true,
8
+ border: 1,
9
+ h: 30,
10
+ radius: "xs",
11
+ borderColor: isSelected ? 'primary' : 'bg-200',
12
+ bg: "bg-200",
13
+ ...props,
14
+ children: /*#__PURE__*/ jsx(Text, {
15
+ body3Bold: true,
16
+ color: isSelected ? 'foreground' : 'secondary',
17
+ children: text
18
+ })
19
+ });
20
+ const date_button = DateButton;
21
+ export { date_button as default };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { UXDatePickerProps } from './types';
3
+ export declare const UXDatePicker: React.FC<UXDatePickerProps>;
@@ -0,0 +1,117 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useState } from "react";
3
+ import dayjs from "dayjs";
4
+ import { useI18n } from "../../hooks/index.js";
5
+ import { UXInput } from "../input/index.js";
6
+ import { HStack } from "../layout/HStack.js";
7
+ import { VStack } from "../layout/VStack.js";
8
+ import { UXButton } from "../UXButton/index.js";
9
+ import { UXModal } from "../UXModal/index.js";
10
+ import { UXPressable } from "../UXPressable/index.js";
11
+ import date_button from "./date-button.js";
12
+ import { DateWheelPicker } from "./date-wheel-picker.js";
13
+ import { TimeWheelPicker } from "./time-wheel-picker.js";
14
+ import { hasTimeInFormat } from "./utils.js";
15
+ const UXDatePicker = ({ value, defaultValue, onConfirm = ()=>null, format = 'YYYY/MM/DD', minDate, maxDate, placeholder, isDisabled = false, isReadOnly = false, ...uxPressableProps })=>{
16
+ const [isOpen, setIsOpen] = useState(false);
17
+ const [pickerType, setPickerType] = useState('date');
18
+ const [internalValue, setInternalValue] = useState(value || defaultValue || new Date());
19
+ const i18n = useI18n();
20
+ const [dateFormat, timeFormat] = format.split(' ');
21
+ const showTimePicker = hasTimeInFormat(format);
22
+ const displayPlaceholder = placeholder ?? format;
23
+ useEffect(()=>{
24
+ if (void 0 !== value) setInternalValue(value);
25
+ }, [
26
+ value
27
+ ]);
28
+ const handleOpenModal = useCallback((picker)=>{
29
+ if (isDisabled || isReadOnly) return;
30
+ setPickerType(picker);
31
+ setIsOpen(true);
32
+ }, [
33
+ isDisabled,
34
+ isReadOnly
35
+ ]);
36
+ const handleConfirm = useCallback(()=>{
37
+ onConfirm(internalValue);
38
+ setIsOpen(false);
39
+ }, [
40
+ internalValue,
41
+ onConfirm
42
+ ]);
43
+ const handleClose = useCallback(()=>{
44
+ setIsOpen(false);
45
+ }, []);
46
+ return /*#__PURE__*/ jsxs(Fragment, {
47
+ children: [
48
+ /*#__PURE__*/ jsx(UXPressable, {
49
+ onPress: ()=>handleOpenModal('date'),
50
+ ...uxPressableProps,
51
+ children: /*#__PURE__*/ jsx(UXInput, {
52
+ containerStyle: {
53
+ flex: 1
54
+ },
55
+ editable: false,
56
+ isDisabled: isDisabled,
57
+ isReadOnly: isReadOnly,
58
+ placeholder: displayPlaceholder,
59
+ pointerEvents: "none",
60
+ value: value ? dayjs(value).format(format) : format
61
+ })
62
+ }),
63
+ /*#__PURE__*/ jsx(UXModal, {
64
+ disableCloseBySwipe: true,
65
+ wrapPortal: true,
66
+ footer: /*#__PURE__*/ jsx(UXButton, {
67
+ fullWidth: true,
68
+ color: "primary",
69
+ size: "lg",
70
+ onPress: handleConfirm,
71
+ children: i18n.datePicker.confirm
72
+ }),
73
+ isOpen: isOpen,
74
+ scrollViewProps: {
75
+ scrollEnabled: false
76
+ },
77
+ title: i18n.datePicker.confirm,
78
+ onClose: handleClose,
79
+ children: /*#__PURE__*/ jsxs(VStack, {
80
+ fullWidth: true,
81
+ gap: "lg",
82
+ children: [
83
+ /*#__PURE__*/ jsxs(HStack, {
84
+ fullWidth: true,
85
+ items: "center",
86
+ gap: 8,
87
+ children: [
88
+ /*#__PURE__*/ jsx(date_button, {
89
+ isSelected: 'date' === pickerType,
90
+ text: dayjs(internalValue).format(dateFormat),
91
+ onPress: ()=>setPickerType('date')
92
+ }),
93
+ showTimePicker && /*#__PURE__*/ jsx(date_button, {
94
+ isSelected: 'time' === pickerType,
95
+ text: dayjs(internalValue).format(timeFormat),
96
+ onPress: ()=>setPickerType('time')
97
+ })
98
+ ]
99
+ }),
100
+ 'date' === pickerType && /*#__PURE__*/ jsx(DateWheelPicker, {
101
+ maxDate: maxDate,
102
+ minDate: minDate,
103
+ selectedDate: internalValue,
104
+ onDateChange: setInternalValue
105
+ }),
106
+ 'time' === pickerType && /*#__PURE__*/ jsx(TimeWheelPicker, {
107
+ selectedDate: internalValue,
108
+ onDateChange: setInternalValue
109
+ })
110
+ ]
111
+ })
112
+ })
113
+ ]
114
+ });
115
+ };
116
+ UXDatePicker.displayName = 'UXDatePicker';
117
+ export { UXDatePicker };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { UXDateRangePickerProps } from './types';
3
+ export declare const UXDateRangePicker: React.FC<UXDateRangePickerProps>;
@@ -0,0 +1,195 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useState } from "react";
3
+ import dayjs from "dayjs";
4
+ import { useI18n } from "../../hooks/index.js";
5
+ import { Icon } from "../../icons/index.js";
6
+ import { UXInput } from "../input/index.js";
7
+ import { HStack } from "../layout/HStack.js";
8
+ import { VStack } from "../layout/VStack.js";
9
+ import { Text } from "../Text/index.js";
10
+ import { UXButton } from "../UXButton/index.js";
11
+ import { UXModal } from "../UXModal/index.js";
12
+ import { UXPressable } from "../UXPressable/index.js";
13
+ import date_button from "./date-button.js";
14
+ import { DateWheelPicker } from "./date-wheel-picker.js";
15
+ import { TimeWheelPicker } from "./time-wheel-picker.js";
16
+ import { hasTimeInFormat } from "./utils.js";
17
+ const UXDateRangePicker = ({ value, defaultValue, onConfirm = ()=>null, format = 'YYYY/MM/DD', minDate, maxDate, startPlaceholder, endPlaceholder, isDisabled = false, isReadOnly = false, ...hStackProps })=>{
18
+ const [isOpen, setIsOpen] = useState(false);
19
+ const [currentEditType, setCurrentEditType] = useState('start');
20
+ const [pickerType, setPickerType] = useState('date');
21
+ const [internalStart, setInternalStart] = useState(value?.start || defaultValue?.start || new Date());
22
+ const [internalEnd, setInternalEnd] = useState(value?.end || defaultValue?.end || new Date());
23
+ const [error, setError] = useState('');
24
+ const i18n = useI18n();
25
+ const [dateFormat, timeFormat] = format.split(' ');
26
+ const showTimePicker = hasTimeInFormat(format);
27
+ const displayStartPlaceholder = startPlaceholder ?? format;
28
+ const displayEndPlaceholder = endPlaceholder ?? format;
29
+ useEffect(()=>{
30
+ if (value?.start !== void 0) setInternalStart(value?.start);
31
+ if (value?.end !== void 0) setInternalEnd(value?.end);
32
+ }, [
33
+ value
34
+ ]);
35
+ const handleOpenModal = useCallback((type, picker)=>{
36
+ if (isDisabled || isReadOnly) return;
37
+ setCurrentEditType(type);
38
+ setPickerType(picker);
39
+ setError('');
40
+ setIsOpen(true);
41
+ }, [
42
+ isDisabled,
43
+ isReadOnly
44
+ ]);
45
+ const handleConfirm = useCallback(()=>{
46
+ if (!internalStart || !internalEnd) return void setError(i18n.datePicker.errorBothRequired);
47
+ if (internalStart > internalEnd) return void setError(i18n.datePicker.errorStartBeforeEnd);
48
+ setError('');
49
+ onConfirm({
50
+ start: internalStart,
51
+ end: internalEnd
52
+ });
53
+ setIsOpen(false);
54
+ }, [
55
+ internalStart,
56
+ internalEnd,
57
+ onConfirm,
58
+ i18n
59
+ ]);
60
+ const handleClose = useCallback(()=>{
61
+ setIsOpen(false);
62
+ }, []);
63
+ return /*#__PURE__*/ jsxs(Fragment, {
64
+ children: [
65
+ /*#__PURE__*/ jsxs(HStack, {
66
+ gap: 8,
67
+ ...hStackProps,
68
+ children: [
69
+ /*#__PURE__*/ jsx(UXPressable, {
70
+ fill: true,
71
+ onPress: ()=>handleOpenModal('start', 'date'),
72
+ children: /*#__PURE__*/ jsx(UXInput, {
73
+ containerStyle: {
74
+ flex: 1
75
+ },
76
+ editable: false,
77
+ isDisabled: isDisabled,
78
+ isReadOnly: isReadOnly,
79
+ placeholder: displayStartPlaceholder,
80
+ pointerEvents: "none",
81
+ value: value?.start ? dayjs(value?.start).format(format) : format
82
+ })
83
+ }),
84
+ /*#__PURE__*/ jsx(Icon, {
85
+ name: "arrow-right",
86
+ color: "tertiary",
87
+ size: 16
88
+ }),
89
+ /*#__PURE__*/ jsx(UXPressable, {
90
+ fill: true,
91
+ onPress: ()=>handleOpenModal('end', 'date'),
92
+ children: /*#__PURE__*/ jsx(UXInput, {
93
+ containerStyle: {
94
+ flex: 1
95
+ },
96
+ editable: false,
97
+ isDisabled: isDisabled,
98
+ isReadOnly: isReadOnly,
99
+ placeholder: displayEndPlaceholder,
100
+ pointerEvents: "none",
101
+ value: value?.end ? dayjs(value?.end).format(format) : format
102
+ })
103
+ })
104
+ ]
105
+ }),
106
+ /*#__PURE__*/ jsx(UXModal, {
107
+ disableCloseBySwipe: true,
108
+ wrapPortal: true,
109
+ footer: /*#__PURE__*/ jsxs(VStack, {
110
+ fullWidth: true,
111
+ gap: 8,
112
+ children: [
113
+ error && /*#__PURE__*/ jsx(Text, {
114
+ color: "danger",
115
+ children: error
116
+ }),
117
+ /*#__PURE__*/ jsx(UXButton, {
118
+ fullWidth: true,
119
+ color: "primary",
120
+ size: "lg",
121
+ onPress: handleConfirm,
122
+ children: i18n.datePicker.confirm
123
+ })
124
+ ]
125
+ }),
126
+ isOpen: isOpen,
127
+ scrollViewProps: {
128
+ scrollEnabled: false
129
+ },
130
+ title: "Time Range",
131
+ onClose: handleClose,
132
+ children: /*#__PURE__*/ jsxs(VStack, {
133
+ fullWidth: true,
134
+ gap: "lg",
135
+ children: [
136
+ /*#__PURE__*/ jsxs(HStack, {
137
+ fullWidth: true,
138
+ items: "center",
139
+ gap: 8,
140
+ children: [
141
+ /*#__PURE__*/ jsx(date_button, {
142
+ isSelected: 'start' === currentEditType && 'date' === pickerType,
143
+ text: dayjs(internalStart).format(dateFormat),
144
+ onPress: ()=>handleOpenModal('start', 'date')
145
+ }),
146
+ showTimePicker && /*#__PURE__*/ jsx(date_button, {
147
+ isSelected: 'start' === currentEditType && 'time' === pickerType,
148
+ text: dayjs(internalStart).format(timeFormat),
149
+ onPress: ()=>handleOpenModal('start', 'time')
150
+ }),
151
+ /*#__PURE__*/ jsx(Icon, {
152
+ name: "arrow-right",
153
+ color: "tertiary",
154
+ size: 16
155
+ }),
156
+ /*#__PURE__*/ jsx(date_button, {
157
+ isSelected: 'end' === currentEditType && 'date' === pickerType,
158
+ text: dayjs(internalEnd).format(dateFormat),
159
+ onPress: ()=>handleOpenModal('end', 'date')
160
+ }),
161
+ showTimePicker && /*#__PURE__*/ jsx(date_button, {
162
+ isSelected: 'end' === currentEditType && 'time' === pickerType,
163
+ text: dayjs(internalEnd).format(timeFormat),
164
+ onPress: ()=>handleOpenModal('end', 'time')
165
+ })
166
+ ]
167
+ }),
168
+ 'start' === currentEditType && 'date' === pickerType && /*#__PURE__*/ jsx(DateWheelPicker, {
169
+ maxDate: maxDate,
170
+ minDate: minDate,
171
+ selectedDate: internalStart,
172
+ onDateChange: setInternalStart
173
+ }),
174
+ 'start' === currentEditType && 'time' === pickerType && /*#__PURE__*/ jsx(TimeWheelPicker, {
175
+ selectedDate: internalStart,
176
+ onDateChange: setInternalStart
177
+ }),
178
+ 'end' === currentEditType && 'date' === pickerType && /*#__PURE__*/ jsx(DateWheelPicker, {
179
+ maxDate: maxDate,
180
+ minDate: minDate,
181
+ selectedDate: internalEnd,
182
+ onDateChange: setInternalEnd
183
+ }),
184
+ 'end' === currentEditType && 'time' === pickerType && /*#__PURE__*/ jsx(TimeWheelPicker, {
185
+ selectedDate: internalEnd,
186
+ onDateChange: setInternalEnd
187
+ })
188
+ ]
189
+ })
190
+ })
191
+ ]
192
+ });
193
+ };
194
+ UXDateRangePicker.displayName = 'UXDateRangePicker';
195
+ export { UXDateRangePicker };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { WheelPickerProps } from './types';
3
+ export declare const DateWheelPicker: React.FC<WheelPickerProps>;
@@ -0,0 +1,121 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from "react";
3
+ import { useI18n, useLocale } from "../../hooks/index.js";
4
+ import { HStack } from "../layout/HStack.js";
5
+ import wheel_column from "./wheel-column.js";
6
+ const MONTHS_EN = [
7
+ 'Jan',
8
+ 'Feb',
9
+ 'Mar',
10
+ 'Apr',
11
+ 'May',
12
+ 'Jun',
13
+ 'Jul',
14
+ 'Aug',
15
+ 'Sep',
16
+ 'Oct',
17
+ 'Nov',
18
+ 'Dec'
19
+ ];
20
+ const MONTHS_ZH = [
21
+ '1月',
22
+ '2月',
23
+ '3月',
24
+ '4月',
25
+ '5月',
26
+ '6月',
27
+ '7月',
28
+ '8月',
29
+ '9月',
30
+ '10月',
31
+ '11月',
32
+ '12月'
33
+ ];
34
+ const DateWheelPicker = ({ selectedDate, onDateChange, minDate, maxDate })=>{
35
+ const i18n = useI18n();
36
+ const { locale } = useLocale();
37
+ const [month, setMonth] = useState(selectedDate.getMonth());
38
+ const [day, setDay] = useState(selectedDate.getDate());
39
+ const [year, setYear] = useState(selectedDate.getFullYear());
40
+ const years = useMemo(()=>{
41
+ const currentYear = new Date().getFullYear();
42
+ const minYear = minDate?.getFullYear() ?? currentYear - 100;
43
+ const maxYear = maxDate?.getFullYear() ?? currentYear + 100;
44
+ return Array.from({
45
+ length: maxYear - minYear + 1
46
+ }, (_, i)=>({
47
+ label: 'en' === locale ? (minYear + i).toString().padStart(4, '0') : `${minYear + i}年`,
48
+ value: minYear + i
49
+ }));
50
+ }, [
51
+ minDate,
52
+ maxDate,
53
+ locale
54
+ ]);
55
+ const daysInMonth = useMemo(()=>new Date(year, month + 1, 0).getDate(), [
56
+ year,
57
+ month
58
+ ]);
59
+ const days = useMemo(()=>Array.from({
60
+ length: daysInMonth
61
+ }, (_, i)=>({
62
+ label: 'en' === locale ? (i + 1).toString().padStart(2, '0') : `${i + 1}日`,
63
+ value: i + 1
64
+ })), [
65
+ daysInMonth,
66
+ locale
67
+ ]);
68
+ const months = useMemo(()=>('en' === locale ? MONTHS_EN : MONTHS_ZH).map((m, index)=>({
69
+ label: m,
70
+ value: index
71
+ })), [
72
+ locale
73
+ ]);
74
+ useEffect(()=>{
75
+ if (day > daysInMonth) setDay(daysInMonth);
76
+ }, [
77
+ day,
78
+ daysInMonth
79
+ ]);
80
+ useEffect(()=>{
81
+ const newDate = new Date(year, month, day);
82
+ newDate.setHours(selectedDate.getHours());
83
+ newDate.setMinutes(selectedDate.getMinutes());
84
+ newDate.setSeconds(selectedDate.getSeconds());
85
+ onDateChange(newDate);
86
+ }, [
87
+ month,
88
+ day,
89
+ year
90
+ ]);
91
+ return /*#__PURE__*/ jsxs(HStack, {
92
+ fullWidth: true,
93
+ children: [
94
+ 'zh' === locale && /*#__PURE__*/ jsx(wheel_column, {
95
+ data: years,
96
+ label: i18n.datePicker.year,
97
+ selectedValue: year,
98
+ onValueChange: setYear
99
+ }),
100
+ /*#__PURE__*/ jsx(wheel_column, {
101
+ data: months,
102
+ label: i18n.datePicker.month,
103
+ selectedValue: month,
104
+ onValueChange: setMonth
105
+ }),
106
+ /*#__PURE__*/ jsx(wheel_column, {
107
+ data: days,
108
+ label: i18n.datePicker.day,
109
+ selectedValue: day,
110
+ onValueChange: setDay
111
+ }),
112
+ 'en' === locale && /*#__PURE__*/ jsx(wheel_column, {
113
+ data: years,
114
+ label: i18n.datePicker.year,
115
+ selectedValue: year,
116
+ onValueChange: setYear
117
+ })
118
+ ]
119
+ });
120
+ };
121
+ export { DateWheelPicker };
@@ -0,0 +1,3 @@
1
+ export * from './date-picker';
2
+ export * from './date-range-picker';
3
+ export type * from './types';
@@ -0,0 +1,2 @@
1
+ export * from "./date-picker.js";
2
+ export * from "./date-range-picker.js";
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface TimeWheelPickerProps {
3
+ selectedDate: Date;
4
+ onDateChange: (date: Date) => void;
5
+ }
6
+ export declare const TimeWheelPicker: React.FC<TimeWheelPickerProps>;
7
+ export {};