@lynx-js/genui 0.0.1-rc.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 +202 -0
- package/README.md +170 -0
- package/a2ui/README.md +140 -0
- package/a2ui/dist/catalog/Button/catalog.json +156 -0
- package/a2ui/dist/catalog/Button/index.d.ts +35 -0
- package/a2ui/dist/catalog/Button/index.js +35 -0
- package/a2ui/dist/catalog/Button/index.js.map +1 -0
- package/a2ui/dist/catalog/Card/catalog.json +24 -0
- package/a2ui/dist/catalog/Card/index.d.ts +11 -0
- package/a2ui/dist/catalog/Card/index.js +19 -0
- package/a2ui/dist/catalog/Card/index.js.map +1 -0
- package/a2ui/dist/catalog/CheckBox/catalog.json +170 -0
- package/a2ui/dist/catalog/CheckBox/index.d.ts +32 -0
- package/a2ui/dist/catalog/CheckBox/index.js +24 -0
- package/a2ui/dist/catalog/CheckBox/index.js.map +1 -0
- package/a2ui/dist/catalog/Column/catalog.json +57 -0
- package/a2ui/dist/catalog/Column/index.d.ts +15 -0
- package/a2ui/dist/catalog/Column/index.js +55 -0
- package/a2ui/dist/catalog/Column/index.js.map +1 -0
- package/a2ui/dist/catalog/Divider/catalog.json +14 -0
- package/a2ui/dist/catalog/Divider/index.d.ts +9 -0
- package/a2ui/dist/catalog/Divider/index.js +8 -0
- package/a2ui/dist/catalog/Divider/index.js.map +1 -0
- package/a2ui/dist/catalog/Icon/catalog.json +45 -0
- package/a2ui/dist/catalog/Icon/index.d.ts +14 -0
- package/a2ui/dist/catalog/Icon/index.js +11 -0
- package/a2ui/dist/catalog/Icon/index.js.map +1 -0
- package/a2ui/dist/catalog/Image/catalog.json +62 -0
- package/a2ui/dist/catalog/Image/index.d.ts +16 -0
- package/a2ui/dist/catalog/Image/index.js +30 -0
- package/a2ui/dist/catalog/Image/index.js.map +1 -0
- package/a2ui/dist/catalog/LineChart/catalog.json +98 -0
- package/a2ui/dist/catalog/LineChart/index.d.ts +31 -0
- package/a2ui/dist/catalog/LineChart/index.js +195 -0
- package/a2ui/dist/catalog/LineChart/index.js.map +1 -0
- package/a2ui/dist/catalog/List/catalog.json +52 -0
- package/a2ui/dist/catalog/List/index.d.ts +15 -0
- package/a2ui/dist/catalog/List/index.js +53 -0
- package/a2ui/dist/catalog/List/index.js.map +1 -0
- package/a2ui/dist/catalog/Modal/catalog.json +18 -0
- package/a2ui/dist/catalog/Modal/index.d.ts +12 -0
- package/a2ui/dist/catalog/Modal/index.js +33 -0
- package/a2ui/dist/catalog/Modal/index.js.map +1 -0
- package/a2ui/dist/catalog/PieChart/catalog.json +87 -0
- package/a2ui/dist/catalog/PieChart/index.d.ts +37 -0
- package/a2ui/dist/catalog/PieChart/index.js +131 -0
- package/a2ui/dist/catalog/PieChart/index.js.map +1 -0
- package/a2ui/dist/catalog/RadioGroup/catalog.json +184 -0
- package/a2ui/dist/catalog/RadioGroup/index.d.ts +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js.map +1 -0
- package/a2ui/dist/catalog/Row/catalog.json +57 -0
- package/a2ui/dist/catalog/Row/index.d.ts +15 -0
- package/a2ui/dist/catalog/Row/index.js +28 -0
- package/a2ui/dist/catalog/Row/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/catalog.json +183 -0
- package/a2ui/dist/catalog/Slider/index.d.ts +41 -0
- package/a2ui/dist/catalog/Slider/index.js +39 -0
- package/a2ui/dist/catalog/Slider/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/utils.d.ts +11 -0
- package/a2ui/dist/catalog/Slider/utils.js +58 -0
- package/a2ui/dist/catalog/Slider/utils.js.map +1 -0
- package/a2ui/dist/catalog/Tabs/catalog.json +28 -0
- package/a2ui/dist/catalog/Tabs/index.d.ts +12 -0
- package/a2ui/dist/catalog/Tabs/index.js +32 -0
- package/a2ui/dist/catalog/Tabs/index.js.map +1 -0
- package/a2ui/dist/catalog/Text/catalog.json +74 -0
- package/a2ui/dist/catalog/Text/index.d.ts +18 -0
- package/a2ui/dist/catalog/Text/index.js +27 -0
- package/a2ui/dist/catalog/Text/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/catalog.json +147 -0
- package/a2ui/dist/catalog/TextField/index.d.ts +35 -0
- package/a2ui/dist/catalog/TextField/index.js +43 -0
- package/a2ui/dist/catalog/TextField/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/utils.d.ts +7 -0
- package/a2ui/dist/catalog/TextField/utils.js +51 -0
- package/a2ui/dist/catalog/TextField/utils.js.map +1 -0
- package/a2ui/dist/catalog/defineCatalog.d.ts +119 -0
- package/a2ui/dist/catalog/defineCatalog.js +196 -0
- package/a2ui/dist/catalog/defineCatalog.js.map +1 -0
- package/a2ui/dist/catalog/index.d.ts +20 -0
- package/a2ui/dist/catalog/index.js +26 -0
- package/a2ui/dist/catalog/index.js.map +1 -0
- package/a2ui/dist/catalog/utils/chart.d.ts +3 -0
- package/a2ui/dist/catalog/utils/chart.js +28 -0
- package/a2ui/dist/catalog/utils/chart.js.map +1 -0
- package/a2ui/dist/functions/index.d.ts +19 -0
- package/a2ui/dist/functions/index.js +87 -0
- package/a2ui/dist/functions/index.js.map +1 -0
- package/a2ui/dist/index.d.ts +11 -0
- package/a2ui/dist/index.js +35 -0
- package/a2ui/dist/index.js.map +1 -0
- package/a2ui/dist/react/A2UI.d.ts +77 -0
- package/a2ui/dist/react/A2UI.js +159 -0
- package/a2ui/dist/react/A2UI.js.map +1 -0
- package/a2ui/dist/react/A2UIProvider.d.ts +25 -0
- package/a2ui/dist/react/A2UIProvider.js +20 -0
- package/a2ui/dist/react/A2UIProvider.js.map +1 -0
- package/a2ui/dist/react/A2UIRenderer.d.ts +34 -0
- package/a2ui/dist/react/A2UIRenderer.js +161 -0
- package/a2ui/dist/react/A2UIRenderer.js.map +1 -0
- package/a2ui/dist/react/FormContext.d.ts +10 -0
- package/a2ui/dist/react/FormContext.js +12 -0
- package/a2ui/dist/react/FormContext.js.map +1 -0
- package/a2ui/dist/react/index.d.ts +8 -0
- package/a2ui/dist/react/index.js +23 -0
- package/a2ui/dist/react/index.js.map +1 -0
- package/a2ui/dist/react/useA2UIContext.d.ts +7 -0
- package/a2ui/dist/react/useA2UIContext.js +19 -0
- package/a2ui/dist/react/useA2UIContext.js.map +1 -0
- package/a2ui/dist/react/useAction.d.ts +9 -0
- package/a2ui/dist/react/useAction.js +38 -0
- package/a2ui/dist/react/useAction.js.map +1 -0
- package/a2ui/dist/react/useCatalog.d.ts +7 -0
- package/a2ui/dist/react/useCatalog.js +13 -0
- package/a2ui/dist/react/useCatalog.js.map +1 -0
- package/a2ui/dist/react/useChecks.d.ts +27 -0
- package/a2ui/dist/react/useChecks.js +76 -0
- package/a2ui/dist/react/useChecks.js.map +1 -0
- package/a2ui/dist/react/useDataBinding.d.ts +10 -0
- package/a2ui/dist/react/useDataBinding.js +175 -0
- package/a2ui/dist/react/useDataBinding.js.map +1 -0
- package/a2ui/dist/store/FormController.d.ts +23 -0
- package/a2ui/dist/store/FormController.js +40 -0
- package/a2ui/dist/store/FormController.js.map +1 -0
- package/a2ui/dist/store/FunctionRegistry.d.ts +47 -0
- package/a2ui/dist/store/FunctionRegistry.js +23 -0
- package/a2ui/dist/store/FunctionRegistry.js.map +1 -0
- package/a2ui/dist/store/MessageProcessor.d.ts +28 -0
- package/a2ui/dist/store/MessageProcessor.js +408 -0
- package/a2ui/dist/store/MessageProcessor.js.map +1 -0
- package/a2ui/dist/store/MessageStore.d.ts +38 -0
- package/a2ui/dist/store/MessageStore.js +37 -0
- package/a2ui/dist/store/MessageStore.js.map +1 -0
- package/a2ui/dist/store/Resource.d.ts +45 -0
- package/a2ui/dist/store/Resource.js +80 -0
- package/a2ui/dist/store/Resource.js.map +1 -0
- package/a2ui/dist/store/SignalStore.d.ts +10 -0
- package/a2ui/dist/store/SignalStore.js +29 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -0
- package/a2ui/dist/store/index.d.ts +14 -0
- package/a2ui/dist/store/index.js +15 -0
- package/a2ui/dist/store/index.js.map +1 -0
- package/a2ui/dist/store/payloadNormalizer.d.ts +27 -0
- package/a2ui/dist/store/payloadNormalizer.js +179 -0
- package/a2ui/dist/store/payloadNormalizer.js.map +1 -0
- package/a2ui/dist/store/resolveFunctionCall.d.ts +18 -0
- package/a2ui/dist/store/resolveFunctionCall.js +131 -0
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -0
- package/a2ui/dist/store/types.d.ts +68 -0
- package/a2ui/dist/store/types.js +2 -0
- package/a2ui/dist/store/types.js.map +1 -0
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui/styles/catalog/Button.css +83 -0
- package/a2ui/styles/catalog/Card.css +49 -0
- package/a2ui/styles/catalog/CheckBox.css +46 -0
- package/a2ui/styles/catalog/Column.css +89 -0
- package/a2ui/styles/catalog/Divider.css +20 -0
- package/a2ui/styles/catalog/Icon.css +39 -0
- package/a2ui/styles/catalog/Image.css +54 -0
- package/a2ui/styles/catalog/LineChart.css +116 -0
- package/a2ui/styles/catalog/List.css +38 -0
- package/a2ui/styles/catalog/Modal.css +60 -0
- package/a2ui/styles/catalog/PieChart.css +109 -0
- package/a2ui/styles/catalog/RadioGroup.css +123 -0
- package/a2ui/styles/catalog/Row.css +83 -0
- package/a2ui/styles/catalog/Slider.css +96 -0
- package/a2ui/styles/catalog/Tabs.css +46 -0
- package/a2ui/styles/catalog/Text.css +121 -0
- package/a2ui/styles/catalog/TextField.css +48 -0
- package/a2ui/styles/theme.css +62 -0
- package/a2ui-catalog-extractor/README.md +605 -0
- package/a2ui-catalog-extractor/bin/a2ui-catalog-extractor.js +6 -0
- package/a2ui-catalog-extractor/dist/cli.d.ts +12 -0
- package/a2ui-catalog-extractor/dist/cli.js +171 -0
- package/a2ui-catalog-extractor/dist/cli.js.map +1 -0
- package/a2ui-catalog-extractor/dist/index.d.ts +140 -0
- package/a2ui-catalog-extractor/dist/index.js +755 -0
- package/a2ui-catalog-extractor/dist/index.js.map +1 -0
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +30 -0
- package/a2ui-prompt/README.md +65 -0
- package/a2ui-prompt/dist/index.d.ts +91 -0
- package/a2ui-prompt/dist/index.js +767 -0
- package/cli/README.md +88 -0
- package/cli/bin/cli.js +271 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/index.ts +114 -0
- package/openui/README.md +211 -0
- package/openui/dist/catalog/Action/index.d.ts +20 -0
- package/openui/dist/catalog/Action/index.js +23 -0
- package/openui/dist/catalog/Action/index.js.map +1 -0
- package/openui/dist/catalog/Button/index.d.ts +64 -0
- package/openui/dist/catalog/Button/index.js +75 -0
- package/openui/dist/catalog/Button/index.js.map +1 -0
- package/openui/dist/catalog/Card/index.d.ts +34 -0
- package/openui/dist/catalog/Card/index.js +69 -0
- package/openui/dist/catalog/Card/index.js.map +1 -0
- package/openui/dist/catalog/CardHeader/index.d.ts +5 -0
- package/openui/dist/catalog/CardHeader/index.js +18 -0
- package/openui/dist/catalog/CardHeader/index.js.map +1 -0
- package/openui/dist/catalog/Separator/index.d.ts +2 -0
- package/openui/dist/catalog/Separator/index.js +13 -0
- package/openui/dist/catalog/Separator/index.js.map +1 -0
- package/openui/dist/catalog/Stack/index.d.ts +29 -0
- package/openui/dist/catalog/Stack/index.js +61 -0
- package/openui/dist/catalog/Stack/index.js.map +1 -0
- package/openui/dist/catalog/Tag/index.d.ts +4 -0
- package/openui/dist/catalog/Tag/index.js +15 -0
- package/openui/dist/catalog/Tag/index.js.map +1 -0
- package/openui/dist/catalog/TextContent/index.d.ts +11 -0
- package/openui/dist/catalog/TextContent/index.js +33 -0
- package/openui/dist/catalog/TextContent/index.js.map +1 -0
- package/openui/dist/catalog/index.d.ts +7 -0
- package/openui/dist/catalog/index.js +11 -0
- package/openui/dist/catalog/index.js.map +1 -0
- package/openui/dist/catalog/utils.d.ts +2 -0
- package/openui/dist/catalog/utils.js +17 -0
- package/openui/dist/catalog/utils.js.map +1 -0
- package/openui/dist/core/context.d.ts +112 -0
- package/openui/dist/core/context.js +99 -0
- package/openui/dist/core/context.js.map +1 -0
- package/openui/dist/core/createLibrary.d.ts +10 -0
- package/openui/dist/core/createLibrary.js +36 -0
- package/openui/dist/core/createLibrary.js.map +1 -0
- package/openui/dist/core/hooks/index.d.ts +4 -0
- package/openui/dist/core/hooks/index.js +6 -0
- package/openui/dist/core/hooks/index.js.map +1 -0
- package/openui/dist/core/hooks/useFormValidation.d.ts +13 -0
- package/openui/dist/core/hooks/useFormValidation.js +76 -0
- package/openui/dist/core/hooks/useFormValidation.js.map +1 -0
- package/openui/dist/core/hooks/useOpenUIState.d.ts +33 -0
- package/openui/dist/core/hooks/useOpenUIState.js +413 -0
- package/openui/dist/core/hooks/useOpenUIState.js.map +1 -0
- package/openui/dist/core/hooks/useStateField.d.ts +2 -0
- package/openui/dist/core/hooks/useStateField.js +11 -0
- package/openui/dist/core/hooks/useStateField.js.map +1 -0
- package/openui/dist/core/index.d.ts +7 -0
- package/openui/dist/core/index.js +8 -0
- package/openui/dist/core/index.js.map +1 -0
- package/openui/dist/core/library.d.ts +20 -0
- package/openui/dist/core/library.js +13 -0
- package/openui/dist/core/library.js.map +1 -0
- package/openui/dist/core/renderer.css +271 -0
- package/openui/dist/core/renderer.d.ts +9 -0
- package/openui/dist/core/renderer.js +139 -0
- package/openui/dist/core/renderer.js.map +1 -0
- package/openui/dist/core/utils.d.ts +1 -0
- package/openui/dist/core/utils.js +76 -0
- package/openui/dist/core/utils.js.map +1 -0
- package/package.json +120 -0
package/openui/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# @lynx-js/genui/openui
|
|
2
|
+
|
|
3
|
+
ReactLynx renderer for the [OpenUI DSL](https://www.openui.com/). Parses
|
|
4
|
+
OpenUI functional notation into a renderable tree and renders it via a
|
|
5
|
+
pluggable component catalog in Lynx applications.
|
|
6
|
+
|
|
7
|
+
This package includes:
|
|
8
|
+
|
|
9
|
+
- `createOpenUiLibrary`: factory that builds an OpenUI `Library` instance
|
|
10
|
+
with built-in components, fully customizable via options.
|
|
11
|
+
- `defineComponent`: define custom components with Zod-validated props.
|
|
12
|
+
- `OpenUiRenderer`: ReactLynx component that renders a parsed OpenUI tree.
|
|
13
|
+
- `createParser` / `createStreamingParser`: parse OpenUI DSL text
|
|
14
|
+
(functional notation) into a renderable AST.
|
|
15
|
+
- `catalog/*`: built-in component renderers (Stack, Card, CardHeader,
|
|
16
|
+
TextContent, Separator, Button, Buttons, Tag).
|
|
17
|
+
|
|
18
|
+
## Exports
|
|
19
|
+
|
|
20
|
+
- `@lynx-js/genui/openui`: `createOpenUiLibrary`, `defineComponent`,
|
|
21
|
+
`OpenUiRenderer`, parser utilities, and all core types.
|
|
22
|
+
- `@lynx-js/genui/openui/catalog`: re-exports of built-in catalog
|
|
23
|
+
components for tree-shake-friendly subpath access.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
Make sure your app provides the peer dependencies:
|
|
28
|
+
|
|
29
|
+
- `@lynx-js/react`
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add @lynx-js/genui
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
1. Create a library and get its JSON Schema.
|
|
38
|
+
2. Create a streaming parser from the schema.
|
|
39
|
+
3. Feed OpenUI DSL text (chunks or full) into the parser.
|
|
40
|
+
4. Render the parse result with `<OpenUiRenderer>`.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import {
|
|
44
|
+
createOpenUiLibrary,
|
|
45
|
+
createStreamingParser,
|
|
46
|
+
OpenUiRenderer,
|
|
47
|
+
} from '@lynx-js/genui/openui';
|
|
48
|
+
import type { ParseResult } from '@lynx-js/genui/openui';
|
|
49
|
+
import { useEffect, useMemo, useState } from '@lynx-js/react';
|
|
50
|
+
|
|
51
|
+
const library = createOpenUiLibrary();
|
|
52
|
+
const schema = library.toJSONSchema();
|
|
53
|
+
|
|
54
|
+
export function App() {
|
|
55
|
+
const [result, setResult] = useState<ParseResult | null>(null);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const parser = createStreamingParser(schema);
|
|
59
|
+
|
|
60
|
+
// OpenUI DSL uses functional notation:
|
|
61
|
+
const rawText = `
|
|
62
|
+
root = Stack([header, card], "column", "l", "center")
|
|
63
|
+
header = TextContent("Hello OpenUI", "large-heavy")
|
|
64
|
+
card = Card([content, btn], "card")
|
|
65
|
+
content = TextContent("Welcome to OpenUI")
|
|
66
|
+
btn = Buttons([Button("Get Started", Action([@ToAssistant("clicked")]), "primary")])
|
|
67
|
+
`.trim();
|
|
68
|
+
|
|
69
|
+
// Feed the entire text (or stream it chunk by chunk)
|
|
70
|
+
const parsed = parser.push(rawText);
|
|
71
|
+
setResult(parsed);
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
if (!result?.root) return null;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<OpenUiRenderer
|
|
78
|
+
result={result}
|
|
79
|
+
library={library}
|
|
80
|
+
onAction={(event) => {
|
|
81
|
+
console.log('Action:', event.humanFriendlyMessage);
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Streaming
|
|
89
|
+
|
|
90
|
+
For real-time streaming scenarios (e.g., LLM output), feed chunks
|
|
91
|
+
incrementally:
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import {
|
|
95
|
+
createOpenUiLibrary,
|
|
96
|
+
createStreamingParser,
|
|
97
|
+
OpenUiRenderer,
|
|
98
|
+
} from '@lynx-js/genui/openui';
|
|
99
|
+
import type { ParseResult } from '@lynx-js/genui/openui';
|
|
100
|
+
import { useEffect, useMemo, useRef, useState } from '@lynx-js/react';
|
|
101
|
+
|
|
102
|
+
const CHUNK_SIZE = 8;
|
|
103
|
+
const STREAM_DELAY_MS = 30;
|
|
104
|
+
|
|
105
|
+
export function StreamingApp({ rawText }: { rawText: string }) {
|
|
106
|
+
const library = useMemo(() => createOpenUiLibrary(), []);
|
|
107
|
+
const [result, setResult] = useState<ParseResult | null>(null);
|
|
108
|
+
const [isStreaming, setIsStreaming] = useState(false);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
let cancelled = false;
|
|
112
|
+
setIsStreaming(true);
|
|
113
|
+
|
|
114
|
+
const schema = library.toJSONSchema();
|
|
115
|
+
const parser = createStreamingParser(schema);
|
|
116
|
+
let offset = 0;
|
|
117
|
+
|
|
118
|
+
const tick = () => {
|
|
119
|
+
if (cancelled || offset >= rawText.length) {
|
|
120
|
+
setIsStreaming(false);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const chunk = rawText.slice(offset, offset + CHUNK_SIZE);
|
|
124
|
+
offset += CHUNK_SIZE;
|
|
125
|
+
setResult(parser.push(chunk));
|
|
126
|
+
setTimeout(tick, STREAM_DELAY_MS);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
tick();
|
|
130
|
+
return () => {
|
|
131
|
+
cancelled = true;
|
|
132
|
+
};
|
|
133
|
+
}, [library, rawText]);
|
|
134
|
+
|
|
135
|
+
if (!result?.root) return null;
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<OpenUiRenderer
|
|
139
|
+
result={result}
|
|
140
|
+
library={library}
|
|
141
|
+
isStreaming={isStreaming}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Customizing the Library
|
|
148
|
+
|
|
149
|
+
`createOpenUiLibrary` accepts an optional `CreateOpenUiLibraryOptions`
|
|
150
|
+
object. Provided `components` and `componentGroups` are **merged** with
|
|
151
|
+
the built-in defaults (appended after the defaults):
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import { createOpenUiLibrary, defineComponent } from '@lynx-js/genui/openui';
|
|
155
|
+
import { z } from 'zod/v4';
|
|
156
|
+
|
|
157
|
+
const MyBanner = defineComponent({
|
|
158
|
+
name: 'Banner',
|
|
159
|
+
description: 'A promotional banner',
|
|
160
|
+
props: z.object({ title: z.string(), color: z.string().optional() }),
|
|
161
|
+
component: (props) => (
|
|
162
|
+
<view style={{ backgroundColor: props.color ?? '#f0f0f0' }}>
|
|
163
|
+
<text>{props.title}</text>
|
|
164
|
+
</view>
|
|
165
|
+
),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const library = createOpenUiLibrary({
|
|
169
|
+
root: 'Stack',
|
|
170
|
+
components: [MyBanner],
|
|
171
|
+
componentGroups: [
|
|
172
|
+
{ name: 'Custom', components: ['Banner'] },
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Options
|
|
178
|
+
|
|
179
|
+
| Option | Type | Default | Description |
|
|
180
|
+
| ----------------- | -------------------- | ------------- | ---------------------------------------------- |
|
|
181
|
+
| `root` | `string` | `'Stack'` | Name of the root component |
|
|
182
|
+
| `components` | `DefinedComponent[]` | `[]` (merged) | Additional components appended to built-in set |
|
|
183
|
+
| `componentGroups` | `ComponentGroup[]` | `[]` (merged) | Additional groups appended to built-in groups |
|
|
184
|
+
|
|
185
|
+
## OpenUI DSL Syntax
|
|
186
|
+
|
|
187
|
+
The DSL uses a **functional notation** (not XML). Each statement assigns
|
|
188
|
+
a component instance to an identifier:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
root = Stack([header, card], "column", "l", "center")
|
|
192
|
+
header = TextContent("Choose Your Plan", "large-heavy")
|
|
193
|
+
card = Card([cardHeader, sep, features, btn], "card")
|
|
194
|
+
cardHeader = CardHeader("Pro", "For growing teams")
|
|
195
|
+
sep = Separator("horizontal", true)
|
|
196
|
+
features = Stack([f1, f2], "column", "s")
|
|
197
|
+
f1 = TextContent("✓ Unlimited projects")
|
|
198
|
+
f2 = TextContent("✓ Priority support")
|
|
199
|
+
btn = Buttons([Button("Start Trial", Action([@ToAssistant("start")]), "primary")])
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## JSON Schema
|
|
203
|
+
|
|
204
|
+
Generate a JSON Schema representation of the library for LLM agent
|
|
205
|
+
handshakes:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
const library = createOpenUiLibrary();
|
|
209
|
+
const schema = library.toJSONSchema();
|
|
210
|
+
// Pass `schema` to your LLM / agent for structured output generation.
|
|
211
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ActionEvent, ActionPlan } from '@openuidev/lang-core';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
/** Shared action prop schema — shows as `ActionExpression` in prompt signatures. */
|
|
4
|
+
export interface LegacyActionConfig {
|
|
5
|
+
type?: ActionEvent['type'];
|
|
6
|
+
params?: Record<string, unknown>;
|
|
7
|
+
url?: string;
|
|
8
|
+
context?: string;
|
|
9
|
+
}
|
|
10
|
+
export type ActionLike = ActionPlan | LegacyActionConfig;
|
|
11
|
+
export declare const actionPropSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
12
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
13
|
+
type: z.ZodString;
|
|
14
|
+
}, z.core.$loose>>;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
type: z.ZodOptional<z.ZodString>;
|
|
17
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
18
|
+
url: z.ZodOptional<z.ZodString>;
|
|
19
|
+
context: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>]>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { tagSchemaId } from '@openuidev/lang-core';
|
|
5
|
+
import { z } from 'zod/v4';
|
|
6
|
+
const actionStepSchema = z.looseObject({
|
|
7
|
+
type: z.string(),
|
|
8
|
+
});
|
|
9
|
+
const actionPlanSchema = z.object({
|
|
10
|
+
steps: z.array(actionStepSchema),
|
|
11
|
+
});
|
|
12
|
+
const legacyActionSchema = z.object({
|
|
13
|
+
type: z.string().optional(),
|
|
14
|
+
params: z.record(z.string(), z.any()).optional(),
|
|
15
|
+
url: z.string().optional(),
|
|
16
|
+
context: z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
export const actionPropSchema = z.union([
|
|
19
|
+
actionPlanSchema,
|
|
20
|
+
legacyActionSchema,
|
|
21
|
+
]);
|
|
22
|
+
tagSchemaId(actionPropSchema, 'ActionExpression');
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/catalog/Action/index.tsx"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAY3B,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;IAChD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC;IACtC,gBAAgB;IAChB,kBAAkB;CACnB,CAAC,CAAC;AACH,WAAW,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export declare const Button: import("../../core/library.js").DefinedComponent<z.ZodObject<{
|
|
3
|
+
label: z.ZodString;
|
|
4
|
+
action: z.ZodUnion<readonly [z.ZodObject<{
|
|
5
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
6
|
+
type: z.ZodString;
|
|
7
|
+
}, z.core.$loose>>;
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
type: z.ZodOptional<z.ZodString>;
|
|
10
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
11
|
+
url: z.ZodOptional<z.ZodString>;
|
|
12
|
+
context: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>]>;
|
|
14
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
primary: "primary";
|
|
16
|
+
secondary: "secondary";
|
|
17
|
+
tertiary: "tertiary";
|
|
18
|
+
}>>;
|
|
19
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
normal: "normal";
|
|
21
|
+
destructive: "destructive";
|
|
22
|
+
}>>;
|
|
23
|
+
size: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
"extra-small": "extra-small";
|
|
25
|
+
small: "small";
|
|
26
|
+
medium: "medium";
|
|
27
|
+
large: "large";
|
|
28
|
+
}>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
export declare const Buttons: import("../../core/library.js").DefinedComponent<z.ZodObject<{
|
|
31
|
+
buttons: z.ZodArray<z.core.$ZodType<import("@openuidev/lang-core").SubComponentOf<{
|
|
32
|
+
label: string;
|
|
33
|
+
action: {
|
|
34
|
+
steps: {
|
|
35
|
+
[x: string]: unknown;
|
|
36
|
+
type: string;
|
|
37
|
+
}[];
|
|
38
|
+
} | {
|
|
39
|
+
type?: string | undefined;
|
|
40
|
+
params?: Record<string, any> | undefined;
|
|
41
|
+
url?: string | undefined;
|
|
42
|
+
context?: string | undefined;
|
|
43
|
+
};
|
|
44
|
+
variant?: "primary" | "secondary" | "tertiary" | undefined;
|
|
45
|
+
type?: "normal" | "destructive" | undefined;
|
|
46
|
+
size?: "extra-small" | "small" | "medium" | "large" | undefined;
|
|
47
|
+
}>, unknown, z.core.$ZodTypeInternals<import("@openuidev/lang-core").SubComponentOf<{
|
|
48
|
+
label: string;
|
|
49
|
+
action: {
|
|
50
|
+
steps: {
|
|
51
|
+
[x: string]: unknown;
|
|
52
|
+
type: string;
|
|
53
|
+
}[];
|
|
54
|
+
} | {
|
|
55
|
+
type?: string | undefined;
|
|
56
|
+
params?: Record<string, any> | undefined;
|
|
57
|
+
url?: string | undefined;
|
|
58
|
+
context?: string | undefined;
|
|
59
|
+
};
|
|
60
|
+
variant?: "primary" | "secondary" | "tertiary" | undefined;
|
|
61
|
+
type?: "normal" | "destructive" | undefined;
|
|
62
|
+
size?: "extra-small" | "small" | "medium" | "large" | undefined;
|
|
63
|
+
}>, unknown>>>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
|
|
2
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
import { BuiltinActionType } from '@openuidev/lang-core';
|
|
6
|
+
import { z } from 'zod/v4';
|
|
7
|
+
import { useFormName, useIsStreaming, useTriggerAction, } from '../../core/context.js';
|
|
8
|
+
import { useFormValidation } from '../../core/hooks/index.js';
|
|
9
|
+
import { defineComponent } from '../../core/library.js';
|
|
10
|
+
import { actionPropSchema } from '../Action/index.js';
|
|
11
|
+
import { asArray } from '../utils.js';
|
|
12
|
+
const CONTINUE_CONVERSATION_ACTION = String(BuiltinActionType.ContinueConversation);
|
|
13
|
+
const OPEN_URL_ACTION = String(BuiltinActionType.OpenUrl);
|
|
14
|
+
const buttonPropsSchema = z.object({
|
|
15
|
+
label: z.string(),
|
|
16
|
+
action: actionPropSchema,
|
|
17
|
+
variant: z.enum(['primary', 'secondary', 'tertiary']).optional(),
|
|
18
|
+
type: z.enum(['normal', 'destructive']).optional(),
|
|
19
|
+
size: z.enum(['extra-small', 'small', 'medium', 'large']).optional(),
|
|
20
|
+
});
|
|
21
|
+
function ButtonRenderer({ props }) {
|
|
22
|
+
const triggerAction = useTriggerAction();
|
|
23
|
+
const formName = useFormName();
|
|
24
|
+
const isStreaming = useIsStreaming();
|
|
25
|
+
const formValidation = useFormValidation();
|
|
26
|
+
const label = String(props.label ?? '');
|
|
27
|
+
const variant = props.variant ?? 'primary';
|
|
28
|
+
const action = props.action;
|
|
29
|
+
let className = 'OpenUIButton OpenUIButtonPrimary';
|
|
30
|
+
if (variant === 'secondary') {
|
|
31
|
+
className = 'OpenUIButton OpenUIButtonSecondary';
|
|
32
|
+
}
|
|
33
|
+
else if (variant === 'tertiary') {
|
|
34
|
+
className = 'OpenUIButton OpenUIButtonGhost';
|
|
35
|
+
}
|
|
36
|
+
const onTap = () => {
|
|
37
|
+
const legacyAction = action && !('steps' in action) ? action : undefined;
|
|
38
|
+
const actionType = legacyAction?.type ?? CONTINUE_CONVERSATION_ACTION;
|
|
39
|
+
if (formValidation && variant === 'primary'
|
|
40
|
+
&& actionType === CONTINUE_CONVERSATION_ACTION) {
|
|
41
|
+
const valid = formValidation.validateForm();
|
|
42
|
+
if (!valid)
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const actionParams = actionType === OPEN_URL_ACTION
|
|
46
|
+
? { url: legacyAction?.url }
|
|
47
|
+
: {
|
|
48
|
+
...(legacyAction?.params ?? {}),
|
|
49
|
+
...(legacyAction?.context ? { context: legacyAction.context } : {}),
|
|
50
|
+
};
|
|
51
|
+
void triggerAction(label, formName, {
|
|
52
|
+
type: actionType,
|
|
53
|
+
params: actionParams,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return (_jsx("view", { className: className, ...(isStreaming ? {} : ({ bindtap: onTap })), children: _jsx("text", { className: 'OpenUIButtonText', children: label }) }));
|
|
57
|
+
}
|
|
58
|
+
export const Button = defineComponent({
|
|
59
|
+
name: 'Button',
|
|
60
|
+
props: buttonPropsSchema,
|
|
61
|
+
description: 'Clickable button',
|
|
62
|
+
component: ButtonRenderer,
|
|
63
|
+
});
|
|
64
|
+
function ButtonsRenderer({ props, renderNode }) {
|
|
65
|
+
return (_jsx("view", { className: 'OpenUIButtonGroup', children: renderNode(asArray(props.buttons)) }));
|
|
66
|
+
}
|
|
67
|
+
export const Buttons = defineComponent({
|
|
68
|
+
name: 'Buttons',
|
|
69
|
+
props: z.object({
|
|
70
|
+
buttons: z.array(Button.ref),
|
|
71
|
+
}),
|
|
72
|
+
description: 'Button group',
|
|
73
|
+
component: ButtonsRenderer,
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/catalog/Button/index.tsx"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,C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C,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,YAE7C,eAAM,SAAS,EAAC,kBAAkB,YAAE,KAAK,GAAQ,GAC5C,CACR,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CAAC;IACpC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,SAAS,EAAE,cAAc;CAC1B,CAAC,CAAC;AAEH,SAAS,eAAe,CACtB,EAAE,KAAK,EAAE,UAAU,EAGlB;IAED,OAAO,CACL,eAAM,SAAS,EAAC,mBAAmB,YAChC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAC9B,CACR,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;IACrC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;KAC7B,CAAC;IACF,WAAW,EAAE,cAAc;IAC3B,SAAS,EAAE,eAAe;CAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export declare const Card: import("../../core/library.js").DefinedComponent<z.ZodObject<{
|
|
3
|
+
children: z.ZodArray<z.ZodAny>;
|
|
4
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
card: "card";
|
|
6
|
+
sunk: "sunk";
|
|
7
|
+
clear: "clear";
|
|
8
|
+
}>>;
|
|
9
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
row: "row";
|
|
11
|
+
column: "column";
|
|
12
|
+
}>>;
|
|
13
|
+
wrap: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
gap: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
none: "none";
|
|
16
|
+
xs: "xs";
|
|
17
|
+
s: "s";
|
|
18
|
+
m: "m";
|
|
19
|
+
l: "l";
|
|
20
|
+
xl: "xl";
|
|
21
|
+
}>>;
|
|
22
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
start: "start";
|
|
24
|
+
center: "center";
|
|
25
|
+
end: "end";
|
|
26
|
+
stretch: "stretch";
|
|
27
|
+
}>>;
|
|
28
|
+
justify: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
start: "start";
|
|
30
|
+
center: "center";
|
|
31
|
+
end: "end";
|
|
32
|
+
between: "between";
|
|
33
|
+
}>>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
|
|
2
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
import { z } from 'zod/v4';
|
|
6
|
+
import { defineComponent } from '../../core/library.js';
|
|
7
|
+
import { GAP_CLASS, asArray } from '../utils.js';
|
|
8
|
+
function getAlignClass(align) {
|
|
9
|
+
switch (align) {
|
|
10
|
+
case 'start':
|
|
11
|
+
return 'OpenUIAlignStart';
|
|
12
|
+
case 'center':
|
|
13
|
+
return 'OpenUIAlignCenter';
|
|
14
|
+
case 'end':
|
|
15
|
+
return 'OpenUIAlignEnd';
|
|
16
|
+
default:
|
|
17
|
+
return 'OpenUIAlignStretch';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getJustifyClass(justify) {
|
|
21
|
+
switch (justify) {
|
|
22
|
+
case 'center':
|
|
23
|
+
return 'OpenUIJustifyCenter';
|
|
24
|
+
case 'end':
|
|
25
|
+
return 'OpenUIJustifyEnd';
|
|
26
|
+
case 'between':
|
|
27
|
+
return 'OpenUIJustifyBetween';
|
|
28
|
+
default:
|
|
29
|
+
return 'OpenUIJustifyStart';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const Card = defineComponent({
|
|
33
|
+
name: 'Card',
|
|
34
|
+
props: z.object({
|
|
35
|
+
children: z.array(z.any()),
|
|
36
|
+
variant: z.enum(['card', 'sunk', 'clear']).optional(),
|
|
37
|
+
direction: z.enum(['row', 'column']).optional(),
|
|
38
|
+
wrap: z.boolean().optional(),
|
|
39
|
+
gap: z.enum(['none', 'xs', 's', 'm', 'l', 'xl']).optional(),
|
|
40
|
+
align: z.enum(['start', 'center', 'end', 'stretch']).optional(),
|
|
41
|
+
justify: z.enum(['start', 'center', 'end', 'between']).optional(),
|
|
42
|
+
}),
|
|
43
|
+
description: 'Styled container (card/sunk/clear). Accept Stack layout parameters.',
|
|
44
|
+
component: ({ props, renderNode }) => {
|
|
45
|
+
const variant = props.variant ?? 'card';
|
|
46
|
+
let variantClass = 'OpenUICardVariantCard';
|
|
47
|
+
if (variant === 'sunk') {
|
|
48
|
+
variantClass = 'OpenUICardVariantSunk';
|
|
49
|
+
}
|
|
50
|
+
else if (variant === 'clear') {
|
|
51
|
+
variantClass = 'OpenUICardVariantClear';
|
|
52
|
+
}
|
|
53
|
+
const direction = props.direction ?? 'column';
|
|
54
|
+
const gap = props.gap ?? 'm';
|
|
55
|
+
const align = props.align ?? 'stretch';
|
|
56
|
+
const justify = props.justify ?? 'start';
|
|
57
|
+
const layoutClassName = [
|
|
58
|
+
direction === 'row' ? 'OpenUIStackRow' : 'OpenUIStackColumn',
|
|
59
|
+
props.wrap ? 'OpenUIStackWrap' : '',
|
|
60
|
+
GAP_CLASS[gap] ?? GAP_CLASS['m'],
|
|
61
|
+
getAlignClass(align),
|
|
62
|
+
getJustifyClass(justify),
|
|
63
|
+
]
|
|
64
|
+
.filter(Boolean)
|
|
65
|
+
.join(' ');
|
|
66
|
+
return (_jsx("view", { className: `OpenUICard ${variantClass} ${layoutClassName}`, children: renderNode(asArray(props.children)) }));
|
|
67
|
+
},
|
|
68
|
+
});
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iBAAiB,CAAC,CAAC,CAAC,EAAE;YACnC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC;YAChC,aAAa,CAAC,KAAK,CAAC;YACpB,eAAe,CAAC,OAAO,CAAC;SACzB;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,OAAO,CACL,eAAM,SAAS,EAAE,cAAc,YAAY,IAAI,eAAe,EAAE,YAC7D,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAC/B,CACR,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@lynx-js/react/jsx-runtime";
|
|
2
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
import { z } from 'zod/v4';
|
|
6
|
+
import { defineComponent } from '../../core/library.js';
|
|
7
|
+
export const CardHeader = defineComponent({
|
|
8
|
+
name: 'CardHeader',
|
|
9
|
+
props: z.object({
|
|
10
|
+
title: z.string(),
|
|
11
|
+
subtitle: z.string().optional(),
|
|
12
|
+
}),
|
|
13
|
+
description: 'Card header with title and optional subtitle.',
|
|
14
|
+
component: ({ props }) => (_jsxs("view", { className: 'OpenUICardHeader', children: [_jsx("text", { className: 'OpenUICardHeaderTitle', children: props.title }), props.subtitle
|
|
15
|
+
? _jsx("text", { className: 'OpenUICardHeaderSubtitle', children: props.subtitle })
|
|
16
|
+
: null] })),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/catalog/CardHeader/index.tsx"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;IACxC,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAChC,CAAC;IACF,WAAW,EAAE,+CAA+C;IAC5D,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CACxB,gBAAM,SAAS,EAAC,kBAAkB,aAChC,eAAM,SAAS,EAAC,uBAAuB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC3D,KAAK,CAAC,QAAQ;gBACb,CAAC,CAAC,eAAM,SAAS,EAAC,0BAA0B,YAAE,KAAK,CAAC,QAAQ,GAAQ;gBACpE,CAAC,CAAC,IAAI,IACH,CACR;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
|
|
2
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
import { z } from 'zod/v4';
|
|
6
|
+
import { defineComponent } from '../../core/library.js';
|
|
7
|
+
export const Separator = defineComponent({
|
|
8
|
+
name: 'Separator',
|
|
9
|
+
props: z.object({}),
|
|
10
|
+
description: 'Separator',
|
|
11
|
+
component: () => _jsx("view", { className: 'OpenUISeparator' }),
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/catalog/Separator/index.tsx"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;IACvC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,WAAW,EAAE,WAAW;IACxB,SAAS,EAAE,GAAG,EAAE,CAAC,eAAM,SAAS,EAAC,iBAAiB,GAAG;CACtD,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export declare const Stack: import("../../core/library.js").DefinedComponent<z.ZodObject<{
|
|
3
|
+
children: z.ZodArray<z.ZodAny>;
|
|
4
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
row: "row";
|
|
6
|
+
column: "column";
|
|
7
|
+
}>>;
|
|
8
|
+
wrap: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
gap: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
none: "none";
|
|
11
|
+
xs: "xs";
|
|
12
|
+
s: "s";
|
|
13
|
+
m: "m";
|
|
14
|
+
l: "l";
|
|
15
|
+
xl: "xl";
|
|
16
|
+
}>>;
|
|
17
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
18
|
+
start: "start";
|
|
19
|
+
center: "center";
|
|
20
|
+
end: "end";
|
|
21
|
+
stretch: "stretch";
|
|
22
|
+
}>>;
|
|
23
|
+
justify: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
start: "start";
|
|
25
|
+
center: "center";
|
|
26
|
+
end: "end";
|
|
27
|
+
between: "between";
|
|
28
|
+
}>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
|
|
2
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
import { z } from 'zod/v4';
|
|
6
|
+
import { defineComponent } from '../../core/library.js';
|
|
7
|
+
import { GAP_CLASS, asArray } from '../utils.js';
|
|
8
|
+
function getAlignClass(align) {
|
|
9
|
+
switch (align) {
|
|
10
|
+
case 'start':
|
|
11
|
+
return 'OpenUIAlignStart';
|
|
12
|
+
case 'center':
|
|
13
|
+
return 'OpenUIAlignCenter';
|
|
14
|
+
case 'end':
|
|
15
|
+
return 'OpenUIAlignEnd';
|
|
16
|
+
default:
|
|
17
|
+
return 'OpenUIAlignStretch';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getJustifyClass(justify) {
|
|
21
|
+
switch (justify) {
|
|
22
|
+
case 'center':
|
|
23
|
+
return 'OpenUIJustifyCenter';
|
|
24
|
+
case 'end':
|
|
25
|
+
return 'OpenUIJustifyEnd';
|
|
26
|
+
case 'between':
|
|
27
|
+
return 'OpenUIJustifyBetween';
|
|
28
|
+
default:
|
|
29
|
+
return 'OpenUIJustifyStart';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const Stack = defineComponent({
|
|
33
|
+
name: 'Stack',
|
|
34
|
+
props: z.object({
|
|
35
|
+
children: z.array(z.any()),
|
|
36
|
+
direction: z.enum(['row', 'column']).optional(),
|
|
37
|
+
wrap: z.boolean().optional(),
|
|
38
|
+
gap: z.enum(['none', 'xs', 's', 'm', 'l', 'xl']).optional(),
|
|
39
|
+
align: z.enum(['start', 'center', 'end', 'stretch']).optional(),
|
|
40
|
+
justify: z.enum(['start', 'center', 'end', 'between']).optional(),
|
|
41
|
+
}),
|
|
42
|
+
description: 'Flex layout container',
|
|
43
|
+
component: ({ props, renderNode }) => {
|
|
44
|
+
const direction = props.direction ?? 'column';
|
|
45
|
+
const gap = props.gap ?? 'm';
|
|
46
|
+
const align = props.align ?? 'stretch';
|
|
47
|
+
const justify = props.justify ?? 'start';
|
|
48
|
+
const className = [
|
|
49
|
+
'OpenUIStack',
|
|
50
|
+
direction === 'row' ? 'OpenUIStackRow' : 'OpenUIStackColumn',
|
|
51
|
+
props.wrap ? 'OpenUIStackWrap' : '',
|
|
52
|
+
GAP_CLASS[gap] ?? GAP_CLASS['m'],
|
|
53
|
+
getAlignClass(align),
|
|
54
|
+
getJustifyClass(justify),
|
|
55
|
+
]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(' ');
|
|
58
|
+
return (_jsx("view", { className: className, children: renderNode(asArray(props.children)) }));
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=index.js.map
|