@startupjs-ui/date-time-picker 0.1.22 → 0.2.0-alpha.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.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.2.0-alpha.1](https://github.com/startupjs/startupjs-ui/compare/v0.2.0-alpha.0...v0.2.0-alpha.1) (2026-04-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @startupjs-ui/date-time-picker
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.2.0-alpha.0](https://github.com/startupjs/startupjs-ui/compare/v0.1.22...v0.2.0-alpha.0) (2026-03-27)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* fix and improve accessibility of various components. Add storybook with tests. ([#21](https://github.com/startupjs/startupjs-ui/issues/21)) ([83b6576](https://github.com/startupjs/startupjs-ui/commit/83b65767ed61b24209f71b143ba1c2986170ab58))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.1.22](https://github.com/startupjs/startupjs-ui/compare/v0.1.21...v0.1.22) (2026-03-25)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @startupjs-ui/date-time-picker
|
|
@@ -37,7 +37,7 @@ function Days ({
|
|
|
37
37
|
._weekdaysShort
|
|
38
38
|
|
|
39
39
|
return data.map((day: string) => day.toUpperCase())
|
|
40
|
-
}, [uiDate, timezone, exactLocale])
|
|
40
|
+
}, [uiDate, timezone, exactLocale, moment])
|
|
41
41
|
|
|
42
42
|
const matrixMonthDays = useMemo(() => {
|
|
43
43
|
const data = []
|
|
@@ -70,7 +70,7 @@ function Days ({
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
return data
|
|
73
|
-
}, [uiDate, timezone])
|
|
73
|
+
}, [uiDate, timezone, moment])
|
|
74
74
|
|
|
75
75
|
function _onChangeDay (item: any) {
|
|
76
76
|
const timestamp = +moment
|
|
@@ -91,7 +91,7 @@ function Days ({
|
|
|
91
91
|
: false
|
|
92
92
|
|
|
93
93
|
return isDisabledDay || isBeforeMinDate || isAfterMaxDate
|
|
94
|
-
}, [disabledDays, maxDate, minDate, timezone])
|
|
94
|
+
}, [disabledDays, maxDate, minDate, timezone, moment])
|
|
95
95
|
|
|
96
96
|
function getLabelActive (value: number) {
|
|
97
97
|
return range
|
|
@@ -107,6 +107,8 @@ function Days ({
|
|
|
107
107
|
Span.shortName(bold)= shortDayName
|
|
108
108
|
|
|
109
109
|
for week, weekIndex in matrixMonthDays
|
|
110
|
+
// noop to prevent eslint error about missing 'week'. TODO: implement eslint disable comments support in pug
|
|
111
|
+
- (week => {})(week)
|
|
110
112
|
Div.row(key='week-' + weekIndex row)
|
|
111
113
|
for day, dayIndex in matrixMonthDays[weekIndex]
|
|
112
114
|
Div.cell(
|
|
@@ -38,7 +38,7 @@ function Header ({
|
|
|
38
38
|
const onChangeMonth = useCallback((value: number) => {
|
|
39
39
|
const ts = +moment($uiDate.get()).add('month', value)
|
|
40
40
|
$uiDate.set(ts)
|
|
41
|
-
}, [$uiDate])
|
|
41
|
+
}, [$uiDate, moment])
|
|
42
42
|
|
|
43
43
|
const isPrevDisabled = minDate
|
|
44
44
|
? +moment.tz($uiDate.get(), timezone).endOf('month').add('month', -1) < minDate
|
|
@@ -103,7 +103,7 @@ const Years = observer(function YearsComponent ({
|
|
|
103
103
|
const ts = +moment($uiDate.get()).year(year)
|
|
104
104
|
$uiDate.set(ts)
|
|
105
105
|
$visible.set(false)
|
|
106
|
-
}, [$uiDate, $visible])
|
|
106
|
+
}, [$uiDate, $visible, moment])
|
|
107
107
|
|
|
108
108
|
const years = useMemo(() => {
|
|
109
109
|
return new Array(yearsDiff + 1).fill(minYear).map((year, index) => {
|
|
@@ -51,10 +51,10 @@ function TimeSelect ({
|
|
|
51
51
|
if (is24Hour != null) return is24Hour
|
|
52
52
|
const lt = (moment().locale(exactLocale))._locale._longDateFormat.LT
|
|
53
53
|
return !/a/i.test(lt)
|
|
54
|
-
}, [is24Hour, exactLocale])
|
|
54
|
+
}, [is24Hour, exactLocale, moment])
|
|
55
55
|
|
|
56
56
|
const preparedData = useMemo(() => {
|
|
57
|
-
const res:
|
|
57
|
+
const res: { label: string, value: number, disabled: boolean }[] = []
|
|
58
58
|
|
|
59
59
|
let currentTimestamp = +moment.tz(date, timezone).locale(exactLocale).startOf('d')
|
|
60
60
|
const endTimestamp = +moment.tz(date, timezone).locale(exactLocale).endOf('d')
|
|
@@ -75,14 +75,14 @@ function TimeSelect ({
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return res
|
|
78
|
-
}, [date, exactLocale, timezone, timeInterval, _is24Hour, maxDate, minDate])
|
|
78
|
+
}, [date, exactLocale, timezone, timeInterval, _is24Hour, maxDate, minDate, moment])
|
|
79
79
|
|
|
80
80
|
const scrollToIndex = useCallback((_date: Date = date) => {
|
|
81
81
|
const dateTimestamp = +moment.tz(_date, timezone)
|
|
82
82
|
const index = preparedData.findIndex(item => dateTimestamp === item.value)
|
|
83
83
|
if (index === -1) return
|
|
84
84
|
refScroll.current?.scrollToIndex?.({ index, animated: false })
|
|
85
|
-
}, [date, timezone, preparedData])
|
|
85
|
+
}, [date, timezone, preparedData, moment])
|
|
86
86
|
|
|
87
87
|
useImperativeHandle(ref, () => ({ scrollToIndex }), [scrollToIndex])
|
|
88
88
|
useEffect(() => {
|
package/helpers/getLocale.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I18nManager,
|
|
1
|
+
import { I18nManager, NativeModules, Platform } from 'react-native'
|
|
2
2
|
|
|
3
3
|
export default function getLocale (): string {
|
|
4
4
|
if (Platform.OS === 'web') {
|
|
@@ -6,8 +6,9 @@ export default function getLocale (): string {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
if (Platform.OS === 'ios') {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const settings = NativeModules.SettingsManager?.settings
|
|
10
|
+
const appleLocale = settings?.AppleLocale as string | undefined
|
|
11
|
+
const appleLanguages = settings?.AppleLanguages as string[] | undefined
|
|
11
12
|
return appleLocale ?? appleLanguages?.[0] ?? 'en'
|
|
12
13
|
}
|
|
13
14
|
|
package/helpers/useMoment.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { use } from 'react'
|
|
|
2
2
|
|
|
3
3
|
let momentPromise: any
|
|
4
4
|
|
|
5
|
-
const loadMoment = (): Promise<any> => {
|
|
5
|
+
const loadMoment = (): Promise<any> => {
|
|
6
6
|
if (!momentPromise) momentPromise = import('moment-timezone').then(m => m.default)
|
|
7
7
|
return momentPromise
|
|
8
8
|
}
|
package/index.tsx
CHANGED
|
@@ -256,7 +256,7 @@ function DateTimePicker ({
|
|
|
256
256
|
const locales = moment.locales()
|
|
257
257
|
const _locale = locale ?? getLocale()
|
|
258
258
|
return locales.includes(_locale) ? _locale : 'en'
|
|
259
|
-
}, [locale])
|
|
259
|
+
}, [locale, moment])
|
|
260
260
|
|
|
261
261
|
const _dateFormat = useMemo(() => {
|
|
262
262
|
if (dateFormat) return dateFormat
|
|
@@ -267,7 +267,7 @@ function DateTimePicker ({
|
|
|
267
267
|
|
|
268
268
|
if (mode === 'date') return (moment().locale(exactLocale))._locale._longDateFormat.L
|
|
269
269
|
if (mode === 'time') return (moment().locale(exactLocale))._locale._longDateFormat.LT
|
|
270
|
-
}, [mode, dateFormat, exactLocale])
|
|
270
|
+
}, [mode, dateFormat, exactLocale, moment])
|
|
271
271
|
|
|
272
272
|
useEffect(() => {
|
|
273
273
|
if (typeof date === 'undefined') {
|
|
@@ -278,7 +278,7 @@ function DateTimePicker ({
|
|
|
278
278
|
const value = +moment.tz(date, timezone).seconds(0).milliseconds(0)
|
|
279
279
|
setTextInput(moment.tz(value, timezone).format(_dateFormat))
|
|
280
280
|
setTempDate(new Date(value))
|
|
281
|
-
}, [date, timezone, _dateFormat, setTempDate])
|
|
281
|
+
}, [date, timezone, _dateFormat, setTempDate, moment])
|
|
282
282
|
|
|
283
283
|
function _onChangeDate (value: any) {
|
|
284
284
|
const timestamp = getTimestampFromValue(value)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs-ui/date-time-picker",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.0-alpha.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
|
12
12
|
"@react-native-community/datetimepicker": "^8.4.4",
|
|
13
|
-
"@startupjs-ui/abstract-popover": "^0.1
|
|
14
|
-
"@startupjs-ui/button": "^0.1
|
|
15
|
-
"@startupjs-ui/core": "^0.1
|
|
16
|
-
"@startupjs-ui/div": "^0.1
|
|
17
|
-
"@startupjs-ui/divider": "^0.1
|
|
18
|
-
"@startupjs-ui/drawer": "^0.1
|
|
19
|
-
"@startupjs-ui/flat-list": "^0.1
|
|
20
|
-
"@startupjs-ui/icon": "^0.1
|
|
21
|
-
"@startupjs-ui/popover": "^0.1
|
|
22
|
-
"@startupjs-ui/span": "^0.1
|
|
23
|
-
"@startupjs-ui/text-input": "^0.1
|
|
13
|
+
"@startupjs-ui/abstract-popover": "^0.2.0-alpha.1",
|
|
14
|
+
"@startupjs-ui/button": "^0.2.0-alpha.1",
|
|
15
|
+
"@startupjs-ui/core": "^0.2.0-alpha.1",
|
|
16
|
+
"@startupjs-ui/div": "^0.2.0-alpha.1",
|
|
17
|
+
"@startupjs-ui/divider": "^0.2.0-alpha.1",
|
|
18
|
+
"@startupjs-ui/drawer": "^0.2.0-alpha.1",
|
|
19
|
+
"@startupjs-ui/flat-list": "^0.2.0-alpha.1",
|
|
20
|
+
"@startupjs-ui/icon": "^0.2.0-alpha.1",
|
|
21
|
+
"@startupjs-ui/popover": "^0.2.0-alpha.1",
|
|
22
|
+
"@startupjs-ui/span": "^0.2.0-alpha.1",
|
|
23
|
+
"@startupjs-ui/text-input": "^0.2.0-alpha.1",
|
|
24
24
|
"moment-timezone": "^0.5.31",
|
|
25
25
|
"react-native-safe-area-context": "^5.6.0"
|
|
26
26
|
},
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"react-native": "*",
|
|
30
30
|
"startupjs": "*"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b48004779559b16c96a2a1995dab13b998eafce9"
|
|
33
33
|
}
|