@octane-xplat/date-picker 0.0.1 → 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 +66 -10
- 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
- package/index.d.ts +0 -1
- package/index.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alec Larson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@octane-xplat/date-picker`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An install boundary for platform-specific date and time selection controls:
|
|
4
|
+
a SwiftUI `DatePicker` on iOS, Material 3 `DatePicker`/`TimePicker` built with
|
|
5
|
+
Jetpack Compose on Android, a labeled `<input type="date|time|datetime-local">`
|
|
6
|
+
on web, and a real `NSDatePicker` on macOS.
|
|
7
|
+
|
|
8
|
+
Install the package in the app that renders a control. Import
|
|
9
|
+
`SwiftUIDatePicker` from `@octane-xplat/date-picker/ios`,
|
|
10
|
+
`MaterialDatePicker` from `@octane-xplat/date-picker/android`, `DateInput`
|
|
11
|
+
from `@octane-xplat/date-picker/web`, or `AppKitDatePicker` from
|
|
12
|
+
`@octane-xplat/date-picker/macos` in the matching platform-suffixed file.
|
|
13
|
+
Each entry exports its own component and types; there is no shared date-picker
|
|
14
|
+
API at the package root.
|
|
15
|
+
|
|
16
|
+
The platform APIs use their own selection vocabulary: the iOS entry takes a
|
|
17
|
+
controlled `selection`/`defaultSelection` `Date` with `displayedComponents`
|
|
18
|
+
and `pickerStyle`; the Android entry follows the uncontrolled
|
|
19
|
+
`initialDate`/`onDateSelected` model of the Material 3 pickers with
|
|
20
|
+
`selectableDates` range bounds; the web entry follows browser input values;
|
|
21
|
+
the macOS entry takes `components`/`pickerStyle` (`'graphical'` embeds the
|
|
22
|
+
inline calendar) with a controlled `selection` `Date`.
|
|
23
|
+
|
|
24
|
+
Android notes: give `MaterialDatePicker` a bounded height (the M3 calendar's
|
|
25
|
+
lazy grid collapses under unbounded height), and keep `initialDate` and
|
|
26
|
+
`selectableDates` identity-stable — the provider keys its state `remember`
|
|
27
|
+
on them, so a per-render `new Date()` resets the selection.
|
|
28
|
+
See the framework guide for details and maintained examples:
|
|
29
|
+
[`docs/date-picker.md`](../../docs/date-picker.md).
|
|
30
|
+
|
|
31
|
+
The native implementations are adapted from `@expo/ui` (MIT,
|
|
32
|
+
`packages/expo-ui` sdk-57): `ios/DatePickerView.swift` and
|
|
33
|
+
`android/.../ui/DatePickerView.kt`. Attribution headers sit on the ported
|
|
34
|
+
files.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineUniversalComponent, registerElement, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
2
|
+
import { ComposeDataDriver, JetpackCompose, registerJetpackCompose } from "@nativescript/jetpack-compose";
|
|
3
|
+
//#region src/MaterialDatePicker.android.tsrx
|
|
4
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
5
|
+
"kind": "host",
|
|
6
|
+
"type": "xplatandroiddatepicker",
|
|
7
|
+
"props": { "composeId": "xplat-material-datepicker" },
|
|
8
|
+
"bindings": [
|
|
9
|
+
["id", 0],
|
|
10
|
+
["className", 1],
|
|
11
|
+
["style", 2],
|
|
12
|
+
["accessibilityLabel", 3],
|
|
13
|
+
["data", 4],
|
|
14
|
+
["onComposeEvent", 5]
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
registerElement("xplatandroiddatepicker", JetpackCompose);
|
|
18
|
+
registerJetpackCompose("xplat-material-datepicker", (owner) => new ComposeDataDriver(new com.octanexplat.datepicker.XplatDatePickerProvider(), owner));
|
|
19
|
+
var MaterialDatePicker = defineUniversalComponent("nativescript", function MaterialDatePicker(props) {
|
|
20
|
+
const data = {
|
|
21
|
+
initialDate: props.initialDate?.getTime() ?? null,
|
|
22
|
+
variant: props.variant ?? "picker",
|
|
23
|
+
displayedComponents: props.displayedComponents ?? "date",
|
|
24
|
+
showVariantToggle: props.showVariantToggle ?? true ? 1 : 0,
|
|
25
|
+
is24Hour: props.is24Hour ?? true ? 1 : 0,
|
|
26
|
+
color: props.color,
|
|
27
|
+
elementColors: props.elementColors,
|
|
28
|
+
selectableDates: {
|
|
29
|
+
start: props.selectableDates?.start?.getTime() ?? null,
|
|
30
|
+
end: props.selectableDates?.end?.getTime() ?? null
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
34
|
+
props.id,
|
|
35
|
+
props.className,
|
|
36
|
+
props.style,
|
|
37
|
+
props.accessibilityLabel,
|
|
38
|
+
data,
|
|
39
|
+
(event) => {
|
|
40
|
+
const millis = event.data?.date;
|
|
41
|
+
props.onDateSelected?.(typeof millis === "number" ? new Date(millis) : null);
|
|
42
|
+
}
|
|
43
|
+
]);
|
|
44
|
+
}, { "module": "@nativescript-community/octane" });
|
|
45
|
+
//#endregion
|
|
46
|
+
export { MaterialDatePicker };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineUniversalComponent, hookSlots, registerElement, universalPlan, universalValue, useState } from "@nativescript-community/octane";
|
|
2
|
+
import { SwiftUI, UIDataDriver, registerSwiftUI } from "@nativescript/swift-ui";
|
|
3
|
+
//#region src/SwiftUIDatePicker.ios.tsrx
|
|
4
|
+
var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
|
|
5
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
6
|
+
"kind": "host",
|
|
7
|
+
"type": "xplatiosdatepicker",
|
|
8
|
+
"props": { "swiftId": "xplat-swiftui-datepicker" },
|
|
9
|
+
"bindings": [
|
|
10
|
+
["id", 0],
|
|
11
|
+
["className", 1],
|
|
12
|
+
["style", 2],
|
|
13
|
+
["data", 3],
|
|
14
|
+
["onSwiftUIEvent", 4]
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
registerElement("xplatiosdatepicker", SwiftUI);
|
|
18
|
+
registerSwiftUI("xplat-swiftui-datepicker", (owner) => new UIDataDriver(new XplatDatePickerProvider(), owner));
|
|
19
|
+
var SwiftUIDatePicker = defineUniversalComponent("nativescript", function SwiftUIDatePicker(props) {
|
|
20
|
+
const controlled = props.selection !== void 0;
|
|
21
|
+
const [internalSelection, setInternalSelection] = useState(props.defaultSelection, _h$0);
|
|
22
|
+
const selection = controlled ? props.selection : internalSelection;
|
|
23
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
24
|
+
props.id,
|
|
25
|
+
props.className,
|
|
26
|
+
props.style,
|
|
27
|
+
{
|
|
28
|
+
title: props.title,
|
|
29
|
+
selection: selection?.getTime(),
|
|
30
|
+
range: {
|
|
31
|
+
start: props.minimumDate?.getTime(),
|
|
32
|
+
end: props.maximumDate?.getTime()
|
|
33
|
+
},
|
|
34
|
+
displayedComponents: props.displayedComponents ?? ["date"],
|
|
35
|
+
pickerStyle: props.pickerStyle ?? "automatic",
|
|
36
|
+
disabled: props.disabled ?? false
|
|
37
|
+
},
|
|
38
|
+
(event) => {
|
|
39
|
+
const millis = event.data?.date;
|
|
40
|
+
if (typeof millis !== "number") return;
|
|
41
|
+
const next = new Date(millis);
|
|
42
|
+
if (!controlled) setInternalSelection(next);
|
|
43
|
+
props.onSelectionChange?.(next);
|
|
44
|
+
}
|
|
45
|
+
]);
|
|
46
|
+
}, { "module": "@nativescript-community/octane" });
|
|
47
|
+
//#endregion
|
|
48
|
+
export { SwiftUIDatePicker };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { __s, bag16, child, clone, delegateEvents, hookSlots, setAriaAttribute, setBooleanAttribute, setEventHandler, setStyle, sibling, template, useState } from "octane";
|
|
2
|
+
import { bindSignalAttribute, bindSignalChild, bindSignalValue, enableSignalBindings, setPlainAttribute } from "octane/internal/client";
|
|
3
|
+
//#region src/DateInput.web.tsrx
|
|
4
|
+
enableSignalBindings(1, true);
|
|
5
|
+
delegateEvents(["change"]);
|
|
6
|
+
var _t$0 = /* @__PURE__ */ template("<label><span></span><input data-octane-input=\"i:ca76d877\"/></label>");
|
|
7
|
+
var _hs$ = /* @__PURE__ */ hookSlots(1);
|
|
8
|
+
var DateInput = /* @__PURE__ */ __s(function DateInput(props, __s, __extra) {
|
|
9
|
+
const controlled = props.value !== void 0;
|
|
10
|
+
const [internalValue, setInternalValue] = useState(props.defaultValue ?? "", _hs$ + 0);
|
|
11
|
+
const value = controlled ? props.value : internalValue;
|
|
12
|
+
const labelId = props.id ? `${props.id}-label` : void 0;
|
|
13
|
+
if (__s.block.pending && !__s.block.crossRenderUpdate) return;
|
|
14
|
+
let _b = __s.slots[0];
|
|
15
|
+
if (_b === void 0) {
|
|
16
|
+
let _m1, _m4, _m6, _m10;
|
|
17
|
+
const _root = clone(_t$0);
|
|
18
|
+
_m1 = _root;
|
|
19
|
+
const _el0 = child(_root);
|
|
20
|
+
_m4 = _el0;
|
|
21
|
+
const _el1 = sibling(_el0, 1);
|
|
22
|
+
_m6 = _el1;
|
|
23
|
+
_m10 = bindSignalValue(__s, void 0, _el1, value, "i:ca76d877");
|
|
24
|
+
setEventHandler(_el1, "$$change", (event) => {
|
|
25
|
+
const nextValue = event.target.value;
|
|
26
|
+
if (!controlled) setInternalValue(nextValue);
|
|
27
|
+
props.onChange?.(nextValue);
|
|
28
|
+
});
|
|
29
|
+
_b = bag16(__s, _root, void 0, _m1, void 0, void 0, _m4, void 0, _m6, void 0, void 0, void 0, _m10, void 0, void 0, void 0, null, void 0);
|
|
30
|
+
} else {
|
|
31
|
+
_b.k = bindSignalValue(__s, _b.k, _b.g, value, "i:ca76d877");
|
|
32
|
+
setEventHandler(_b.g, "$$change", (event) => {
|
|
33
|
+
const nextValue = event.target.value;
|
|
34
|
+
if (!controlled) setInternalValue(nextValue);
|
|
35
|
+
props.onChange?.(nextValue);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
_b.a = bindSignalAttribute(__s, _b.a, _b.b, "class", props.className, "b:cabeae14", "class");
|
|
39
|
+
{
|
|
40
|
+
const _v = props.style;
|
|
41
|
+
if (_b.c !== _v) {
|
|
42
|
+
setStyle(_b.b, _v, _b.c);
|
|
43
|
+
_b.c = _v;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
_b.d = bindSignalAttribute(__s, _b.d, _b.e, "id", labelId, "b:6dc088f1", setPlainAttribute);
|
|
47
|
+
_b.f = bindSignalAttribute(__s, _b.f, _b.g, "id", props.id, "b:f74893e7", setPlainAttribute);
|
|
48
|
+
_b.h = bindSignalAttribute(__s, _b.h, _b.g, "type", props.type ?? "date", "b:47e366ba", setPlainAttribute);
|
|
49
|
+
_b.i = bindSignalAttribute(__s, _b.i, _b.g, "aria-label", props.accessibilityLabel ?? props.label, "b:a953fab4", setAriaAttribute);
|
|
50
|
+
_b.j = bindSignalAttribute(__s, _b.j, _b.g, "aria-labelledby", labelId, "b:10bc1230", setAriaAttribute);
|
|
51
|
+
_b.l = bindSignalAttribute(__s, _b.l, _b.g, "min", props.min, "b:4fe4c70f", setPlainAttribute);
|
|
52
|
+
_b.m = bindSignalAttribute(__s, _b.m, _b.g, "max", props.max, "b:4c98be11", setPlainAttribute);
|
|
53
|
+
_b.n = bindSignalAttribute(__s, _b.n, _b.g, "disabled", props.disabled, "b:701d5b16", setBooleanAttribute);
|
|
54
|
+
_b.q = bindSignalChild(__s, _b.q, 1, _b.e, props.label, "b:25c6cb91", null, void 0, void 0, void 0, true);
|
|
55
|
+
});
|
|
56
|
+
//#endregion
|
|
57
|
+
export { DateInput };
|
package/package.json
CHANGED
|
@@ -1,18 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/date-picker",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Platform-specific date and time selection controls for Octane xplat",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/octane-xplat/octane-xplat
|
|
7
|
+
"url": "https://github.com/octane-xplat/octane-xplat",
|
|
8
8
|
"directory": "packages/date-picker"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/date-picker",
|
|
11
|
-
"main": "./index.js",
|
|
12
|
-
"types": "./index.d.ts",
|
|
13
10
|
"files": [
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
"dist",
|
|
12
|
+
"types",
|
|
13
|
+
"src",
|
|
14
|
+
"platforms"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./ios": {
|
|
19
|
+
"types": "./types/ios/index.d.ts",
|
|
20
|
+
"native": "./dist/native/ios/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./android": {
|
|
23
|
+
"types": "./types/android/index.d.ts",
|
|
24
|
+
"native": "./dist/native/android/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./web": {
|
|
27
|
+
"types": "./types/web/index.d.ts",
|
|
28
|
+
"web": "./dist/web/web/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@nativescript/jetpack-compose": "1.0.0-beta.0",
|
|
36
|
+
"@nativescript/swift-ui": "4.0.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@nativescript-community/octane": "0.2.4",
|
|
40
|
+
"@nativescript/core": "9.1.2",
|
|
41
|
+
"@octanejs/vite-plugin": "0.1.60",
|
|
42
|
+
"octane": "0.5.0",
|
|
43
|
+
"tsrx-typegen": "0.2.1",
|
|
44
|
+
"typescript": "5.9.3",
|
|
45
|
+
"vite": "8.3.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@nativescript-community/octane": ">=0.2.1 <1",
|
|
49
|
+
"@nativescript/core": ">=9.1.0 <10",
|
|
50
|
+
"octane": ">=0.1.51 <1"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"@nativescript-community/octane": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@nativescript/core": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"octane": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"nativescript": {
|
|
64
|
+
"platforms": {
|
|
65
|
+
"android": "9.1.0",
|
|
66
|
+
"ios": "9.1.0"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "vite build && vite build --mode native && tsc -p tsconfig.types.json",
|
|
71
|
+
"test:packed": "node tests/packed-consumer.mjs",
|
|
72
|
+
"pack:check": "tsrx-typegen --pack-check"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
|
|
2
|
+
|
|
3
|
+
android {
|
|
4
|
+
buildFeatures {
|
|
5
|
+
compose true
|
|
6
|
+
}
|
|
7
|
+
kotlinOptions {
|
|
8
|
+
jvmTarget = '17'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
dependencies {
|
|
13
|
+
implementation platform('androidx.compose:compose-bom:2024.12.01')
|
|
14
|
+
implementation 'androidx.compose.material3:material3'
|
|
15
|
+
}
|