@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.
@@ -1,219 +1,228 @@
1
- import { sanitizePropName as m, getComponentPropType as R, getComponentPropName as H } from "./parser.js";
2
- function L(A, x, P, E, u, c, N, v, l, $ = "dynamic", I) {
3
- const y = [], a = [], p = [], f = [], D = [], z = [];
4
- u.forEach((o) => {
5
- y.push(` ${o.propName}?: ${o.propType};`);
6
- }), c.forEach((o) => {
7
- const t = m(o.groupName);
8
- p.push(` ${t}?: string;`), p.push(
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 w = [];
15
- N.forEach((o) => {
16
- const t = m(o.formName), s = `${t[0].toUpperCase()}${t.slice(
14
+ const j = [];
15
+ y.forEach((e) => {
16
+ const t = u(e.formName), i = `${t[0].toUpperCase()}${t.slice(
17
17
  1
18
- )}FormData`, r = [];
19
- o.inputs.forEach((d) => {
20
- const U = d.propName, b = R(d.type, d.name);
21
- r.push(` ${U}: ${b};`);
22
- }), w.push(`export interface ${s} {
23
- ${r.join(`
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
- }`), f.push(
25
+ }`), N.push(
26
26
  ` on${t[0].toUpperCase()}${t.slice(
27
27
  1
28
- )}Submit?: (formData: ${s}) => void;`
28
+ )}Submit?: (formData: ${i}) => void;`
29
29
  );
30
- }), v.forEach((o) => {
31
- const t = o.propName, s = t[0].toUpperCase() + t.slice(1);
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${s}Change?: (value: string) => void;`
35
+ ` on${i}Change?: (value: string) => void;`
36
36
  );
37
- }), l.forEach((o) => {
38
- const t = o.propName, s = t[0].toUpperCase() + t.slice(1);
39
- z.push(` on${s}Click?: () => void;`);
40
- }), E.forEach((o) => {
41
- if (o.arrayContainer && o.arrayContainer.components.length > 0) {
42
- const s = o.arrayContainer, r = `${s.propName[0].toUpperCase()}${s.propName.slice(
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
- y.push(` ${s.propName}: ${r}[];`);
45
+ P.push(` ${i.propName}: ${s}[];`);
46
46
  }
47
- const t = m(o.name || "container");
48
- a.push(` ${t}CurrentIndex?: number;`), a.push(
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 O = [
55
- ...y,
56
- ...a,
54
+ const B = [
55
+ ...P,
57
56
  ...p,
58
- ...f,
57
+ ...r,
58
+ ...N,
59
59
  ...D,
60
- ...z
61
- ], j = O.length > 0, M = j ? `export interface ${P}Props {
62
- ${O.join(`
60
+ ...M
61
+ ], S = B.length > 0, F = S ? `export interface ${v}Props {
62
+ ${B.join(`
63
63
  `)}
64
- }` : "", B = E.filter((o) => o.arrayContainer && o.arrayContainer.components.length > 0).map((o) => {
65
- const t = o.arrayContainer, s = `${t.propName[0].toUpperCase()}${t.propName.slice(
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`, r = t.components.map((d) => ` ${d.propName}: ${d.propType};`).join(`
67
+ )}Item`, s = t.components.map((f) => ` ${f.propName}: ${f.propType};`).join(`
68
68
  `);
69
- return `export interface ${s} {
70
- ${r}
69
+ return `export interface ${i} {
70
+ ${s}
71
71
  }`;
72
72
  }).join(`
73
73
 
74
- `), F = w.join(`
75
-
76
- `), S = [], k = [];
77
- u.forEach((o) => {
78
- const t = H(o.type);
79
- S.push(` // ${o.name}
80
- ...(props.${o.propName} !== undefined && { "${o.id}": { ${t}: props.${o.propName} } as any }),`);
81
- }), v.forEach((o) => {
82
- S.push(` // ${o.name}
83
- ...((props.${o.propName} !== undefined || props.${o.propName}Options !== undefined) && {
84
- "${o.id}": {
85
- ...(props.${o.propName} !== undefined && { value: props.${o.propName} }),
86
- ...(props.${o.propName}Options !== undefined && { options: props.${o.propName}Options }),
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((o) => {
90
- if (o.arrayContainer && o.arrayContainer.components.length > 0) {
91
- const d = o.arrayContainer, U = d.components.map((b) => {
92
- const W = H(b.type);
93
- return ` // ${b.name}
94
- "${b.id}": {
95
- ${W}: item.${b.propName},
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
- S.push(` // ${d.name}
100
- "${d.id}": props.${d.propName}.map((item) => ({
104
+ x.push(` // ${f.name}
105
+ "${f.id}": props.${f.propName}.map((item) => ({
101
106
  ${U}
102
107
  })),`);
103
108
  }
104
- const t = m(o.name || "container"), s = `${t[0].toUpperCase()}${t.slice(
109
+ const t = u(e.name || "container"), i = `${t[0].toUpperCase()}${t.slice(
105
110
  1
106
- )}IndexChange`, r = [];
107
- o.id && (r.push(` // ${o.name}`), r.push(` "${o.id}": {`), r.push(
111
+ )}IndexChange`, s = [];
112
+ e.id && (s.push(` // ${e.name}`), s.push(` "${e.id}": {`), s.push(
108
113
  ` currentIndex: props.${t}CurrentIndex,`
109
- ), r.push(` onIndexChange: props.on${s},`), r.push(" }")), r.length > 0 && k.push(r.join(`
114
+ ), s.push(` onIndexChange: props.on${i},`), s.push(" }")), s.length > 0 && T.push(s.join(`
110
115
  `));
111
116
  });
112
- const G = k.length > 0 ? `
117
+ const n = T.length > 0 ? `
113
118
  repeatingContainerControls={{
114
- ${k.join(`,
119
+ ${T.join(`,
115
120
  `)}
116
- }}` : "", n = [], e = [];
117
- (c.length > 0 || N.length > 0 || v.length > 0 || l.length > 0) && (e.push(" const handleAction = (payload: any) => {"), e.push(" const { action } = payload?.bravo || {};"), e.push(""), v.length > 0 && (e.push(" // Handle select input changes"), e.push(
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
- ), e.push(" const nodeId = action?.nodeId;"), e.push(" const value = action?.params?.value;"), e.push(""), v.forEach((o) => {
120
- const t = o.propName, r = `on${t[0].toUpperCase() + t.slice(1)}Change`;
121
- e.push(` // ${o.name}`), e.push(
122
- ` if (nodeId === "${o.id}" && props.${r}) {`
123
- ), e.push(` props.${r}(value);`), e.push(" return;"), e.push(" }");
124
- }), e.push(" }"), e.push("")), l.length > 0 && (e.push(" // Handle button clicks"), e.push(
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
- ), e.push(" const nodeId = action?.nodeId;"), e.push(""), l.forEach((o) => {
127
- const t = o.propName, r = `on${t[0].toUpperCase() + t.slice(1)}Click`;
128
- e.push(` // ${o.name}`), e.push(
129
- ` if (nodeId === "${o.id}" && props.${r}) {`
130
- ), e.push(` props.${r}();`), e.push(" return;"), e.push(" }");
131
- }), e.push(" }"), e.push("")), c.length > 0 && (e.push(
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
- ), e.push(
138
+ ), o.push(
134
139
  " const { groupName, value } = action.params;"
135
- ), c.forEach((o) => {
136
- const t = m(o.groupName), s = `on${t[0].toUpperCase()}${t.slice(
140
+ ), h.forEach((e) => {
141
+ const t = u(e.groupName), i = `on${t[0].toUpperCase()}${t.slice(
137
142
  1
138
143
  )}Change`;
139
- e.push(
140
- ` if (groupName === "${o.groupName}" && props.${s}) {`
141
- ), e.push(` props.${s}(value);`), e.push(" return;"), e.push(" }");
142
- }), e.push(" }"), e.push("")), N.length > 0 && (e.push(' if (action?.action === "submit") {'), e.push(" // Get form inputs from Encore state"), e.push(
143
- ` const formInputs = useEncoreState.getState().formInputs["${x}"] || {};`
144
- ), e.push(" const submitNodeId = action?.nodeId;"), e.push(""), N.forEach((o, t) => {
145
- const s = m(o.formName), r = `on${s[0].toUpperCase()}${s.slice(
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 && e.push(""), e.push(
149
- ` // Form: ${o.formName} (${o.formId})`
150
- ), o.submitButtonId ? e.push(
151
- ` if (submitNodeId === "${o.submitButtonId}" && props.${r}) {`
152
- ) : N.length === 1 ? e.push(` if (props.${r}) {`) : e.push(` if (props.${r}) {`), e.push(" // Extract form inputs for this form");
153
- const d = `${s[0].toUpperCase()}${s.slice(
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
- e.push(
157
- ` const formData: ${d} = {`
161
+ o.push(
162
+ ` const formData: ${f} = {`
158
163
  );
159
164
  const U = [];
160
- o.inputs.forEach((b) => {
161
- const W = b.propName;
165
+ e.inputs.forEach((C) => {
166
+ const R = C.propName;
162
167
  U.push(
163
- ` ${W}: formInputs["${b.id}"]`
168
+ ` ${R}: formInputs["${C.id}"]`
164
169
  );
165
- }), e.push(U.join(`,
166
- `)), e.push(" };"), e.push(` props.${r}(formData);`), e.push(
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
- ), e.push(" }");
169
- }), e.push(" }")), e.push(" };")), c.forEach((o) => {
170
- const t = m(o.groupName);
171
- n.push(
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 C = n.length > 0 ? `
180
+ const c = a.length > 0 ? `
176
181
  inputGroups={{
177
- ${n.join(`
182
+ ${a.join(`
183
+ `)}
184
+ }}` : "", g = o.length > 0 ? `
185
+ onAction={handleAction}` : "", l = k.length > 0 ? `
186
+ embeds={{
187
+ ${k.join(`
178
188
  `)}
179
- }}` : "", i = e.length > 0 ? `
180
- onAction={handleAction}` : "", g = j ? `props: ${P}Props` : "", h = M ? `${M}
189
+ }}` : "", A = S ? `props: ${v}Props` : "", z = F ? `${F}
181
190
 
182
- ` : "", T = $ === "production" || $ === "optimistic";
191
+ ` : "", K = d === "production" || d === "optimistic";
183
192
  return `/**
184
- * ${P}
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${N.length > 0 ? ", useEncoreState" : ""} } from "@bravostudioai/react";
191
- ${T ? 'import productionData from "./data.json";' : ""}
199
+ import { EncoreApp${y.length > 0 ? ", useEncoreState" : ""} } from "@bravostudioai/react";
200
+ ${K ? 'import productionData from "./data.json";' : ""}
192
201
 
193
- ${B ? `${B}
202
+ ${G ? `${G}
194
203
 
195
- ` : ""}${F ? `${F}
204
+ ` : ""}${W ? `${W}
196
205
 
197
- ` : ""}${h}export function ${P}(${g}) {
198
- ${e.length > 0 ? e.join(`
206
+ ` : ""}${z}export function ${v}(${A}) {
207
+ ${o.length > 0 ? o.join(`
199
208
  `) : ""}
200
209
  return (
201
210
  <EncoreApp
202
- appId="${A}"
203
- pageId="${x}"
204
- mode="${$}"
205
- ${T ? `appDefinition={productionData.app}
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
- ${S.join(`
218
+ ${x.join(`
210
219
  `)}
211
- }}${G}${C}${i}
220
+ }}${n}${c}${g}${l}
212
221
  />
213
222
  );
214
223
  }
215
224
 
216
- export default ${P};
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 Y(A, x, P, E, u, c, N, v, l, $, I) {
226
- const y = [], a = [], p = [], f = [];
227
- N.forEach((n) => {
228
- y.push(`### \`${n.propName}\` (${n.propType}, optional)
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
- }), c.forEach((n) => {
240
+ }), h.forEach((n) => {
232
241
  if (n.arrayContainer && n.arrayContainer.components.length > 0) {
233
- const i = n.arrayContainer, g = i.components.map((h) => `- \`${h.propName}\` (${h.propType}): ${h.name} (${h.type}) - Component ID: ${h.id}`).join(`
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
- y.push(`### \`${i.propName}\` (${i.propName[0].toUpperCase()}${i.propName.slice(
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 "${i.name}" container (ID: ${i.id})
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 e = m(n.name || "container"), C = `${e[0].toUpperCase()}${e.slice(
254
+ const a = u(n.name || "container"), o = `${a[0].toUpperCase()}${a.slice(
246
255
  1
247
256
  )}IndexChange`;
248
- a.push(`### \`${e}CurrentIndex\` (number, optional)
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${C}\` ((index: number) => void, optional)
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 = y.length > 0 ? y.join(`
269
+ const D = P.length > 0 ? P.join(`
261
270
 
262
- `) : "This component currently has no data-bound props.", z = a.length > 0 ? `## Control 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
- ${a.join(`
275
+ ${p.join(`
267
276
 
268
- `)}` : "", w = [];
269
- v.forEach((n) => {
270
- const e = m(n.groupName), C = `on${e[0].toUpperCase()}${e.slice(
277
+ `)}` : "", j = [];
278
+ b.forEach((n) => {
279
+ const a = u(n.groupName), o = `on${a[0].toUpperCase()}${a.slice(
271
280
  1
272
- )}Change`, i = n.elements.map((g) => `- "${g.name}"`).join(`
281
+ )}Change`, c = n.elements.map((g) => `- "${g.name}"`).join(`
273
282
  `);
274
- w.push(`### \`${e}\` (string, optional)
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
- ${i}
288
+ ${c}
280
289
 
281
- ### \`${C}\` ((value: string) => void, optional)
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 O = w.length > 0 ? `## Input Group Props
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
- ${w.join(`
298
+ ${j.join(`
290
299
 
291
- `)}` : "", j = [];
292
- l.forEach((n) => {
293
- const e = m(n.formName), C = `on${e[0].toUpperCase()}${e.slice(
300
+ `)}` : "", S = [];
301
+ m.forEach((n) => {
302
+ const a = u(n.formName), o = `on${a[0].toUpperCase()}${a.slice(
294
303
  1
295
- )}Submit`, i = `${e[0].toUpperCase()}${e.slice(
304
+ )}Submit`, c = `${a[0].toUpperCase()}${a.slice(
296
305
  1
297
- )}FormData`, g = n.inputs.map((h) => {
298
- const T = h.propName, o = R(h.type, h.name);
299
- return `- \`${T}\` (${o}) - ${h.name}`;
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
- j.push(`### \`${C}\` ((formData: ${i}) => void, optional)
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 ${i} {
309
- ${n.inputs.map((h) => {
310
- const T = h.propName, o = R(h.type, h.name);
311
- return ` ${T}: ${o};`;
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 M = j.length > 0 ? `## Form Submission Props
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
- ${j.join(`
333
+ ${S.join(`
325
334
 
326
335
  `)}` : "";
327
- $.forEach((n) => {
328
- const e = n.propName, i = `on${e[0].toUpperCase() + e.slice(1)}Change`, g = `${e}Options`;
329
- p.push(`### \`${e}\` (string, optional)
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
- ### \`${i}\` ((value: string) => void, optional)
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 B = p.length > 0 ? `## Select Input Props
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
- ${p.join(`
368
+ ${r.join(`
360
369
 
361
370
  `)}` : "";
362
371
  I.forEach((n) => {
363
- const e = n.propName, i = `on${e[0].toUpperCase() + e.slice(1)}Click`;
364
- f.push(`### \`${i}\` (() => void, optional)
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 F = f.length > 0 ? `## Action Button Props
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
- ${f.join(`
383
+ ${N.join(`
375
384
 
376
- `)}` : "", S = `## Props
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}`, k = c.length > 0 && c[0].arrayContainer ? `<${u}
391
- ${c.map(
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
- (e) => `${e.propName}: "${e.type === "component:image" ? "https://example.com/image.jpg" : "Example value"}"`
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
- />` : `<${u} />`;
403
- let G = "";
404
- if (c.length > 0 && c[0]) {
405
- const n = c[0], e = m(n.name || "container"), C = `${e[0].toUpperCase()}${e.slice(
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
- G = `## Controlling Slides
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 { ${u} } from "./${u}";
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
- <${u}
428
- ${c.map(
429
- (i) => i.arrayContainer ? `${i.arrayContainer.propName}={[/* array of items */]}` : ""
436
+ <${$}
437
+ ${h.map(
438
+ (c) => c.arrayContainer ? `${c.arrayContainer.propName}={[/* array of items */]}` : ""
430
439
  ).filter(Boolean).join(`
431
440
  `)}
432
- ${e}CurrentIndex={currentSlide}
433
- on${C}={(index) => setCurrentSlide(index)}
441
+ ${a}CurrentIndex={currentSlide}
442
+ on${o}={(index) => setCurrentSlide(index)}
434
443
  />
435
444
  </>
436
445
  );
437
446
  }
438
447
  \`\`\``;
439
448
  }
440
- return `# ${u}
449
+ return `# ${$}
441
450
 
442
451
  Encore App Wrapper Component
443
452
 
444
- This component wraps the Encore Studio app **"${P}"** (App ID: \`${A}\`) for the page **"${E}"** (Page ID: \`${x}\`).
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
- ${S}
457
+ ${x}
449
458
 
450
459
  ## Usage
451
460
 
452
461
  \`\`\`tsx
453
- import { ${u} } from "./${u}";
462
+ import { ${$} } from "./${$}";
454
463
 
455
464
  function MyComponent() {
456
465
  return (
457
- <${u}
458
- ${c.map(
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
- ${G}
482
+ ${T}
474
483
  `;
475
484
  }
476
- function _(A, x, P, E, u, c, N, v) {
477
- const l = [], $ = [], I = m(x);
478
- E.forEach((a) => {
479
- l.push(a.propName);
480
- }), u.forEach((a) => {
481
- const p = m(a.groupName);
482
- l.push(p), $.push(`on${p[0].toUpperCase()}${p.slice(1)}Change`);
483
- }), c.forEach((a) => {
484
- const p = m(a.formName);
485
- $.push(
486
- `on${p[0].toUpperCase()}${p.slice(1)}Submit`
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
- }), N.forEach((a) => {
489
- const p = a.propName, f = p[0].toUpperCase() + p.slice(1);
490
- l.push(p), l.push(`${p}Options`), $.push(`on${f}Change`);
491
- }), v.forEach((a) => {
492
- const p = a.propName, f = p[0].toUpperCase() + p.slice(1);
493
- $.push(`on${f}Click`);
494
- }), P.forEach((a) => {
495
- a.arrayContainer && a.arrayContainer.components.length > 0 && l.push(a.arrayContainer.propName);
496
- const p = m(a.name || "container"), f = `${p[0].toUpperCase()}${p.slice(
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
- l.push(`${p}CurrentIndex`), $.push(`on${f}`);
508
+ m.push(`${r}CurrentIndex`), d.push(`on${N}`);
500
509
  });
501
- const y = `<${I}
502
- ${l.map((a) => `${a}={${a}}`).join(`
510
+ const P = `<${I}
511
+ ${m.map((p) => `${p}={${p}}`).join(`
503
512
  `)}
504
- ${$.map((a) => `${a}={${a}}`).join(`
513
+ ${d.map((p) => `${p}={${p}}`).join(`
505
514
  `)}
506
515
  />`;
507
516
  return {
508
- props: l,
509
- events: $,
510
- jsx: y
517
+ props: m,
518
+ events: d,
519
+ jsx: P
511
520
  };
512
521
  }
513
522
  export {
514
- L as generateComponentCode,
515
- _ as generateComponentMetadata,
516
- Y as generateReadme
523
+ _ as generateComponentCode,
524
+ J as generateComponentMetadata,
525
+ q as generateReadme
517
526
  };
518
527
  //# sourceMappingURL=generator.js.map