@octane-xplat/date-picker 0.0.0-stage → 0.9.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/LICENSE +21 -0
- package/README.md +33 -2
- package/dist/native/MaterialDatePicker.android.tsrx.js +46 -0
- package/dist/native/SwiftUIDatePicker.ios.tsrx.js +48 -0
- package/dist/native/android/index.js +2 -0
- package/dist/native/ios/index.js +2 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/web/DateInput.web.tsrx.js +57 -0
- package/dist/web/octane-client-build.json +8 -0
- package/dist/web/web/index.js +2 -0
- package/package.json +71 -3
- package/platforms/android/include.gradle +15 -0
- package/platforms/android/java/com/octanexplat/datepicker/XplatDatePickerProvider.kt +335 -0
- package/platforms/ios/src/XplatDatePickerProvider.swift +144 -0
- package/src/AppKitDatePicker.macos.tsrx +56 -0
- package/src/DateInput.web.tsrx +30 -0
- package/src/MaterialDatePicker.android.tsrx +49 -0
- package/src/SwiftUIDatePicker.ios.tsrx +51 -0
- package/src/android/index.ts +7 -0
- package/src/android/types.ts +80 -0
- package/src/ios/index.ts +6 -0
- package/src/ios/types.ts +26 -0
- package/src/macos/index.ts +6 -0
- package/src/macos/types.ts +24 -0
- package/src/web/index.ts +2 -0
- package/src/web/types.ts +20 -0
- package/types/android/index.d.ts +61 -0
- package/types/ios/index.d.ts +21 -0
- package/types/macos/index.d.ts +20 -0
- package/types/web/index.d.ts +18 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Adapted from @expo/ui (MIT) — Copyright 2025-present 650 Industries.
|
|
2
|
+
// Upstream: expo/packages/expo-ui/ios/DatePickerView.swift (sdk-57).
|
|
3
|
+
// The ExpoModules glue (@Field props record, EventDispatcher, Children label
|
|
4
|
+
// slot) is replaced by the @nativescript/swift-ui provider contract:
|
|
5
|
+
// updateData(NSDictionary) + onEvent. Children-as-label is not ported; the
|
|
6
|
+
// title string prop covers the label slot.
|
|
7
|
+
|
|
8
|
+
import SwiftUI
|
|
9
|
+
|
|
10
|
+
private final class DatePickerModel: ObservableObject {
|
|
11
|
+
@Published var title: String? = nil
|
|
12
|
+
@Published var selection: Date? = nil
|
|
13
|
+
@Published var rangeStart: Date? = nil
|
|
14
|
+
@Published var rangeEnd: Date? = nil
|
|
15
|
+
@Published var displayedComponents: DatePicker.Components = [.date]
|
|
16
|
+
@Published var pickerStyle: String = "automatic"
|
|
17
|
+
@Published var disabled = false
|
|
18
|
+
var onDateChange: ((Date) -> Void)?
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private struct DatePickerContent: View {
|
|
22
|
+
@ObservedObject var model: DatePickerModel
|
|
23
|
+
@State private var date = Date()
|
|
24
|
+
|
|
25
|
+
// `.graphical` has an AutoLayout bug (it uses UICalendarView under the
|
|
26
|
+
// hood): it shrinks height when the user taps a date.
|
|
27
|
+
// https://github.com/expo/expo/issues/47062
|
|
28
|
+
// Fixed min width of 320 while the style is graphical.
|
|
29
|
+
private var isGraphicalStyle: Bool {
|
|
30
|
+
model.pickerStyle == "graphical"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var body: some View {
|
|
34
|
+
styledPicker()
|
|
35
|
+
.disabled(model.disabled)
|
|
36
|
+
.frame(minWidth: isGraphicalStyle ? 320 : nil)
|
|
37
|
+
.onChange(of: date) { newDate in
|
|
38
|
+
if model.selection == newDate { return }
|
|
39
|
+
model.onDateChange?(newDate)
|
|
40
|
+
}
|
|
41
|
+
.onChange(of: model.selection) { newValue in
|
|
42
|
+
date = newValue ?? Date()
|
|
43
|
+
}
|
|
44
|
+
.onAppear {
|
|
45
|
+
date = model.selection ?? Date()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ViewBuilder
|
|
50
|
+
private func styledPicker() -> some View {
|
|
51
|
+
switch model.pickerStyle {
|
|
52
|
+
case "compact":
|
|
53
|
+
createDatePicker().datePickerStyle(.compact)
|
|
54
|
+
case "graphical":
|
|
55
|
+
createDatePicker().datePickerStyle(.graphical)
|
|
56
|
+
case "wheel":
|
|
57
|
+
createDatePicker().datePickerStyle(.wheel)
|
|
58
|
+
default:
|
|
59
|
+
createDatePicker().datePickerStyle(.automatic)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ViewBuilder
|
|
64
|
+
private func createDatePicker() -> some View {
|
|
65
|
+
let components = model.displayedComponents
|
|
66
|
+
let start = model.rangeStart
|
|
67
|
+
let end = model.rangeEnd
|
|
68
|
+
let title = model.title ?? ""
|
|
69
|
+
|
|
70
|
+
let picker = Group {
|
|
71
|
+
if let start, let end {
|
|
72
|
+
DatePicker(title, selection: $date, in: start...end, displayedComponents: components)
|
|
73
|
+
} else if let start {
|
|
74
|
+
DatePicker(title, selection: $date, in: start..., displayedComponents: components)
|
|
75
|
+
} else if let end {
|
|
76
|
+
DatePicker(title, selection: $date, in: ...end, displayedComponents: components)
|
|
77
|
+
} else {
|
|
78
|
+
DatePicker(title, selection: $date, displayedComponents: components)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if model.title == nil {
|
|
83
|
+
picker.labelsHidden()
|
|
84
|
+
} else {
|
|
85
|
+
picker
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@objc(XplatDatePickerProvider)
|
|
91
|
+
public final class XplatDatePickerProvider: UIViewController, SwiftUIProvider {
|
|
92
|
+
private let model = DatePickerModel()
|
|
93
|
+
|
|
94
|
+
public required init() {
|
|
95
|
+
super.init(nibName: nil, bundle: nil)
|
|
96
|
+
model.onDateChange = { [weak self] date in
|
|
97
|
+
self?.onEvent?(["date": date.timeIntervalSince1970 * 1000])
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public required init?(coder: NSCoder) {
|
|
102
|
+
super.init(coder: coder)
|
|
103
|
+
model.onDateChange = { [weak self] date in
|
|
104
|
+
self?.onEvent?(["date": date.timeIntervalSince1970 * 1000])
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public override func viewDidLoad() {
|
|
109
|
+
super.viewDidLoad()
|
|
110
|
+
setupSwiftUIView(content: DatePickerContent(model: model))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private static func millisToDate(_ value: Any?) -> Date? {
|
|
114
|
+
guard let millis = value as? NSNumber else { return nil }
|
|
115
|
+
return Date(timeIntervalSince1970: millis.doubleValue / 1000)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public func updateData(data: NSDictionary) {
|
|
119
|
+
if let title = data["title"] as? String {
|
|
120
|
+
model.title = title.isEmpty ? nil : title
|
|
121
|
+
}
|
|
122
|
+
if let selection = data["selection"] as? NSNumber {
|
|
123
|
+
model.selection = Date(timeIntervalSince1970: selection.doubleValue / 1000)
|
|
124
|
+
}
|
|
125
|
+
if let range = data["range"] as? [String: Any] {
|
|
126
|
+
model.rangeStart = Self.millisToDate(range["start"])
|
|
127
|
+
model.rangeEnd = Self.millisToDate(range["end"])
|
|
128
|
+
}
|
|
129
|
+
if let components = data["displayedComponents"] as? [String] {
|
|
130
|
+
var mapped: DatePicker.Components = []
|
|
131
|
+
if components.contains("date") { mapped.insert(.date) }
|
|
132
|
+
if components.contains("hourAndMinute") { mapped.insert(.hourAndMinute) }
|
|
133
|
+
if !mapped.isEmpty { model.displayedComponents = mapped }
|
|
134
|
+
}
|
|
135
|
+
if let pickerStyle = data["pickerStyle"] as? String {
|
|
136
|
+
model.pickerStyle = pickerStyle
|
|
137
|
+
}
|
|
138
|
+
if let disabled = data["disabled"] as? NSNumber {
|
|
139
|
+
model.disabled = disabled.boolValue
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public var onEvent: ((NSDictionary) -> Void)?
|
|
144
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** @jsxImportSource @xplat/macos/renderer */
|
|
2
|
+
import { useEffect, useRef } from 'octane'
|
|
3
|
+
import type { AppKitDatePickerProps } from './macos/types'
|
|
4
|
+
|
|
5
|
+
const host = (): any => (globalThis as any).__xplatAppKit ?? {}
|
|
6
|
+
|
|
7
|
+
/** Embeds a real NSDatePicker in the leaf's backing view via the
|
|
8
|
+
* `__xplatAppKit` bridge. 'date' uses a text field (or the inline
|
|
9
|
+
* graphical calendar when `pickerStyle` is 'graphical'); 'time' uses the
|
|
10
|
+
* clock-and-calendar field; 'dateAndTime' shows both element groups.
|
|
11
|
+
* The host element carries an explicit size — the picker is pinned to
|
|
12
|
+
* its edges. */
|
|
13
|
+
export function AppKitDatePicker(props: AppKitDatePickerProps) @{
|
|
14
|
+
const anchor = useRef<any>(null)
|
|
15
|
+
const handle = useRef<any>(null)
|
|
16
|
+
|
|
17
|
+
const options = () => ({
|
|
18
|
+
mode: props.components === 'time' ? 'time' : 'date',
|
|
19
|
+
style: props.pickerStyle,
|
|
20
|
+
selectionMillis: (props.selection ?? props.defaultSelection)?.getTime?.(),
|
|
21
|
+
minimumMillis: props.minimumDate?.getTime?.(),
|
|
22
|
+
maximumMillis: props.maximumDate?.getTime?.(),
|
|
23
|
+
enabled: !props.disabled,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const view = anchor.current
|
|
28
|
+
const attach = host().attachDatePicker
|
|
29
|
+
if (!view || typeof attach !== 'function') return
|
|
30
|
+
handle.current = attach(view, options(), (millis: number) => {
|
|
31
|
+
props.onSelectionChange?.(new Date(millis))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
handle.current?.detach()
|
|
36
|
+
handle.current = null
|
|
37
|
+
}
|
|
38
|
+
}, [props.components, props.pickerStyle])
|
|
39
|
+
|
|
40
|
+
// Push controlled selection/range updates into the mounted picker; the
|
|
41
|
+
// bridge update is echo-suppressed by comparing against dateValue.
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
handle.current?.update(options())
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
<flexboxlayout
|
|
47
|
+
ref={(v: any) => { anchor.current = v }}
|
|
48
|
+
id={props.id}
|
|
49
|
+
className={props.className}
|
|
50
|
+
style={{
|
|
51
|
+
minWidth: 240,
|
|
52
|
+
minHeight: props.pickerStyle === 'graphical' ? 300 : 26,
|
|
53
|
+
...props.style,
|
|
54
|
+
}}
|
|
55
|
+
/>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsxImportSource octane */
|
|
2
|
+
import { useState } from 'octane'
|
|
3
|
+
import type { DateInputProps } from './web/types'
|
|
4
|
+
|
|
5
|
+
/** Renders a labeled browser date/time input. */
|
|
6
|
+
export function DateInput(props: DateInputProps) @{
|
|
7
|
+
const controlled = props.value !== undefined
|
|
8
|
+
const [internalValue, setInternalValue] = useState(props.defaultValue ?? '')
|
|
9
|
+
const value = controlled ? props.value! : internalValue
|
|
10
|
+
const labelId = props.id ? `${props.id}-label` : undefined
|
|
11
|
+
|
|
12
|
+
<label className={props.className} style={props.style}>
|
|
13
|
+
<span id={labelId}>{props.label}</span>
|
|
14
|
+
<input
|
|
15
|
+
id={props.id}
|
|
16
|
+
type={props.type ?? 'date'}
|
|
17
|
+
aria-label={props.accessibilityLabel ?? props.label}
|
|
18
|
+
aria-labelledby={labelId}
|
|
19
|
+
value={value}
|
|
20
|
+
min={props.min}
|
|
21
|
+
max={props.max}
|
|
22
|
+
disabled={props.disabled}
|
|
23
|
+
onChange={(event: any) => {
|
|
24
|
+
const nextValue = event.target.value as string
|
|
25
|
+
if (!controlled) setInternalValue(nextValue)
|
|
26
|
+
props.onChange?.(nextValue)
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
</label>
|
|
30
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
2
|
+
import { registerElement } from '@nativescript-community/octane'
|
|
3
|
+
import type { Attributes } from '@nativescript-community/octane/intrinsics'
|
|
4
|
+
import { ComposeDataDriver, JetpackCompose, registerJetpackCompose } from '@nativescript/jetpack-compose'
|
|
5
|
+
import type { MaterialDatePickerProps } from './android/types'
|
|
6
|
+
|
|
7
|
+
declare const com: any
|
|
8
|
+
|
|
9
|
+
declare module '@nativescript-community/octane/intrinsics' {
|
|
10
|
+
interface NativeScriptElements {
|
|
11
|
+
xplatandroiddatepicker: Attributes<typeof JetpackCompose>
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
registerElement('xplatandroiddatepicker', JetpackCompose)
|
|
16
|
+
registerJetpackCompose('xplat-material-datepicker', (owner: any) =>
|
|
17
|
+
new ComposeDataDriver(new com.octanexplat.datepicker.XplatDatePickerProvider(), owner),
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
/** Renders a Material 3 DatePicker/TimePicker through the NativeScript Jetpack Compose bridge. */
|
|
21
|
+
export function MaterialDatePicker(props: MaterialDatePickerProps) @{
|
|
22
|
+
const data = {
|
|
23
|
+
initialDate: props.initialDate?.getTime() ?? null,
|
|
24
|
+
variant: props.variant ?? 'picker',
|
|
25
|
+
displayedComponents: props.displayedComponents ?? 'date',
|
|
26
|
+
// The bridge's dataSerialize throws on booleans; send numbers.
|
|
27
|
+
showVariantToggle: (props.showVariantToggle ?? true) ? 1 : 0,
|
|
28
|
+
is24Hour: (props.is24Hour ?? true) ? 1 : 0,
|
|
29
|
+
color: props.color,
|
|
30
|
+
elementColors: props.elementColors,
|
|
31
|
+
selectableDates: {
|
|
32
|
+
start: props.selectableDates?.start?.getTime() ?? null,
|
|
33
|
+
end: props.selectableDates?.end?.getTime() ?? null,
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
<xplatandroiddatepicker
|
|
38
|
+
id={props.id}
|
|
39
|
+
className={props.className}
|
|
40
|
+
style={props.style}
|
|
41
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
42
|
+
composeId="xplat-material-datepicker"
|
|
43
|
+
data={data}
|
|
44
|
+
onComposeEvent={(event: any) => {
|
|
45
|
+
const millis = event.data?.date
|
|
46
|
+
props.onDateSelected?.(typeof millis === 'number' ? new Date(millis) : null)
|
|
47
|
+
}}
|
|
48
|
+
/>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
2
|
+
import { registerElement } from '@nativescript-community/octane'
|
|
3
|
+
import type { Attributes } from '@nativescript-community/octane/intrinsics'
|
|
4
|
+
import { SwiftUI, UIDataDriver, registerSwiftUI } from '@nativescript/swift-ui'
|
|
5
|
+
import { useState } from 'octane'
|
|
6
|
+
import type { SwiftUIDatePickerProps } from './ios/types'
|
|
7
|
+
|
|
8
|
+
declare const XplatDatePickerProvider: any
|
|
9
|
+
|
|
10
|
+
declare module '@nativescript-community/octane/intrinsics' {
|
|
11
|
+
interface NativeScriptElements {
|
|
12
|
+
xplatiosdatepicker: Attributes<typeof SwiftUI>
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
registerElement('xplatiosdatepicker', SwiftUI)
|
|
17
|
+
registerSwiftUI('xplat-swiftui-datepicker', (owner: any) =>
|
|
18
|
+
new UIDataDriver(new XplatDatePickerProvider(), owner),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
/** Renders a SwiftUI DatePicker through NativeScript's SwiftUI bridge. */
|
|
22
|
+
export function SwiftUIDatePicker(props: SwiftUIDatePickerProps) @{
|
|
23
|
+
const controlled = props.selection !== undefined
|
|
24
|
+
const [internalSelection, setInternalSelection] = useState<Date | undefined>(props.defaultSelection)
|
|
25
|
+
const selection = controlled ? props.selection! : internalSelection
|
|
26
|
+
|
|
27
|
+
<xplatiosdatepicker
|
|
28
|
+
id={props.id}
|
|
29
|
+
className={props.className}
|
|
30
|
+
style={props.style}
|
|
31
|
+
swiftId="xplat-swiftui-datepicker"
|
|
32
|
+
data={{
|
|
33
|
+
title: props.title,
|
|
34
|
+
selection: selection?.getTime(),
|
|
35
|
+
range: {
|
|
36
|
+
start: props.minimumDate?.getTime(),
|
|
37
|
+
end: props.maximumDate?.getTime(),
|
|
38
|
+
},
|
|
39
|
+
displayedComponents: props.displayedComponents ?? ['date'],
|
|
40
|
+
pickerStyle: props.pickerStyle ?? 'automatic',
|
|
41
|
+
disabled: props.disabled ?? false,
|
|
42
|
+
}}
|
|
43
|
+
onSwiftUIEvent={(event: any) => {
|
|
44
|
+
const millis = event.data?.date
|
|
45
|
+
if (typeof millis !== 'number') return
|
|
46
|
+
const next = new Date(millis)
|
|
47
|
+
if (!controlled) setInternalSelection(next)
|
|
48
|
+
props.onSelectionChange?.(next)
|
|
49
|
+
}}
|
|
50
|
+
/>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type MaterialDatePickerVariant = 'picker' | 'input'
|
|
2
|
+
|
|
3
|
+
export type MaterialDatePickerComponents = 'date' | 'hourAndMinute' | 'dateAndTime'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Color overrides for the Material 3 picker elements. Every field is a CSS
|
|
7
|
+
* hex string (`#rgb`, `#rrggbb`, or `#aarrggbb`); unset fields use the
|
|
8
|
+
* Material 3 theme defaults.
|
|
9
|
+
*/
|
|
10
|
+
export interface MaterialDatePickerElementColors {
|
|
11
|
+
containerColor?: string
|
|
12
|
+
titleContentColor?: string
|
|
13
|
+
headlineContentColor?: string
|
|
14
|
+
weekdayContentColor?: string
|
|
15
|
+
subheadContentColor?: string
|
|
16
|
+
navigationContentColor?: string
|
|
17
|
+
yearContentColor?: string
|
|
18
|
+
disabledYearContentColor?: string
|
|
19
|
+
currentYearContentColor?: string
|
|
20
|
+
selectedYearContentColor?: string
|
|
21
|
+
disabledSelectedYearContentColor?: string
|
|
22
|
+
selectedYearContainerColor?: string
|
|
23
|
+
disabledSelectedYearContainerColor?: string
|
|
24
|
+
dayContentColor?: string
|
|
25
|
+
disabledDayContentColor?: string
|
|
26
|
+
selectedDayContentColor?: string
|
|
27
|
+
disabledSelectedDayContentColor?: string
|
|
28
|
+
selectedDayContainerColor?: string
|
|
29
|
+
disabledSelectedDayContainerColor?: string
|
|
30
|
+
todayContentColor?: string
|
|
31
|
+
todayDateBorderColor?: string
|
|
32
|
+
dayInSelectionRangeContentColor?: string
|
|
33
|
+
dayInSelectionRangeContainerColor?: string
|
|
34
|
+
dividerColor?: string
|
|
35
|
+
clockDialColor?: string
|
|
36
|
+
clockDialSelectedContentColor?: string
|
|
37
|
+
clockDialUnselectedContentColor?: string
|
|
38
|
+
selectorColor?: string
|
|
39
|
+
periodSelectorBorderColor?: string
|
|
40
|
+
periodSelectorSelectedContainerColor?: string
|
|
41
|
+
periodSelectorUnselectedContainerColor?: string
|
|
42
|
+
periodSelectorSelectedContentColor?: string
|
|
43
|
+
periodSelectorUnselectedContentColor?: string
|
|
44
|
+
timeSelectorSelectedContainerColor?: string
|
|
45
|
+
timeSelectorUnselectedContainerColor?: string
|
|
46
|
+
timeSelectorSelectedContentColor?: string
|
|
47
|
+
timeSelectorUnselectedContentColor?: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface MaterialDatePickerProps {
|
|
51
|
+
id?: string
|
|
52
|
+
className?: any
|
|
53
|
+
style?: any
|
|
54
|
+
/** Date the picker starts on. The picker keeps its own selection after mount. */
|
|
55
|
+
initialDate?: Date
|
|
56
|
+
/** Calendar grid or text-field input. @default 'picker' */
|
|
57
|
+
variant?: MaterialDatePickerVariant
|
|
58
|
+
/**
|
|
59
|
+
* `'date'` renders the M3 DatePicker, `'hourAndMinute'` the M3 TimePicker.
|
|
60
|
+
* `'dateAndTime'` renders the date picker (combined input is not supported).
|
|
61
|
+
* @default 'date'
|
|
62
|
+
*/
|
|
63
|
+
displayedComponents?: MaterialDatePickerComponents
|
|
64
|
+
/** Show the picker/input mode toggle. @default true */
|
|
65
|
+
showVariantToggle?: boolean
|
|
66
|
+
/** 24-hour dial for the time picker. @default true */
|
|
67
|
+
is24Hour?: boolean
|
|
68
|
+
/** Accent applied to a subset of elements when `elementColors` is unset. */
|
|
69
|
+
color?: string
|
|
70
|
+
elementColors?: MaterialDatePickerElementColors
|
|
71
|
+
/** Bounds the selectable date range; also derives the calendar year range. */
|
|
72
|
+
selectableDates?: { start?: Date; end?: Date }
|
|
73
|
+
accessibilityLabel?: string
|
|
74
|
+
/**
|
|
75
|
+
* Called with the selected timestamp (null when the selection clears). The
|
|
76
|
+
* DatePicker emits the chosen UTC day; the TimePicker emits the chosen
|
|
77
|
+
* hour/minute on the initial date's day.
|
|
78
|
+
*/
|
|
79
|
+
onDateSelected?: (date: Date | null) => void
|
|
80
|
+
}
|
package/src/ios/index.ts
ADDED
package/src/ios/types.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type SwiftUIDatePickerStyle = 'automatic' | 'compact' | 'graphical' | 'wheel'
|
|
2
|
+
|
|
3
|
+
export type SwiftUIDatePickerComponent = 'date' | 'hourAndMinute'
|
|
4
|
+
|
|
5
|
+
export interface SwiftUIDatePickerProps {
|
|
6
|
+
id?: string
|
|
7
|
+
className?: any
|
|
8
|
+
style?: any
|
|
9
|
+
/** Label shown next to the picker. When omitted, the label is hidden. */
|
|
10
|
+
title?: string
|
|
11
|
+
/** Controlled selection. Pair with `onSelectionChange`. */
|
|
12
|
+
selection?: Date
|
|
13
|
+
/** Initial selection when `selection` is not provided. */
|
|
14
|
+
defaultSelection?: Date
|
|
15
|
+
/** Earliest selectable date. */
|
|
16
|
+
minimumDate?: Date
|
|
17
|
+
/** Latest selectable date. */
|
|
18
|
+
maximumDate?: Date
|
|
19
|
+
/** Which components the picker displays. @default ['date'] */
|
|
20
|
+
displayedComponents?: readonly SwiftUIDatePickerComponent[]
|
|
21
|
+
/** SwiftUI presentation style. `graphical` renders an inline calendar. @default 'automatic' */
|
|
22
|
+
pickerStyle?: SwiftUIDatePickerStyle
|
|
23
|
+
disabled?: boolean
|
|
24
|
+
accessibilityLabel?: string
|
|
25
|
+
onSelectionChange?: (date: Date) => void
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type AppKitDatePickerComponents = 'date' | 'time' | 'dateAndTime'
|
|
2
|
+
|
|
3
|
+
export type AppKitDatePickerStyle = 'textField' | 'graphical'
|
|
4
|
+
|
|
5
|
+
export interface AppKitDatePickerProps {
|
|
6
|
+
id?: string
|
|
7
|
+
className?: any
|
|
8
|
+
style?: any
|
|
9
|
+
/** Which element groups the NSDatePicker shows. @default 'date' */
|
|
10
|
+
components?: AppKitDatePickerComponents
|
|
11
|
+
/** 'graphical' embeds the inline calendar (date mode only). @default 'textField' */
|
|
12
|
+
pickerStyle?: AppKitDatePickerStyle
|
|
13
|
+
/** Controlled selection. Pair with `onSelectionChange`. */
|
|
14
|
+
selection?: Date
|
|
15
|
+
/** Initial selection when `selection` is not provided. */
|
|
16
|
+
defaultSelection?: Date
|
|
17
|
+
/** Earliest selectable date. */
|
|
18
|
+
minimumDate?: Date
|
|
19
|
+
/** Latest selectable date. */
|
|
20
|
+
maximumDate?: Date
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
accessibilityLabel?: string
|
|
23
|
+
onSelectionChange?: (date: Date) => void
|
|
24
|
+
}
|
package/src/web/index.ts
ADDED
package/src/web/types.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type DateInputType = 'date' | 'time' | 'datetime-local'
|
|
2
|
+
|
|
3
|
+
export interface DateInputProps {
|
|
4
|
+
id?: string
|
|
5
|
+
className?: any
|
|
6
|
+
style?: any
|
|
7
|
+
label?: string
|
|
8
|
+
/** The `<input>` type. @default 'date' */
|
|
9
|
+
type?: DateInputType
|
|
10
|
+
/** Controlled value: `YYYY-MM-DD`, `HH:MM`, or `YYYY-MM-DDTHH:MM`. */
|
|
11
|
+
value?: string
|
|
12
|
+
defaultValue?: string
|
|
13
|
+
/** Earliest allowed value, in the same format as `value`. */
|
|
14
|
+
min?: string
|
|
15
|
+
/** Latest allowed value, in the same format as `value`. */
|
|
16
|
+
max?: string
|
|
17
|
+
disabled?: boolean
|
|
18
|
+
accessibilityLabel?: string
|
|
19
|
+
onChange?: (value: string) => void
|
|
20
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type MaterialDatePickerVariant = 'picker' | 'input'
|
|
2
|
+
|
|
3
|
+
export type MaterialDatePickerComponents = 'date' | 'hourAndMinute' | 'dateAndTime'
|
|
4
|
+
|
|
5
|
+
export interface MaterialDatePickerElementColors {
|
|
6
|
+
containerColor?: string
|
|
7
|
+
titleContentColor?: string
|
|
8
|
+
headlineContentColor?: string
|
|
9
|
+
weekdayContentColor?: string
|
|
10
|
+
subheadContentColor?: string
|
|
11
|
+
navigationContentColor?: string
|
|
12
|
+
yearContentColor?: string
|
|
13
|
+
disabledYearContentColor?: string
|
|
14
|
+
currentYearContentColor?: string
|
|
15
|
+
selectedYearContentColor?: string
|
|
16
|
+
disabledSelectedYearContentColor?: string
|
|
17
|
+
selectedYearContainerColor?: string
|
|
18
|
+
disabledSelectedYearContainerColor?: string
|
|
19
|
+
dayContentColor?: string
|
|
20
|
+
disabledDayContentColor?: string
|
|
21
|
+
selectedDayContentColor?: string
|
|
22
|
+
disabledSelectedDayContentColor?: string
|
|
23
|
+
selectedDayContainerColor?: string
|
|
24
|
+
disabledSelectedDayContainerColor?: string
|
|
25
|
+
todayContentColor?: string
|
|
26
|
+
todayDateBorderColor?: string
|
|
27
|
+
dayInSelectionRangeContentColor?: string
|
|
28
|
+
dayInSelectionRangeContainerColor?: string
|
|
29
|
+
dividerColor?: string
|
|
30
|
+
clockDialColor?: string
|
|
31
|
+
clockDialSelectedContentColor?: string
|
|
32
|
+
clockDialUnselectedContentColor?: string
|
|
33
|
+
selectorColor?: string
|
|
34
|
+
periodSelectorBorderColor?: string
|
|
35
|
+
periodSelectorSelectedContainerColor?: string
|
|
36
|
+
periodSelectorUnselectedContainerColor?: string
|
|
37
|
+
periodSelectorSelectedContentColor?: string
|
|
38
|
+
periodSelectorUnselectedContentColor?: string
|
|
39
|
+
timeSelectorSelectedContainerColor?: string
|
|
40
|
+
timeSelectorUnselectedContainerColor?: string
|
|
41
|
+
timeSelectorSelectedContentColor?: string
|
|
42
|
+
timeSelectorUnselectedContentColor?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface MaterialDatePickerProps {
|
|
46
|
+
id?: string
|
|
47
|
+
className?: any
|
|
48
|
+
style?: any
|
|
49
|
+
initialDate?: Date
|
|
50
|
+
variant?: MaterialDatePickerVariant
|
|
51
|
+
displayedComponents?: MaterialDatePickerComponents
|
|
52
|
+
showVariantToggle?: boolean
|
|
53
|
+
is24Hour?: boolean
|
|
54
|
+
color?: string
|
|
55
|
+
elementColors?: MaterialDatePickerElementColors
|
|
56
|
+
selectableDates?: { start?: Date; end?: Date }
|
|
57
|
+
accessibilityLabel?: string
|
|
58
|
+
onDateSelected?: (date: Date | null) => void
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare function MaterialDatePicker(props: MaterialDatePickerProps): unknown
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type SwiftUIDatePickerStyle = 'automatic' | 'compact' | 'graphical' | 'wheel'
|
|
2
|
+
|
|
3
|
+
export type SwiftUIDatePickerComponent = 'date' | 'hourAndMinute'
|
|
4
|
+
|
|
5
|
+
export interface SwiftUIDatePickerProps {
|
|
6
|
+
id?: string
|
|
7
|
+
className?: any
|
|
8
|
+
style?: any
|
|
9
|
+
title?: string
|
|
10
|
+
selection?: Date
|
|
11
|
+
defaultSelection?: Date
|
|
12
|
+
minimumDate?: Date
|
|
13
|
+
maximumDate?: Date
|
|
14
|
+
displayedComponents?: readonly SwiftUIDatePickerComponent[]
|
|
15
|
+
pickerStyle?: SwiftUIDatePickerStyle
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
accessibilityLabel?: string
|
|
18
|
+
onSelectionChange?: (date: Date) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare function SwiftUIDatePicker(props: SwiftUIDatePickerProps): unknown
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type AppKitDatePickerComponents = 'date' | 'time' | 'dateAndTime'
|
|
2
|
+
|
|
3
|
+
export type AppKitDatePickerStyle = 'textField' | 'graphical'
|
|
4
|
+
|
|
5
|
+
export interface AppKitDatePickerProps {
|
|
6
|
+
id?: string
|
|
7
|
+
className?: any
|
|
8
|
+
style?: any
|
|
9
|
+
components?: AppKitDatePickerComponents
|
|
10
|
+
pickerStyle?: AppKitDatePickerStyle
|
|
11
|
+
selection?: Date
|
|
12
|
+
defaultSelection?: Date
|
|
13
|
+
minimumDate?: Date
|
|
14
|
+
maximumDate?: Date
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
accessibilityLabel?: string
|
|
17
|
+
onSelectionChange?: (date: Date) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare function AppKitDatePicker(props: AppKitDatePickerProps): unknown
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DateInputType = 'date' | 'time' | 'datetime-local'
|
|
2
|
+
|
|
3
|
+
export interface DateInputProps {
|
|
4
|
+
id?: string
|
|
5
|
+
className?: any
|
|
6
|
+
style?: any
|
|
7
|
+
label?: string
|
|
8
|
+
type?: DateInputType
|
|
9
|
+
value?: string
|
|
10
|
+
defaultValue?: string
|
|
11
|
+
min?: string
|
|
12
|
+
max?: string
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
accessibilityLabel?: string
|
|
15
|
+
onChange?: (value: string) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare function DateInput(props: DateInputProps): unknown
|