@octane-xplat/date-picker 0.19.0 → 0.20.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/README.md +2 -181
- package/package.json +8 -8
- package/src/AppKitDatePicker.macos.tsrx +39 -36
- package/src/AppKitDatePicker.tsrx +2 -0
- package/src/MaterialDatePicker.android.tsrx +43 -42
- package/src/MaterialDatePicker.tsrx +2 -0
- package/src/SwiftUIDatePicker.ios.tsrx +47 -45
- package/src/SwiftUIDatePicker.tsrx +2 -0
- package/src/android/index.ts +4 -4
- package/src/android/types.ts +111 -111
- package/src/date-picker-owner.macos.ts +240 -210
- package/src/ios/index.ts +3 -3
- package/src/ios/types.ts +26 -26
- package/src/macos/index.ts +3 -3
- package/src/macos/types.ts +24 -24
- package/src/style-merge.ts +40 -37
package/README.md
CHANGED
|
@@ -1,184 +1,5 @@
|
|
|
1
1
|
# `@octane-xplat/date-picker`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
`DatePicker` on iOS, Material 3 `DatePicker`/`TimePicker` built with Jetpack
|
|
5
|
-
Compose on Android, and an experimental `NSDatePicker` source implementation
|
|
6
|
-
on native macOS. Native macOS editing, layout and VoiceOver qualification is
|
|
7
|
-
pending. For a shared form API, use `Calendar`, `DateInput`,
|
|
8
|
-
`TimeInput`, `DateTimeInput`, and `DateRangeInput` from `@octane-xplat/ui`.
|
|
3
|
+
[Documentation](https://octane-xplat.goddardai.org/package-date-picker).
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
```sh
|
|
13
|
-
bun add @octane-xplat/date-picker
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
```tsx
|
|
17
|
-
import { useState } from 'octane'
|
|
18
|
-
import { DateInput } from '@octane-xplat/ui'
|
|
19
|
-
|
|
20
|
-
export function DepartureDate() {
|
|
21
|
-
const [date, setDate] = useState<string | null>('2026-10-02')
|
|
22
|
-
return <DateInput value={date} onChange={setDate} label="Departure" />
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
There is no shared picker component. Install the package in the app that
|
|
27
|
-
renders a control, then import `SwiftUIDatePicker` from
|
|
28
|
-
`@octane-xplat/date-picker/ios`, `MaterialDatePicker` from
|
|
29
|
-
`@octane-xplat/date-picker/android`, or `AppKitDatePicker` from
|
|
30
|
-
`@octane-xplat/date-picker/macos` in the matching platform-suffixed file.
|
|
31
|
-
These native entries have platform-specific contracts.
|
|
32
|
-
The old `@octane-xplat/date-picker/web` `DateInput` subpath was removed because
|
|
33
|
-
its browser-only string contract conflicted with the shared `DateInput` API.
|
|
34
|
-
|
|
35
|
-
In an existing app, install the package with Bun. The macOS entry needs a
|
|
36
|
-
[native AppKit app](../../docs/platform/macos-native.md); the renderer supplies
|
|
37
|
-
its native attachment automatically.
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
bun add @octane-xplat/date-picker
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
/** @jsxImportSource @octane-xplat/jsx */
|
|
45
|
-
// SwiftUIDatePickerExample.ios.tsx
|
|
46
|
-
import { SwiftUIDatePicker } from '@octane-xplat/date-picker/ios'
|
|
47
|
-
|
|
48
|
-
export function Picker() {
|
|
49
|
-
return (
|
|
50
|
-
<SwiftUIDatePicker
|
|
51
|
-
defaultSelection={new Date(2026, 9, 2)}
|
|
52
|
-
displayedComponents={['date']}
|
|
53
|
-
pickerStyle="graphical"
|
|
54
|
-
onSelectionChange={console.log}
|
|
55
|
-
/>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```tsx
|
|
61
|
-
/** @jsxImportSource @octane-xplat/jsx */
|
|
62
|
-
// MaterialDatePickerExample.android.tsx
|
|
63
|
-
import { MaterialDatePicker } from '@octane-xplat/date-picker/android'
|
|
64
|
-
|
|
65
|
-
const initialDate = new Date(2026, 9, 2)
|
|
66
|
-
const bounds = { start: new Date(2026, 0, 1), end: new Date(2026, 11, 31) }
|
|
67
|
-
|
|
68
|
-
export function Picker() {
|
|
69
|
-
return (
|
|
70
|
-
<MaterialDatePicker
|
|
71
|
-
initialDate={initialDate}
|
|
72
|
-
selectableDates={bounds}
|
|
73
|
-
onDateSelected={console.log}
|
|
74
|
-
/>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
```tsx
|
|
80
|
-
// AppKitDatePickerExample.macos.tsx
|
|
81
|
-
import { useState } from 'octane'
|
|
82
|
-
import { AppKitDatePicker } from '@octane-xplat/date-picker/macos'
|
|
83
|
-
import { Text } from '@octane-xplat/ui'
|
|
84
|
-
|
|
85
|
-
export function Picker() {
|
|
86
|
-
const [selection, setSelection] = useState(new Date(2026, 9, 29))
|
|
87
|
-
return (
|
|
88
|
-
<>
|
|
89
|
-
<AppKitDatePicker
|
|
90
|
-
components="date"
|
|
91
|
-
pickerStyle="graphical"
|
|
92
|
-
selection={selection}
|
|
93
|
-
onSelectionChange={setSelection}
|
|
94
|
-
accessibilityLabel="Departure date"
|
|
95
|
-
/>
|
|
96
|
-
<Text>{selection.toLocaleString()}</Text>
|
|
97
|
-
</>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
The platform APIs use their own selection vocabulary: the iOS entry takes a
|
|
103
|
-
controlled `selection`/`defaultSelection` `Date` with `displayedComponents`
|
|
104
|
-
and `pickerStyle`; the Android entry follows the uncontrolled
|
|
105
|
-
`initialDate`/`onDateSelected` model of the Material 3 pickers with
|
|
106
|
-
`selectableDates` range bounds; the macOS entry takes
|
|
107
|
-
`components`/`pickerStyle` (`'graphical'` embeds the
|
|
108
|
-
inline date calendar) with a controlled `selection` `Date`.
|
|
109
|
-
|
|
110
|
-
```tsx
|
|
111
|
-
// Departure.macos.tsx
|
|
112
|
-
import { useState } from 'octane'
|
|
113
|
-
import { AppKitDatePicker } from '@octane-xplat/date-picker/macos'
|
|
114
|
-
|
|
115
|
-
export function Departure() {
|
|
116
|
-
const [selection, setSelection] = useState(new Date(2026, 9, 2))
|
|
117
|
-
return (
|
|
118
|
-
<AppKitDatePicker
|
|
119
|
-
components="date"
|
|
120
|
-
pickerStyle="graphical"
|
|
121
|
-
selection={selection}
|
|
122
|
-
onSelectionChange={setSelection}
|
|
123
|
-
/>
|
|
124
|
-
)
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
On native macOS, `defaultSelection` seeds an uncontrolled picker once. Its
|
|
129
|
-
accepted date survives component/style changes and replacement of the backing
|
|
130
|
-
view; later defaults do not reset it. Bounds are inclusive. Invalid dates,
|
|
131
|
-
reversed bounds or an out-of-bounds controlled selection show a generic message
|
|
132
|
-
until the props are repaired. Uncontrolled selection clamps to new bounds without
|
|
133
|
-
emitting a change. Disabled, retired and programmatic changes do not call
|
|
134
|
-
`onSelectionChange`; the current callback receives user changes. See the
|
|
135
|
-
[native macOS workflow and remaining limits](../../docs/platform/date-picker.md#native-macos-selection-lifecycle).
|
|
136
|
-
|
|
137
|
-
```tsx
|
|
138
|
-
// BoundedDate.macos.tsx — defaultSelection is only the initial seed.
|
|
139
|
-
import { AppKitDatePicker } from '@octane-xplat/date-picker/macos'
|
|
140
|
-
const initial = new Date(2026, 9, 29)
|
|
141
|
-
const minimum = new Date(2026, 0, 1)
|
|
142
|
-
export function BoundedDate() {
|
|
143
|
-
return <AppKitDatePicker defaultSelection={initial} minimumDate={minimum}
|
|
144
|
-
accessibilityLabel="Departure date" onSelectionChange={(date) => console.log(date)} />
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Android notes: give `MaterialDatePicker` a bounded height (the M3 calendar's
|
|
149
|
-
lazy grid collapses under unbounded height), and keep `initialDate` and
|
|
150
|
-
`selectableDates` identity-stable — the provider keys its state `remember`
|
|
151
|
-
on them, so a per-render `new Date()` resets the selection.
|
|
152
|
-
See the framework guide for details and maintained examples:
|
|
153
|
-
[`docs/platform/date-picker.md`](https://octane-xplat.goddardai.org/date-picker).
|
|
154
|
-
|
|
155
|
-
```tsx
|
|
156
|
-
/** @jsxImportSource @octane-xplat/jsx */
|
|
157
|
-
// Departure.android.tsx — reuse these objects while the picker is mounted.
|
|
158
|
-
import { MaterialDatePicker } from '@octane-xplat/date-picker/android'
|
|
159
|
-
|
|
160
|
-
const initialDate = new Date(2026, 9, 2)
|
|
161
|
-
const selectableDates = { start: new Date(2026, 0, 1) }
|
|
162
|
-
export function Departure() {
|
|
163
|
-
return (
|
|
164
|
-
<MaterialDatePicker
|
|
165
|
-
className="departure-calendar"
|
|
166
|
-
initialDate={initialDate}
|
|
167
|
-
selectableDates={selectableDates}
|
|
168
|
-
onDateSelected={console.log}
|
|
169
|
-
/>
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
```css
|
|
175
|
-
/* App stylesheet: give the Android calendar room for its grid. */
|
|
176
|
-
.departure-calendar {
|
|
177
|
-
height: 480px;
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
The native implementations are adapted from `@expo/ui` (MIT,
|
|
182
|
-
`packages/expo-ui` sdk-57): `ios/DatePickerView.swift` and
|
|
183
|
-
`android/.../ui/DatePickerView.kt`. Attribution headers sit on the ported
|
|
184
|
-
files.
|
|
5
|
+
[API reference](https://octane-xplat.goddardai.org/api-date-picker).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/date-picker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Platform-specific date and time selection controls for Octane xplat",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,23 +44,23 @@
|
|
|
44
44
|
"test:packed": "node tests/packed-consumer.mjs",
|
|
45
45
|
"pack:check": "tsrx-typegen --pack-check",
|
|
46
46
|
"typegen": "tsrx-typegen --target date-picker",
|
|
47
|
-
"typecheck": "
|
|
47
|
+
"typecheck": "tsc --runExternalCode --noEmit -p tsconfig.types.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@nativescript/jetpack-compose": "1.0.0-beta.0",
|
|
51
51
|
"@nativescript/swift-ui": "4.0.2",
|
|
52
|
-
"@octane-xplat/jsx": "0.
|
|
52
|
+
"@octane-xplat/jsx": "0.20.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@nativescript-community/octane": "0.2.5",
|
|
56
56
|
"@nativescript/core": "9.1.3",
|
|
57
|
-
"@octane-xplat/macos-
|
|
57
|
+
"@octane-xplat/macos-appkit": "0.20.0",
|
|
58
58
|
"@octanejs/vite-plugin": "0.5.0",
|
|
59
59
|
"octane": "0.16.3",
|
|
60
|
-
"tsrx-typegen": "0.
|
|
61
|
-
"typescript": "
|
|
62
|
-
"vite": "8.3.
|
|
63
|
-
"@tsrx/
|
|
60
|
+
"tsrx-typegen": "0.6.1",
|
|
61
|
+
"typescript": "7.1.0-beta",
|
|
62
|
+
"vite": "8.3.6",
|
|
63
|
+
"@tsrx/content-mapper": "0.1.2"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@nativescript-community/octane": ">=0.2.1 <1",
|
|
@@ -15,42 +15,45 @@ const host = (): any => (globalThis as any).__xplatAppKit ?? {}
|
|
|
15
15
|
* The host element carries an explicit size — the picker is pinned to
|
|
16
16
|
* its edges. */
|
|
17
17
|
export function AppKitDatePicker(props: AppKitDatePickerProps): unknown @{
|
|
18
|
-
|
|
19
|
-
live.current = props
|
|
20
|
-
const [, rerender] = useState(0)
|
|
21
|
-
const owner = useMemo(
|
|
22
|
-
() =>
|
|
23
|
-
createDatePickerOwner({
|
|
24
|
-
props: () => live.current,
|
|
25
|
-
attach: () =>
|
|
26
|
-
typeof host().attachDatePicker === 'function'
|
|
27
|
-
? (host().attachDatePicker as DatePickerAttach)
|
|
28
|
-
: undefined,
|
|
29
|
-
status: () => rerender((n) => n + 1),
|
|
30
|
-
}),
|
|
31
|
-
[],
|
|
32
|
-
)
|
|
18
|
+
const live = useRef(props)
|
|
33
19
|
|
|
34
|
-
|
|
35
|
-
useEffect(() => () => owner.dispose(), [])
|
|
36
|
-
const graphical =
|
|
37
|
-
props.components === 'time' ||
|
|
38
|
-
((props.components ?? 'date') === 'date' && props.pickerStyle === 'graphical')
|
|
20
|
+
live.current = props
|
|
39
21
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
const [, rerender] = useState(0)
|
|
23
|
+
const owner = useMemo(
|
|
24
|
+
() =>
|
|
25
|
+
createDatePickerOwner({
|
|
26
|
+
props: () => live.current,
|
|
27
|
+
attach: () =>
|
|
28
|
+
typeof host().attachDatePicker === 'function'
|
|
29
|
+
? (host().attachDatePicker as DatePickerAttach)
|
|
30
|
+
: undefined,
|
|
31
|
+
status: () => rerender((n) => n + 1),
|
|
32
|
+
}),
|
|
33
|
+
[],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
useLayoutEffect(() => owner.update(), null)
|
|
37
|
+
useEffect(() => () => owner.dispose(), [])
|
|
38
|
+
|
|
39
|
+
const graphical =
|
|
40
|
+
props.components === 'time' ||
|
|
41
|
+
((props.components ?? 'date') === 'date' && props.pickerStyle === 'graphical')
|
|
42
|
+
|
|
43
|
+
<masonview
|
|
44
|
+
ref={owner.bind}
|
|
45
|
+
id={props.id}
|
|
46
|
+
className={['xplat-appkit-date-picker', props.className]}
|
|
47
|
+
style={mergeStyle({ minHeight: graphical ? 300 : 26 }, props.style)}
|
|
48
|
+
>
|
|
49
|
+
@if (owner.getStatus() === 'invalid') {
|
|
50
|
+
<label text="Choose a valid date and date range." accessibilityLiveRegion="polite" />
|
|
51
|
+
}
|
|
52
|
+
@if (owner.getStatus() === 'unavailable') {
|
|
53
|
+
<label
|
|
54
|
+
text="Date selection is unavailable in this app."
|
|
55
|
+
accessibilityLiveRegion="polite"
|
|
56
|
+
/>
|
|
57
|
+
}
|
|
58
|
+
</masonview>
|
|
56
59
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { registerElement } from '@nativescript-community/octane'
|
|
3
3
|
import type { Attributes } from '@octane-xplat/jsx/intrinsics'
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
ComposeDataDriver,
|
|
6
|
+
JetpackCompose,
|
|
7
|
+
registerJetpackCompose,
|
|
8
8
|
} from '@nativescript/jetpack-compose'
|
|
9
9
|
|
|
10
10
|
import type { MaterialDatePickerProps } from './android/types'
|
|
@@ -12,52 +12,53 @@ import type { MaterialDatePickerProps } from './android/types'
|
|
|
12
12
|
declare const com: any
|
|
13
13
|
|
|
14
14
|
declare module '@octane-xplat/jsx/intrinsics' {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
interface NativeElements<TElement> {
|
|
16
|
+
xplatandroiddatepicker: Attributes<
|
|
17
|
+
TElement,
|
|
18
|
+
{
|
|
19
|
+
composeId?: string
|
|
20
|
+
data?: Record<string, unknown>
|
|
21
|
+
onComposeEvent?: (event: { data?: unknown }) => void
|
|
22
|
+
}
|
|
23
|
+
>
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
registerElement('xplatandroiddatepicker', JetpackCompose)
|
|
28
28
|
registerJetpackCompose(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
'xplat-material-datepicker',
|
|
30
|
+
(owner: any) =>
|
|
31
|
+
new ComposeDataDriver(new com.octanexplat.datepicker.XplatDatePickerProvider(), owner),
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
/** Renders a Material 3 DatePicker/TimePicker through the NativeScript Jetpack Compose bridge. */
|
|
35
35
|
export function MaterialDatePicker(props: MaterialDatePickerProps): unknown @{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const data = {
|
|
37
|
+
initialDate: props.initialDate?.getTime() ?? null,
|
|
38
|
+
variant: props.variant ?? 'picker',
|
|
39
|
+
displayedComponents: props.displayedComponents ?? 'date',
|
|
40
|
+
// The bridge's dataSerialize throws on booleans; send numbers.
|
|
41
|
+
showVariantToggle: (props.showVariantToggle ?? true) ? 1 : 0,
|
|
42
|
+
is24Hour: (props.is24Hour ?? true) ? 1 : 0,
|
|
43
|
+
color: props.color,
|
|
44
|
+
elementColors: props.elementColors,
|
|
45
|
+
selectableDates: {
|
|
46
|
+
start: props.selectableDates?.start?.getTime() ?? null,
|
|
47
|
+
end: props.selectableDates?.end?.getTime() ?? null,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
<xplatandroiddatepicker
|
|
52
|
+
id={props.id}
|
|
53
|
+
className={props.className}
|
|
54
|
+
style={props.style}
|
|
55
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
56
|
+
composeId="xplat-material-datepicker"
|
|
57
|
+
data={data}
|
|
58
|
+
onComposeEvent={(event: any) => {
|
|
59
|
+
const millis = event.data?.date
|
|
60
|
+
|
|
61
|
+
props.onDateSelected?.(typeof millis === 'number' ? new Date(millis) : null)
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
63
64
|
}
|
|
@@ -8,61 +8,63 @@ import type { SwiftUIDatePickerProps } from './ios/types'
|
|
|
8
8
|
declare const XplatDatePickerProvider: any
|
|
9
9
|
|
|
10
10
|
declare module '@octane-xplat/jsx/intrinsics' {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
interface NativeElements<TElement> {
|
|
12
|
+
xplatiosdatepicker: Attributes<
|
|
13
|
+
TElement,
|
|
14
|
+
{
|
|
15
|
+
swiftId?: string
|
|
16
|
+
data?: Record<string, unknown>
|
|
17
|
+
onSwiftUIEvent?: (event: { data?: unknown }) => void
|
|
18
|
+
}
|
|
19
|
+
>
|
|
20
|
+
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
registerElement('xplatiosdatepicker', SwiftUI)
|
|
24
24
|
registerSwiftUI(
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
'xplat-swiftui-datepicker',
|
|
26
|
+
(owner: any) => new UIDataDriver(new XplatDatePickerProvider(), owner),
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
/** Renders a SwiftUI DatePicker through NativeScript's SwiftUI bridge. */
|
|
30
30
|
export function SwiftUIDatePicker(props: SwiftUIDatePickerProps): unknown @{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const controlled = props.selection !== undefined
|
|
32
|
+
const [internalSelection, setInternalSelection] = useState<Date | undefined>(
|
|
33
|
+
props.defaultSelection,
|
|
34
|
+
)
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const selection = controlled ? props.selection! : internalSelection
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (typeof millis !== 'number') {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
38
|
+
<xplatiosdatepicker
|
|
39
|
+
id={props.id}
|
|
40
|
+
className={props.className}
|
|
41
|
+
style={props.style}
|
|
42
|
+
swiftId="xplat-swiftui-datepicker"
|
|
43
|
+
data={{
|
|
44
|
+
title: props.title,
|
|
45
|
+
selection: selection?.getTime(),
|
|
46
|
+
range: {
|
|
47
|
+
start: props.minimumDate?.getTime(),
|
|
48
|
+
end: props.maximumDate?.getTime(),
|
|
49
|
+
},
|
|
50
|
+
displayedComponents: props.displayedComponents ?? ['date'],
|
|
51
|
+
pickerStyle: props.pickerStyle ?? 'automatic',
|
|
52
|
+
disabled: props.disabled ?? false,
|
|
53
|
+
}}
|
|
54
|
+
onSwiftUIEvent={(event: any) => {
|
|
55
|
+
const millis = event.data?.date
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
57
|
+
if (typeof millis !== 'number') {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
const next = new Date(millis)
|
|
62
|
+
|
|
63
|
+
if (!controlled) {
|
|
64
|
+
setInternalSelection(next)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
props.onSelectionChange?.(next)
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
68
70
|
}
|
package/src/android/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { MaterialDatePicker } from '../MaterialDatePicker.android.tsrx'
|
|
2
2
|
export type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
MaterialDatePickerComponents,
|
|
4
|
+
MaterialDatePickerElementColors,
|
|
5
|
+
MaterialDatePickerProps,
|
|
6
|
+
MaterialDatePickerVariant,
|
|
7
7
|
} from './types'
|