@pineui/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +168 -0
- package/README.md +144 -0
- package/dist/PineUI.d.ts +10 -0
- package/dist/components/AppBar.d.ts +12 -0
- package/dist/components/Avatar.d.ts +11 -0
- package/dist/components/Badge.d.ts +9 -0
- package/dist/components/BottomNav.d.ts +17 -0
- package/dist/components/Button.d.ts +16 -0
- package/dist/components/Card.d.ts +13 -0
- package/dist/components/Chip.d.ts +12 -0
- package/dist/components/Collection.d.ts +21 -0
- package/dist/components/ConditionalRender.d.ts +14 -0
- package/dist/components/Divider.d.ts +8 -0
- package/dist/components/ErrorBoundary.d.ts +17 -0
- package/dist/components/Grid.d.ts +12 -0
- package/dist/components/Icon.d.ts +12 -0
- package/dist/components/Image.d.ts +15 -0
- package/dist/components/Input.d.ts +17 -0
- package/dist/components/Layout.d.ts +29 -0
- package/dist/components/Modal.d.ts +24 -0
- package/dist/components/Progress.d.ts +10 -0
- package/dist/components/Scaffold.d.ts +13 -0
- package/dist/components/Snackbar.d.ts +17 -0
- package/dist/components/Table.d.ts +17 -0
- package/dist/components/Tabs.d.ts +17 -0
- package/dist/components/Text.d.ts +14 -0
- package/dist/components/View.d.ts +12 -0
- package/dist/index.d.ts +5 -0
- package/dist/loader/imports.d.ts +3 -0
- package/dist/pineui.es.js +1117 -0
- package/dist/pineui.standalone.js +45 -0
- package/dist/pineui.umd.js +14 -0
- package/dist/renderer/Renderer.d.ts +9 -0
- package/dist/renderer/bindings.d.ts +5 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +65 -0
- package/package.json +65 -0
|
@@ -0,0 +1,1117 @@
|
|
|
1
|
+
import ee, { useState as x, useEffect as R, Component as se } from "react";
|
|
2
|
+
import ie from "react-dom";
|
|
3
|
+
var U = {}, K = ie;
|
|
4
|
+
U.createRoot = K.createRoot, U.hydrateRoot = K.hydrateRoot;
|
|
5
|
+
var te = { exports: {} }, T = {};
|
|
6
|
+
/**
|
|
7
|
+
* @license React
|
|
8
|
+
* react-jsx-runtime.production.min.js
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/
|
|
15
|
+
var oe = ee, ae = Symbol.for("react.element"), le = Symbol.for("react.fragment"), ce = Object.prototype.hasOwnProperty, de = oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, ue = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
16
|
+
function ne(e, n, r) {
|
|
17
|
+
var t, i = {}, o = null, a = null;
|
|
18
|
+
r !== void 0 && (o = "" + r), n.key !== void 0 && (o = "" + n.key), n.ref !== void 0 && (a = n.ref);
|
|
19
|
+
for (t in n) ce.call(n, t) && !ue.hasOwnProperty(t) && (i[t] = n[t]);
|
|
20
|
+
if (e && e.defaultProps) for (t in n = e.defaultProps, n) i[t] === void 0 && (i[t] = n[t]);
|
|
21
|
+
return { $$typeof: ae, type: e, key: o, ref: a, props: i, _owner: de.current };
|
|
22
|
+
}
|
|
23
|
+
T.Fragment = le;
|
|
24
|
+
T.jsx = ne;
|
|
25
|
+
T.jsxs = ne;
|
|
26
|
+
te.exports = T;
|
|
27
|
+
var s = te.exports;
|
|
28
|
+
function W(e, n) {
|
|
29
|
+
if (typeof e == "string")
|
|
30
|
+
return pe(e, n);
|
|
31
|
+
if (Array.isArray(e))
|
|
32
|
+
return e.map((r) => W(r, n));
|
|
33
|
+
if (e && typeof e == "object") {
|
|
34
|
+
const r = {};
|
|
35
|
+
for (const t in e)
|
|
36
|
+
r[t] = W(e[t], n);
|
|
37
|
+
return r;
|
|
38
|
+
}
|
|
39
|
+
return e;
|
|
40
|
+
}
|
|
41
|
+
function pe(e, n) {
|
|
42
|
+
const r = e.match(/^\{\{(.+)\}\}$/);
|
|
43
|
+
if (r) {
|
|
44
|
+
const t = r[1].trim();
|
|
45
|
+
return (t === "item" || t.startsWith("item.")) && (!("item" in n) || n.item === void 0) ? e : Q(t, n);
|
|
46
|
+
}
|
|
47
|
+
return e.replace(/\{\{(.+?)\}\}/g, (t, i) => {
|
|
48
|
+
const o = Q(i.trim(), n);
|
|
49
|
+
return o != null ? String(o) : "";
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function Q(e, n) {
|
|
53
|
+
try {
|
|
54
|
+
return /^[\w.]+$/.test(e) ? M(n, e) : e.includes("!") || e.includes("==") || e.includes("!=") ? fe(e, n) : e.includes("|") ? he(e, n) : M(n, e);
|
|
55
|
+
} catch (r) {
|
|
56
|
+
console.warn(`Failed to evaluate expression: ${e}`, r);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function M(e, n) {
|
|
61
|
+
const r = n.split(".");
|
|
62
|
+
let t = e;
|
|
63
|
+
for (const i of r) {
|
|
64
|
+
if (t == null) return;
|
|
65
|
+
t = t[i];
|
|
66
|
+
}
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
69
|
+
function fe(e, n) {
|
|
70
|
+
if (e.startsWith("!"))
|
|
71
|
+
return !M(n, e.slice(1).trim());
|
|
72
|
+
if (e.includes("!= null")) {
|
|
73
|
+
const r = e.split("!=")[0].trim();
|
|
74
|
+
return M(n, r) != null;
|
|
75
|
+
}
|
|
76
|
+
if (e.includes("==")) {
|
|
77
|
+
const [r, t] = e.split("==").map((a) => a.trim()), i = M(n, r), o = t.startsWith("'") || t.startsWith('"') ? t.slice(1, -1) : M(n, t);
|
|
78
|
+
return i == o;
|
|
79
|
+
}
|
|
80
|
+
return !1;
|
|
81
|
+
}
|
|
82
|
+
function he(e, n) {
|
|
83
|
+
const [r, t] = e.split("|").map((o) => o.trim()), i = M(n, r);
|
|
84
|
+
return t === "timeAgo" ? me(i) : i;
|
|
85
|
+
}
|
|
86
|
+
function me(e) {
|
|
87
|
+
if (!e) return "";
|
|
88
|
+
const n = new Date(e);
|
|
89
|
+
if (isNaN(n.getTime())) return e;
|
|
90
|
+
const t = Math.floor(((/* @__PURE__ */ new Date()).getTime() - n.getTime()) / 1e3);
|
|
91
|
+
return t < 60 ? `${t}s` : t < 3600 ? `${Math.floor(t / 60)}m` : t < 86400 ? `${Math.floor(t / 3600)}h` : t < 2592e3 ? `${Math.floor(t / 86400)}d` : t < 31536e3 ? `${Math.floor(t / 2592e3)}mo` : `${Math.floor(t / 31536e3)}y`;
|
|
92
|
+
}
|
|
93
|
+
function re(e) {
|
|
94
|
+
var n, r, t = "";
|
|
95
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
96
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
97
|
+
var i = e.length;
|
|
98
|
+
for (n = 0; n < i; n++) e[n] && (r = re(e[n])) && (t && (t += " "), t += r);
|
|
99
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
100
|
+
return t;
|
|
101
|
+
}
|
|
102
|
+
function V() {
|
|
103
|
+
for (var e, n, r = 0, t = "", i = arguments.length; r < i; r++) (e = arguments[r]) && (n = re(e)) && (t && (t += " "), t += n);
|
|
104
|
+
return t;
|
|
105
|
+
}
|
|
106
|
+
const ve = ({
|
|
107
|
+
content: e,
|
|
108
|
+
style: n = "bodyMedium",
|
|
109
|
+
color: r,
|
|
110
|
+
fontWeight: t,
|
|
111
|
+
maxLines: i
|
|
112
|
+
}) => {
|
|
113
|
+
const o = V("pineui-text", `pineui-text--${n}`, {
|
|
114
|
+
"pineui-text--bold": t === "bold"
|
|
115
|
+
}), a = {
|
|
116
|
+
color: r ? `var(--md-sys-color-${r}, ${r})` : void 0,
|
|
117
|
+
WebkitLineClamp: i ?? void 0,
|
|
118
|
+
display: i ? "-webkit-box" : void 0,
|
|
119
|
+
WebkitBoxOrient: i ? "vertical" : void 0,
|
|
120
|
+
overflow: i ? "hidden" : void 0
|
|
121
|
+
};
|
|
122
|
+
return /* @__PURE__ */ s.jsx("p", { className: o, style: a, children: e || "(empty)" });
|
|
123
|
+
}, J = ({
|
|
124
|
+
type: e,
|
|
125
|
+
label: n,
|
|
126
|
+
icon: r,
|
|
127
|
+
enabled: t = !0,
|
|
128
|
+
loading: i = !1,
|
|
129
|
+
onPress: o,
|
|
130
|
+
context: a,
|
|
131
|
+
size: d = "medium",
|
|
132
|
+
color: c
|
|
133
|
+
}) => {
|
|
134
|
+
const u = async () => {
|
|
135
|
+
if (!t || i || !o || !a) return;
|
|
136
|
+
const j = W(o, a);
|
|
137
|
+
await a.executeAction(j);
|
|
138
|
+
}, v = V("pineui-button", `pineui-button--${e.split(".")[1]}`, {
|
|
139
|
+
"pineui-button--disabled": !t,
|
|
140
|
+
"pineui-button--loading": i,
|
|
141
|
+
[`pineui-button--${d}`]: d
|
|
142
|
+
}), y = {
|
|
143
|
+
color: c ? `var(--md-sys-color-${c}, ${c})` : void 0
|
|
144
|
+
};
|
|
145
|
+
return /* @__PURE__ */ s.jsxs(
|
|
146
|
+
"button",
|
|
147
|
+
{
|
|
148
|
+
className: v,
|
|
149
|
+
onClick: u,
|
|
150
|
+
disabled: !t || i,
|
|
151
|
+
style: y,
|
|
152
|
+
children: [
|
|
153
|
+
i ? /* @__PURE__ */ s.jsx("span", { className: "pineui-button__spinner", children: "⏳" }) : r ? /* @__PURE__ */ s.jsx("span", { className: "pineui-button__icon", children: r }) : null,
|
|
154
|
+
n && /* @__PURE__ */ s.jsx("span", { className: "pineui-button__label", children: n })
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}, X = ({
|
|
159
|
+
type: e,
|
|
160
|
+
children: n = [],
|
|
161
|
+
spacing: r = 0,
|
|
162
|
+
padding: t = 0,
|
|
163
|
+
mainAxisAlignment: i = "start",
|
|
164
|
+
crossAxisAlignment: o = "start",
|
|
165
|
+
flex: a,
|
|
166
|
+
width: d,
|
|
167
|
+
height: c,
|
|
168
|
+
maxWidth: u,
|
|
169
|
+
overflow: v,
|
|
170
|
+
backgroundColor: y,
|
|
171
|
+
border: j,
|
|
172
|
+
borderRadius: B,
|
|
173
|
+
elevation: C,
|
|
174
|
+
borderRight: A,
|
|
175
|
+
borderLeft: k,
|
|
176
|
+
borderTop: D,
|
|
177
|
+
borderBottom: E,
|
|
178
|
+
onPress: _,
|
|
179
|
+
context: w,
|
|
180
|
+
renderer: I
|
|
181
|
+
}) => {
|
|
182
|
+
if (!I || !w) return null;
|
|
183
|
+
const P = async () => {
|
|
184
|
+
if (_ && w) {
|
|
185
|
+
const g = W(_, w);
|
|
186
|
+
await w.executeAction(g);
|
|
187
|
+
}
|
|
188
|
+
}, f = e === "layout.column", h = V("pineui-layout", {
|
|
189
|
+
"pineui-layout--column": f,
|
|
190
|
+
"pineui-layout--row": !f
|
|
191
|
+
}), l = {
|
|
192
|
+
display: "flex",
|
|
193
|
+
flexDirection: f ? "column" : "row",
|
|
194
|
+
gap: `${r}px`,
|
|
195
|
+
padding: `${t}px`,
|
|
196
|
+
justifyContent: ye(i),
|
|
197
|
+
alignItems: ge(o),
|
|
198
|
+
flex: a,
|
|
199
|
+
width: d !== void 0 ? typeof d == "number" ? `${d}px` : d : void 0,
|
|
200
|
+
height: c !== void 0 ? typeof c == "number" ? `${c}px` : c : void 0,
|
|
201
|
+
maxWidth: u !== void 0 ? typeof u == "number" ? `${u}px` : u : void 0,
|
|
202
|
+
overflow: v,
|
|
203
|
+
backgroundColor: y,
|
|
204
|
+
border: j,
|
|
205
|
+
borderRadius: B !== void 0 ? `${B}px` : void 0,
|
|
206
|
+
boxShadow: C ? xe(C) : void 0,
|
|
207
|
+
borderRight: A,
|
|
208
|
+
borderLeft: k,
|
|
209
|
+
borderTop: D,
|
|
210
|
+
borderBottom: E,
|
|
211
|
+
minWidth: 0,
|
|
212
|
+
// Permite que flex shrink funcione corretamente
|
|
213
|
+
cursor: _ ? "pointer" : void 0
|
|
214
|
+
};
|
|
215
|
+
return /* @__PURE__ */ s.jsx("div", { className: h, style: l, onClick: _ ? P : void 0, children: n.map((g, p) => /* @__PURE__ */ s.jsx(I, { node: g, context: w }, p)) });
|
|
216
|
+
};
|
|
217
|
+
function ye(e) {
|
|
218
|
+
return {
|
|
219
|
+
start: "flex-start",
|
|
220
|
+
center: "center",
|
|
221
|
+
end: "flex-end",
|
|
222
|
+
spaceBetween: "space-between",
|
|
223
|
+
spaceAround: "space-around"
|
|
224
|
+
}[e] || "flex-start";
|
|
225
|
+
}
|
|
226
|
+
function ge(e) {
|
|
227
|
+
return {
|
|
228
|
+
start: "flex-start",
|
|
229
|
+
center: "center",
|
|
230
|
+
end: "flex-end",
|
|
231
|
+
stretch: "stretch"
|
|
232
|
+
}[e] || "flex-start";
|
|
233
|
+
}
|
|
234
|
+
function xe(e) {
|
|
235
|
+
const n = {
|
|
236
|
+
1: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
237
|
+
2: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
|
|
238
|
+
3: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
|
|
239
|
+
4: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
|
|
240
|
+
5: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"
|
|
241
|
+
};
|
|
242
|
+
return n[e] || n[1];
|
|
243
|
+
}
|
|
244
|
+
const be = ({
|
|
245
|
+
child: e,
|
|
246
|
+
elevation: n = 1,
|
|
247
|
+
padding: r = 16,
|
|
248
|
+
onTap: t,
|
|
249
|
+
context: i,
|
|
250
|
+
renderer: o
|
|
251
|
+
}) => {
|
|
252
|
+
if (!o || !i) return null;
|
|
253
|
+
const a = async () => {
|
|
254
|
+
if (t && i) {
|
|
255
|
+
const u = W(t, i);
|
|
256
|
+
await i.executeAction(u);
|
|
257
|
+
}
|
|
258
|
+
}, d = V("pineui-card", `pineui-card--elevation-${n}`, {
|
|
259
|
+
"pineui-card--clickable": !!t
|
|
260
|
+
}), c = {
|
|
261
|
+
padding: `${r}px`
|
|
262
|
+
};
|
|
263
|
+
return /* @__PURE__ */ s.jsx("div", { className: d, style: c, onClick: t ? a : void 0, children: /* @__PURE__ */ s.jsx(o, { node: e, context: i }) });
|
|
264
|
+
}, je = ({
|
|
265
|
+
src: e,
|
|
266
|
+
alt: n = "",
|
|
267
|
+
aspectRatio: r,
|
|
268
|
+
borderRadius: t = 0,
|
|
269
|
+
loading: i = "lazy",
|
|
270
|
+
onTap: o,
|
|
271
|
+
context: a
|
|
272
|
+
}) => {
|
|
273
|
+
const d = async () => {
|
|
274
|
+
o && a && await a.executeAction(o);
|
|
275
|
+
}, c = {
|
|
276
|
+
width: "100%",
|
|
277
|
+
aspectRatio: r,
|
|
278
|
+
borderRadius: `${t}px`,
|
|
279
|
+
objectFit: "cover",
|
|
280
|
+
cursor: o ? "pointer" : void 0
|
|
281
|
+
};
|
|
282
|
+
return /* @__PURE__ */ s.jsx(
|
|
283
|
+
"img",
|
|
284
|
+
{
|
|
285
|
+
className: "pineui-image",
|
|
286
|
+
src: e,
|
|
287
|
+
alt: n,
|
|
288
|
+
loading: i,
|
|
289
|
+
style: c,
|
|
290
|
+
onClick: o ? d : void 0
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
}, _e = ({
|
|
294
|
+
src: e,
|
|
295
|
+
size: n = 40,
|
|
296
|
+
onTap: r,
|
|
297
|
+
context: t
|
|
298
|
+
}) => {
|
|
299
|
+
const i = async () => {
|
|
300
|
+
r && t && await t.executeAction(r);
|
|
301
|
+
}, o = {
|
|
302
|
+
width: `${n}px`,
|
|
303
|
+
height: `${n}px`,
|
|
304
|
+
borderRadius: "50%",
|
|
305
|
+
objectFit: "cover",
|
|
306
|
+
cursor: r ? "pointer" : void 0
|
|
307
|
+
};
|
|
308
|
+
return /* @__PURE__ */ s.jsx(
|
|
309
|
+
"img",
|
|
310
|
+
{
|
|
311
|
+
className: "pineui-avatar",
|
|
312
|
+
src: e,
|
|
313
|
+
alt: "Avatar",
|
|
314
|
+
style: o,
|
|
315
|
+
onClick: r ? i : void 0
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
}, we = ({
|
|
319
|
+
name: e,
|
|
320
|
+
size: n = 24,
|
|
321
|
+
color: r,
|
|
322
|
+
visible: t = !0
|
|
323
|
+
}) => {
|
|
324
|
+
if (!t) return null;
|
|
325
|
+
const i = {
|
|
326
|
+
fontSize: `${n}px`,
|
|
327
|
+
color: r ? `var(--md-sys-color-${r}, ${r})` : void 0
|
|
328
|
+
}, o = {
|
|
329
|
+
verified: "✓",
|
|
330
|
+
favorite: "❤️",
|
|
331
|
+
favoriteBorder: "🤍",
|
|
332
|
+
chatBubbleOutline: "💬",
|
|
333
|
+
repeat: "🔁",
|
|
334
|
+
bookmark: "🔖",
|
|
335
|
+
bookmarkBorder: "🔖",
|
|
336
|
+
iosShare: "↗️",
|
|
337
|
+
moreVert: "⋮"
|
|
338
|
+
};
|
|
339
|
+
return /* @__PURE__ */ s.jsx("span", { className: "pineui-icon", style: i, children: o[e] || e });
|
|
340
|
+
}, Ne = ({
|
|
341
|
+
id: e,
|
|
342
|
+
layout: n = "list",
|
|
343
|
+
columns: r = 3,
|
|
344
|
+
spacing: t = 16,
|
|
345
|
+
data: i,
|
|
346
|
+
itemTemplate: o,
|
|
347
|
+
loadingState: a,
|
|
348
|
+
emptyState: d,
|
|
349
|
+
errorState: c,
|
|
350
|
+
refreshable: u = !1,
|
|
351
|
+
context: v,
|
|
352
|
+
renderer: y
|
|
353
|
+
}) => {
|
|
354
|
+
const [j, B] = x([]), [C, A] = x(!0), [k, D] = x(!1), [E, _] = x(null), [w, I] = x(!0), [P, f] = x(null);
|
|
355
|
+
R(() => {
|
|
356
|
+
h();
|
|
357
|
+
}, [v == null ? void 0 : v.state]);
|
|
358
|
+
const h = async (g = !1) => {
|
|
359
|
+
if (v)
|
|
360
|
+
try {
|
|
361
|
+
if (g ? D(!0) : A(!0), _(null), i.type === "action.http") {
|
|
362
|
+
let p = i.url;
|
|
363
|
+
p.includes("{{state.") && (p = p.replace(/\{\{state\.([^}]+)\}\}/g, (N, L) => {
|
|
364
|
+
const O = L.split(".");
|
|
365
|
+
let S = v.state;
|
|
366
|
+
for (const F of O) {
|
|
367
|
+
if (S == null) return "";
|
|
368
|
+
S = S[F];
|
|
369
|
+
}
|
|
370
|
+
return S != null ? String(S) : "";
|
|
371
|
+
})), g && P && (p += `${p.includes("?") ? "&" : "?"}after=${P}`);
|
|
372
|
+
const b = await (await fetch(p)).json(), $ = b.data || b;
|
|
373
|
+
B((N) => g ? [...N, ...$] : $), b.pagination ? (I(b.pagination.hasMore), f(b.pagination.cursor)) : I(!1);
|
|
374
|
+
}
|
|
375
|
+
} catch (p) {
|
|
376
|
+
_(p);
|
|
377
|
+
} finally {
|
|
378
|
+
A(!1), D(!1);
|
|
379
|
+
}
|
|
380
|
+
}, l = () => {
|
|
381
|
+
!k && w && h(!0);
|
|
382
|
+
};
|
|
383
|
+
return !y || !v ? null : C && a ? /* @__PURE__ */ s.jsx(y, { node: a, context: v }) : E && c ? /* @__PURE__ */ s.jsx(y, { node: c, context: v }) : j.length === 0 && d ? /* @__PURE__ */ s.jsx(y, { node: d, context: v }) : /* @__PURE__ */ s.jsxs("div", { className: "pineui-collection", "data-collection-id": e, children: [
|
|
384
|
+
u && /* @__PURE__ */ s.jsx("div", { className: "pineui-collection__refresh", children: /* @__PURE__ */ s.jsx("button", { onClick: () => h(!1), children: "Refresh" }) }),
|
|
385
|
+
/* @__PURE__ */ s.jsx(
|
|
386
|
+
"div",
|
|
387
|
+
{
|
|
388
|
+
className: `pineui-collection__${n}`,
|
|
389
|
+
style: n === "grid" ? {
|
|
390
|
+
display: "grid",
|
|
391
|
+
gridTemplateColumns: `repeat(${r}, 1fr)`,
|
|
392
|
+
gap: `${t}px`
|
|
393
|
+
} : void 0,
|
|
394
|
+
children: j.map((g, p) => {
|
|
395
|
+
var b, $, N, L, O, S, F, q, G, Y;
|
|
396
|
+
let m = o;
|
|
397
|
+
return (b = o.type) != null && b.startsWith("pattern.") && (($ = o.props) == null ? void 0 : $.post) === "{{item}}" ? m = {
|
|
398
|
+
...o,
|
|
399
|
+
props: {
|
|
400
|
+
...o.props,
|
|
401
|
+
post: g
|
|
402
|
+
}
|
|
403
|
+
} : (N = o.type) != null && N.startsWith("pattern.") && ((L = o.props) == null ? void 0 : L.course) === "{{item}}" ? m = {
|
|
404
|
+
...o,
|
|
405
|
+
props: {
|
|
406
|
+
...o.props,
|
|
407
|
+
course: g
|
|
408
|
+
}
|
|
409
|
+
} : (O = o.type) != null && O.startsWith("pattern.") && ((S = o.props) == null ? void 0 : S.conversation) === "{{item}}" ? m = {
|
|
410
|
+
...o,
|
|
411
|
+
props: {
|
|
412
|
+
...o.props,
|
|
413
|
+
conversation: g
|
|
414
|
+
}
|
|
415
|
+
} : (F = o.type) != null && F.startsWith("pattern.") && ((q = o.props) == null ? void 0 : q.message) === "{{item}}" ? m = {
|
|
416
|
+
...o,
|
|
417
|
+
props: {
|
|
418
|
+
...o.props,
|
|
419
|
+
message: g
|
|
420
|
+
}
|
|
421
|
+
} : (G = o.type) != null && G.startsWith("pattern.") && ((Y = o.props) == null ? void 0 : Y.profile) === "{{item}}" && (m = {
|
|
422
|
+
...o,
|
|
423
|
+
props: {
|
|
424
|
+
...o.props,
|
|
425
|
+
profile: g
|
|
426
|
+
}
|
|
427
|
+
}), /* @__PURE__ */ s.jsx("div", { className: `pineui-collection__item ${n === "grid" ? "pineui-collection__item--grid" : ""}`, children: /* @__PURE__ */ s.jsx(y, { node: m, context: v, parentData: g }) }, g.id || p);
|
|
428
|
+
})
|
|
429
|
+
}
|
|
430
|
+
),
|
|
431
|
+
w && !C && /* @__PURE__ */ s.jsx("div", { className: "pineui-collection__load-more", style: { padding: "16px", textAlign: "center" }, children: /* @__PURE__ */ s.jsx(
|
|
432
|
+
"button",
|
|
433
|
+
{
|
|
434
|
+
onClick: l,
|
|
435
|
+
disabled: k,
|
|
436
|
+
style: {
|
|
437
|
+
padding: "12px 24px",
|
|
438
|
+
fontSize: "14px",
|
|
439
|
+
fontWeight: 500,
|
|
440
|
+
cursor: k ? "not-allowed" : "pointer",
|
|
441
|
+
opacity: k ? 0.6 : 1
|
|
442
|
+
},
|
|
443
|
+
children: k ? "Carregando..." : "Carregar mais"
|
|
444
|
+
}
|
|
445
|
+
) })
|
|
446
|
+
] });
|
|
447
|
+
}, ke = ({
|
|
448
|
+
appBar: e,
|
|
449
|
+
body: n,
|
|
450
|
+
floatingActionButton: r,
|
|
451
|
+
bottomNavigationBar: t,
|
|
452
|
+
context: i,
|
|
453
|
+
renderer: o
|
|
454
|
+
}) => !o || !i ? null : /* @__PURE__ */ s.jsxs("div", { className: "pineui-scaffold", children: [
|
|
455
|
+
e && /* @__PURE__ */ s.jsx("header", { className: "pineui-scaffold__appbar", children: /* @__PURE__ */ s.jsx(o, { node: e, context: i }) }),
|
|
456
|
+
/* @__PURE__ */ s.jsx("main", { className: "pineui-scaffold__body", children: /* @__PURE__ */ s.jsx(o, { node: n, context: i }) }),
|
|
457
|
+
r && /* @__PURE__ */ s.jsx("div", { className: "pineui-scaffold__fab", children: /* @__PURE__ */ s.jsx(o, { node: r, context: i }) }),
|
|
458
|
+
t && /* @__PURE__ */ s.jsx("footer", { className: "pineui-scaffold__bottomnav", children: /* @__PURE__ */ s.jsx(o, { node: t, context: i }) })
|
|
459
|
+
] }), $e = ({
|
|
460
|
+
title: e,
|
|
461
|
+
leading: n,
|
|
462
|
+
actions: r = [],
|
|
463
|
+
context: t,
|
|
464
|
+
renderer: i
|
|
465
|
+
}) => !i || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "pineui-appbar", children: [
|
|
466
|
+
n && /* @__PURE__ */ s.jsx("div", { className: "pineui-appbar__leading", children: /* @__PURE__ */ s.jsx(i, { node: n, context: t }) }),
|
|
467
|
+
e && /* @__PURE__ */ s.jsx("div", { className: "pineui-appbar__title", children: /* @__PURE__ */ s.jsx(i, { node: e, context: t }) }),
|
|
468
|
+
r.length > 0 && /* @__PURE__ */ s.jsx("div", { className: "pineui-appbar__actions", children: r.map((o, a) => /* @__PURE__ */ s.jsx(i, { node: o, context: t }, a)) })
|
|
469
|
+
] }), Ce = ({
|
|
470
|
+
items: e,
|
|
471
|
+
currentIndex: n,
|
|
472
|
+
onItemTap: r,
|
|
473
|
+
context: t
|
|
474
|
+
}) => {
|
|
475
|
+
const i = async (o) => {
|
|
476
|
+
if (!t) return;
|
|
477
|
+
const a = JSON.parse(
|
|
478
|
+
JSON.stringify(r).replace(/\{\{item\.(\w+)\}\}/g, (d, c) => {
|
|
479
|
+
const u = o[c];
|
|
480
|
+
return u != null ? String(u) : "";
|
|
481
|
+
})
|
|
482
|
+
);
|
|
483
|
+
await t.executeAction(a);
|
|
484
|
+
};
|
|
485
|
+
return /* @__PURE__ */ s.jsx("nav", { className: "pineui-bottomnav", children: e.map((o, a) => /* @__PURE__ */ s.jsxs(
|
|
486
|
+
"button",
|
|
487
|
+
{
|
|
488
|
+
className: `pineui-bottomnav__item ${a === n ? "pineui-bottomnav__item--active" : ""}`,
|
|
489
|
+
onClick: () => i(o),
|
|
490
|
+
children: [
|
|
491
|
+
/* @__PURE__ */ s.jsxs("div", { className: "pineui-bottomnav__icon-container", children: [
|
|
492
|
+
/* @__PURE__ */ s.jsx("span", { className: "pineui-bottomnav__icon", children: o.icon }),
|
|
493
|
+
o.badge && o.badge > 0 && /* @__PURE__ */ s.jsx("span", { className: "pineui-bottomnav__badge", children: o.badge })
|
|
494
|
+
] }),
|
|
495
|
+
/* @__PURE__ */ s.jsx("span", { className: "pineui-bottomnav__label", children: o.label })
|
|
496
|
+
]
|
|
497
|
+
},
|
|
498
|
+
a
|
|
499
|
+
)) });
|
|
500
|
+
}, Ae = ({
|
|
501
|
+
id: e,
|
|
502
|
+
placeholder: n = "",
|
|
503
|
+
value: r = "",
|
|
504
|
+
multiline: t = !1,
|
|
505
|
+
maxLines: i = 1,
|
|
506
|
+
maxLength: o,
|
|
507
|
+
autofocus: a = !1,
|
|
508
|
+
onChanged: d,
|
|
509
|
+
context: c
|
|
510
|
+
}) => {
|
|
511
|
+
const v = {
|
|
512
|
+
id: e,
|
|
513
|
+
placeholder: n,
|
|
514
|
+
defaultValue: r,
|
|
515
|
+
maxLength: o,
|
|
516
|
+
autoFocus: a,
|
|
517
|
+
onChange: async (y) => {
|
|
518
|
+
if (!d || !c) return;
|
|
519
|
+
const j = JSON.parse(
|
|
520
|
+
JSON.stringify(d).replace(/\{\{value\}\}/g, y.target.value)
|
|
521
|
+
);
|
|
522
|
+
await c.executeAction(j);
|
|
523
|
+
},
|
|
524
|
+
className: "pineui-input"
|
|
525
|
+
};
|
|
526
|
+
return t ? /* @__PURE__ */ s.jsx(
|
|
527
|
+
"textarea",
|
|
528
|
+
{
|
|
529
|
+
...v,
|
|
530
|
+
rows: i,
|
|
531
|
+
style: {
|
|
532
|
+
resize: "none",
|
|
533
|
+
minHeight: `${i * 24}px`
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
) : /* @__PURE__ */ s.jsx("input", { ...v, type: "text" });
|
|
537
|
+
}, Ee = ({
|
|
538
|
+
thickness: e = 1,
|
|
539
|
+
color: n = "surfaceVariant"
|
|
540
|
+
}) => {
|
|
541
|
+
const r = {
|
|
542
|
+
height: `${e}px`,
|
|
543
|
+
backgroundColor: `var(--md-sys-color-${n}, #e0e0e0)`,
|
|
544
|
+
border: "none",
|
|
545
|
+
margin: 0
|
|
546
|
+
};
|
|
547
|
+
return /* @__PURE__ */ s.jsx("hr", { className: "pineui-divider", style: r });
|
|
548
|
+
}, Se = ({
|
|
549
|
+
conditions: e,
|
|
550
|
+
context: n,
|
|
551
|
+
renderer: r
|
|
552
|
+
}) => {
|
|
553
|
+
if (!r || !n) return null;
|
|
554
|
+
for (const t of e) {
|
|
555
|
+
const i = W({ when: t.when }, n);
|
|
556
|
+
if (i.when === !0 || i.when === "true")
|
|
557
|
+
return /* @__PURE__ */ s.jsx(r, { node: t.render, context: n });
|
|
558
|
+
}
|
|
559
|
+
return null;
|
|
560
|
+
}, Ie = ({
|
|
561
|
+
tabs: e,
|
|
562
|
+
defaultTab: n,
|
|
563
|
+
context: r,
|
|
564
|
+
renderer: t
|
|
565
|
+
}) => {
|
|
566
|
+
var d;
|
|
567
|
+
const [i, o] = x(n || ((d = e[0]) == null ? void 0 : d.id));
|
|
568
|
+
if (!t || !r) return null;
|
|
569
|
+
const a = e.find((c) => c.id === i);
|
|
570
|
+
return /* @__PURE__ */ s.jsxs("div", { className: "pineui-tabs", children: [
|
|
571
|
+
/* @__PURE__ */ s.jsx("div", { className: "pineui-tabs__header", children: e.map((c) => /* @__PURE__ */ s.jsxs(
|
|
572
|
+
"button",
|
|
573
|
+
{
|
|
574
|
+
className: `pineui-tabs__tab ${i === c.id ? "pineui-tabs__tab--active" : ""}`,
|
|
575
|
+
onClick: () => o(c.id),
|
|
576
|
+
children: [
|
|
577
|
+
c.icon && /* @__PURE__ */ s.jsx("span", { className: "pineui-tabs__icon", children: c.icon }),
|
|
578
|
+
/* @__PURE__ */ s.jsx("span", { className: "pineui-tabs__label", children: c.label }),
|
|
579
|
+
c.badge !== void 0 && c.badge > 0 && /* @__PURE__ */ s.jsx("span", { className: "pineui-tabs__badge", children: c.badge })
|
|
580
|
+
]
|
|
581
|
+
},
|
|
582
|
+
c.id
|
|
583
|
+
)) }),
|
|
584
|
+
/* @__PURE__ */ s.jsx("div", { className: "pineui-tabs__content", children: a && /* @__PURE__ */ s.jsx(t, { node: a.content, context: r }) })
|
|
585
|
+
] });
|
|
586
|
+
}, Oe = ({
|
|
587
|
+
label: e,
|
|
588
|
+
variant: n = "default",
|
|
589
|
+
size: r = "medium"
|
|
590
|
+
}) => {
|
|
591
|
+
const t = V(
|
|
592
|
+
"pineui-badge",
|
|
593
|
+
`pineui-badge--${n}`,
|
|
594
|
+
`pineui-badge--${r}`
|
|
595
|
+
);
|
|
596
|
+
return /* @__PURE__ */ s.jsx("span", { className: t, children: e });
|
|
597
|
+
}, Me = ({
|
|
598
|
+
label: e,
|
|
599
|
+
icon: n,
|
|
600
|
+
selected: r = !1,
|
|
601
|
+
onPress: t,
|
|
602
|
+
context: i
|
|
603
|
+
}) => {
|
|
604
|
+
const o = async () => {
|
|
605
|
+
t && i && await i.executeAction(t);
|
|
606
|
+
}, a = V("pineui-chip", {
|
|
607
|
+
"pineui-chip--selected": r
|
|
608
|
+
});
|
|
609
|
+
return /* @__PURE__ */ s.jsxs("button", { className: a, onClick: o, children: [
|
|
610
|
+
n && /* @__PURE__ */ s.jsx("span", { className: "pineui-chip__icon", children: n }),
|
|
611
|
+
/* @__PURE__ */ s.jsx("span", { className: "pineui-chip__label", children: e })
|
|
612
|
+
] });
|
|
613
|
+
}, We = ({
|
|
614
|
+
children: e,
|
|
615
|
+
columns: n = 3,
|
|
616
|
+
spacing: r = 16,
|
|
617
|
+
context: t,
|
|
618
|
+
renderer: i
|
|
619
|
+
}) => {
|
|
620
|
+
if (!i || !t) return null;
|
|
621
|
+
const o = {
|
|
622
|
+
display: "grid",
|
|
623
|
+
gridTemplateColumns: `repeat(${n}, 1fr)`,
|
|
624
|
+
gap: `${r}px`
|
|
625
|
+
};
|
|
626
|
+
return /* @__PURE__ */ s.jsx("div", { className: "pineui-grid", style: o, children: e.map((a, d) => /* @__PURE__ */ s.jsx(i, { node: a, context: t }, d)) });
|
|
627
|
+
}, Be = ({
|
|
628
|
+
value: e,
|
|
629
|
+
label: n,
|
|
630
|
+
showPercentage: r = !1,
|
|
631
|
+
color: t = "primary"
|
|
632
|
+
}) => {
|
|
633
|
+
const i = Math.min(100, Math.max(0, e));
|
|
634
|
+
return /* @__PURE__ */ s.jsxs("div", { className: "pineui-progress", children: [
|
|
635
|
+
(n || r) && /* @__PURE__ */ s.jsxs("div", { className: "pineui-progress__header", children: [
|
|
636
|
+
n && /* @__PURE__ */ s.jsx("span", { className: "pineui-progress__label", children: n }),
|
|
637
|
+
r && /* @__PURE__ */ s.jsxs("span", { className: "pineui-progress__percentage", children: [
|
|
638
|
+
i,
|
|
639
|
+
"%"
|
|
640
|
+
] })
|
|
641
|
+
] }),
|
|
642
|
+
/* @__PURE__ */ s.jsx("div", { className: "pineui-progress__track", children: /* @__PURE__ */ s.jsx(
|
|
643
|
+
"div",
|
|
644
|
+
{
|
|
645
|
+
className: `pineui-progress__fill pineui-progress__fill--${t}`,
|
|
646
|
+
style: { width: `${i}%` }
|
|
647
|
+
}
|
|
648
|
+
) })
|
|
649
|
+
] });
|
|
650
|
+
}, De = ({
|
|
651
|
+
columns: e,
|
|
652
|
+
data: n,
|
|
653
|
+
context: r,
|
|
654
|
+
renderer: t
|
|
655
|
+
}) => {
|
|
656
|
+
const [i, o] = x([]), [a, d] = x(!0);
|
|
657
|
+
R(() => {
|
|
658
|
+
c();
|
|
659
|
+
}, []);
|
|
660
|
+
const c = async () => {
|
|
661
|
+
if (r) {
|
|
662
|
+
if (Array.isArray(n)) {
|
|
663
|
+
o(n), d(!1);
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (n.type === "action.http")
|
|
667
|
+
try {
|
|
668
|
+
const u = n, y = await (await fetch(u.url, {
|
|
669
|
+
method: u.method || "GET",
|
|
670
|
+
headers: {
|
|
671
|
+
"Content-Type": "application/json"
|
|
672
|
+
},
|
|
673
|
+
body: u.body ? JSON.stringify(u.body) : void 0
|
|
674
|
+
})).json();
|
|
675
|
+
o(y.data || y), d(!1);
|
|
676
|
+
} catch (u) {
|
|
677
|
+
console.error("Table data fetch error:", u), d(!1);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
return !t || !r ? null : a ? /* @__PURE__ */ s.jsx("div", { className: "pineui-table", children: /* @__PURE__ */ s.jsx("p", { style: { padding: "16px", textAlign: "center" }, children: "Loading..." }) }) : /* @__PURE__ */ s.jsx("div", { className: "pineui-table", children: /* @__PURE__ */ s.jsxs("table", { children: [
|
|
682
|
+
/* @__PURE__ */ s.jsx("thead", { children: /* @__PURE__ */ s.jsx("tr", { children: e.map((u) => /* @__PURE__ */ s.jsx(
|
|
683
|
+
"th",
|
|
684
|
+
{
|
|
685
|
+
style: { width: u.width },
|
|
686
|
+
className: "pineui-table__header",
|
|
687
|
+
children: u.label
|
|
688
|
+
},
|
|
689
|
+
u.key
|
|
690
|
+
)) }) }),
|
|
691
|
+
/* @__PURE__ */ s.jsx("tbody", { children: i.map((u, v) => /* @__PURE__ */ s.jsx("tr", { className: "pineui-table__row", children: e.map((y) => /* @__PURE__ */ s.jsx("td", { className: "pineui-table__cell", children: y.template ? /* @__PURE__ */ s.jsx(
|
|
692
|
+
t,
|
|
693
|
+
{
|
|
694
|
+
node: y.template,
|
|
695
|
+
context: r,
|
|
696
|
+
parentData: u
|
|
697
|
+
}
|
|
698
|
+
) : /* @__PURE__ */ s.jsx("span", { children: u[y.key] }) }, y.key)) }, v)) })
|
|
699
|
+
] }) });
|
|
700
|
+
}, Pe = ({ name: e, context: n, renderer: r, flex: t, width: i, height: o }) => {
|
|
701
|
+
var c;
|
|
702
|
+
const a = (c = n == null ? void 0 : n.views) == null ? void 0 : c[e];
|
|
703
|
+
if (!a)
|
|
704
|
+
return console.warn(`View not found: ${e}`), null;
|
|
705
|
+
const d = {};
|
|
706
|
+
return t && (d.flex = t), i && (d.width = i), o && (d.height = o), /* @__PURE__ */ s.jsx("div", { className: "pineui-view", style: d, children: /* @__PURE__ */ s.jsx(r, { node: a.screen, context: n }) });
|
|
707
|
+
}, Le = {
|
|
708
|
+
text: ve,
|
|
709
|
+
"button.filled": J,
|
|
710
|
+
"button.text": J,
|
|
711
|
+
"button.icon": J,
|
|
712
|
+
"button.fab": J,
|
|
713
|
+
"layout.column": X,
|
|
714
|
+
"layout.row": X,
|
|
715
|
+
"layout.scaffold": ke,
|
|
716
|
+
"layout.appBar": $e,
|
|
717
|
+
"layout.bottomNav": Ce,
|
|
718
|
+
card: be,
|
|
719
|
+
image: je,
|
|
720
|
+
avatar: _e,
|
|
721
|
+
icon: we,
|
|
722
|
+
collection: Ne,
|
|
723
|
+
"input.text": Ae,
|
|
724
|
+
divider: Ee,
|
|
725
|
+
conditionalRender: Se,
|
|
726
|
+
tabs: Ie,
|
|
727
|
+
badge: Oe,
|
|
728
|
+
chip: Me,
|
|
729
|
+
grid: We,
|
|
730
|
+
progress: Be,
|
|
731
|
+
table: De,
|
|
732
|
+
view: Pe
|
|
733
|
+
}, z = ({ node: e, context: n, parentData: r }) => {
|
|
734
|
+
if (!e || !e.type)
|
|
735
|
+
return null;
|
|
736
|
+
const t = r !== void 0 ? Object.assign({}, n, { item: r }) : n, o = e.type !== "collection" ? W(e, t) : e;
|
|
737
|
+
if (o.type.startsWith("component.")) {
|
|
738
|
+
const d = o.type, c = n.components[d];
|
|
739
|
+
if (!c)
|
|
740
|
+
return console.warn(`Component not found: ${d}`), null;
|
|
741
|
+
const u = {
|
|
742
|
+
...t,
|
|
743
|
+
props: o.props
|
|
744
|
+
};
|
|
745
|
+
return /* @__PURE__ */ s.jsx(z, { node: c.definition, context: u, parentData: r });
|
|
746
|
+
}
|
|
747
|
+
const a = Le[o.type];
|
|
748
|
+
return a ? /* @__PURE__ */ s.jsx(
|
|
749
|
+
a,
|
|
750
|
+
{
|
|
751
|
+
...o,
|
|
752
|
+
context: n,
|
|
753
|
+
renderer: z
|
|
754
|
+
}
|
|
755
|
+
) : (console.warn(`Unknown component type: ${o.type}`), null);
|
|
756
|
+
}, Re = ({ messages: e, onDismiss: n }) => /* @__PURE__ */ s.jsx("div", { className: "pineui-snackbar-container", children: e.map((r) => /* @__PURE__ */ s.jsx(Ve, { message: r, onDismiss: n }, r.id)) }), Ve = ({
|
|
757
|
+
message: e,
|
|
758
|
+
onDismiss: n
|
|
759
|
+
}) => {
|
|
760
|
+
const [r, t] = x(!1);
|
|
761
|
+
return R(() => {
|
|
762
|
+
setTimeout(() => t(!0), 10);
|
|
763
|
+
const i = setTimeout(() => {
|
|
764
|
+
t(!1), setTimeout(() => n(e.id), 300);
|
|
765
|
+
}, e.duration || 3e3);
|
|
766
|
+
return () => clearTimeout(i);
|
|
767
|
+
}, [e, n]), /* @__PURE__ */ s.jsxs("div", { className: `pineui-snackbar ${r ? "pineui-snackbar--visible" : ""}`, children: [
|
|
768
|
+
/* @__PURE__ */ s.jsx("span", { className: "pineui-snackbar__message", children: e.message }),
|
|
769
|
+
e.action && /* @__PURE__ */ s.jsx("button", { className: "pineui-snackbar__action", onClick: e.action.onPress, children: e.action.label })
|
|
770
|
+
] });
|
|
771
|
+
}, Fe = ({
|
|
772
|
+
presentation: e = "modal",
|
|
773
|
+
dismissible: n = !0,
|
|
774
|
+
child: r,
|
|
775
|
+
onClose: t,
|
|
776
|
+
context: i,
|
|
777
|
+
renderer: o
|
|
778
|
+
}) => {
|
|
779
|
+
if (R(() => (document.body.style.overflow = "hidden", () => {
|
|
780
|
+
document.body.style.overflow = "";
|
|
781
|
+
}), []), !o || !i) return null;
|
|
782
|
+
const a = (u) => {
|
|
783
|
+
n && u.target === u.currentTarget && t();
|
|
784
|
+
}, d = (u) => {
|
|
785
|
+
n && u.key === "Escape" && t();
|
|
786
|
+
};
|
|
787
|
+
R(() => (window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d)), [n]);
|
|
788
|
+
const c = e === "bottomSheet" ? "pineui-modal-backdrop pineui-modal-backdrop--bottomSheet" : "pineui-modal-backdrop";
|
|
789
|
+
return /* @__PURE__ */ s.jsx("div", { className: c, onClick: a, children: /* @__PURE__ */ s.jsx("div", { className: `pineui-modal pineui-modal--${e}`, children: /* @__PURE__ */ s.jsx(o, { node: r, context: i }) }) });
|
|
790
|
+
}, Je = ({
|
|
791
|
+
overlays: e,
|
|
792
|
+
onClose: n,
|
|
793
|
+
context: r,
|
|
794
|
+
renderer: t
|
|
795
|
+
}) => /* @__PURE__ */ s.jsx(s.Fragment, { children: Object.entries(e).map(
|
|
796
|
+
([i, { visible: o, config: a }]) => o ? /* @__PURE__ */ s.jsx(
|
|
797
|
+
Fe,
|
|
798
|
+
{
|
|
799
|
+
id: i,
|
|
800
|
+
...a,
|
|
801
|
+
onClose: () => n(i),
|
|
802
|
+
context: r,
|
|
803
|
+
renderer: t
|
|
804
|
+
},
|
|
805
|
+
i
|
|
806
|
+
) : null
|
|
807
|
+
) });
|
|
808
|
+
function H(e, n) {
|
|
809
|
+
if (n.startsWith("http://") || n.startsWith("https://"))
|
|
810
|
+
return n;
|
|
811
|
+
try {
|
|
812
|
+
const r = new URL(e, window.location.href);
|
|
813
|
+
return new URL(n, r).href;
|
|
814
|
+
} catch {
|
|
815
|
+
const r = n.replace(/^\.\//, "");
|
|
816
|
+
return `${e.endsWith("/") ? e.slice(0, -1) : e}/${r}`;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
async function Z(e, n) {
|
|
820
|
+
if (!e.imports) return e;
|
|
821
|
+
const r = { ...e };
|
|
822
|
+
if (e.imports.components)
|
|
823
|
+
for (const t of e.imports.components)
|
|
824
|
+
try {
|
|
825
|
+
const i = H(n, t), a = await (await fetch(i)).json();
|
|
826
|
+
r.components = {
|
|
827
|
+
...r.components,
|
|
828
|
+
...a
|
|
829
|
+
};
|
|
830
|
+
} catch (i) {
|
|
831
|
+
console.error(`❌ Failed to load component from ${t}:`, i), console.error(` Resolved URL: ${H(n, t)}`);
|
|
832
|
+
}
|
|
833
|
+
if (e.imports.views)
|
|
834
|
+
for (const t of e.imports.views)
|
|
835
|
+
try {
|
|
836
|
+
const i = H(n, t), a = await (await fetch(i)).json();
|
|
837
|
+
r.views = {
|
|
838
|
+
...r.views,
|
|
839
|
+
...a
|
|
840
|
+
};
|
|
841
|
+
} catch (i) {
|
|
842
|
+
console.error(`Failed to load view from ${t}:`, i);
|
|
843
|
+
}
|
|
844
|
+
return r;
|
|
845
|
+
}
|
|
846
|
+
class ze extends se {
|
|
847
|
+
constructor(n) {
|
|
848
|
+
super(n), this.state = { hasError: !1, error: null };
|
|
849
|
+
}
|
|
850
|
+
static getDerivedStateFromError(n) {
|
|
851
|
+
return { hasError: !0, error: n };
|
|
852
|
+
}
|
|
853
|
+
componentDidCatch(n, r) {
|
|
854
|
+
console.error("🚨 PineUI Error:", n), console.error("Component Stack:", r.componentStack);
|
|
855
|
+
}
|
|
856
|
+
render() {
|
|
857
|
+
var n;
|
|
858
|
+
return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ s.jsxs("div", { className: "pineui-error", style: { padding: "24px", textAlign: "center" }, children: [
|
|
859
|
+
/* @__PURE__ */ s.jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "⚠️" }),
|
|
860
|
+
/* @__PURE__ */ s.jsx("h3", { style: { marginBottom: "8px", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
|
|
861
|
+
/* @__PURE__ */ s.jsx("p", { style: { color: "#79747E", fontSize: "14px", marginBottom: "16px" }, children: ((n = this.state.error) == null ? void 0 : n.message) || "An unexpected error occurred" }),
|
|
862
|
+
/* @__PURE__ */ s.jsx(
|
|
863
|
+
"button",
|
|
864
|
+
{
|
|
865
|
+
onClick: () => window.location.reload(),
|
|
866
|
+
style: {
|
|
867
|
+
padding: "10px 20px",
|
|
868
|
+
background: "#6750A4",
|
|
869
|
+
color: "white",
|
|
870
|
+
border: "none",
|
|
871
|
+
borderRadius: "20px",
|
|
872
|
+
cursor: "pointer",
|
|
873
|
+
fontSize: "14px",
|
|
874
|
+
fontWeight: 500
|
|
875
|
+
},
|
|
876
|
+
children: "Reload Page"
|
|
877
|
+
}
|
|
878
|
+
)
|
|
879
|
+
] }) : this.props.children;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function Te(e, n) {
|
|
883
|
+
const r = n.split(".");
|
|
884
|
+
let t = e;
|
|
885
|
+
for (const i of r) {
|
|
886
|
+
if (t == null) return;
|
|
887
|
+
t = t[i];
|
|
888
|
+
}
|
|
889
|
+
return t;
|
|
890
|
+
}
|
|
891
|
+
const He = ({ schema: e, schemaUrl: n, baseUrl: r = "" }) => {
|
|
892
|
+
const [t, i] = x(null), [o, a] = x(!0), [d, c] = x(null), [u, v] = x([]), [y, j] = x({}), B = (e == null ? void 0 : e.state) || {
|
|
893
|
+
currentUser: {
|
|
894
|
+
id: "user_current",
|
|
895
|
+
username: "currentuser",
|
|
896
|
+
displayName: "Current User",
|
|
897
|
+
avatar: "https://i.pravatar.cc/150?img=1"
|
|
898
|
+
},
|
|
899
|
+
composer: {
|
|
900
|
+
text: "",
|
|
901
|
+
media: null,
|
|
902
|
+
posting: !1
|
|
903
|
+
},
|
|
904
|
+
testInput: ""
|
|
905
|
+
}, [C, A] = x(B);
|
|
906
|
+
R(() => {
|
|
907
|
+
n && !e ? D() : e && k();
|
|
908
|
+
}, [n, e, r]);
|
|
909
|
+
const k = async () => {
|
|
910
|
+
try {
|
|
911
|
+
a(!0);
|
|
912
|
+
let f = e;
|
|
913
|
+
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 || {}))), i(f), f.state && A((h) => ({ ...h, ...f.state }));
|
|
914
|
+
} catch (f) {
|
|
915
|
+
c(f);
|
|
916
|
+
} finally {
|
|
917
|
+
a(!1);
|
|
918
|
+
}
|
|
919
|
+
}, D = async () => {
|
|
920
|
+
try {
|
|
921
|
+
a(!0);
|
|
922
|
+
let h = await (await fetch(n)).json();
|
|
923
|
+
h.imports && r && (h = await Z(h, r)), i(h), h.state && A((l) => ({ ...l, ...h.state }));
|
|
924
|
+
} catch (f) {
|
|
925
|
+
c(f);
|
|
926
|
+
} finally {
|
|
927
|
+
a(!1);
|
|
928
|
+
}
|
|
929
|
+
}, E = async (f, h) => {
|
|
930
|
+
var g;
|
|
931
|
+
console.log("Executing action:", f, "with params:", h);
|
|
932
|
+
let l = f;
|
|
933
|
+
if (h) {
|
|
934
|
+
const m = JSON.stringify(f).replace(/\{\{([^}]+)\}\}/g, (b, $) => {
|
|
935
|
+
const N = $.trim();
|
|
936
|
+
return h[N] !== void 0 ? String(h[N]) : "";
|
|
937
|
+
});
|
|
938
|
+
l = JSON.parse(m);
|
|
939
|
+
}
|
|
940
|
+
if (l.intent) {
|
|
941
|
+
const p = l.intent, m = { ...h, ...l };
|
|
942
|
+
return delete m.intent, _(p, m);
|
|
943
|
+
}
|
|
944
|
+
if (l.type && l.type.startsWith("intent.")) {
|
|
945
|
+
const p = l.type.substring(7), m = { ...h, ...l };
|
|
946
|
+
return delete m.type, _(p, m);
|
|
947
|
+
}
|
|
948
|
+
switch (l.type) {
|
|
949
|
+
case "action.http": {
|
|
950
|
+
try {
|
|
951
|
+
const p = l.url.startsWith("http") ? l.url : `${r}${l.url}`, b = await (await fetch(p, {
|
|
952
|
+
method: l.method || "GET",
|
|
953
|
+
headers: {
|
|
954
|
+
"Content-Type": "application/json"
|
|
955
|
+
},
|
|
956
|
+
body: l.body ? JSON.stringify(l.body) : void 0
|
|
957
|
+
})).json();
|
|
958
|
+
console.log("HTTP action result:", b);
|
|
959
|
+
} catch (p) {
|
|
960
|
+
console.error("HTTP action error:", p);
|
|
961
|
+
}
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
case "action.state.patch": {
|
|
965
|
+
A((p) => {
|
|
966
|
+
const m = { ...p };
|
|
967
|
+
return Ue(m, l.path, l.value), m;
|
|
968
|
+
});
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
case "action.overlay.open": {
|
|
972
|
+
const p = (g = t == null ? void 0 : t.overlays) == null ? void 0 : g[l.overlayId];
|
|
973
|
+
p ? j((m) => ({
|
|
974
|
+
...m,
|
|
975
|
+
[l.overlayId]: { visible: !0, config: p }
|
|
976
|
+
})) : console.warn("Overlay not found:", l.overlayId);
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
case "action.overlay.close": {
|
|
980
|
+
j((p) => ({
|
|
981
|
+
...p,
|
|
982
|
+
[l.overlayId]: { ...p[l.overlayId], visible: !1 }
|
|
983
|
+
}));
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
case "action.collection.refresh": {
|
|
987
|
+
console.log("Refresh collection:", l.collectionId);
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
case "action.snackbar.show": {
|
|
991
|
+
const p = typeof l.message == "string" && l.message.includes("{{") ? l.message.replace(/\{\{(.+?)\}\}/g, (b, $) => {
|
|
992
|
+
const N = $.trim();
|
|
993
|
+
if (N.startsWith("state.")) {
|
|
994
|
+
const L = N.substring(6), O = Te(C, L);
|
|
995
|
+
return O != null ? String(O) : "";
|
|
996
|
+
}
|
|
997
|
+
return "";
|
|
998
|
+
}) : l.message, m = {
|
|
999
|
+
id: `snackbar-${Date.now()}`,
|
|
1000
|
+
message: p,
|
|
1001
|
+
duration: l.duration || 3e3,
|
|
1002
|
+
action: l.action ? {
|
|
1003
|
+
label: l.action.label,
|
|
1004
|
+
onPress: () => E(l.action.onPress)
|
|
1005
|
+
} : void 0
|
|
1006
|
+
};
|
|
1007
|
+
v((b) => [...b, m]);
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
case "action.delay": {
|
|
1011
|
+
const p = l.duration || 1e3;
|
|
1012
|
+
await new Promise((m) => setTimeout(m, p));
|
|
1013
|
+
break;
|
|
1014
|
+
}
|
|
1015
|
+
default:
|
|
1016
|
+
console.warn("Unknown action type:", l.type);
|
|
1017
|
+
}
|
|
1018
|
+
}, _ = async (f, h) => {
|
|
1019
|
+
if (console.log("Executing intent:", f, h), !(t != null && t.intents)) return;
|
|
1020
|
+
const l = t.intents[f];
|
|
1021
|
+
if (!l) {
|
|
1022
|
+
console.warn("Intent not found:", f);
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
if (Array.isArray(l.handler))
|
|
1026
|
+
for (const g of l.handler)
|
|
1027
|
+
await E(g, h);
|
|
1028
|
+
else
|
|
1029
|
+
await E(l.handler, h);
|
|
1030
|
+
}, w = {
|
|
1031
|
+
state: C,
|
|
1032
|
+
data: {},
|
|
1033
|
+
components: (t == null ? void 0 : t.components) || {},
|
|
1034
|
+
views: (t == null ? void 0 : t.views) || {},
|
|
1035
|
+
intents: (t == null ? void 0 : t.intents) || {},
|
|
1036
|
+
schema: t,
|
|
1037
|
+
executeAction: E,
|
|
1038
|
+
executeIntent: _
|
|
1039
|
+
};
|
|
1040
|
+
if (o)
|
|
1041
|
+
return /* @__PURE__ */ s.jsxs("div", { className: "pineui-loading", style: {
|
|
1042
|
+
display: "flex",
|
|
1043
|
+
flexDirection: "column",
|
|
1044
|
+
alignItems: "center",
|
|
1045
|
+
justifyContent: "center",
|
|
1046
|
+
minHeight: "400px",
|
|
1047
|
+
gap: "16px",
|
|
1048
|
+
color: "#79747E"
|
|
1049
|
+
}, children: [
|
|
1050
|
+
/* @__PURE__ */ s.jsx("div", { style: {
|
|
1051
|
+
width: "40px",
|
|
1052
|
+
height: "40px",
|
|
1053
|
+
border: "4px solid #E7E0EC",
|
|
1054
|
+
borderTop: "4px solid #6750A4",
|
|
1055
|
+
borderRadius: "50%",
|
|
1056
|
+
animation: "pineui-spin 1s linear infinite"
|
|
1057
|
+
} }),
|
|
1058
|
+
/* @__PURE__ */ s.jsx("p", { style: { margin: 0, fontSize: "14px", fontWeight: 500 }, children: "Loading application..." }),
|
|
1059
|
+
/* @__PURE__ */ s.jsx("style", { dangerouslySetInnerHTML: {
|
|
1060
|
+
__html: `
|
|
1061
|
+
@keyframes pineui-spin {
|
|
1062
|
+
0% { transform: rotate(0deg); }
|
|
1063
|
+
100% { transform: rotate(360deg); }
|
|
1064
|
+
}
|
|
1065
|
+
`
|
|
1066
|
+
} })
|
|
1067
|
+
] });
|
|
1068
|
+
if (d)
|
|
1069
|
+
return /* @__PURE__ */ s.jsx("div", { className: "pineui-error", children: /* @__PURE__ */ s.jsxs("p", { children: [
|
|
1070
|
+
"Error loading schema: ",
|
|
1071
|
+
d.message
|
|
1072
|
+
] }) });
|
|
1073
|
+
if (!t)
|
|
1074
|
+
return /* @__PURE__ */ s.jsx("div", { className: "pineui-error", children: /* @__PURE__ */ s.jsx("p", { children: "No schema provided" }) });
|
|
1075
|
+
const I = (f) => {
|
|
1076
|
+
v((h) => h.filter((l) => l.id !== f));
|
|
1077
|
+
}, P = (f) => {
|
|
1078
|
+
j((h) => ({
|
|
1079
|
+
...h,
|
|
1080
|
+
[f]: { ...h[f], visible: !1 }
|
|
1081
|
+
}));
|
|
1082
|
+
};
|
|
1083
|
+
return /* @__PURE__ */ s.jsx(ze, { children: /* @__PURE__ */ s.jsxs("div", { className: "pineui-root", children: [
|
|
1084
|
+
/* @__PURE__ */ s.jsx(z, { node: t.screen, context: w }),
|
|
1085
|
+
/* @__PURE__ */ s.jsx(Re, { messages: u, onDismiss: I }),
|
|
1086
|
+
/* @__PURE__ */ s.jsx(Je, { overlays: y, onClose: P, context: w, renderer: z })
|
|
1087
|
+
] }) });
|
|
1088
|
+
};
|
|
1089
|
+
function Ue(e, n, r) {
|
|
1090
|
+
const t = n.split(".");
|
|
1091
|
+
let i = e;
|
|
1092
|
+
for (let o = 0; o < t.length - 1; o++)
|
|
1093
|
+
i[t[o]] || (i[t[o]] = {}), i = i[t[o]];
|
|
1094
|
+
i[t[t.length - 1]] = r;
|
|
1095
|
+
}
|
|
1096
|
+
function qe(e) {
|
|
1097
|
+
var t, i;
|
|
1098
|
+
const n = typeof e.target == "string" ? document.querySelector(e.target) : e.target;
|
|
1099
|
+
if (!n) {
|
|
1100
|
+
console.error("PineUI: Target element not found"), (t = e.onError) == null || t.call(e, new Error("Target element not found"));
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
U.createRoot(n).render(
|
|
1104
|
+
ee.createElement(He, {
|
|
1105
|
+
schema: e.schema,
|
|
1106
|
+
schemaUrl: e.schemaUrl,
|
|
1107
|
+
baseUrl: e.baseUrl
|
|
1108
|
+
})
|
|
1109
|
+
), (i = e.onReady) == null || i.call(e);
|
|
1110
|
+
}
|
|
1111
|
+
typeof window < "u" && (window.PineUI = {
|
|
1112
|
+
render: qe
|
|
1113
|
+
});
|
|
1114
|
+
export {
|
|
1115
|
+
He as PineUI,
|
|
1116
|
+
qe as render
|
|
1117
|
+
};
|