@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,64 +1,64 @@
1
1
  import { qualifyPropNames as E } from "./propQualification.js";
2
2
  function g(i) {
3
- const c = i.replace(/[^a-zA-Z0-9\s]/g, "").trim();
4
- return c ? c.split(/\s+/).map((s, y) => {
3
+ const o = i.replace(/[^a-zA-Z0-9\s]/g, "").trim();
4
+ return o ? o.split(/\s+/).map((s, y) => {
5
5
  if (!s) return "";
6
- const t = s === s.toUpperCase() && s.length > 1 ? s.toLowerCase() : s, o = t.charAt(0), r = t.slice(1);
7
- return y === 0 ? o.toLowerCase() + r : o.toUpperCase() + r;
6
+ const t = s === s.toUpperCase() && s.length > 1 ? s.toLowerCase() : s, e = t.charAt(0), r = t.slice(1);
7
+ return y === 0 ? e.toLowerCase() + r : e.toUpperCase() + r;
8
8
  }).join("").replace(/^[0-9]/, "_$&") : "item";
9
9
  }
10
- function F(i, c) {
10
+ function d(i, o) {
11
11
  const s = g(i);
12
- if (c.length === 0)
12
+ if (o.length === 0)
13
13
  return s;
14
- const y = c.filter((r) => r && r.trim()).reverse();
14
+ const y = o.filter((r) => r && r.trim()).reverse();
15
15
  return y.length === 0 ? s : y.map(
16
16
  (r) => g(r)
17
17
  ).map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join("") + s;
18
18
  }
19
- function S(i, c) {
20
- if (c.length === 0)
19
+ function F(i, o) {
20
+ if (o.length === 0)
21
21
  return [];
22
22
  let s = 0;
23
23
  const y = Math.min(
24
24
  i.length,
25
- ...c.map((o) => o.length)
25
+ ...o.map((e) => e.length)
26
26
  );
27
- for (let o = 0; o < y; o++) {
28
- const r = i[o];
29
- if (c.every((f) => f[o] === r))
27
+ for (let e = 0; e < y; e++) {
28
+ const r = i[e];
29
+ if (o.every((f) => f[e] === r))
30
30
  s++;
31
31
  else
32
32
  break;
33
33
  }
34
34
  const t = i.slice(s);
35
- for (let o = 1; o <= t.length; o++) {
36
- const r = t.slice(0, o);
37
- if (c.every((f) => {
38
- if (f.length < s + o)
35
+ for (let e = 1; e <= t.length; e++) {
36
+ const r = t.slice(0, e);
37
+ if (o.every((f) => {
38
+ if (f.length < s + e)
39
39
  return !0;
40
40
  const a = f.slice(
41
41
  s,
42
- s + o
42
+ s + e
43
43
  );
44
- return !W(r, a);
44
+ return !v(r, a);
45
45
  }))
46
46
  return r;
47
47
  }
48
48
  return t;
49
49
  }
50
- function W(i, c) {
51
- return i.length !== c.length ? !1 : i.every((s, y) => s === c[y]);
50
+ function v(i, o) {
51
+ return i.length !== o.length ? !1 : i.every((s, y) => s === o[y]);
52
52
  }
53
- function P(i, c) {
54
- return i === "component:image" || i === "component:text" || i?.startsWith("component:input-") ? "string" : "any";
53
+ function P(i, o) {
54
+ return i === "component:image" || i === "component:text" || i?.startsWith("component:input-") || i === "component:webview" || i === "component:video" || i === "component:video" ? "string" : i === "component:embed" ? "React.ReactNode" : "any";
55
55
  }
56
- function j(i) {
57
- return i === "component:image" ? "imageUrl" : i === "component:text" ? "text" : "value";
56
+ function S(i) {
57
+ return i === "component:image" ? "imageUrl" : i === "component:text" ? "text" : i === "component:webview" ? "url" : i === "component:video" ? "videoUrl" : "value";
58
58
  }
59
- function x(i) {
60
- const c = [];
61
- function s(t, o = []) {
59
+ function j(i) {
60
+ const o = [];
61
+ function s(t, e = []) {
62
62
  if (!(!t || typeof t != "object")) {
63
63
  if (t.type === "container:slider") {
64
64
  const r = {
@@ -79,60 +79,60 @@ function x(i) {
79
79
  if (t.containers && Array.isArray(t.containers) && t.containers.forEach(f), !p && t.components && Array.isArray(t.components) && t.components.forEach(f), p) {
80
80
  const a = p;
81
81
  let u = [];
82
- const n = [], l = (e, b = []) => {
83
- if (!e || typeof e != "object") return;
84
- if (e.type === "component:image" && n.push(e), Array.isArray(e.tags) && (e.tags.includes("encore:data") || e.tags.includes("bravo:data"))) {
85
- const A = g(e.name || "item"), C = P(e.type, e.name);
82
+ const c = [], h = (n, b = []) => {
83
+ if (!n || typeof n != "object") return;
84
+ if (n.type === "component:image" && c.push(n), Array.isArray(n.tags) && (n.tags.includes("encore:data") || n.tags.includes("bravo:data"))) {
85
+ const l = g(n.name || "item"), C = P(n.type, n.name);
86
86
  u.push({
87
- id: e.id,
88
- name: e.name || "Unnamed",
89
- type: e.type,
90
- tags: e.tags || [],
91
- propName: A,
87
+ id: n.id,
88
+ name: n.name || "Unnamed",
89
+ type: n.type,
90
+ tags: n.tags || [],
91
+ propName: l,
92
92
  // Will be qualified later if needed
93
93
  propType: C,
94
94
  // Store parent path for later qualification
95
95
  _parentPath: [...b]
96
96
  });
97
97
  }
98
- const h = [...b];
99
- if (e.name && (e.type?.startsWith("container:") || e.type?.startsWith("component:"))) {
100
- const A = e.name.trim(), C = /^frame\s*\d*$/i.test(A) || A.toUpperCase() === "FRAME";
101
- A && !C && h.push(e.name);
98
+ const A = [...b];
99
+ if (n.name && (n.type?.startsWith("container:") || n.type?.startsWith("component:"))) {
100
+ const l = n.name.trim(), C = /^frame\s*\d*$/i.test(l) || l.toUpperCase() === "FRAME";
101
+ l && !C && A.push(n.name);
102
102
  }
103
- e.body && Array.isArray(e.body) && e.body.forEach(
104
- (A) => l(A, h)
105
- ), e.containers && Array.isArray(e.containers) && e.containers.forEach(
106
- (A) => l(A, h)
107
- ), e.components && Array.isArray(e.components) && e.components.forEach(
108
- (A) => l(A, h)
103
+ n.body && Array.isArray(n.body) && n.body.forEach(
104
+ (l) => h(l, A)
105
+ ), n.containers && Array.isArray(n.containers) && n.containers.forEach(
106
+ (l) => h(l, A)
107
+ ), n.components && Array.isArray(n.components) && n.components.forEach(
108
+ (l) => h(l, A)
109
109
  );
110
110
  };
111
111
  if (a.components && Array.isArray(a.components) && a.components.forEach(
112
- (e) => l(e, [])
112
+ (n) => h(n, [])
113
113
  ), !u.some(
114
- (e) => e.type === "component:image"
115
- ) && n.length > 0) {
116
- const e = n[0], h = (e.name || "image").toLowerCase().includes("image") ? "imageUrl" : g(e.name || "image");
114
+ (n) => n.type === "component:image"
115
+ ) && c.length > 0) {
116
+ const n = c[0], A = (n.name || "image").toLowerCase().includes("image") ? "imageUrl" : g(n.name || "image");
117
117
  u.push({
118
- id: e.id,
119
- name: e.name || "Image",
120
- type: e.type,
121
- tags: e.tags || [],
122
- propName: h,
118
+ id: n.id,
119
+ name: n.name || "Image",
120
+ type: n.type,
121
+ tags: n.tags || [],
122
+ propName: A,
123
123
  // Will be qualified later if needed
124
124
  propType: "string",
125
125
  // imageUrl is always string
126
126
  _parentPath: []
127
127
  });
128
128
  }
129
- if (E(u), n.length > 0) {
130
- const b = (n[0].name || "").toLowerCase();
131
- u = u.filter((h) => {
132
- if (h.type === "component:image") return !0;
133
- if (h.type === "component:color") {
134
- const A = (h.name || "").toLowerCase();
135
- if (b.includes(A) || A.includes("image"))
129
+ if (E(u), c.length > 0) {
130
+ const b = (c[0].name || "").toLowerCase();
131
+ u = u.filter((A) => {
132
+ if (A.type === "component:image") return !0;
133
+ if (A.type === "component:color") {
134
+ const l = (A.name || "").toLowerCase();
135
+ if (b.includes(l) || l.includes("image"))
136
136
  return !1;
137
137
  }
138
138
  return !0;
@@ -145,73 +145,74 @@ function x(i) {
145
145
  components: u
146
146
  };
147
147
  }
148
- c.push(r);
148
+ o.push(r);
149
149
  }
150
- t.body && Array.isArray(t.body) && t.body.forEach((r) => s(r, [...o, "body"])), t.containers && Array.isArray(t.containers) && t.containers.forEach(
151
- (r) => s(r, [...o, "containers"])
150
+ t.body && Array.isArray(t.body) && t.body.forEach((r) => s(r, [...e, "body"])), t.containers && Array.isArray(t.containers) && t.containers.forEach(
151
+ (r) => s(r, [...e, "containers"])
152
152
  ), t.components && Array.isArray(t.components) && t.components.forEach(
153
- (r) => s(r, [...o, "components"])
153
+ (r) => s(r, [...e, "components"])
154
154
  );
155
155
  }
156
156
  }
157
157
  const y = i.data?.body || i.body || i.data?.body || [];
158
- return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), c;
158
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), o;
159
159
  }
160
- function N(i) {
161
- const c = [], s = /* @__PURE__ */ new Set();
160
+ function x(i) {
161
+ const o = [], s = /* @__PURE__ */ new Set();
162
162
  function y(r) {
163
163
  !r || typeof r != "object" || (r.type === "container:slider" && s.add(r.id), r.body && Array.isArray(r.body) && r.body.forEach(y), r.containers && Array.isArray(r.containers) && r.containers.forEach(y));
164
164
  }
165
165
  function t(r, p, f = []) {
166
166
  if (!r || typeof r != "object" || p && s.has(p)) return;
167
- if (Array.isArray(r.tags) && (r.tags.includes("encore:data") || r.tags.includes("bravo:data")) && (r.type === "component:text" || r.type === "component:image")) {
168
- const n = g(r.name || "item"), l = P(r.type, r.name);
169
- c.push({
167
+ const a = Array.isArray(r.tags) && (r.tags.includes("encore:data") || r.tags.includes("bravo:data"));
168
+ if (r.type === "component:embed" || a && (r.type === "component:text" || r.type === "component:image" || r.type === "component:webview" || r.type === "component:video")) {
169
+ const h = g(r.name || "item"), m = P(r.type, r.name);
170
+ o.push({
170
171
  id: r.id,
171
172
  name: r.name || "Unnamed",
172
173
  type: r.type,
173
174
  tags: r.tags || [],
174
- propName: n,
175
+ propName: h,
175
176
  // Will be qualified later if needed
176
- propType: l,
177
+ propType: m,
177
178
  // Store parent path for later qualification
178
179
  _parentPath: [...f]
179
180
  });
180
181
  }
181
- const a = [...f];
182
+ const u = [...f];
182
183
  if (r.name && (r.type?.startsWith("container:") || r.type?.startsWith("component:"))) {
183
- const n = r.name.trim(), l = /^frame\s*\d*$/i.test(n) || n.toUpperCase() === "FRAME";
184
- n && !l && a.push(r.name);
184
+ const h = r.name.trim(), m = /^frame\s*\d*$/i.test(h) || h.toUpperCase() === "FRAME";
185
+ h && !m && u.push(r.name);
185
186
  }
186
- const u = r.id;
187
+ const c = r.id;
187
188
  r.body && Array.isArray(r.body) && r.body.forEach(
188
- (n) => t(n, u, a)
189
+ (h) => t(h, c, u)
189
190
  ), r.containers && Array.isArray(r.containers) && r.containers.forEach(
190
- (n) => t(n, u, a)
191
+ (h) => t(h, c, u)
191
192
  ), r.components && Array.isArray(r.components) && r.components.forEach(
192
- (n) => t(n, u, a)
193
+ (h) => t(h, c, u)
193
194
  );
194
195
  }
195
- const o = i.data?.body || i.body || i.data?.body || [];
196
- return Array.isArray(o) && o.length > 0 && (o.forEach(y), o.forEach((r) => t(r))), E(c), c;
196
+ const e = i.data?.body || i.body || i.data?.body || [];
197
+ return Array.isArray(e) && e.length > 0 && (e.forEach(y), e.forEach((r) => t(r))), E(o), o;
197
198
  }
198
- function d(i) {
199
- const c = /* @__PURE__ */ new Map();
199
+ function w(i) {
200
+ const o = /* @__PURE__ */ new Map();
200
201
  function s(t) {
201
202
  if (!(!t || typeof t != "object")) {
202
203
  if (t.type === "component:input-stateful-set" && Array.isArray(t.tags)) {
203
- const o = t.tags.find(
204
+ const e = t.tags.find(
204
205
  (r) => r.startsWith("input-group:")
205
206
  );
206
- if (o) {
207
- const r = o.split(":");
207
+ if (e) {
208
+ const r = e.split(":");
208
209
  if (r.length >= 3) {
209
210
  const p = r[1], f = r[2];
210
- c.has(f) || c.set(f, {
211
+ o.has(f) || o.set(f, {
211
212
  groupName: f,
212
213
  groupType: p,
213
214
  elements: []
214
- }), c.get(f).elements.push({
215
+ }), o.get(f).elements.push({
215
216
  id: t.id,
216
217
  name: t.name || "Unnamed"
217
218
  });
@@ -222,72 +223,72 @@ function d(i) {
222
223
  }
223
224
  }
224
225
  const y = i.data?.body || i.body || i.data?.body || [];
225
- return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), Array.from(c.values());
226
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), Array.from(o.values());
226
227
  }
227
- function M(i) {
228
- const c = [];
229
- function s(t, o) {
228
+ function N(i) {
229
+ const o = [];
230
+ function s(t, e) {
230
231
  if (!t || typeof t != "object") return;
231
232
  const r = t.type?.startsWith("container:") || t.type === "container:default", p = t.name?.toLowerCase().includes("form") || Array.isArray(t.tags) && t.tags.includes("form");
232
233
  let f = !1, a;
233
- function u(n) {
234
- if (!(!n || typeof n != "object")) {
235
- if (Array.isArray(n.tags) && (n.tags.includes("action:submit") || n.tags.includes("submit"))) {
236
- f = !0, a = n.id;
234
+ function u(c) {
235
+ if (!(!c || typeof c != "object")) {
236
+ if (Array.isArray(c.tags) && (c.tags.includes("action:submit") || c.tags.includes("submit"))) {
237
+ f = !0, a = c.id;
237
238
  return;
238
239
  }
239
- if (n.actions?.tap?.action === "submit") {
240
- f = !0, a = n.id;
240
+ if (c.actions?.tap?.action === "submit") {
241
+ f = !0, a = c.id;
241
242
  return;
242
243
  }
243
- n.components && Array.isArray(n.components) && n.components.forEach(u), n.body && Array.isArray(n.body) && n.body.forEach(u);
244
+ c.components && Array.isArray(c.components) && c.components.forEach(u), c.body && Array.isArray(c.body) && c.body.forEach(u);
244
245
  }
245
246
  }
246
- if (r && (p || o === void 0) && u(t), r && (f || p)) {
247
- const n = [], l = (m, e = []) => {
247
+ if (r && (p || e === void 0) && u(t), r && (f || p)) {
248
+ const c = [], h = (m, n = []) => {
248
249
  if (!m || typeof m != "object") return;
249
250
  if (m.type?.startsWith("component:input-") || m.type === "component:input-text" || m.type === "component:input-image" || m.type === "component:input-email" || m.type === "component:input-password" || m.type === "component:input-select") {
250
- const h = g(m.name || "Unnamed input");
251
- n.push({
251
+ const A = g(m.name || "Unnamed input");
252
+ c.push({
252
253
  id: m.id,
253
254
  name: m.name || "Unnamed input",
254
255
  type: m.type,
255
- propName: h,
256
+ propName: A,
256
257
  // Will be qualified later if needed
257
- _parentPath: [...e]
258
+ _parentPath: [...n]
258
259
  // Store parent path for qualification
259
260
  });
260
261
  }
261
- const b = [...e];
262
+ const b = [...n];
262
263
  if (m.name && (m.type?.startsWith("container:") || m.type?.startsWith("component:"))) {
263
- const h = m.name.trim(), A = /^frame\s*\d*$/i.test(h) || h.toUpperCase() === "FRAME";
264
- h && !A && b.push(m.name);
264
+ const A = m.name.trim(), l = /^frame\s*\d*$/i.test(A) || A.toUpperCase() === "FRAME";
265
+ A && !l && b.push(m.name);
265
266
  }
266
267
  m.components && Array.isArray(m.components) && m.components.forEach(
267
- (h) => l(h, b)
268
- ), m.body && Array.isArray(m.body) && m.body.forEach((h) => l(h, b));
268
+ (A) => h(A, b)
269
+ ), m.body && Array.isArray(m.body) && m.body.forEach((A) => h(A, b));
269
270
  };
270
- l(t, []), n.length > 0 && c.push({
271
+ h(t, []), c.length > 0 && o.push({
271
272
  formId: t.id,
272
273
  formName: t.name || "Form",
273
274
  submitButtonId: a,
274
- inputs: n
275
+ inputs: c
275
276
  });
276
277
  }
277
278
  t.body && Array.isArray(t.body) && t.body.forEach(
278
- (n) => s(n, r ? t : o)
279
+ (c) => s(c, r ? t : e)
279
280
  ), t.containers && Array.isArray(t.containers) && t.containers.forEach(
280
- (n) => s(n, r ? t : o)
281
+ (c) => s(c, r ? t : e)
281
282
  ), t.components && Array.isArray(t.components) && t.components.forEach(
282
- (n) => s(n, r ? t : o)
283
+ (c) => s(c, r ? t : e)
283
284
  );
284
285
  }
285
286
  const y = i.data?.body || i.body || i.data?.body || [];
286
- return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), c;
287
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), o;
287
288
  }
288
- function L(i, c) {
289
+ function M(i, o) {
289
290
  const s = [], y = /* @__PURE__ */ new Set();
290
- c.forEach((r) => {
291
+ o.forEach((r) => {
291
292
  r.inputs.forEach((p) => {
292
293
  y.add(p.id);
293
294
  });
@@ -314,36 +315,36 @@ function L(i, c) {
314
315
  (a) => t(a, f)
315
316
  );
316
317
  }
317
- const o = i.data?.body || i.body || i.data?.body || [];
318
- return Array.isArray(o) && o.length > 0 && o.forEach((r) => t(r)), I(s), s;
318
+ const e = i.data?.body || i.body || i.data?.body || [];
319
+ return Array.isArray(e) && e.length > 0 && e.forEach((r) => t(r)), W(s), s;
319
320
  }
320
- function I(i) {
321
+ function W(i) {
321
322
  E(i);
322
323
  }
323
- function _(i) {
324
- const c = [];
325
- function s(t, o = []) {
324
+ function L(i) {
325
+ const o = [];
326
+ function s(t, e = []) {
326
327
  if (!t || typeof t != "object") return;
327
328
  const r = Array.isArray(t.tags) && t.tags.some((a) => a.startsWith("action:")), p = t.actions && typeof t.actions == "object";
328
329
  if (r || p) {
329
330
  let a = "tap";
330
331
  if (Array.isArray(t.tags)) {
331
- const n = t.tags.find(
332
- (l) => l.startsWith("action:")
332
+ const c = t.tags.find(
333
+ (h) => h.startsWith("action:")
333
334
  );
334
- n && (a = n.replace("action:", ""));
335
+ c && (a = c.replace("action:", ""));
335
336
  }
336
337
  t.actions?.tap?.action && (a = t.actions.tap.action);
337
338
  const u = g(t.name || "button");
338
- c.push({
339
+ o.push({
339
340
  id: t.id,
340
341
  name: t.name || "Button",
341
342
  propName: u,
342
343
  actionType: a,
343
- _parentPath: [...o]
344
+ _parentPath: [...e]
344
345
  });
345
346
  }
346
- const f = [...o];
347
+ const f = [...e];
347
348
  if (t.name && (t.type?.startsWith("container:") || t.type?.startsWith("component:"))) {
348
349
  const a = t.name.trim(), u = /^frame\s*\d*$/i.test(a) || a.toUpperCase() === "FRAME";
349
350
  a && !u && f.push(t.name);
@@ -355,29 +356,29 @@ function _(i) {
355
356
  );
356
357
  }
357
358
  const y = i.data?.body || i.body || i.data?.body || [];
358
- return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), v(c), c;
359
+ return Array.isArray(y) && y.length > 0 && y.forEach((t) => s(t)), I(o), o;
359
360
  }
360
- function v(i) {
361
+ function I(i) {
361
362
  E(i);
362
363
  }
363
- function q(i) {
364
- i.forEach((c) => {
365
- E(c.inputs);
364
+ function _(i) {
365
+ i.forEach((o) => {
366
+ E(o.inputs);
366
367
  });
367
368
  }
368
369
  export {
369
- W as arraysEqual,
370
- _ as findActionButtons,
371
- M as findForms,
372
- d as findInputGroups,
373
- S as findMinimalDistinguishingPath,
374
- x as findSlidersAndDataBindings,
375
- N as findStandaloneComponents,
376
- L as findStandaloneSelectInputs,
377
- F as generateQualifiedPropName,
378
- j as getComponentPropName,
370
+ v as arraysEqual,
371
+ L as findActionButtons,
372
+ N as findForms,
373
+ w as findInputGroups,
374
+ F as findMinimalDistinguishingPath,
375
+ j as findSlidersAndDataBindings,
376
+ x as findStandaloneComponents,
377
+ M as findStandaloneSelectInputs,
378
+ d as generateQualifiedPropName,
379
+ S as getComponentPropName,
379
380
  P as getComponentPropType,
380
- q as qualifyFormInputs,
381
+ _ as qualifyFormInputs,
381
382
  g as sanitizePropName
382
383
  };
383
384
  //# sourceMappingURL=parser.js.map