@astryxdesign/native 0.0.0-bootstrap.1 → 0.7.4-canary.720bb10
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 +119 -1
- package/apple/Package.swift +18 -0
- package/apple/Sources/AstryxNative/Generated/AstryxBase.swift +12 -0
- package/apple/Sources/AstryxNative/Generated/Selector.swift +159 -0
- package/apple/Tests/AstryxNativeTests/SelectorPropsTests.swift +17 -0
- package/dist/components/Selector.d.ts +10 -0
- package/dist/components/Selector.d.ts.map +1 -0
- package/dist/components/Selector.js +38 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/contract/fromComponentDoc.d.ts +32 -0
- package/dist/contract/fromComponentDoc.d.ts.map +1 -0
- package/dist/contract/fromComponentDoc.js +81 -0
- package/dist/contract/generateSwift.d.ts +4 -0
- package/dist/contract/generateSwift.d.ts.map +1 -0
- package/dist/contract/generateSwift.js +133 -0
- package/dist/contract/generateTypeScript.d.ts +4 -0
- package/dist/contract/generateTypeScript.d.ts.map +1 -0
- package/dist/contract/generateTypeScript.js +87 -0
- package/dist/contract/index.d.ts +20 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +33 -0
- package/dist/contract/names.d.ts +20 -0
- package/dist/contract/names.d.ts.map +1 -0
- package/dist/contract/names.js +90 -0
- package/dist/contract/parseDocType.d.ts +22 -0
- package/dist/contract/parseDocType.d.ts.map +1 -0
- package/dist/contract/parseDocType.js +183 -0
- package/dist/contract/rules.d.ts +10 -0
- package/dist/contract/rules.d.ts.map +1 -0
- package/dist/contract/rules.js +87 -0
- package/dist/contract/types.d.ts +57 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +2 -0
- package/dist/icons/defaults.d.ts +25 -0
- package/dist/icons/defaults.d.ts.map +1 -0
- package/dist/icons/defaults.js +111 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/platforms.d.ts +13 -0
- package/dist/platforms.d.ts.map +1 -0
- package/dist/platforms.js +14 -0
- package/dist/theme/defineNativeTheme.d.ts +75 -0
- package/dist/theme/defineNativeTheme.d.ts.map +1 -0
- package/dist/theme/defineNativeTheme.js +126 -0
- package/dist/types/android.d.ts +8 -0
- package/dist/types/core.d.ts +35 -0
- package/dist/types/ios.d.ts +8 -0
- package/dist/types/macos.d.ts +8 -0
- package/dist/types/shared.d.ts +6 -0
- package/dist/types/windows.d.ts +6 -0
- package/package.json +72 -5
- package/src/components/Selector.ts +50 -0
- package/src/components/index.ts +14 -0
- package/src/contract/contracts.test.ts +150 -0
- package/src/contract/fromComponentDoc.ts +131 -0
- package/src/contract/generateSwift.ts +170 -0
- package/src/contract/generateTypeScript.ts +115 -0
- package/src/contract/index.ts +53 -0
- package/src/contract/names.ts +103 -0
- package/src/contract/parseDocType.test.ts +52 -0
- package/src/contract/parseDocType.ts +211 -0
- package/src/contract/rules.ts +132 -0
- package/src/contract/types.ts +52 -0
- package/src/icons/defaults.test.ts +47 -0
- package/src/icons/defaults.ts +136 -0
- package/src/index.ts +35 -0
- package/src/platforms.ts +20 -0
- package/src/theme/defineNativeTheme.test.ts +88 -0
- package/src/theme/defineNativeTheme.ts +224 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Meta Platforms, Inc.
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
1
|
# @astryxdesign/native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Experimental. Canary only.** This package is published only under the
|
|
4
|
+
> `@canary` dist-tag and is never released as a stable version. Its APIs change
|
|
5
|
+
> without notice. Nothing here is supported for production apps.
|
|
6
|
+
|
|
7
|
+
`@astryxdesign/native` is where Astryx experiments with native platforms
|
|
8
|
+
(iOS, Android, macOS, Windows) under AST-082 (Native-first surfaces). The
|
|
9
|
+
experiment compares ways of building Astryx components on each platform and
|
|
10
|
+
measures them against the same scorecard, so the decision for each platform
|
|
11
|
+
rests on evidence.
|
|
12
|
+
|
|
13
|
+
## What is here today
|
|
14
|
+
|
|
15
|
+
| Part | Path | What it does |
|
|
16
|
+
| -------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| Contracts | `src/contract/` | Reads a core component's documentation and splits its props into a portable **core contract** and a **web-only** part, with a reason for each web-only prop. Checks prop names against Swift and Kotlin keywords and platform toolkit names. |
|
|
18
|
+
| Platform types | `@astryxdesign/native/components` | TypeScript props per platform, chosen by type-resolution condition: `ios`, `android`, `macos`, `windows`, or `shared` for the core contract only. |
|
|
19
|
+
| Swift binding | `apple/` | A Swift package with props generated from the same contracts. iOS and macOS props sit behind `#if os(...)`. |
|
|
20
|
+
| Native theme | `defineNativeTheme` | Durable theme intent (`material: 'opaque' \| 'translucent'`) plus platform entries scoped by OS version, such as Liquid Glass from iOS 26. Never sets tokens. |
|
|
21
|
+
| Icons | `NATIVE_ICON_DEFAULTS` | Astryx's built-in icon names mapped to SF Symbols on Apple platforms and Material Symbols on Android. |
|
|
22
|
+
|
|
23
|
+
Only `Selector` has native additions so far. React Native and Android bindings
|
|
24
|
+
are not built yet; see [the experiment matrix](#experiment-matrix).
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
// tsconfig.json for an iOS app: "customConditions": ["ios"]
|
|
28
|
+
import type {SelectorProps} from '@astryxdesign/native/components';
|
|
29
|
+
|
|
30
|
+
const props: SelectorProps = {
|
|
31
|
+
label: 'Shipping',
|
|
32
|
+
options: [{value: 'standard', label: 'Standard'}],
|
|
33
|
+
menuStyle: 'pullDown', // iOS-only prop; an Android build rejects it
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Working on it
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pnpm -F @astryxdesign/native build # dist/, including platform types
|
|
41
|
+
pnpm -F @astryxdesign/native generate:apple # regenerate apple/Sources/.../Generated
|
|
42
|
+
pnpm vitest run --project node packages/native
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Generated Swift is committed so a Swift package can pin a commit. A test fails
|
|
46
|
+
when it drifts from the contracts.
|
|
47
|
+
|
|
48
|
+
Boundaries, checked by `pnpm check:package-boundaries`:
|
|
49
|
+
|
|
50
|
+
- `@astryxdesign/core` never imports this package.
|
|
51
|
+
- This package's source never imports core. It reads core's documentation
|
|
52
|
+
files as data at build time.
|
|
53
|
+
|
|
54
|
+
## Experiment matrix
|
|
55
|
+
|
|
56
|
+
Every arm runs the same subjects on the same devices and is scored against a
|
|
57
|
+
**reference**: the same screens hand-built with the platform toolkit (SwiftUI,
|
|
58
|
+
Jetpack Compose, WinUI).
|
|
59
|
+
|
|
60
|
+
| Arm | How components are built | iOS | Android | macOS | Windows |
|
|
61
|
+
| ------------------------- | ---------------------------------------------------------------------------------------- | --- | ------- | ----- | ------- |
|
|
62
|
+
| A. Pure native | Platform views (SwiftUI, Compose, WinUI) on generated contracts | ✓ | ✓ | ✓ | ✓ |
|
|
63
|
+
| B. React Native | React Native components; desktop through `react-native-macos` and `react-native-windows` | ✓ | ✓ | ✓ | ✓ |
|
|
64
|
+
| C. Shared logic core | Component logic in TypeScript running in Hermes, driving platform views | ✓ | ✓ | ✓ | — |
|
|
65
|
+
| D. Web on native | Web React components through a native renderer, such as Expo's experimental fork | ✓ | ✓ | — | — |
|
|
66
|
+
| E. Web in a desktop shell | Astryx's web components unchanged inside Electron | — | — | ✓ | ✓ |
|
|
67
|
+
|
|
68
|
+
Arms D and E are measured but cannot become required runtimes as written:
|
|
69
|
+
arm D depends on a third-party fork and arm E on Electron, a third-party
|
|
70
|
+
runtime (AST-082 FR13). Arm E is the baseline for how far plain web gets on
|
|
71
|
+
desktop.
|
|
72
|
+
|
|
73
|
+
### Test subjects
|
|
74
|
+
|
|
75
|
+
Templates come first because their web version is a known reference for
|
|
76
|
+
content and states.
|
|
77
|
+
|
|
78
|
+
1. **Wave 1:** `checkout-wizard` (forms, stepper, pickers, validation, keyboard),
|
|
79
|
+
`table-inbox` (long list, row actions, search, compose sheet), `dashboard`
|
|
80
|
+
(charts, tables, scrolling).
|
|
81
|
+
2. **Wave 2:** `settings`, `kanban-board`, `ai-chat`, `product-detail`.
|
|
82
|
+
3. **Component flows:** Selector, text entry, dialog and sheet, list with row
|
|
83
|
+
actions.
|
|
84
|
+
|
|
85
|
+
Each subject has one scripted interaction that every arm replays.
|
|
86
|
+
|
|
87
|
+
Visual scores come from real screens. Every scripted step is captured as a
|
|
88
|
+
screenshot on the device, every behavior (sheet open and dismiss, navigation
|
|
89
|
+
transitions, gestures, scrolling, press feedback, keyboard) as a short video or
|
|
90
|
+
GIF, and every scenario as a recording, for each arm, the
|
|
91
|
+
reference, and the web version, in light and dark and at the largest text size.
|
|
92
|
+
Reviewers compare captures side by side with arm names hidden, and pixel checks
|
|
93
|
+
read colors and sizes from the captures, never from source.
|
|
94
|
+
|
|
95
|
+
### Metrics
|
|
96
|
+
|
|
97
|
+
| Area | Measure | How | Unit |
|
|
98
|
+
| --------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
|
|
99
|
+
| Gate | Required runtimes | Dependency manifest against FR13 | pass/fail |
|
|
100
|
+
| Gate | Screen-reader parity | VoiceOver, TalkBack, Narrator task script | pass/fail |
|
|
101
|
+
| Gate | Completeness | Every subject renders every state | pass/fail |
|
|
102
|
+
| Experience | Platform feel | Blind reviewer rating of captured screens and recordings against the reference, plus a platform-conventions checklist | score, % of checklist |
|
|
103
|
+
| Experience | Behavior and motion | Blind reviewer rating of behavior videos against the reference: timing, easing, gesture response, interruptibility | score per behavior |
|
|
104
|
+
| Experience | Time to adopt a new OS feature | Days from OS release to shipping it in the arm (for example, Liquid Glass) | days |
|
|
105
|
+
| Performance | Startup to first content | Release build, cold start, median of runs | ms |
|
|
106
|
+
| Performance | Smoothness | Dropped frames during the scripted interaction | % frames |
|
|
107
|
+
| Performance | Input latency | Touch or key to visible response | ms |
|
|
108
|
+
| Performance | Memory and size | Peak memory during the script; app download size | MB |
|
|
109
|
+
| Maintenance | Change cost | Time to ship one real Astryx change on the arm (a new prop, a new token) | hours |
|
|
110
|
+
| Developer speed | Iteration | Edit to visible on device | seconds |
|
|
111
|
+
| Developer speed | Sharing | Share of app code reused across platforms | % lines |
|
|
112
|
+
| Design | Brand preservation | Blind designer review of whether the brand is recognizable from the web version while the screen still feels native, plus pixel checks on the captures for the theme's color, type, shape, spacing, and icons | score, % token checks |
|
|
113
|
+
| Fidelity | Match to web | Content and states matching the web template | % checks |
|
|
114
|
+
|
|
115
|
+
### Judging
|
|
116
|
+
|
|
117
|
+
1. An arm that fails a gate is out for that platform.
|
|
118
|
+
2. The remaining arms are compared per platform, each measure relative to the
|
|
119
|
+
reference on the same device.
|
|
120
|
+
3. Whether the measures are weighted into one score or ranked side by side is
|
|
121
|
+
not decided yet.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// swift-tools-version: 6.0
|
|
2
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
|
|
4
|
+
// Experimental Astryx for Apple platforms (AST-082). The contract types under
|
|
5
|
+
// Sources/AstryxNative/Generated are generated by `pnpm generate:apple`; do not
|
|
6
|
+
// edit them by hand.
|
|
7
|
+
|
|
8
|
+
import PackageDescription
|
|
9
|
+
|
|
10
|
+
let package = Package(
|
|
11
|
+
name: "AstryxNative",
|
|
12
|
+
platforms: [.iOS(.v17), .macOS(.v14)],
|
|
13
|
+
products: [.library(name: "AstryxNative", targets: ["AstryxNative"])],
|
|
14
|
+
targets: [
|
|
15
|
+
.target(name: "AstryxNative", path: "Sources/AstryxNative"),
|
|
16
|
+
.testTarget(name: "AstryxNativeTests", dependencies: ["AstryxNative"], path: "Tests/AstryxNativeTests"),
|
|
17
|
+
]
|
|
18
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public enum AstryxBaseTarget: String, Sendable { case root, trigger, control, container }
|
|
3
|
+
|
|
4
|
+
/// Base props shared by every platform (AST-082 FR7).
|
|
5
|
+
public struct AstryxBaseProps: Equatable, Sendable {
|
|
6
|
+
public var id: String?
|
|
7
|
+
public var isHidden: Bool?
|
|
8
|
+
public init(id: String? = nil, isHidden: Bool? = nil) {
|
|
9
|
+
self.id = id
|
|
10
|
+
self.isHidden = isHidden
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Generated by @astryxdesign/native. Do not edit.
|
|
2
|
+
public struct SelectorOption: Equatable, Sendable {
|
|
3
|
+
public var value: String
|
|
4
|
+
public var label: String?
|
|
5
|
+
public var disabled: Bool?
|
|
6
|
+
public init(value: String, label: String? = nil, disabled: Bool? = nil) {
|
|
7
|
+
self.value = value
|
|
8
|
+
self.label = label
|
|
9
|
+
self.disabled = disabled
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
public enum SelectorSize: String, CaseIterable, Sendable {
|
|
13
|
+
case sm = "sm"
|
|
14
|
+
case md = "md"
|
|
15
|
+
case lg = "lg"
|
|
16
|
+
}
|
|
17
|
+
public enum SelectorVariant: String, CaseIterable, Sendable {
|
|
18
|
+
case input = "input"
|
|
19
|
+
case secondary = "secondary"
|
|
20
|
+
case ghost = "ghost"
|
|
21
|
+
}
|
|
22
|
+
public enum SelectorStatusType: String, CaseIterable, Sendable {
|
|
23
|
+
case error = "error"
|
|
24
|
+
case warning = "warning"
|
|
25
|
+
case success = "success"
|
|
26
|
+
}
|
|
27
|
+
public struct SelectorStatus: Equatable, Sendable {
|
|
28
|
+
public var type: SelectorStatusType
|
|
29
|
+
public var message: String?
|
|
30
|
+
public init(type: SelectorStatusType, message: String? = nil) {
|
|
31
|
+
self.type = type
|
|
32
|
+
self.message = message
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
public enum SelectorStatusVariant: String, CaseIterable, Sendable {
|
|
36
|
+
case attached = "attached"
|
|
37
|
+
case detached = "detached"
|
|
38
|
+
case tooltip = "tooltip"
|
|
39
|
+
}
|
|
40
|
+
public enum SelectorIndicatorPosition: String, CaseIterable, Sendable {
|
|
41
|
+
case start = "start"
|
|
42
|
+
case end = "end"
|
|
43
|
+
}
|
|
44
|
+
#if os(iOS)
|
|
45
|
+
public enum SelectorMenuStyle: String, CaseIterable, Sendable {
|
|
46
|
+
case popUp = "popUp"
|
|
47
|
+
case pullDown = "pullDown"
|
|
48
|
+
}
|
|
49
|
+
public struct SelectorProps {
|
|
50
|
+
/// Base props attach to this part on every platform.
|
|
51
|
+
public static let baseTarget: AstryxBaseTarget = .trigger
|
|
52
|
+
public var base: AstryxBaseProps
|
|
53
|
+
public var label: String
|
|
54
|
+
public var options: [SelectorOption]
|
|
55
|
+
public var value: String?
|
|
56
|
+
public var onChange: ((String) -> Void)?
|
|
57
|
+
public var hasClear: Bool?
|
|
58
|
+
public var hasSearch: Bool?
|
|
59
|
+
public var searchPlaceholder: String?
|
|
60
|
+
public var placeholder: String?
|
|
61
|
+
public var size: SelectorSize?
|
|
62
|
+
public var variant: SelectorVariant?
|
|
63
|
+
public var isDisabled: Bool?
|
|
64
|
+
public var isReadOnly: Bool?
|
|
65
|
+
public var disabledMessage: String?
|
|
66
|
+
public var isLabelHidden: Bool?
|
|
67
|
+
public var description: String?
|
|
68
|
+
public var isOptional: Bool?
|
|
69
|
+
public var isRequired: Bool?
|
|
70
|
+
public var status: SelectorStatus?
|
|
71
|
+
public var statusVariant: SelectorStatusVariant?
|
|
72
|
+
public var indicatorPosition: SelectorIndicatorPosition?
|
|
73
|
+
public var isLoading: Bool?
|
|
74
|
+
public var menuStyle: SelectorMenuStyle?
|
|
75
|
+
public init(label: String, options: [SelectorOption], value: String? = nil, onChange: ((String) -> Void)? = nil, hasClear: Bool? = nil, hasSearch: Bool? = nil, searchPlaceholder: String? = nil, placeholder: String? = nil, size: SelectorSize? = nil, variant: SelectorVariant? = nil, isDisabled: Bool? = nil, isReadOnly: Bool? = nil, disabledMessage: String? = nil, isLabelHidden: Bool? = nil, description: String? = nil, isOptional: Bool? = nil, isRequired: Bool? = nil, status: SelectorStatus? = nil, statusVariant: SelectorStatusVariant? = nil, indicatorPosition: SelectorIndicatorPosition? = nil, isLoading: Bool? = nil, menuStyle: SelectorMenuStyle? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
76
|
+
self.label = label
|
|
77
|
+
self.options = options
|
|
78
|
+
self.value = value
|
|
79
|
+
self.onChange = onChange
|
|
80
|
+
self.hasClear = hasClear
|
|
81
|
+
self.hasSearch = hasSearch
|
|
82
|
+
self.searchPlaceholder = searchPlaceholder
|
|
83
|
+
self.placeholder = placeholder
|
|
84
|
+
self.size = size
|
|
85
|
+
self.variant = variant
|
|
86
|
+
self.isDisabled = isDisabled
|
|
87
|
+
self.isReadOnly = isReadOnly
|
|
88
|
+
self.disabledMessage = disabledMessage
|
|
89
|
+
self.isLabelHidden = isLabelHidden
|
|
90
|
+
self.description = description
|
|
91
|
+
self.isOptional = isOptional
|
|
92
|
+
self.isRequired = isRequired
|
|
93
|
+
self.status = status
|
|
94
|
+
self.statusVariant = statusVariant
|
|
95
|
+
self.indicatorPosition = indicatorPosition
|
|
96
|
+
self.isLoading = isLoading
|
|
97
|
+
self.menuStyle = menuStyle
|
|
98
|
+
self.base = base
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
#endif
|
|
102
|
+
#if os(macOS)
|
|
103
|
+
public enum SelectorMenuStyle: String, CaseIterable, Sendable {
|
|
104
|
+
case popUp = "popUp"
|
|
105
|
+
case pullDown = "pullDown"
|
|
106
|
+
}
|
|
107
|
+
public struct SelectorProps {
|
|
108
|
+
/// Base props attach to this part on every platform.
|
|
109
|
+
public static let baseTarget: AstryxBaseTarget = .trigger
|
|
110
|
+
public var base: AstryxBaseProps
|
|
111
|
+
public var label: String
|
|
112
|
+
public var options: [SelectorOption]
|
|
113
|
+
public var value: String?
|
|
114
|
+
public var onChange: ((String) -> Void)?
|
|
115
|
+
public var hasClear: Bool?
|
|
116
|
+
public var hasSearch: Bool?
|
|
117
|
+
public var searchPlaceholder: String?
|
|
118
|
+
public var placeholder: String?
|
|
119
|
+
public var size: SelectorSize?
|
|
120
|
+
public var variant: SelectorVariant?
|
|
121
|
+
public var isDisabled: Bool?
|
|
122
|
+
public var isReadOnly: Bool?
|
|
123
|
+
public var disabledMessage: String?
|
|
124
|
+
public var isLabelHidden: Bool?
|
|
125
|
+
public var description: String?
|
|
126
|
+
public var isOptional: Bool?
|
|
127
|
+
public var isRequired: Bool?
|
|
128
|
+
public var status: SelectorStatus?
|
|
129
|
+
public var statusVariant: SelectorStatusVariant?
|
|
130
|
+
public var indicatorPosition: SelectorIndicatorPosition?
|
|
131
|
+
public var isLoading: Bool?
|
|
132
|
+
public var menuStyle: SelectorMenuStyle?
|
|
133
|
+
public init(label: String, options: [SelectorOption], value: String? = nil, onChange: ((String) -> Void)? = nil, hasClear: Bool? = nil, hasSearch: Bool? = nil, searchPlaceholder: String? = nil, placeholder: String? = nil, size: SelectorSize? = nil, variant: SelectorVariant? = nil, isDisabled: Bool? = nil, isReadOnly: Bool? = nil, disabledMessage: String? = nil, isLabelHidden: Bool? = nil, description: String? = nil, isOptional: Bool? = nil, isRequired: Bool? = nil, status: SelectorStatus? = nil, statusVariant: SelectorStatusVariant? = nil, indicatorPosition: SelectorIndicatorPosition? = nil, isLoading: Bool? = nil, menuStyle: SelectorMenuStyle? = nil, base: AstryxBaseProps = AstryxBaseProps()) {
|
|
134
|
+
self.label = label
|
|
135
|
+
self.options = options
|
|
136
|
+
self.value = value
|
|
137
|
+
self.onChange = onChange
|
|
138
|
+
self.hasClear = hasClear
|
|
139
|
+
self.hasSearch = hasSearch
|
|
140
|
+
self.searchPlaceholder = searchPlaceholder
|
|
141
|
+
self.placeholder = placeholder
|
|
142
|
+
self.size = size
|
|
143
|
+
self.variant = variant
|
|
144
|
+
self.isDisabled = isDisabled
|
|
145
|
+
self.isReadOnly = isReadOnly
|
|
146
|
+
self.disabledMessage = disabledMessage
|
|
147
|
+
self.isLabelHidden = isLabelHidden
|
|
148
|
+
self.description = description
|
|
149
|
+
self.isOptional = isOptional
|
|
150
|
+
self.isRequired = isRequired
|
|
151
|
+
self.status = status
|
|
152
|
+
self.statusVariant = statusVariant
|
|
153
|
+
self.indicatorPosition = indicatorPosition
|
|
154
|
+
self.isLoading = isLoading
|
|
155
|
+
self.menuStyle = menuStyle
|
|
156
|
+
self.base = base
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
#endif
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import Testing
|
|
4
|
+
@testable import AstryxNative
|
|
5
|
+
|
|
6
|
+
@Test func selectorCoreAndPlatformProps() {
|
|
7
|
+
let props = SelectorProps(
|
|
8
|
+
label: "Shipping",
|
|
9
|
+
options: [SelectorOption(value: "std", label: "Standard")],
|
|
10
|
+
onChange: { _ in },
|
|
11
|
+
menuStyle: .pullDown,
|
|
12
|
+
base: AstryxBaseProps(id: "shipping")
|
|
13
|
+
)
|
|
14
|
+
#expect(props.label == "Shipping")
|
|
15
|
+
#expect(props.menuStyle == .pullDown)
|
|
16
|
+
#expect(SelectorProps.baseTarget == .trigger)
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/Selector.ts
|
|
3
|
+
* @input None
|
|
4
|
+
* @output What @astryxdesign/native adds to the core Selector contract
|
|
5
|
+
* @position Native additions read by fromComponentDoc together with core's
|
|
6
|
+
* Selector documentation
|
|
7
|
+
*/
|
|
8
|
+
import type { NativeAdditions } from '../contract/fromComponentDoc.js';
|
|
9
|
+
export declare const selector: NativeAdditions;
|
|
10
|
+
//# sourceMappingURL=Selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Selector.d.ts","sourceRoot":"","sources":["../../src/components/Selector.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAErE,eAAO,MAAM,QAAQ,EAAE,eAqCtB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
export const selector = {
|
|
3
|
+
name: 'Selector',
|
|
4
|
+
baseTarget: 'trigger',
|
|
5
|
+
typeNames: { SelectorOption: 'SelectorOption' },
|
|
6
|
+
types: {
|
|
7
|
+
// The portable part of core's option data. Its rich description, icon,
|
|
8
|
+
// and secondary control are web-only until typed slots exist.
|
|
9
|
+
SelectorOption: {
|
|
10
|
+
value: { type: { kind: 'string' } },
|
|
11
|
+
label: { type: { kind: 'string' }, optional: true },
|
|
12
|
+
disabled: { type: { kind: 'boolean' }, optional: true },
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
webOnly: {
|
|
16
|
+
presentation: 'web presentation choice; native platforms use their own control (FR11)',
|
|
17
|
+
},
|
|
18
|
+
platforms: {
|
|
19
|
+
ios: {
|
|
20
|
+
menuStyle: {
|
|
21
|
+
type: { kind: 'enum', values: ['popUp', 'pullDown'] },
|
|
22
|
+
optional: true,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
macos: {
|
|
26
|
+
menuStyle: {
|
|
27
|
+
type: { kind: 'enum', values: ['popUp', 'pullDown'] },
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
android: {
|
|
32
|
+
menuStyle: {
|
|
33
|
+
type: { kind: 'enum', values: ['dropdown', 'bottomSheet'] },
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/index.ts
|
|
3
|
+
* @input None
|
|
4
|
+
* @output Every component the native package adds to, by core component name
|
|
5
|
+
* @position The generator walks this list; each entry pairs with core's
|
|
6
|
+
* `<Name>/<Name>.doc.mjs`
|
|
7
|
+
*/
|
|
8
|
+
import type { NativeAdditions } from '../contract/fromComponentDoc.js';
|
|
9
|
+
export declare const NATIVE_COMPONENTS: readonly NativeAdditions[];
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAGrE,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAAe,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BaseTarget, ComponentContract, PropMap } from './types.js';
|
|
2
|
+
import type { NativePlatform } from '../platforms.js';
|
|
3
|
+
/** The subset of a ComponentDoc this reader needs. */
|
|
4
|
+
export interface ComponentDocLike {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly props?: ReadonlyArray<{
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly type?: unknown;
|
|
9
|
+
readonly required?: boolean;
|
|
10
|
+
readonly description?: unknown;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/** What the native package adds to one core component. */
|
|
14
|
+
export interface NativeAdditions {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly baseTarget: BaseTarget;
|
|
17
|
+
/**
|
|
18
|
+
* Portable definitions for named types the documentation references. Fields
|
|
19
|
+
* the web type has that are not portable are left out on purpose.
|
|
20
|
+
*/
|
|
21
|
+
readonly types?: Readonly<Record<string, PropMap>>;
|
|
22
|
+
/** Documented types renamed to a native definition, e.g. `SelectorOption[]`. */
|
|
23
|
+
readonly typeNames?: Readonly<Record<string, string>>;
|
|
24
|
+
readonly platforms?: Readonly<Partial<Record<NativePlatform, PropMap>>>;
|
|
25
|
+
/**
|
|
26
|
+
* Portable-typed props that still belong to the web contract, with the
|
|
27
|
+
* reason, such as a web presentation heuristic a native platform replaces.
|
|
28
|
+
*/
|
|
29
|
+
readonly webOnly?: Readonly<Record<string, string>>;
|
|
30
|
+
}
|
|
31
|
+
export declare function fromComponentDoc(doc: ComponentDocLike, additions: NativeAdditions): ComponentContract;
|
|
32
|
+
//# sourceMappingURL=fromComponentDoc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fromComponentDoc.d.ts","sourceRoot":"","sources":["../../src/contract/fromComponentDoc.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,OAAO,EAGR,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAEpD,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;QAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC,CAAC;CACJ;AAED,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACxE;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,gBAAgB,EACrB,SAAS,EAAE,eAAe,GACzB,iBAAiB,CA0EnB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
/**
|
|
3
|
+
* @file contract/fromComponentDoc.ts
|
|
4
|
+
* @input A component's documentation (.doc.mjs) plus the native additions for it
|
|
5
|
+
* @output A component contract: the portable core, native platform props, and the
|
|
6
|
+
* web-only props with reasons
|
|
7
|
+
* @position Turns core documentation into the contract the generators consume.
|
|
8
|
+
* Reads documentation as data at build time; never imports core at run time
|
|
9
|
+
* (AST-082 FR16)
|
|
10
|
+
*/
|
|
11
|
+
import { parseDocType } from './parseDocType.js';
|
|
12
|
+
import { coreNameProblem } from './rules.js';
|
|
13
|
+
export function fromComponentDoc(doc, additions) {
|
|
14
|
+
const core = {};
|
|
15
|
+
const webOnly = [];
|
|
16
|
+
const types = additions.types ?? {};
|
|
17
|
+
for (const prop of doc.props ?? []) {
|
|
18
|
+
const declaredWebOnly = additions.webOnly?.[prop.name];
|
|
19
|
+
if (declaredWebOnly) {
|
|
20
|
+
webOnly.push({ name: prop.name, reason: declaredWebOnly });
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (/(?:Xstyle|XStyle|ClassName|Style)$/.test(prop.name) ||
|
|
24
|
+
prop.name === 'xstyle') {
|
|
25
|
+
webOnly.push({ name: prop.name, reason: 'web styling input' });
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (prop.name.startsWith('html') || prop.name.startsWith('aria-')) {
|
|
29
|
+
webOnly.push({ name: prop.name, reason: 'HTML attribute' });
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const parsed = parseDocType(String(prop.type ?? ''));
|
|
33
|
+
if (!parsed.ok) {
|
|
34
|
+
webOnly.push({ name: prop.name, reason: parsed.reason });
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// A portable type can still carry a name another platform owns.
|
|
38
|
+
const nameProblem = coreNameProblem(prop.name);
|
|
39
|
+
if (nameProblem) {
|
|
40
|
+
webOnly.push({ name: prop.name, reason: nameProblem });
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
let type = parsed.type;
|
|
44
|
+
const renamed = (name) => additions.typeNames?.[name] ?? name;
|
|
45
|
+
if (type.kind === 'named') {
|
|
46
|
+
type = { kind: 'named', name: renamed(type.name) };
|
|
47
|
+
}
|
|
48
|
+
if (type.kind === 'array' && type.of.kind === 'named') {
|
|
49
|
+
type = { kind: 'array', of: { kind: 'named', name: renamed(type.of.name) } };
|
|
50
|
+
}
|
|
51
|
+
if (type.kind === 'named' && !(type.name in types)) {
|
|
52
|
+
webOnly.push({
|
|
53
|
+
name: prop.name,
|
|
54
|
+
reason: `type "${type.name}" has no portable definition yet`,
|
|
55
|
+
});
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (type.kind === 'array' &&
|
|
59
|
+
type.of.kind === 'named' &&
|
|
60
|
+
!(type.of.name in types)) {
|
|
61
|
+
webOnly.push({
|
|
62
|
+
name: prop.name,
|
|
63
|
+
reason: `type "${type.of.name}" has no portable definition yet`,
|
|
64
|
+
});
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
core[prop.name] = {
|
|
68
|
+
type,
|
|
69
|
+
optional: prop.required !== true,
|
|
70
|
+
...(typeof prop.description === 'string' ? { doc: prop.description } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
name: additions.name,
|
|
75
|
+
baseTarget: additions.baseTarget,
|
|
76
|
+
types,
|
|
77
|
+
core,
|
|
78
|
+
platforms: additions.platforms ?? {},
|
|
79
|
+
webOnly,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComponentContract } from './types.js';
|
|
2
|
+
/** Returns file name to contents, relative to the generated Swift folder. */
|
|
3
|
+
export declare function generateSwift(contracts: readonly ComponentContract[]): Record<string, string>;
|
|
4
|
+
//# sourceMappingURL=generateSwift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateSwift.d.ts","sourceRoot":"","sources":["../../src/contract/generateSwift.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AAoJrE,6EAA6E;AAC7E,wBAAgB,aAAa,CAC3B,SAAS,EAAE,SAAS,iBAAiB,EAAE,GACtC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB"}
|