@pineui/react 0.1.2 → 0.1.3

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/pineui.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import Q, { useState as b, useEffect as W, Component as se } from "react";
1
+ import Q, { useState as w, useEffect as W, Component as se } from "react";
2
2
  import ie from "react-dom";
3
3
  var J = {}, G = ie;
4
4
  J.createRoot = G.createRoot, J.hydrateRoot = G.hydrateRoot;
@@ -25,15 +25,15 @@ H.jsx = ee;
25
25
  H.jsxs = ee;
26
26
  X.exports = H;
27
27
  var i = X.exports;
28
- function S(e, n) {
28
+ function T(e, n) {
29
29
  if (typeof e == "string")
30
30
  return pe(e, n);
31
31
  if (Array.isArray(e))
32
- return e.map((r) => S(r, n));
32
+ return e.map((r) => T(r, n));
33
33
  if (e && typeof e == "object") {
34
34
  const r = {};
35
35
  for (const t in e)
36
- r[t] = S(e[t], n);
36
+ r[t] = T(e[t], n);
37
37
  return r;
38
38
  }
39
39
  return e;
@@ -91,7 +91,7 @@ function ne(e) {
91
91
  } else for (r in e) e[r] && (t && (t += " "), t += r);
92
92
  return t;
93
93
  }
94
- function F() {
94
+ function D() {
95
95
  for (var e, n, r = 0, t = "", s = arguments.length; r < s; r++) (e = arguments[r]) && (n = ne(e)) && (t && (t += " "), t += n);
96
96
  return t;
97
97
  }
@@ -102,7 +102,7 @@ const he = ({
102
102
  fontWeight: t,
103
103
  maxLines: s
104
104
  }) => {
105
- const o = F("pineui-text", `pineui-text--${n}`, {
105
+ const o = D("pineui-text", `pineui-text--${n}`, {
106
106
  "pineui-text--bold": t === "bold"
107
107
  }), a = {
108
108
  color: r ? `var(--md-sys-color-${r}, ${r})` : void 0,
@@ -125,9 +125,9 @@ const he = ({
125
125
  }) => {
126
126
  const p = async () => {
127
127
  if (!t || s || !o || !a) return;
128
- const g = S(o, a);
128
+ const g = T(o, a);
129
129
  await a.executeAction(g);
130
- }, m = F("pineui-button", `pineui-button--${e.split(".")[1]}`, {
130
+ }, m = D("pineui-button", `pineui-button--${e.split(".")[1]}`, {
131
131
  "pineui-button--disabled": !t,
132
132
  "pineui-button--loading": s,
133
133
  [`pineui-button--${d}`]: d
@@ -162,10 +162,10 @@ const he = ({
162
162
  backgroundColor: y,
163
163
  border: g,
164
164
  borderRadius: j,
165
- elevation: w,
166
- borderRight: T,
165
+ elevation: b,
166
+ borderRight: E,
167
167
  borderLeft: $,
168
- borderTop: E,
168
+ borderTop: S,
169
169
  borderBottom: _,
170
170
  onPress: N,
171
171
  context: C,
@@ -174,10 +174,10 @@ const he = ({
174
174
  if (!O || !C) return null;
175
175
  const B = async () => {
176
176
  if (N && C) {
177
- const A = S(N, C);
177
+ const A = T(N, C);
178
178
  await C.executeAction(A);
179
179
  }
180
- }, f = e === "layout.column", h = F("pineui-layout", {
180
+ }, f = e === "layout.column", h = D("pineui-layout", {
181
181
  "pineui-layout--column": f,
182
182
  "pineui-layout--row": !f
183
183
  }), l = {
@@ -195,10 +195,10 @@ const he = ({
195
195
  backgroundColor: y,
196
196
  border: g,
197
197
  borderRadius: j !== void 0 ? `${j}px` : void 0,
198
- boxShadow: w ? xe(w) : void 0,
199
- borderRight: T,
198
+ boxShadow: b ? xe(b) : void 0,
199
+ borderRight: E,
200
200
  borderLeft: $,
201
- borderTop: E,
201
+ borderTop: S,
202
202
  borderBottom: _,
203
203
  minWidth: 0,
204
204
  // Permite que flex shrink funcione corretamente
@@ -246,10 +246,10 @@ const ge = ({
246
246
  if (!d || !a) return null;
247
247
  const c = async () => {
248
248
  if (o && a) {
249
- const j = S(o, a);
249
+ const j = T(o, a);
250
250
  await a.executeAction(j);
251
251
  }
252
- }, m = F("pineui-card", `pineui-card--elevation-${s === "outlined" || s === "filled" ? 0 : r}`, {
252
+ }, m = D("pineui-card", `pineui-card--elevation-${s === "outlined" || s === "filled" ? 0 : r}`, {
253
253
  "pineui-card--clickable": !!o,
254
254
  "pineui-card--outlined": s === "outlined",
255
255
  "pineui-card--filled": s === "filled"
@@ -257,7 +257,7 @@ const ge = ({
257
257
  padding: `${t}px`,
258
258
  ...s === "outlined" ? { border: "1px solid var(--md-sys-color-outline)" } : {},
259
259
  ...s === "filled" ? { background: "var(--md-sys-color-surfaceVariant)" } : {}
260
- }, g = e ? /* @__PURE__ */ i.jsx(d, { node: e, context: a }) : n ? /* @__PURE__ */ i.jsx(i.Fragment, { children: n.map((j, w) => /* @__PURE__ */ i.jsx(d, { node: j, context: a }, w)) }) : null;
260
+ }, g = e ? /* @__PURE__ */ i.jsx(d, { node: e, context: a }) : n ? /* @__PURE__ */ i.jsx(i.Fragment, { children: n.map((j, b) => /* @__PURE__ */ i.jsx(d, { node: j, context: a }, b)) }) : null;
261
261
  return /* @__PURE__ */ i.jsx("div", { className: m, style: y, onClick: o ? c : void 0, children: g });
262
262
  }, be = ({
263
263
  src: e,
@@ -355,7 +355,7 @@ const _e = ({
355
355
  context: m,
356
356
  renderer: y
357
357
  }) => {
358
- const [g, j] = b([]), [w, T] = b(!0), [$, E] = b(!1), [_, N] = b(null), [C, O] = b(!0), [B, f] = b(null), h = s.type === "action.http" && m ? s.url.replace(/\{\{state\.([^}]+)\}\}/g, (k, u) => {
358
+ const [g, j] = w([]), [b, E] = w(!0), [$, S] = w(!1), [_, N] = w(null), [C, O] = w(!0), [B, f] = w(null), h = s.type === "action.http" && m ? s.url.replace(/\{\{state\.([^}]+)\}\}/g, (k, u) => {
359
359
  const v = u.split(".");
360
360
  let x = m.state;
361
361
  for (const I of v) {
@@ -370,16 +370,16 @@ const _e = ({
370
370
  const l = async (k = !1) => {
371
371
  if (m)
372
372
  try {
373
- if (k ? E(!0) : T(!0), N(null), s.type === "action.http") {
373
+ if (k ? S(!0) : E(!0), N(null), s.type === "action.http") {
374
374
  let u = s.url;
375
375
  u.includes("{{state.") && (u = u.replace(/\{\{state\.([^}]+)\}\}/g, (M, P) => {
376
376
  const z = P.split(".");
377
- let D = m.state;
377
+ let F = m.state;
378
378
  for (const re of z) {
379
- if (D == null) return "";
380
- D = D[re];
379
+ if (F == null) return "";
380
+ F = F[re];
381
381
  }
382
- return D != null ? String(D) : "";
382
+ return F != null ? String(F) : "";
383
383
  })), k && B && (u += `${u.includes("?") ? "&" : "?"}after=${B}`);
384
384
  const x = await (await fetch(u)).json(), I = x.data || x;
385
385
  if (j((M) => k ? [...M, ...I] : I), s.onSuccess && m) {
@@ -392,12 +392,12 @@ const _e = ({
392
392
  } catch (u) {
393
393
  N(u);
394
394
  } finally {
395
- T(!1), E(!1);
395
+ E(!1), S(!1);
396
396
  }
397
397
  }, A = () => {
398
398
  !$ && C && l(!0);
399
399
  };
400
- return !y || !m ? null : w && a ? /* @__PURE__ */ i.jsx(y, { node: a, context: m }) : _ && c ? /* @__PURE__ */ i.jsx(y, { node: c, context: m }) : g.length === 0 && d ? /* @__PURE__ */ i.jsx(y, { node: d, context: m }) : /* @__PURE__ */ i.jsxs("div", { className: "pineui-collection", "data-collection-id": e, children: [
400
+ return !y || !m ? null : b && a ? /* @__PURE__ */ i.jsx(y, { node: a, context: m }) : _ && c ? /* @__PURE__ */ i.jsx(y, { node: c, context: m }) : g.length === 0 && d ? /* @__PURE__ */ i.jsx(y, { node: d, context: m }) : /* @__PURE__ */ i.jsxs("div", { className: "pineui-collection", "data-collection-id": e, children: [
401
401
  p && /* @__PURE__ */ i.jsx("div", { className: "pineui-collection__refresh", children: /* @__PURE__ */ i.jsx("button", { onClick: () => l(!1), children: "Refresh" }) }),
402
402
  /* @__PURE__ */ i.jsx(
403
403
  "div",
@@ -414,7 +414,7 @@ const _e = ({
414
414
  })
415
415
  }
416
416
  ),
417
- C && !w && /* @__PURE__ */ i.jsx("div", { className: "pineui-collection__load-more", style: { padding: "16px", textAlign: "center" }, children: /* @__PURE__ */ i.jsx(
417
+ C && !b && /* @__PURE__ */ i.jsx("div", { className: "pineui-collection__load-more", style: { padding: "16px", textAlign: "center" }, children: /* @__PURE__ */ i.jsx(
418
418
  "button",
419
419
  {
420
420
  onClick: A,
@@ -443,18 +443,18 @@ const _e = ({
443
443
  if (!d || !a) return null;
444
444
  const c = n || r;
445
445
  if (!c) return null;
446
- const p = Array.isArray(e) ? e : [];
447
- if (p.length === 0) return null;
448
- const m = t === "grid" ? { display: "grid", gridTemplateColumns: `repeat(${s}, 1fr)`, gap: `${o}px` } : { display: "flex", flexDirection: "column", gap: `${o}px` };
449
- return /* @__PURE__ */ i.jsx("div", { style: m, children: p.map((y, g) => {
450
- const j = { ...a, item: y, index: g };
446
+ const p = typeof e == "string" ? T(e, a) : e, m = Array.isArray(p) ? p : [];
447
+ if (m.length === 0) return null;
448
+ const y = t === "grid" ? { display: "grid", gridTemplateColumns: `repeat(${s}, 1fr)`, gap: `${o}px` } : { display: "flex", flexDirection: "column", gap: `${o}px` };
449
+ return /* @__PURE__ */ i.jsx("div", { style: y, children: m.map((g, j) => {
450
+ const b = { ...a, item: g, index: j };
451
451
  return /* @__PURE__ */ i.jsx(
452
452
  d,
453
453
  {
454
454
  node: c,
455
- context: j
455
+ context: b
456
456
  },
457
- y.id ?? g
457
+ g.id ?? j
458
458
  );
459
459
  }) });
460
460
  }, ke = ({
@@ -525,7 +525,7 @@ const _e = ({
525
525
  onChange: y,
526
526
  context: g
527
527
  }) => {
528
- const j = y || m, w = async (_) => {
528
+ const j = y || m, b = async (_) => {
529
529
  !j || !g || await g.executeAction(j, { event: { value: _.target.value }, value: _.target.value });
530
530
  }, $ = {
531
531
  "input.email": "email",
@@ -533,13 +533,13 @@ const _e = ({
533
533
  "input.number": "number",
534
534
  "input.search": "search",
535
535
  "input.text": "text"
536
- }[e] || "text", E = {
536
+ }[e] || "text", S = {
537
537
  id: n,
538
538
  placeholder: t,
539
539
  defaultValue: s,
540
540
  maxLength: c,
541
541
  autoFocus: p,
542
- onChange: w,
542
+ onChange: b,
543
543
  className: `pineui-input${o ? " pineui-input--error" : ""}`
544
544
  };
545
545
  return /* @__PURE__ */ i.jsxs("div", { className: "pineui-input-wrapper", style: { width: "100%" }, children: [
@@ -560,11 +560,11 @@ const _e = ({
560
560
  a ? /* @__PURE__ */ i.jsx(
561
561
  "textarea",
562
562
  {
563
- ...E,
563
+ ...S,
564
564
  rows: d,
565
565
  style: { resize: "none", minHeight: `${d * 24}px` }
566
566
  }
567
- ) : /* @__PURE__ */ i.jsx("input", { ...E, type: $ }),
567
+ ) : /* @__PURE__ */ i.jsx("input", { ...S, type: $ }),
568
568
  o && /* @__PURE__ */ i.jsx("p", { style: {
569
569
  fontSize: "12px",
570
570
  color: "var(--md-sys-color-error)",
@@ -589,7 +589,7 @@ const _e = ({
589
589
  }) => {
590
590
  if (!r || !n) return null;
591
591
  for (const t of e) {
592
- const s = S({ when: t.when }, n);
592
+ const s = T({ when: t.when }, n);
593
593
  if (s.when === !0 || s.when === "true")
594
594
  return /* @__PURE__ */ i.jsx(r, { node: t.render, context: n });
595
595
  }
@@ -602,7 +602,7 @@ const _e = ({
602
602
  renderer: s
603
603
  }) => {
604
604
  if (!s || !t) return null;
605
- const o = S({ condition: e }, t);
605
+ const o = T({ condition: e }, t);
606
606
  return o.condition === !0 || o.condition === "true" || o.condition === 1 ? r ? /* @__PURE__ */ i.jsx(s, { node: r, context: t }) : n ? /* @__PURE__ */ i.jsx(i.Fragment, { children: n.map((d, c) => /* @__PURE__ */ i.jsx(s, { node: d, context: t }, c)) }) : null : null;
607
607
  }, Se = ({
608
608
  tabs: e,
@@ -611,7 +611,7 @@ const _e = ({
611
611
  renderer: t
612
612
  }) => {
613
613
  var d;
614
- const [s, o] = b(n || ((d = e[0]) == null ? void 0 : d.id));
614
+ const [s, o] = w(n || ((d = e[0]) == null ? void 0 : d.id));
615
615
  if (!t || !r) return null;
616
616
  const a = e.find((c) => c.id === s);
617
617
  return /* @__PURE__ */ i.jsxs("div", { className: "pineui-tabs", children: [
@@ -635,7 +635,7 @@ const _e = ({
635
635
  variant: n = "default",
636
636
  size: r = "medium"
637
637
  }) => {
638
- const t = F(
638
+ const t = D(
639
639
  "pineui-badge",
640
640
  `pineui-badge--${n}`,
641
641
  `pineui-badge--${r}`
@@ -650,7 +650,7 @@ const _e = ({
650
650
  }) => {
651
651
  const o = async () => {
652
652
  t && s && await s.executeAction(t);
653
- }, a = F("pineui-chip", {
653
+ }, a = D("pineui-chip", {
654
654
  "pineui-chip--selected": r
655
655
  });
656
656
  return /* @__PURE__ */ i.jsxs("button", { className: a, onClick: o, children: [
@@ -700,7 +700,7 @@ const _e = ({
700
700
  context: r,
701
701
  renderer: t
702
702
  }) => {
703
- const [s, o] = b([]), [a, d] = b(!0);
703
+ const [s, o] = w([]), [a, d] = w(!0);
704
704
  W(() => {
705
705
  c();
706
706
  }, []);
@@ -744,14 +744,14 @@ const _e = ({
744
744
  }
745
745
  ) : /* @__PURE__ */ i.jsx("span", { children: p[y.key] }) }, y.key)) }, m)) })
746
746
  ] }) });
747
- }, Fe = ({ name: e, context: n, renderer: r, flex: t, width: s, height: o }) => {
747
+ }, De = ({ name: e, context: n, renderer: r, flex: t, width: s, height: o }) => {
748
748
  var c;
749
749
  const a = (c = n == null ? void 0 : n.views) == null ? void 0 : c[e];
750
750
  if (!a)
751
751
  return console.warn(`View not found: ${e}`), null;
752
752
  const d = {};
753
753
  return t && (d.flex = t), s && (d.width = s), o && (d.height = o), /* @__PURE__ */ i.jsx("div", { className: "pineui-view", style: d, children: /* @__PURE__ */ i.jsx(r, { node: a.screen, context: n }) });
754
- }, De = {
754
+ }, Fe = {
755
755
  text: he,
756
756
  "button.filled": L,
757
757
  "button.text": L,
@@ -783,11 +783,11 @@ const _e = ({
783
783
  grid: Me,
784
784
  progress: Be,
785
785
  table: We,
786
- view: Fe
786
+ view: De
787
787
  }, R = ({ node: e, context: n, parentData: r }) => {
788
788
  if (!e || !e.type)
789
789
  return null;
790
- const t = r !== void 0 ? Object.assign({}, n, { item: r }) : n, o = e.type !== "collection" ? S(e, t) : e;
790
+ const t = r !== void 0 ? Object.assign({}, n, { item: r }) : n, o = e.type !== "collection" && e.type !== "collection.map" ? T(e, t) : e;
791
791
  if (o.type.startsWith("component.")) {
792
792
  const d = o.type, c = n.components[d];
793
793
  if (!c)
@@ -798,7 +798,7 @@ const _e = ({
798
798
  };
799
799
  return /* @__PURE__ */ i.jsx(R, { node: c.definition, context: p, parentData: r });
800
800
  }
801
- const a = De[o.type];
801
+ const a = Fe[o.type];
802
802
  return a ? /* @__PURE__ */ i.jsx(
803
803
  a,
804
804
  {
@@ -811,7 +811,7 @@ const _e = ({
811
811
  message: e,
812
812
  onDismiss: n
813
813
  }) => {
814
- const [r, t] = b(!1);
814
+ const [r, t] = w(!1);
815
815
  return W(() => {
816
816
  setTimeout(() => t(!0), 10);
817
817
  const s = setTimeout(() => {
@@ -943,7 +943,7 @@ function Pe(e, n) {
943
943
  return t;
944
944
  }
945
945
  const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
946
- const [t, s] = b(null), [o, a] = b(!0), [d, c] = b(null), [p, m] = b([]), [y, g] = b({}), j = (e == null ? void 0 : e.state) || {
946
+ const [t, s] = w(null), [o, a] = w(!0), [d, c] = w(null), [p, m] = w([]), [y, g] = w({}), j = (e == null ? void 0 : e.state) || {
947
947
  currentUser: {
948
948
  id: "user_current",
949
949
  username: "currentuser",
@@ -956,25 +956,25 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
956
956
  posting: !1
957
957
  },
958
958
  testInput: ""
959
- }, [w, T] = b(j);
959
+ }, [b, E] = w(j);
960
960
  W(() => {
961
- n && !e ? E() : e && $();
961
+ n && !e ? S() : e && $();
962
962
  }, [n, e, r]);
963
963
  const $ = async () => {
964
964
  try {
965
965
  a(!0);
966
966
  let f = e;
967
- f.imports && r && (console.log("Loading imports for initial schema...", f.imports), f = await Z(f, r), console.log("Imports loaded! Components:", Object.keys(f.components || {}))), s(f), f.state && T((h) => ({ ...h, ...f.state }));
967
+ f.imports && r && (console.log("Loading imports for initial schema...", f.imports), f = await Z(f, r), console.log("Imports loaded! Components:", Object.keys(f.components || {}))), s(f), f.state && E((h) => ({ ...h, ...f.state }));
968
968
  } catch (f) {
969
969
  c(f);
970
970
  } finally {
971
971
  a(!1);
972
972
  }
973
- }, E = async () => {
973
+ }, S = async () => {
974
974
  try {
975
975
  a(!0);
976
976
  let h = await (await fetch(n)).json();
977
- h.imports && r && (h = await Z(h, r)), s(h), h.state && T((l) => ({ ...l, ...h.state }));
977
+ h.imports && r && (h = await Z(h, r)), s(h), h.state && E((l) => ({ ...l, ...h.state }));
978
978
  } catch (f) {
979
979
  c(f);
980
980
  } finally {
@@ -982,8 +982,8 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
982
982
  }
983
983
  }, _ = async (f, h) => {
984
984
  var A, k;
985
- (f.type === "action.sequence" || f.intent && f.intent.startsWith("course")) && console.log(`[executeAction] type=${f.intent || f.type}, courseList.length=${((A = w.courseList) == null ? void 0 : A.length) ?? "N/A"}, selectedCourseIndex=${w.selectedCourseIndex}`);
986
- const l = S(f, { state: w, ...h });
985
+ (f.type === "action.sequence" || f.intent && f.intent.startsWith("course")) && console.log(`[executeAction] type=${f.intent || f.type}, courseList.length=${((A = b.courseList) == null ? void 0 : A.length) ?? "N/A"}, selectedCourseIndex=${b.selectedCourseIndex}`);
986
+ const l = T(f, { state: b, ...h });
987
987
  if (l.intent) {
988
988
  const u = l.intent, v = { ...h, ...l };
989
989
  return delete v.intent, N(u, v);
@@ -1014,7 +1014,7 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
1014
1014
  }
1015
1015
  case "action.state.patch": {
1016
1016
  const u = l.value;
1017
- console.log(`[patch] ${l.path} =`, typeof u == "object" && u !== null ? Array.isArray(u) ? `Array(${u.length})` : `{id: ${u == null ? void 0 : u.id}, title: ${u == null ? void 0 : u.title}}` : u), T((v) => {
1017
+ console.log(`[patch] ${l.path} =`, typeof u == "object" && u !== null ? Array.isArray(u) ? `Array(${u.length})` : `{id: ${u == null ? void 0 : u.id}, title: ${u == null ? void 0 : u.title}}` : u), E((v) => {
1018
1018
  const x = { ...v };
1019
1019
  return Je(x, l.path, l.value), x;
1020
1020
  });
@@ -1043,7 +1043,7 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
1043
1043
  const u = typeof l.message == "string" && l.message.includes("{{") ? l.message.replace(/\{\{(.+?)\}\}/g, (x, I) => {
1044
1044
  const M = I.trim();
1045
1045
  if (M.startsWith("state.")) {
1046
- const P = M.substring(6), z = Pe(w, P);
1046
+ const P = M.substring(6), z = Pe(b, P);
1047
1047
  return z != null ? String(z) : "";
1048
1048
  }
1049
1049
  return "";
@@ -1085,7 +1085,7 @@ const qe = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
1085
1085
  else
1086
1086
  await _(l.handler, h);
1087
1087
  }, C = {
1088
- state: w,
1088
+ state: b,
1089
1089
  data: {},
1090
1090
  components: (t == null ? void 0 : t.components) || {},
1091
1091
  views: (t == null ? void 0 : t.views) || {},