@bravostudioai/react 0.1.35 → 0.1.36
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/dist/codegen/generator.js +243 -234
- package/dist/codegen/generator.js.map +1 -1
- package/dist/codegen/parser.js +150 -149
- package/dist/codegen/parser.js.map +1 -1
- package/dist/components/EncoreApp.js +61 -58
- package/dist/components/EncoreApp.js.map +1 -1
- package/dist/components.js +512 -449
- package/dist/components.js.map +1 -1
- package/dist/contexts/EncoreBindingContext.js +9 -3
- package/dist/contexts/EncoreBindingContext.js.map +1 -1
- package/dist/src/codegen/generator.d.ts.map +1 -1
- package/dist/src/codegen/parser.d.ts.map +1 -1
- package/dist/src/components/EncoreApp.d.ts +3 -1
- package/dist/src/components/EncoreApp.d.ts.map +1 -1
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/contexts/EncoreBindingContext.d.ts +14 -2
- package/dist/src/contexts/EncoreBindingContext.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/codegen/generator.ts +24 -2
- package/src/codegen/parser.ts +29 -4
- package/src/components/EncoreApp.tsx +6 -1
- package/src/components.tsx +131 -4
- package/src/contexts/EncoreBindingContext.ts +20 -3
- package/src/version.ts +1 -1
|
@@ -1,219 +1,228 @@
|
|
|
1
|
-
import { sanitizePropName as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}),
|
|
7
|
-
const t =
|
|
8
|
-
|
|
1
|
+
import { sanitizePropName as u, getComponentPropType as H, getComponentPropName as L } from "./parser.js";
|
|
2
|
+
function _(O, w, v, E, $, h, y, b, m, d = "dynamic", I) {
|
|
3
|
+
const P = [], p = [], r = [], N = [], D = [], M = [];
|
|
4
|
+
$.forEach((e) => {
|
|
5
|
+
P.push(` ${e.propName}?: ${e.propType};`);
|
|
6
|
+
}), h.forEach((e) => {
|
|
7
|
+
const t = u(e.groupName);
|
|
8
|
+
r.push(` ${t}?: string;`), r.push(
|
|
9
9
|
` on${t[0].toUpperCase()}${t.slice(
|
|
10
10
|
1
|
|
11
11
|
)}Change?: (value: string) => void;`
|
|
12
12
|
);
|
|
13
13
|
});
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const t =
|
|
14
|
+
const j = [];
|
|
15
|
+
y.forEach((e) => {
|
|
16
|
+
const t = u(e.formName), i = `${t[0].toUpperCase()}${t.slice(
|
|
17
17
|
1
|
|
18
|
-
)}FormData`,
|
|
19
|
-
|
|
20
|
-
const U =
|
|
21
|
-
|
|
22
|
-
}),
|
|
23
|
-
${
|
|
18
|
+
)}FormData`, s = [];
|
|
19
|
+
e.inputs.forEach((f) => {
|
|
20
|
+
const U = f.propName, C = H(f.type, f.name);
|
|
21
|
+
s.push(` ${U}: ${C};`);
|
|
22
|
+
}), j.push(`export interface ${i} {
|
|
23
|
+
${s.join(`
|
|
24
24
|
`)}
|
|
25
|
-
}`),
|
|
25
|
+
}`), N.push(
|
|
26
26
|
` on${t[0].toUpperCase()}${t.slice(
|
|
27
27
|
1
|
|
28
|
-
)}Submit?: (formData: ${
|
|
28
|
+
)}Submit?: (formData: ${i}) => void;`
|
|
29
29
|
);
|
|
30
|
-
}),
|
|
31
|
-
const t =
|
|
30
|
+
}), b.forEach((e) => {
|
|
31
|
+
const t = e.propName, i = t[0].toUpperCase() + t.slice(1);
|
|
32
32
|
D.push(` ${t}?: string;`), D.push(
|
|
33
33
|
` ${t}Options?: Array<string | { value: string; label: string }>;`
|
|
34
34
|
), D.push(
|
|
35
|
-
` on${
|
|
35
|
+
` on${i}Change?: (value: string) => void;`
|
|
36
36
|
);
|
|
37
|
-
}),
|
|
38
|
-
const t =
|
|
39
|
-
|
|
40
|
-
}), E.forEach((
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
37
|
+
}), m.forEach((e) => {
|
|
38
|
+
const t = e.propName, i = t[0].toUpperCase() + t.slice(1);
|
|
39
|
+
M.push(` on${i}Click?: () => void;`);
|
|
40
|
+
}), E.forEach((e) => {
|
|
41
|
+
if (e.arrayContainer && e.arrayContainer.components.length > 0) {
|
|
42
|
+
const i = e.arrayContainer, s = `${i.propName[0].toUpperCase()}${i.propName.slice(
|
|
43
43
|
1
|
|
44
44
|
)}Item`;
|
|
45
|
-
|
|
45
|
+
P.push(` ${i.propName}: ${s}[];`);
|
|
46
46
|
}
|
|
47
|
-
const t =
|
|
48
|
-
|
|
47
|
+
const t = u(e.name || "container");
|
|
48
|
+
p.push(` ${t}CurrentIndex?: number;`), p.push(
|
|
49
49
|
` on${t[0].toUpperCase()}${t.slice(
|
|
50
50
|
1
|
|
51
51
|
)}IndexChange?: (index: number) => void;`
|
|
52
52
|
);
|
|
53
53
|
});
|
|
54
|
-
const
|
|
55
|
-
...
|
|
56
|
-
...a,
|
|
54
|
+
const B = [
|
|
55
|
+
...P,
|
|
57
56
|
...p,
|
|
58
|
-
...
|
|
57
|
+
...r,
|
|
58
|
+
...N,
|
|
59
59
|
...D,
|
|
60
|
-
...
|
|
61
|
-
],
|
|
62
|
-
${
|
|
60
|
+
...M
|
|
61
|
+
], S = B.length > 0, F = S ? `export interface ${v}Props {
|
|
62
|
+
${B.join(`
|
|
63
63
|
`)}
|
|
64
|
-
}` : "",
|
|
65
|
-
const t =
|
|
64
|
+
}` : "", G = E.filter((e) => e.arrayContainer && e.arrayContainer.components.length > 0).map((e) => {
|
|
65
|
+
const t = e.arrayContainer, i = `${t.propName[0].toUpperCase()}${t.propName.slice(
|
|
66
66
|
1
|
|
67
|
-
)}Item`,
|
|
67
|
+
)}Item`, s = t.components.map((f) => ` ${f.propName}: ${f.propType};`).join(`
|
|
68
68
|
`);
|
|
69
|
-
return `export interface ${
|
|
70
|
-
${
|
|
69
|
+
return `export interface ${i} {
|
|
70
|
+
${s}
|
|
71
71
|
}`;
|
|
72
72
|
}).join(`
|
|
73
73
|
|
|
74
|
-
`),
|
|
75
|
-
|
|
76
|
-
`),
|
|
77
|
-
|
|
78
|
-
const t =
|
|
79
|
-
|
|
80
|
-
...(props.${
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
`), W = j.join(`
|
|
75
|
+
|
|
76
|
+
`), x = [], k = [], T = [];
|
|
77
|
+
$.forEach((e) => {
|
|
78
|
+
const t = L(e.type);
|
|
79
|
+
e.type === "component:webview" ? x.push(` // ${e.name}
|
|
80
|
+
...(props.${e.propName} !== undefined && { "${e.id}": { params: { url: props.${e.propName} } } as any }),`) : e.type === "component:embed" ? k.push(` // ${e.name}
|
|
81
|
+
...(props.${e.propName} !== undefined && { "${e.id}": props.${e.propName} }),`) : x.push(` // ${e.name}
|
|
82
|
+
...(props.${e.propName} !== undefined && { "${e.id}": { ${t}: props.${e.propName} } as any }),`);
|
|
83
|
+
}), b.forEach((e) => {
|
|
84
|
+
x.push(` // ${e.name}
|
|
85
|
+
...((props.${e.propName} !== undefined || props.${e.propName}Options !== undefined) && {
|
|
86
|
+
"${e.id}": {
|
|
87
|
+
...(props.${e.propName} !== undefined && { value: props.${e.propName} }),
|
|
88
|
+
...(props.${e.propName}Options !== undefined && { options: props.${e.propName}Options }),
|
|
87
89
|
} as any
|
|
88
90
|
}),`);
|
|
89
|
-
}), E.forEach((
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
return ` // ${
|
|
94
|
-
"${
|
|
95
|
-
|
|
91
|
+
}), E.forEach((e) => {
|
|
92
|
+
if (e.arrayContainer && e.arrayContainer.components.length > 0) {
|
|
93
|
+
const f = e.arrayContainer, U = f.components.map((C) => {
|
|
94
|
+
const R = L(C.type);
|
|
95
|
+
return C.type === "component:webview" ? ` // ${C.name}
|
|
96
|
+
"${C.id}": {
|
|
97
|
+
params: { url: item.${C.propName} },
|
|
98
|
+
}` : ` // ${C.name}
|
|
99
|
+
"${C.id}": {
|
|
100
|
+
${R}: item.${C.propName},
|
|
96
101
|
}`;
|
|
97
102
|
}).join(`,
|
|
98
103
|
`);
|
|
99
|
-
|
|
100
|
-
"${
|
|
104
|
+
x.push(` // ${f.name}
|
|
105
|
+
"${f.id}": props.${f.propName}.map((item) => ({
|
|
101
106
|
${U}
|
|
102
107
|
})),`);
|
|
103
108
|
}
|
|
104
|
-
const t =
|
|
109
|
+
const t = u(e.name || "container"), i = `${t[0].toUpperCase()}${t.slice(
|
|
105
110
|
1
|
|
106
|
-
)}IndexChange`,
|
|
107
|
-
|
|
111
|
+
)}IndexChange`, s = [];
|
|
112
|
+
e.id && (s.push(` // ${e.name}`), s.push(` "${e.id}": {`), s.push(
|
|
108
113
|
` currentIndex: props.${t}CurrentIndex,`
|
|
109
|
-
),
|
|
114
|
+
), s.push(` onIndexChange: props.on${i},`), s.push(" }")), s.length > 0 && T.push(s.join(`
|
|
110
115
|
`));
|
|
111
116
|
});
|
|
112
|
-
const
|
|
117
|
+
const n = T.length > 0 ? `
|
|
113
118
|
repeatingContainerControls={{
|
|
114
|
-
${
|
|
119
|
+
${T.join(`,
|
|
115
120
|
`)}
|
|
116
|
-
}}` : "",
|
|
117
|
-
(
|
|
121
|
+
}}` : "", a = [], o = [];
|
|
122
|
+
(h.length > 0 || y.length > 0 || b.length > 0 || m.length > 0) && (o.push(" const handleAction = (payload: any) => {"), o.push(" const { action } = payload?.bravo || {};"), o.push(""), b.length > 0 && (o.push(" // Handle select input changes"), o.push(
|
|
118
123
|
' if (action?.action === "input-change" || action?.action === "select-change") {'
|
|
119
|
-
),
|
|
120
|
-
const t =
|
|
121
|
-
|
|
122
|
-
` if (nodeId === "${
|
|
123
|
-
),
|
|
124
|
-
}),
|
|
124
|
+
), o.push(" const nodeId = action?.nodeId;"), o.push(" const value = action?.params?.value;"), o.push(""), b.forEach((e) => {
|
|
125
|
+
const t = e.propName, s = `on${t[0].toUpperCase() + t.slice(1)}Change`;
|
|
126
|
+
o.push(` // ${e.name}`), o.push(
|
|
127
|
+
` if (nodeId === "${e.id}" && props.${s}) {`
|
|
128
|
+
), o.push(` props.${s}(value);`), o.push(" return;"), o.push(" }");
|
|
129
|
+
}), o.push(" }"), o.push("")), m.length > 0 && (o.push(" // Handle button clicks"), o.push(
|
|
125
130
|
' if (action?.action === "remote" || action?.action === "tap" || action?.action === "link") {'
|
|
126
|
-
),
|
|
127
|
-
const t =
|
|
128
|
-
|
|
129
|
-
` if (nodeId === "${
|
|
130
|
-
),
|
|
131
|
-
}),
|
|
131
|
+
), o.push(" const nodeId = action?.nodeId;"), o.push(""), m.forEach((e) => {
|
|
132
|
+
const t = e.propName, s = `on${t[0].toUpperCase() + t.slice(1)}Click`;
|
|
133
|
+
o.push(` // ${e.name}`), o.push(
|
|
134
|
+
` if (nodeId === "${e.id}" && props.${s}) {`
|
|
135
|
+
), o.push(` props.${s}();`), o.push(" return;"), o.push(" }");
|
|
136
|
+
}), o.push(" }"), o.push("")), h.length > 0 && (o.push(
|
|
132
137
|
' if (action?.action === "input-group-change") {'
|
|
133
|
-
),
|
|
138
|
+
), o.push(
|
|
134
139
|
" const { groupName, value } = action.params;"
|
|
135
|
-
),
|
|
136
|
-
const t =
|
|
140
|
+
), h.forEach((e) => {
|
|
141
|
+
const t = u(e.groupName), i = `on${t[0].toUpperCase()}${t.slice(
|
|
137
142
|
1
|
|
138
143
|
)}Change`;
|
|
139
|
-
|
|
140
|
-
` if (groupName === "${
|
|
141
|
-
),
|
|
142
|
-
}),
|
|
143
|
-
` const formInputs = useEncoreState.getState().formInputs["${
|
|
144
|
-
),
|
|
145
|
-
const
|
|
144
|
+
o.push(
|
|
145
|
+
` if (groupName === "${e.groupName}" && props.${i}) {`
|
|
146
|
+
), o.push(` props.${i}(value);`), o.push(" return;"), o.push(" }");
|
|
147
|
+
}), o.push(" }"), o.push("")), y.length > 0 && (o.push(' if (action?.action === "submit") {'), o.push(" // Get form inputs from Encore state"), o.push(
|
|
148
|
+
` const formInputs = useEncoreState.getState().formInputs["${w}"] || {};`
|
|
149
|
+
), o.push(" const submitNodeId = action?.nodeId;"), o.push(""), y.forEach((e, t) => {
|
|
150
|
+
const i = u(e.formName), s = `on${i[0].toUpperCase()}${i.slice(
|
|
146
151
|
1
|
|
147
152
|
)}Submit`;
|
|
148
|
-
t > 0 &&
|
|
149
|
-
` // Form: ${
|
|
150
|
-
),
|
|
151
|
-
` if (submitNodeId === "${
|
|
152
|
-
) :
|
|
153
|
-
const
|
|
153
|
+
t > 0 && o.push(""), o.push(
|
|
154
|
+
` // Form: ${e.formName} (${e.formId})`
|
|
155
|
+
), e.submitButtonId ? o.push(
|
|
156
|
+
` if (submitNodeId === "${e.submitButtonId}" && props.${s}) {`
|
|
157
|
+
) : y.length === 1 ? o.push(` if (props.${s}) {`) : o.push(` if (props.${s}) {`), o.push(" // Extract form inputs for this form");
|
|
158
|
+
const f = `${i[0].toUpperCase()}${i.slice(
|
|
154
159
|
1
|
|
155
160
|
)}FormData`;
|
|
156
|
-
|
|
157
|
-
` const formData: ${
|
|
161
|
+
o.push(
|
|
162
|
+
` const formData: ${f} = {`
|
|
158
163
|
);
|
|
159
164
|
const U = [];
|
|
160
|
-
|
|
161
|
-
const
|
|
165
|
+
e.inputs.forEach((C) => {
|
|
166
|
+
const R = C.propName;
|
|
162
167
|
U.push(
|
|
163
|
-
` ${
|
|
168
|
+
` ${R}: formInputs["${C.id}"]`
|
|
164
169
|
);
|
|
165
|
-
}),
|
|
166
|
-
`)),
|
|
170
|
+
}), o.push(U.join(`,
|
|
171
|
+
`)), o.push(" };"), o.push(` props.${s}(formData);`), o.push(
|
|
167
172
|
" // Note: Default form submission will still proceed after callback"
|
|
168
|
-
),
|
|
169
|
-
}),
|
|
170
|
-
const t =
|
|
171
|
-
|
|
173
|
+
), o.push(" }");
|
|
174
|
+
}), o.push(" }")), o.push(" };")), h.forEach((e) => {
|
|
175
|
+
const t = u(e.groupName);
|
|
176
|
+
a.push(
|
|
172
177
|
` ...(props.${t} !== undefined && { ${t}: props.${t} }),`
|
|
173
178
|
);
|
|
174
179
|
});
|
|
175
|
-
const
|
|
180
|
+
const c = a.length > 0 ? `
|
|
176
181
|
inputGroups={{
|
|
177
|
-
${
|
|
182
|
+
${a.join(`
|
|
183
|
+
`)}
|
|
184
|
+
}}` : "", g = o.length > 0 ? `
|
|
185
|
+
onAction={handleAction}` : "", l = k.length > 0 ? `
|
|
186
|
+
embeds={{
|
|
187
|
+
${k.join(`
|
|
178
188
|
`)}
|
|
179
|
-
}}` : "",
|
|
180
|
-
onAction={handleAction}` : "", g = j ? `props: ${P}Props` : "", h = M ? `${M}
|
|
189
|
+
}}` : "", A = S ? `props: ${v}Props` : "", z = F ? `${F}
|
|
181
190
|
|
|
182
|
-
` : "",
|
|
191
|
+
` : "", K = d === "production" || d === "optimistic";
|
|
183
192
|
return `/**
|
|
184
|
-
* ${
|
|
193
|
+
* ${v}
|
|
185
194
|
*
|
|
186
195
|
* Wrapper component for Encore Studio app.
|
|
187
196
|
* See README.md for detailed documentation.
|
|
188
197
|
*/
|
|
189
198
|
|
|
190
|
-
import { EncoreApp${
|
|
191
|
-
${
|
|
199
|
+
import { EncoreApp${y.length > 0 ? ", useEncoreState" : ""} } from "@bravostudioai/react";
|
|
200
|
+
${K ? 'import productionData from "./data.json";' : ""}
|
|
192
201
|
|
|
193
|
-
${
|
|
202
|
+
${G ? `${G}
|
|
194
203
|
|
|
195
|
-
` : ""}${
|
|
204
|
+
` : ""}${W ? `${W}
|
|
196
205
|
|
|
197
|
-
` : ""}${
|
|
198
|
-
${
|
|
206
|
+
` : ""}${z}export function ${v}(${A}) {
|
|
207
|
+
${o.length > 0 ? o.join(`
|
|
199
208
|
`) : ""}
|
|
200
209
|
return (
|
|
201
210
|
<EncoreApp
|
|
202
|
-
appId="${
|
|
203
|
-
pageId="${
|
|
204
|
-
mode="${
|
|
205
|
-
${
|
|
211
|
+
appId="${O}"
|
|
212
|
+
pageId="${w}"
|
|
213
|
+
mode="${d}"
|
|
214
|
+
${K ? `appDefinition={productionData.app}
|
|
206
215
|
pageDefinition={productionData.page}
|
|
207
216
|
componentCode={productionData.componentCode}` : ""}
|
|
208
217
|
data={{
|
|
209
|
-
${
|
|
218
|
+
${x.join(`
|
|
210
219
|
`)}
|
|
211
|
-
}}${
|
|
220
|
+
}}${n}${c}${g}${l}
|
|
212
221
|
/>
|
|
213
222
|
);
|
|
214
223
|
}
|
|
215
224
|
|
|
216
|
-
export default ${
|
|
225
|
+
export default ${v};
|
|
217
226
|
|
|
218
227
|
export const PageMeta = {
|
|
219
228
|
width: ${I?.width ?? "undefined"},
|
|
@@ -222,93 +231,93 @@ export const PageMeta = {
|
|
|
222
231
|
};
|
|
223
232
|
`;
|
|
224
233
|
}
|
|
225
|
-
function
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
234
|
+
function q(O, w, v, E, $, h, y, b, m, d, I) {
|
|
235
|
+
const P = [], p = [], r = [], N = [];
|
|
236
|
+
y.forEach((n) => {
|
|
237
|
+
P.push(`### \`${n.propName}\` (${n.propType}, optional)
|
|
229
238
|
|
|
230
239
|
${n.name} (${n.type}) - Component ID: ${n.id}`);
|
|
231
|
-
}),
|
|
240
|
+
}), h.forEach((n) => {
|
|
232
241
|
if (n.arrayContainer && n.arrayContainer.components.length > 0) {
|
|
233
|
-
const
|
|
242
|
+
const c = n.arrayContainer, g = c.components.map((l) => `- \`${l.propName}\` (${l.propType}): ${l.name} (${l.type}) - Component ID: ${l.id}`).join(`
|
|
234
243
|
`);
|
|
235
|
-
|
|
244
|
+
P.push(`### \`${c.propName}\` (${c.propName[0].toUpperCase()}${c.propName.slice(
|
|
236
245
|
1
|
|
237
246
|
)}Item[])
|
|
238
247
|
|
|
239
|
-
Array of items for "${
|
|
248
|
+
Array of items for "${c.name}" container (ID: ${c.id})
|
|
240
249
|
|
|
241
250
|
**Properties:**
|
|
242
251
|
|
|
243
252
|
${g}`);
|
|
244
253
|
}
|
|
245
|
-
const
|
|
254
|
+
const a = u(n.name || "container"), o = `${a[0].toUpperCase()}${a.slice(
|
|
246
255
|
1
|
|
247
256
|
)}IndexChange`;
|
|
248
|
-
|
|
257
|
+
p.push(`### \`${a}CurrentIndex\` (number, optional)
|
|
249
258
|
|
|
250
259
|
Controls the currently visible slide/index for the "${n.name}" container (ID: ${n.id}).
|
|
251
260
|
|
|
252
261
|
When provided, the slider operates in controlled mode - the parent component controls which slide is displayed. When not provided, the slider manages its own state.
|
|
253
262
|
|
|
254
|
-
### \`on${
|
|
263
|
+
### \`on${o}\` ((index: number) => void, optional)
|
|
255
264
|
|
|
256
265
|
Callback fired when the user navigates to a different slide. Called with the new slide index (0-based).
|
|
257
266
|
|
|
258
267
|
This event fires whenever the slide changes, whether by user interaction, automatic advancement, or programmatic control.`);
|
|
259
268
|
});
|
|
260
|
-
const D =
|
|
269
|
+
const D = P.length > 0 ? P.join(`
|
|
261
270
|
|
|
262
|
-
`) : "This component currently has no data-bound props.",
|
|
271
|
+
`) : "This component currently has no data-bound props.", M = p.length > 0 ? `## Control Props
|
|
263
272
|
|
|
264
273
|
These props allow you to imperatively control repeating containers (sliders, lists, etc.) and receive notifications when the current index changes.
|
|
265
274
|
|
|
266
|
-
${
|
|
275
|
+
${p.join(`
|
|
267
276
|
|
|
268
|
-
`)}` : "",
|
|
269
|
-
|
|
270
|
-
const
|
|
277
|
+
`)}` : "", j = [];
|
|
278
|
+
b.forEach((n) => {
|
|
279
|
+
const a = u(n.groupName), o = `on${a[0].toUpperCase()}${a.slice(
|
|
271
280
|
1
|
|
272
|
-
)}Change`,
|
|
281
|
+
)}Change`, c = n.elements.map((g) => `- "${g.name}"`).join(`
|
|
273
282
|
`);
|
|
274
|
-
|
|
283
|
+
j.push(`### \`${a}\` (string, optional)
|
|
275
284
|
|
|
276
285
|
Sets which element is active in the "${n.groupName}" input group (type: ${n.groupType}).
|
|
277
286
|
|
|
278
287
|
**Available elements:**
|
|
279
|
-
${
|
|
288
|
+
${c}
|
|
280
289
|
|
|
281
|
-
### \`${
|
|
290
|
+
### \`${o}\` ((value: string) => void, optional)
|
|
282
291
|
|
|
283
292
|
Callback fired when the user selects a different element in the "${n.groupName}" input group. Called with the name of the selected element.`);
|
|
284
293
|
});
|
|
285
|
-
const
|
|
294
|
+
const B = j.length > 0 ? `## Input Group Props
|
|
286
295
|
|
|
287
296
|
These props allow you to control input groups (radio button-like behavior) and receive notifications when the selection changes.
|
|
288
297
|
|
|
289
|
-
${
|
|
298
|
+
${j.join(`
|
|
290
299
|
|
|
291
|
-
`)}` : "",
|
|
292
|
-
|
|
293
|
-
const
|
|
300
|
+
`)}` : "", S = [];
|
|
301
|
+
m.forEach((n) => {
|
|
302
|
+
const a = u(n.formName), o = `on${a[0].toUpperCase()}${a.slice(
|
|
294
303
|
1
|
|
295
|
-
)}Submit`,
|
|
304
|
+
)}Submit`, c = `${a[0].toUpperCase()}${a.slice(
|
|
296
305
|
1
|
|
297
|
-
)}FormData`, g = n.inputs.map((
|
|
298
|
-
const
|
|
299
|
-
return `- \`${
|
|
306
|
+
)}FormData`, g = n.inputs.map((l) => {
|
|
307
|
+
const A = l.propName, z = H(l.type, l.name);
|
|
308
|
+
return `- \`${A}\` (${z}) - ${l.name}`;
|
|
300
309
|
}).join(`
|
|
301
310
|
`);
|
|
302
|
-
|
|
311
|
+
S.push(`### \`${o}\` ((formData: ${c}) => void, optional)
|
|
303
312
|
|
|
304
313
|
Callback fired when the "${n.formName}" form is submitted. Called with a typed object containing all form input values with human-readable property names.
|
|
305
314
|
|
|
306
315
|
**Form data shape:**
|
|
307
316
|
\`\`\`typescript
|
|
308
|
-
interface ${
|
|
309
|
-
${n.inputs.map((
|
|
310
|
-
const
|
|
311
|
-
return ` ${
|
|
317
|
+
interface ${c} {
|
|
318
|
+
${n.inputs.map((l) => {
|
|
319
|
+
const A = l.propName, z = H(l.type, l.name);
|
|
320
|
+
return ` ${A}: ${z};`;
|
|
312
321
|
}).join(`
|
|
313
322
|
`)}
|
|
314
323
|
}
|
|
@@ -317,16 +326,16 @@ ${n.inputs.map((h) => {
|
|
|
317
326
|
**Form inputs:**
|
|
318
327
|
${g}`);
|
|
319
328
|
});
|
|
320
|
-
const
|
|
329
|
+
const F = S.length > 0 ? `## Form Submission Props
|
|
321
330
|
|
|
322
331
|
These props allow you to handle form submissions and access form input values.
|
|
323
332
|
|
|
324
|
-
${
|
|
333
|
+
${S.join(`
|
|
325
334
|
|
|
326
335
|
`)}` : "";
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
336
|
+
d.forEach((n) => {
|
|
337
|
+
const a = n.propName, c = `on${a[0].toUpperCase() + a.slice(1)}Change`, g = `${a}Options`;
|
|
338
|
+
r.push(`### \`${a}\` (string, optional)
|
|
330
339
|
|
|
331
340
|
Controls the selected value of the "${n.name}" dropdown (Component ID: ${n.id}).
|
|
332
341
|
|
|
@@ -348,70 +357,70 @@ ${g}={[
|
|
|
348
357
|
]}
|
|
349
358
|
\`\`\`
|
|
350
359
|
|
|
351
|
-
### \`${
|
|
360
|
+
### \`${c}\` ((value: string) => void, optional)
|
|
352
361
|
|
|
353
362
|
Callback fired when the user selects a different option in the "${n.name}" dropdown. Called with the selected value.`);
|
|
354
363
|
});
|
|
355
|
-
const
|
|
364
|
+
const G = r.length > 0 ? `## Select Input Props
|
|
356
365
|
|
|
357
366
|
These props allow you to control select/dropdown inputs and respond to value changes.
|
|
358
367
|
|
|
359
|
-
${
|
|
368
|
+
${r.join(`
|
|
360
369
|
|
|
361
370
|
`)}` : "";
|
|
362
371
|
I.forEach((n) => {
|
|
363
|
-
const
|
|
364
|
-
|
|
372
|
+
const a = n.propName, c = `on${a[0].toUpperCase() + a.slice(1)}Click`;
|
|
373
|
+
N.push(`### \`${c}\` (() => void, optional)
|
|
365
374
|
|
|
366
375
|
Callback fired when the "${n.name}" button is clicked (Component ID: ${n.id}).
|
|
367
376
|
|
|
368
377
|
Action type: \`${n.actionType}\``);
|
|
369
378
|
});
|
|
370
|
-
const
|
|
379
|
+
const W = N.length > 0 ? `## Action Button Props
|
|
371
380
|
|
|
372
381
|
These props allow you to respond to button clicks and other user interactions.
|
|
373
382
|
|
|
374
|
-
${
|
|
383
|
+
${N.join(`
|
|
375
384
|
|
|
376
|
-
`)}` : "",
|
|
385
|
+
`)}` : "", x = `## Props
|
|
377
386
|
|
|
378
387
|
### Data Props
|
|
379
388
|
|
|
380
389
|
${D}
|
|
381
390
|
|
|
382
|
-
${z}
|
|
383
|
-
|
|
384
|
-
${O}
|
|
385
|
-
|
|
386
391
|
${M}
|
|
387
392
|
|
|
388
393
|
${B}
|
|
389
394
|
|
|
390
|
-
${F}
|
|
391
|
-
|
|
395
|
+
${F}
|
|
396
|
+
|
|
397
|
+
${G}
|
|
398
|
+
|
|
399
|
+
${W}`, k = h.length > 0 && h[0].arrayContainer ? `<${$}
|
|
400
|
+
${h.map(
|
|
392
401
|
(n) => n.arrayContainer ? `${n.arrayContainer.propName}={[
|
|
393
402
|
{
|
|
394
403
|
${n.arrayContainer?.components.map(
|
|
395
|
-
(
|
|
404
|
+
(a) => `${a.propName}: "${a.type === "component:image" ? "https://example.com/image.jpg" : "Example value"}"`
|
|
396
405
|
).join(`,
|
|
397
406
|
`)}
|
|
398
407
|
}
|
|
399
408
|
]}` : ""
|
|
400
409
|
).filter(Boolean).join(`
|
|
401
410
|
`)}
|
|
402
|
-
/>` : `<${
|
|
403
|
-
let
|
|
404
|
-
if (
|
|
405
|
-
const n =
|
|
411
|
+
/>` : `<${$} />`;
|
|
412
|
+
let T = "";
|
|
413
|
+
if (h.length > 0 && h[0]) {
|
|
414
|
+
const n = h[0], a = u(n.name || "container"), o = `${a[0].toUpperCase()}${a.slice(
|
|
406
415
|
1
|
|
407
416
|
)}IndexChange`;
|
|
408
|
-
|
|
417
|
+
T = `## Controlling Slides
|
|
409
418
|
|
|
410
419
|
You can imperatively control which slide is displayed and listen for slide changes:
|
|
411
420
|
|
|
412
421
|
\`\`\`tsx
|
|
413
422
|
import { useState } from "react";
|
|
414
|
-
import { ${
|
|
423
|
+
import { ${$} } from "./${$}";
|
|
415
424
|
|
|
416
425
|
function MyComponent() {
|
|
417
426
|
const [currentSlide, setCurrentSlide] = useState(0);
|
|
@@ -424,38 +433,38 @@ function MyComponent() {
|
|
|
424
433
|
<button onClick={() => setCurrentSlide((prev) => prev + 1)}>
|
|
425
434
|
Next
|
|
426
435
|
</button>
|
|
427
|
-
<${
|
|
428
|
-
${
|
|
429
|
-
(
|
|
436
|
+
<${$}
|
|
437
|
+
${h.map(
|
|
438
|
+
(c) => c.arrayContainer ? `${c.arrayContainer.propName}={[/* array of items */]}` : ""
|
|
430
439
|
).filter(Boolean).join(`
|
|
431
440
|
`)}
|
|
432
|
-
${
|
|
433
|
-
on${
|
|
441
|
+
${a}CurrentIndex={currentSlide}
|
|
442
|
+
on${o}={(index) => setCurrentSlide(index)}
|
|
434
443
|
/>
|
|
435
444
|
</>
|
|
436
445
|
);
|
|
437
446
|
}
|
|
438
447
|
\`\`\``;
|
|
439
448
|
}
|
|
440
|
-
return `# ${
|
|
449
|
+
return `# ${$}
|
|
441
450
|
|
|
442
451
|
Encore App Wrapper Component
|
|
443
452
|
|
|
444
|
-
This component wraps the Encore Studio app **"${
|
|
453
|
+
This component wraps the Encore Studio app **"${v}"** (App ID: \`${O}\`) for the page **"${E}"** (Page ID: \`${w}\`).
|
|
445
454
|
|
|
446
455
|
The component automatically maps props to data-bound components within the app. Components marked with \`encore:data\` tags are exposed as props, allowing you to dynamically populate content.
|
|
447
456
|
|
|
448
|
-
${
|
|
457
|
+
${x}
|
|
449
458
|
|
|
450
459
|
## Usage
|
|
451
460
|
|
|
452
461
|
\`\`\`tsx
|
|
453
|
-
import { ${
|
|
462
|
+
import { ${$} } from "./${$}";
|
|
454
463
|
|
|
455
464
|
function MyComponent() {
|
|
456
465
|
return (
|
|
457
|
-
<${
|
|
458
|
-
${
|
|
466
|
+
<${$}
|
|
467
|
+
${h.map(
|
|
459
468
|
(n) => n.arrayContainer ? `${n.arrayContainer.propName}={[/* array of items */]}` : ""
|
|
460
469
|
).filter(Boolean).join(`
|
|
461
470
|
`)}
|
|
@@ -470,49 +479,49 @@ function MyComponent() {
|
|
|
470
479
|
${k}
|
|
471
480
|
\`\`\`
|
|
472
481
|
|
|
473
|
-
${
|
|
482
|
+
${T}
|
|
474
483
|
`;
|
|
475
484
|
}
|
|
476
|
-
function
|
|
477
|
-
const
|
|
478
|
-
E.forEach((
|
|
479
|
-
|
|
480
|
-
}),
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
}),
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
`on${
|
|
485
|
+
function J(O, w, v, E, $, h, y, b) {
|
|
486
|
+
const m = [], d = [], I = u(w);
|
|
487
|
+
E.forEach((p) => {
|
|
488
|
+
m.push(p.propName);
|
|
489
|
+
}), $.forEach((p) => {
|
|
490
|
+
const r = u(p.groupName);
|
|
491
|
+
m.push(r), d.push(`on${r[0].toUpperCase()}${r.slice(1)}Change`);
|
|
492
|
+
}), h.forEach((p) => {
|
|
493
|
+
const r = u(p.formName);
|
|
494
|
+
d.push(
|
|
495
|
+
`on${r[0].toUpperCase()}${r.slice(1)}Submit`
|
|
487
496
|
);
|
|
488
|
-
}),
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
}),
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
}),
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
+
}), y.forEach((p) => {
|
|
498
|
+
const r = p.propName, N = r[0].toUpperCase() + r.slice(1);
|
|
499
|
+
m.push(r), m.push(`${r}Options`), d.push(`on${N}Change`);
|
|
500
|
+
}), b.forEach((p) => {
|
|
501
|
+
const r = p.propName, N = r[0].toUpperCase() + r.slice(1);
|
|
502
|
+
d.push(`on${N}Click`);
|
|
503
|
+
}), v.forEach((p) => {
|
|
504
|
+
p.arrayContainer && p.arrayContainer.components.length > 0 && m.push(p.arrayContainer.propName);
|
|
505
|
+
const r = u(p.name || "container"), N = `${r[0].toUpperCase()}${r.slice(
|
|
497
506
|
1
|
|
498
507
|
)}IndexChange`;
|
|
499
|
-
|
|
508
|
+
m.push(`${r}CurrentIndex`), d.push(`on${N}`);
|
|
500
509
|
});
|
|
501
|
-
const
|
|
502
|
-
${
|
|
510
|
+
const P = `<${I}
|
|
511
|
+
${m.map((p) => `${p}={${p}}`).join(`
|
|
503
512
|
`)}
|
|
504
|
-
${
|
|
513
|
+
${d.map((p) => `${p}={${p}}`).join(`
|
|
505
514
|
`)}
|
|
506
515
|
/>`;
|
|
507
516
|
return {
|
|
508
|
-
props:
|
|
509
|
-
events:
|
|
510
|
-
jsx:
|
|
517
|
+
props: m,
|
|
518
|
+
events: d,
|
|
519
|
+
jsx: P
|
|
511
520
|
};
|
|
512
521
|
}
|
|
513
522
|
export {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
523
|
+
_ as generateComponentCode,
|
|
524
|
+
J as generateComponentMetadata,
|
|
525
|
+
q as generateReadme
|
|
517
526
|
};
|
|
518
527
|
//# sourceMappingURL=generator.js.map
|