@sawabona/forms 1.0.0 → 1.0.2

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 +1 @@
1
- {"version":3,"file":"FormRenderer.d.ts","sourceRoot":"","sources":["../../src/lib/components/FormRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAO3D,UAAU,iBAAiB;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC;AAWD,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CAsLnE"}
1
+ {"version":3,"file":"FormRenderer.d.ts","sourceRoot":"","sources":["../../src/lib/components/FormRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAO3D,UAAU,iBAAiB;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC;AAWD,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CAwLnE"}
@@ -48,6 +48,7 @@ export interface FormTheme {
48
48
  borderRadius: string;
49
49
  poweredBy?: string;
50
50
  showPoweredBy?: boolean;
51
+ poweredByUrl?: string;
51
52
  brandColor?: string;
52
53
  submitText?: string;
53
54
  buttonVariant?: 'solid' | 'outline';
@@ -58,12 +59,13 @@ export interface FormSchema {
58
59
  questions: Question[];
59
60
  theme?: FormTheme;
60
61
  i18n?: {
61
- next: string;
62
- back: string;
63
- submit: string;
64
- required: string;
65
- optional: string;
66
- stepInfo: string;
62
+ next?: string;
63
+ back?: string;
64
+ submit?: string;
65
+ required?: string;
66
+ optional?: string;
67
+ stepInfo?: string;
68
+ pressEnter?: string;
67
69
  };
68
70
  autoReload?: boolean;
69
71
  reloadDelay?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/core/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAClB,MAAM,GACN,OAAO,GACP,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,cAAc,GACd,MAAM,GACN,SAAS,GACT,QAAQ,GACR,eAAe,GACf,WAAW,CAAC;AAElB,MAAM,WAAW,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,GAAG,WAAW,CAAC;IAC9E,KAAK,EAAE,GAAG,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC1B,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,GAAG,OAAO,CAAC;CAC7C;AAED,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM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AAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAC9C,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5D,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACrE"}
@@ -1,83 +1,83 @@
1
- var Q = Object.defineProperty, H = Object.defineProperties;
2
- var K = Object.getOwnPropertyDescriptors;
1
+ var H = Object.defineProperty, K = Object.defineProperties;
2
+ var U = Object.getOwnPropertyDescriptors;
3
3
  var R = Object.getOwnPropertySymbols;
4
- var z = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
5
- var j = (e, i, r) => i in e ? Q(e, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[i] = r, h = (e, i) => {
4
+ var P = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable;
5
+ var z = (e, i, r) => i in e ? H(e, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[i] = r, h = (e, i) => {
6
6
  for (var r in i || (i = {}))
7
- z.call(i, r) && j(e, r, i[r]);
7
+ P.call(i, r) && z(e, r, i[r]);
8
8
  if (R)
9
9
  for (var r of R(i))
10
- $.call(i, r) && j(e, r, i[r]);
10
+ _.call(i, r) && z(e, r, i[r]);
11
11
  return e;
12
- }, g = (e, i) => H(e, K(i));
13
- var B = (e) => typeof e == "symbol" ? e : e + "", _ = (e, i) => {
12
+ }, g = (e, i) => K(e, U(i));
13
+ var $ = (e) => typeof e == "symbol" ? e : e + "", D = (e, i) => {
14
14
  var r = {};
15
15
  for (var t in e)
16
- z.call(e, t) && i.indexOf(t) < 0 && (r[t] = e[t]);
16
+ P.call(e, t) && i.indexOf(t) < 0 && (r[t] = e[t]);
17
17
  if (e != null && R)
18
18
  for (var t of R(e))
19
- i.indexOf(t) < 0 && $.call(e, t) && (r[t] = e[t]);
19
+ i.indexOf(t) < 0 && _.call(e, t) && (r[t] = e[t]);
20
20
  return r;
21
21
  };
22
- import { jsxs as m, jsx as n } from "react/jsx-runtime";
23
- import { useState as V, useMemo as W, useCallback as S, createContext as M, useContext as U, useRef as G, useEffect as P } from "react";
24
- import { motion as w, AnimatePresence as X } from "framer-motion";
25
- import { Check as D, Star as J, ChevronLeft as Y, ChevronRight as Z } from "lucide-react";
26
- function q({ schema: e, onSubmit: i }) {
27
- var v;
22
+ import { jsxs as u, jsx as n } from "react/jsx-runtime";
23
+ import { useState as V, useMemo as W, useCallback as k, createContext as M, useContext as G, useRef as X, useEffect as B } from "react";
24
+ import { motion as w, AnimatePresence as J } from "framer-motion";
25
+ import { Check as O, Star as Y, ChevronLeft as Z, ChevronRight as q } from "lucide-react";
26
+ function ee({ schema: e, onSubmit: i }) {
27
+ var N;
28
28
  const [r, t] = V({
29
29
  answers: {},
30
- currentStepId: ((v = e.questions[0]) == null ? void 0 : v.id) || "",
30
+ currentStepId: ((N = e.questions[0]) == null ? void 0 : N.id) || "",
31
31
  history: [],
32
32
  isSubmitting: !1,
33
33
  errors: {},
34
34
  isCompleted: !1
35
- }), u = W(
35
+ }), d = W(
36
36
  () => e.questions.findIndex((a) => a.id === r.currentStepId),
37
37
  [e.questions, r.currentStepId]
38
- ), s = e.questions[u], p = S((a, o) => {
38
+ ), o = e.questions[d], p = k((a, s) => {
39
39
  t((l) => g(h({}, l), {
40
40
  answers: g(h({}, l.answers), {
41
- [a]: o
41
+ [a]: s
42
42
  }),
43
43
  // Clear error on modification
44
44
  errors: g(h({}, l.errors), {
45
45
  [a]: ""
46
46
  })
47
47
  }));
48
- }, []), d = S((a, o) => {
48
+ }, []), c = k((a, s) => {
49
49
  t((l) => {
50
- if (o === null) {
51
- const F = l.errors, { [a]: N } = F, y = _(F, [B(a)]);
52
- return g(h({}, l), { errors: y });
50
+ if (s === null) {
51
+ const F = l.errors, { [a]: j } = F, b = D(F, [$(a)]);
52
+ return g(h({}, l), { errors: b });
53
53
  }
54
54
  return g(h({}, l), {
55
- errors: g(h({}, l.errors), { [a]: o })
55
+ errors: g(h({}, l.errors), { [a]: s })
56
56
  });
57
57
  });
58
- }, []), c = S(() => {
58
+ }, []), m = k(() => {
59
59
  var l;
60
- if (!s) return !0;
61
- const a = r.answers[s.id], o = s.validation;
62
- return o && o.required && (a === void 0 || a === "" || Array.isArray(a) && a.length === 0) ? (d(s.id, ((l = e.i18n) == null ? void 0 : l.required) || "This field is required"), !1) : !0;
63
- }, [s, r.answers, d, e.i18n]), f = S((a) => {
64
- const o = e.questions.findIndex((l) => l.id === a.id);
65
- return o < e.questions.length - 1 ? e.questions[o + 1].id : "submit";
66
- }, [e.questions]), x = S(() => {
67
- if (!c()) return;
68
- const a = f(s);
69
- a === "submit" ? (t((o) => g(h({}, o), { isCompleted: !0 })), i == null || i(r.answers)) : t((o) => g(h({}, o), {
70
- history: [...o.history, o.currentStepId],
60
+ if (!o) return !0;
61
+ const a = r.answers[o.id], s = o.validation;
62
+ return s && s.required && (a === void 0 || a === "" || Array.isArray(a) && a.length === 0) ? (c(o.id, ((l = e.i18n) == null ? void 0 : l.required) || "This field is required"), !1) : !0;
63
+ }, [o, r.answers, c, e.i18n]), f = k((a) => {
64
+ const s = e.questions.findIndex((l) => l.id === a.id);
65
+ return s < e.questions.length - 1 ? e.questions[s + 1].id : "submit";
66
+ }, [e.questions]), x = k(() => {
67
+ if (!m()) return;
68
+ const a = f(o);
69
+ a === "submit" ? (t((s) => g(h({}, s), { isCompleted: !0 })), i == null || i(r.answers)) : t((s) => g(h({}, s), {
70
+ history: [...s.history, s.currentStepId],
71
71
  currentStepId: a
72
72
  }));
73
- }, [s, r.answers, c, f, i]), b = S(() => {
73
+ }, [o, r.answers, m, f, i]), v = k(() => {
74
74
  if (r.history.length === 0) return;
75
75
  const a = r.history[r.history.length - 1];
76
- t((o) => g(h({}, o), {
77
- history: o.history.slice(0, -1),
76
+ t((s) => g(h({}, s), {
77
+ history: s.history.slice(0, -1),
78
78
  currentStepId: a
79
79
  }));
80
- }, [r.history]), C = S((a) => {
80
+ }, [r.history]), C = k((a) => {
81
81
  if (!e.questions.some((l) => l.id === a)) {
82
82
  console.warn(`Step ${a} does not exist`);
83
83
  return;
@@ -86,7 +86,7 @@ function q({ schema: e, onSubmit: i }) {
86
86
  history: [...l.history, l.currentStepId],
87
87
  currentStepId: a
88
88
  }));
89
- }, [e.questions]), I = S(() => {
89
+ }, [e.questions]), I = k(() => {
90
90
  var a;
91
91
  t({
92
92
  answers: {},
@@ -100,63 +100,63 @@ function q({ schema: e, onSubmit: i }) {
100
100
  return g(h({}, r), {
101
101
  setAnswer: p,
102
102
  nextStep: x,
103
- prevStep: b,
103
+ prevStep: v,
104
104
  jumpToStep: C,
105
105
  submitForm: () => i == null ? void 0 : i(r.answers),
106
106
  resetForm: I,
107
- registerError: d,
107
+ registerError: c,
108
108
  // Helper to calculate progress
109
- progress: u / e.questions.length * 100
109
+ progress: d / e.questions.length * 100
110
110
  });
111
111
  }
112
- const O = M(void 0), L = () => {
113
- const e = U(O);
112
+ const Q = M(void 0), L = () => {
113
+ const e = G(Q);
114
114
  if (!e)
115
115
  throw new Error("useFormContext must be used within a FormProvider");
116
116
  return e;
117
117
  };
118
- function ee({ question: e }) {
119
- var v, a, o, l, F;
120
- const { answers: i, setAnswer: r, nextStep: t, schema: u } = L(), s = i[e.id], p = s != null ? String(s) : "", d = G(null), c = u.questions[0].id === e.id, f = !u.disableAutoFocus || !c;
121
- P(() => {
118
+ function te({ question: e }) {
119
+ var N, a, s, l, F, j;
120
+ const { answers: i, setAnswer: r, nextStep: t, schema: d } = L(), o = i[e.id], p = o != null ? String(o) : "", c = X(null), m = d.questions[0].id === e.id, f = !d.disableAutoFocus || !m;
121
+ B(() => {
122
122
  if (f) {
123
- const N = setTimeout(() => {
123
+ const b = setTimeout(() => {
124
124
  var y;
125
- (y = d.current) == null || y.focus();
125
+ (y = c.current) == null || y.focus();
126
126
  }, 500);
127
- return () => clearTimeout(N);
127
+ return () => clearTimeout(b);
128
128
  }
129
129
  }, [e.id, f]);
130
- const x = (N) => {
130
+ const x = (b) => {
131
131
  var E;
132
- let y = N.target.value;
132
+ let y = b.target.value;
133
133
  const A = ((E = e.validation) == null ? void 0 : E.maxLength) || 2048;
134
134
  if (y.length > A && (y = y.slice(0, A)), e.type === "number") {
135
135
  const T = y === "" ? "" : parseFloat(y);
136
136
  r(e.id, T);
137
137
  } else
138
138
  r(e.id, y);
139
- }, b = () => {
140
- var N, y, A, E, T;
141
- if ((N = e.validation) != null && N.required && !p) return !1;
139
+ }, v = () => {
140
+ var b, y, A, E, T;
141
+ if ((b = e.validation) != null && b.required && !p) return !1;
142
142
  if (p) {
143
143
  if ((y = e.validation) != null && y.minLength && p.length < e.validation.minLength || e.type === "email" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p)) return !1;
144
144
  if ((A = e.validation) != null && A.pattern)
145
145
  try {
146
146
  if (!new RegExp(e.validation.pattern).test(p)) return !1;
147
- } catch (k) {
148
- console.error("Invalid regex pattern in schema", k);
147
+ } catch (S) {
148
+ console.error("Invalid regex pattern in schema", S);
149
149
  }
150
150
  if (e.type === "number") {
151
- const k = parseFloat(p);
152
- if (!isNaN(k) && (((E = e.validation) == null ? void 0 : E.min) !== void 0 && k < e.validation.min || ((T = e.validation) == null ? void 0 : T.max) !== void 0 && k > e.validation.max))
151
+ const S = parseFloat(p);
152
+ if (!isNaN(S) && (((E = e.validation) == null ? void 0 : E.min) !== void 0 && S < e.validation.min || ((T = e.validation) == null ? void 0 : T.max) !== void 0 && S > e.validation.max))
153
153
  return !1;
154
154
  }
155
155
  }
156
156
  return !0;
157
- }, C = (N) => {
158
- if (N.key === "Enter" && !N.shiftKey) {
159
- if (N.preventDefault(), !b()) {
157
+ }, C = (b) => {
158
+ if (b.key === "Enter" && !b.shiftKey) {
159
+ if (b.preventDefault(), !v()) {
160
160
  const y = document.querySelector(".sawabona-form-container") || document.body;
161
161
  y.classList.add("shake-animation"), setTimeout(() => y.classList.remove("shake-animation"), 500);
162
162
  return;
@@ -164,19 +164,19 @@ function ee({ question: e }) {
164
164
  t();
165
165
  }
166
166
  };
167
- return /* @__PURE__ */ m("div", { className: "w-full relative group", children: [
167
+ return /* @__PURE__ */ u("div", { className: "w-full relative group", children: [
168
168
  /* @__PURE__ */ n(
169
169
  "input",
170
170
  {
171
- ref: d,
171
+ ref: c,
172
172
  type: e.type,
173
173
  value: typeof p == "string" || typeof p == "number" ? p : "",
174
174
  onChange: x,
175
175
  onKeyDown: C,
176
176
  placeholder: e.placeholder,
177
- minLength: (v = e.validation) == null ? void 0 : v.minLength,
177
+ minLength: (N = e.validation) == null ? void 0 : N.minLength,
178
178
  maxLength: ((a = e.validation) == null ? void 0 : a.maxLength) || 2048,
179
- min: (o = e.validation) == null ? void 0 : o.min,
179
+ min: (s = e.validation) == null ? void 0 : s.min,
180
180
  max: (l = e.validation) == null ? void 0 : l.max,
181
181
  pattern: (F = e.validation) == null ? void 0 : F.pattern,
182
182
  className: `
@@ -189,89 +189,84 @@ function ee({ question: e }) {
189
189
  }
190
190
  ),
191
191
  void 0,
192
- /* @__PURE__ */ m("p", { className: "text-sm opacity-50 mt-4", children: [
193
- e.type === "email" && "Press Enter to continue",
194
- e.type === "text" && "Press Enter to continue",
195
- e.type === "number" && "Press Enter to continue",
196
- e.type === "url" && "Press Enter to continue"
197
- ] })
192
+ /* @__PURE__ */ n("p", { className: "text-sm opacity-50 mt-4", children: (e.type === "email" || e.type === "text" || e.type === "number" || e.type === "url") && (((j = d.i18n) == null ? void 0 : j.pressEnter) || "Press Enter to continue") })
198
193
  ] });
199
194
  }
200
- function te({ question: e }) {
201
- var d;
202
- const { answers: i, setAnswer: r, nextStep: t } = L(), u = i[e.id] || "", s = (c) => {
203
- r(e.id, c), setTimeout(() => t(), 400);
195
+ function re({ question: e }) {
196
+ var c;
197
+ const { answers: i, setAnswer: r, nextStep: t } = L(), d = i[e.id] || "", o = (m) => {
198
+ r(e.id, m), setTimeout(() => t(), 400);
204
199
  }, p = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
205
- return P(() => {
206
- const c = (f) => {
200
+ return B(() => {
201
+ const m = (f) => {
207
202
  var C;
208
- const x = f.key.toUpperCase(), b = p.indexOf(x);
209
- b >= 0 && b < (((C = e.options) == null ? void 0 : C.length) || 0) && s(e.options[b].value);
203
+ const x = f.key.toUpperCase(), v = p.indexOf(x);
204
+ v >= 0 && v < (((C = e.options) == null ? void 0 : C.length) || 0) && o(e.options[v].value);
210
205
  };
211
- return window.addEventListener("keydown", c), () => window.removeEventListener("keydown", c);
212
- }, [e.options, e.id]), /* @__PURE__ */ n("div", { className: "flex flex-col gap-3 w-full max-w-xl", children: (d = e.options) == null ? void 0 : d.map((c, f) => {
213
- const x = Array.isArray(u) ? u.includes(c.value) : u === c.value;
214
- return /* @__PURE__ */ m(
206
+ return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
207
+ }, [e.options, e.id]), /* @__PURE__ */ n("div", { className: "flex flex-col gap-3 w-full max-w-xl", children: (c = e.options) == null ? void 0 : c.map((m, f) => {
208
+ const x = Array.isArray(d) ? d.includes(m.value) : d === m.value;
209
+ return /* @__PURE__ */ u(
215
210
  w.button,
216
211
  {
217
212
  initial: { opacity: 0, y: 10 },
218
213
  animate: { opacity: 1, y: 0 },
219
214
  transition: { delay: f * 0.05 },
220
- onClick: () => s(c.value),
215
+ onClick: () => o(m.value),
221
216
  className: `
222
217
  w-full text-left p-4 rounded-lg border-2 transition-all duration-200
223
218
  flex items-center justify-between group
224
219
  ${x ? "border-sw-primary bg-sw-primary/5 text-sw-primary" : "border-sw-text-secondary/10 hover:border-sw-primary/50 hover:bg-sw-primary/5"}
225
220
  `,
226
221
  children: [
227
- /* @__PURE__ */ m("span", { className: "text-lg font-medium flex items-center gap-3", children: [
222
+ /* @__PURE__ */ u("span", { className: "text-lg font-medium flex items-center gap-3", children: [
228
223
  /* @__PURE__ */ n("span", { className: `
229
224
  w-6 h-6 rounded-full border-2 flex items-center justify-center transition-colors
230
225
  ${x ? "border-sw-primary bg-sw-primary" : "border-sw-text-secondary/30 group-hover:border-sw-primary/50"}
231
- `, children: x && /* @__PURE__ */ n(D, { size: 14, className: "text-sw-background" }) }),
232
- c.label
226
+ `, children: x && /* @__PURE__ */ n(O, { size: 14, className: "text-sw-background" }) }),
227
+ m.label
233
228
  ] }),
234
- /* @__PURE__ */ m("span", { className: "opacity-0 group-hover:opacity-100 transition-opacity text-xs font-mono uppercase tracking-widest text-sw-text-secondary/50", children: [
229
+ /* @__PURE__ */ u("span", { className: "opacity-0 group-hover:opacity-100 transition-opacity text-xs font-mono uppercase tracking-widest text-sw-text-secondary/50", children: [
235
230
  "Select ",
236
- /* @__PURE__ */ m("span", { className: "hidden md:inline", children: [
231
+ /* @__PURE__ */ u("span", { className: "hidden md:inline", children: [
237
232
  "Key ",
238
233
  f + 1
239
234
  ] })
240
235
  ] })
241
236
  ]
242
237
  },
243
- String(c.value)
238
+ String(m.value)
244
239
  );
245
240
  }) });
246
241
  }
247
- function re({ question: e }) {
248
- var s;
249
- const { answers: i, setAnswer: r } = L(), t = i[e.id] || 0, u = Math.min(((s = e.validation) == null ? void 0 : s.max) || 5, 20);
250
- return /* @__PURE__ */ m("div", { className: "flex flex-col gap-6", children: [
251
- /* @__PURE__ */ n("div", { className: "flex gap-4 flex-wrap", children: Array.from({ length: u }).map((p, d) => {
252
- const c = d + 1, f = c <= t;
242
+ function ne({ question: e }) {
243
+ var o;
244
+ const { answers: i, setAnswer: r } = L(), t = i[e.id] || 0, d = Math.min(((o = e.validation) == null ? void 0 : o.max) || 5, 20);
245
+ return /* @__PURE__ */ u("div", { className: "flex flex-col gap-6", children: [
246
+ /* @__PURE__ */ n("div", { className: "flex gap-4 flex-wrap", children: Array.from({ length: d }).map((p, c) => {
247
+ const m = c + 1, f = m <= t;
253
248
  return /* @__PURE__ */ n(
254
249
  w.button,
255
250
  {
256
251
  initial: { opacity: 0, scale: 0 },
257
252
  animate: { opacity: 1, scale: 1 },
258
- transition: { delay: d * 0.05 },
259
- onClick: () => r(e.id, c),
253
+ transition: { delay: c * 0.05 },
254
+ onClick: () => r(e.id, m),
260
255
  whileHover: { scale: 1.2, rotate: 5 },
261
256
  whileTap: { scale: 0.9 },
262
257
  className: "focus:outline-none",
263
258
  children: /* @__PURE__ */ n(
264
- J,
259
+ Y,
265
260
  {
266
261
  className: `w-12 h-12 md:w-16 md:h-16 transition-all duration-300 ${f ? "fill-yellow-400 text-yellow-400 drop-shadow-[0_0_15px_rgba(250,204,21,0.4)]" : "text-zinc-600 hover:text-yellow-400/50"}`,
267
262
  strokeWidth: 1.5
268
263
  }
269
264
  )
270
265
  },
271
- d
266
+ c
272
267
  );
273
268
  }) }),
274
- /* @__PURE__ */ m("div", { className: "flex justify-between w-full max-w-[300px] md:max-w-[400px] px-2 items-center", children: [
269
+ /* @__PURE__ */ u("div", { className: "flex justify-between w-full max-w-[300px] md:max-w-[400px] px-2 items-center", children: [
275
270
  /* @__PURE__ */ n("span", { className: "text-sm md:text-base font-medium text-sw-text-secondary/50 uppercase tracking-wide", children: e.minLabel || "Poor" }),
276
271
  /* @__PURE__ */ n(
277
272
  w.div,
@@ -279,22 +274,22 @@ function re({ question: e }) {
279
274
  initial: { opacity: 0, scale: 0.8 },
280
275
  animate: { opacity: t ? 1 : 0, scale: t ? 1 : 0.8 },
281
276
  className: "font-bold text-primary text-xl",
282
- children: t ? `${t} / ${u}` : ""
277
+ children: t ? `${t} / ${d}` : ""
283
278
  }
284
279
  ),
285
280
  /* @__PURE__ */ n("span", { className: "text-sm md:text-base font-medium text-muted-foreground uppercase tracking-wide", children: e.maxLabel || "Excellent" })
286
281
  ] })
287
282
  ] });
288
283
  }
289
- function ne({ question: e }) {
290
- const { schema: i } = L(), r = i.questions.findIndex((d) => d.id === e.id) + 1, t = i.questions.length, u = {
284
+ function ie({ question: e }) {
285
+ const { schema: i } = L(), r = i.questions.findIndex((c) => c.id === e.id) + 1, t = i.questions.length, d = {
291
286
  hidden: { opacity: 0, y: 20 },
292
287
  visible: { opacity: 1, y: 0, transition: { duration: 0.5, ease: [0.22, 1, 0.36, 1] } }
293
- }, s = (d) => d && d.replace(/\{\{(\w+)\}\}/g, (c, f) => {
288
+ }, o = (c) => c && c.replace(/\{\{(\w+)\}\}/g, (m, f) => {
294
289
  const x = p.answers[f];
295
290
  return x != null ? String(x) : "";
296
291
  }), p = L();
297
- return /* @__PURE__ */ m(
292
+ return /* @__PURE__ */ u(
298
293
  w.div,
299
294
  {
300
295
  className: "flex flex-col gap-8 w-full max-w-4xl mx-auto",
@@ -304,19 +299,19 @@ function ne({ question: e }) {
304
299
  visible: { transition: { staggerChildren: 0.1 } }
305
300
  },
306
301
  children: [
307
- /* @__PURE__ */ m("div", { className: "flex flex-col gap-2", children: [
308
- /* @__PURE__ */ n(w.div, { variants: u, className: "flex gap-4 items-baseline", children: /* @__PURE__ */ m("span", { className: "flex items-center gap-2 text-sm md:text-base font-medium text-sw-primary/90 bg-sw-primary/10 px-3 py-1 rounded-full border border-sw-primary/20 backdrop-blur-sm", children: [
302
+ /* @__PURE__ */ u("div", { className: "flex flex-col gap-2", children: [
303
+ /* @__PURE__ */ n(w.div, { variants: d, className: "flex gap-4 items-baseline", children: /* @__PURE__ */ u("span", { className: "flex items-center gap-2 text-sm md:text-base font-medium text-sw-primary/90 bg-sw-primary/10 px-3 py-1 rounded-full border border-sw-primary/20 backdrop-blur-sm", children: [
309
304
  /* @__PURE__ */ n("span", { children: r }),
310
305
  /* @__PURE__ */ n("span", { className: "opacity-40 text-xs", children: "/" }),
311
306
  /* @__PURE__ */ n("span", { className: "opacity-60", children: t })
312
307
  ] }) }),
313
- /* @__PURE__ */ m(
308
+ /* @__PURE__ */ u(
314
309
  w.h2,
315
310
  {
316
- variants: u,
311
+ variants: d,
317
312
  className: "text-3xl md:text-4xl lg:text-5xl font-bold leading-tight tracking-tight text-pretty mt-2 font-sw-heading",
318
313
  children: [
319
- s(e.title),
314
+ o(e.title),
320
315
  " ",
321
316
  /* @__PURE__ */ n("span", { className: "text-sw-primary", children: "*" })
322
317
  ]
@@ -325,13 +320,13 @@ function ne({ question: e }) {
325
320
  e.description && /* @__PURE__ */ n(
326
321
  w.p,
327
322
  {
328
- variants: u,
323
+ variants: d,
329
324
  className: "text-lg md:text-xl text-muted-foreground font-normal leading-relaxed max-w-2xl mt-2",
330
- children: s(e.description)
325
+ children: o(e.description)
331
326
  }
332
327
  )
333
328
  ] }),
334
- /* @__PURE__ */ n(w.div, { variants: u, className: "w-full mt-6", children: e.type === "text" || e.type === "email" || e.type === "number" || e.type === "url" ? /* @__PURE__ */ n(ee, { question: e }) : e.type === "select" ? /* @__PURE__ */ n(te, { question: e }) : e.type === "rating" ? /* @__PURE__ */ n(re, { question: e }) : /* @__PURE__ */ m("div", { className: "p-4 bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 rounded", children: [
329
+ /* @__PURE__ */ n(w.div, { variants: d, className: "w-full mt-6", children: e.type === "text" || e.type === "email" || e.type === "number" || e.type === "url" ? /* @__PURE__ */ n(te, { question: e }) : e.type === "select" ? /* @__PURE__ */ n(re, { question: e }) : e.type === "rating" ? /* @__PURE__ */ n(ne, { question: e }) : /* @__PURE__ */ u("div", { className: "p-4 bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 rounded", children: [
335
330
  "Unsupported question type: ",
336
331
  e.type,
337
332
  " (ID: ",
@@ -342,7 +337,7 @@ function ne({ question: e }) {
342
337
  }
343
338
  );
344
339
  }
345
- const ie = {
340
+ const ae = {
346
341
  next: "Next",
347
342
  back: "Back",
348
343
  submit: "Submit",
@@ -350,16 +345,16 @@ const ie = {
350
345
  optional: "Optional",
351
346
  stepInfo: "Question {{current}} of {{total}}"
352
347
  };
353
- function ce({ schema: e, onSubmit: i }) {
348
+ function me({ schema: e, onSubmit: i }) {
354
349
  var I;
355
- const r = q({ schema: e, onSubmit: i }), t = e.theme || {
350
+ const r = ee({ schema: e, onSubmit: i }), t = e.theme || {
356
351
  backgroundColor: "#ffffff",
357
352
  textColor: "#000000",
358
353
  // Start with generic defaults, override in usage
359
354
  primaryColor: "#000000",
360
355
  borderRadius: "8px"
361
356
  // fontFamily removed to allow inheritance
362
- }, u = h(h({}, ie), e.i18n), s = {
357
+ }, d = h(h({}, ae), e.i18n), o = {
363
358
  backgroundColor: t.backgroundColor,
364
359
  color: t.textColor,
365
360
  fontFamily: t.fontFamily,
@@ -370,30 +365,30 @@ function ce({ schema: e, onSubmit: i }) {
370
365
  "--color-sw-text-secondary": t.textColor,
371
366
  "--font-sw-heading": t.fontFamily || "inherit",
372
367
  "--font-sw-body": t.fontFamily || "inherit"
373
- }, p = t.buttonVariant === "outline", d = {
368
+ }, p = t.buttonVariant === "outline", c = {
374
369
  backgroundColor: p ? "transparent" : t.primaryColor,
375
370
  color: p ? t.primaryColor : t.textColor,
376
371
  border: p ? `2px solid ${t.primaryColor}` : "none",
377
372
  borderRadius: t.borderRadius || "8px",
378
373
  fontWeight: 600
379
- }, c = {
374
+ }, m = {
380
375
  color: t.primaryColor,
381
376
  borderRadius: t.borderRadius || "8px",
382
377
  fontWeight: 600
383
378
  }, { autoReload: f, reloadDelay: x = 3e3 } = e;
384
- if (P(() => {
379
+ if (B(() => {
385
380
  if (r.isCompleted && f) {
386
- const v = setTimeout(() => {
381
+ const N = setTimeout(() => {
387
382
  r.resetForm();
388
383
  }, x);
389
- return () => clearTimeout(v);
384
+ return () => clearTimeout(N);
390
385
  }
391
386
  }, [r.isCompleted, f, x, r.resetForm]), r.isCompleted)
392
- return /* @__PURE__ */ m(
387
+ return /* @__PURE__ */ u(
393
388
  "div",
394
389
  {
395
390
  className: "flex flex-col items-center justify-center h-full w-full p-8 text-center relative overflow-hidden",
396
- style: s,
391
+ style: o,
397
392
  children: [
398
393
  f && /* @__PURE__ */ n(
399
394
  w.div,
@@ -404,7 +399,7 @@ function ce({ schema: e, onSubmit: i }) {
404
399
  className: "absolute top-0 left-0 h-1 bg-green-500 z-50"
405
400
  }
406
401
  ),
407
- /* @__PURE__ */ m(
402
+ /* @__PURE__ */ u(
408
403
  w.div,
409
404
  {
410
405
  initial: { scale: 0.9, opacity: 0, y: 20 },
@@ -412,7 +407,7 @@ function ce({ schema: e, onSubmit: i }) {
412
407
  transition: { duration: 0.6, ease: [0.22, 1, 0.36, 1] },
413
408
  className: "flex flex-col items-center",
414
409
  children: [
415
- /* @__PURE__ */ n("div", { className: "mb-6 p-4 rounded-full bg-green-500/20 text-green-500 w-24 h-24 flex items-center justify-center", children: /* @__PURE__ */ n(D, { size: 48 }) }),
410
+ /* @__PURE__ */ n("div", { className: "mb-6 p-4 rounded-full bg-green-500/20 text-green-500 w-24 h-24 flex items-center justify-center", children: /* @__PURE__ */ n(O, { size: 48 }) }),
416
411
  /* @__PURE__ */ n("h1", { className: "text-4xl md:text-5xl font-bold mb-4 tracking-tight", children: "Obrigado!" }),
417
412
  /* @__PURE__ */ n("p", { className: "text-xl opacity-70 max-w-md leading-relaxed", children: "Suas respostas foram enviadas com sucesso." })
418
413
  ]
@@ -421,14 +416,14 @@ function ce({ schema: e, onSubmit: i }) {
421
416
  ]
422
417
  }
423
418
  );
424
- const b = e.questions.find((v) => v.id === r.currentStepId), C = (e.questions.findIndex((v) => v.id === r.currentStepId) + 1) / e.questions.length * 100;
425
- return /* @__PURE__ */ n(O.Provider, { value: g(h({}, r), { schema: e }), children: /* @__PURE__ */ m(
419
+ const v = e.questions.find((N) => N.id === r.currentStepId), C = (e.questions.findIndex((N) => N.id === r.currentStepId) + 1) / e.questions.length * 100;
420
+ return /* @__PURE__ */ n(Q.Provider, { value: g(h({}, r), { schema: e }), children: /* @__PURE__ */ u(
426
421
  "div",
427
422
  {
428
423
  className: "w-full h-full flex flex-col relative overflow-hidden transition-colors duration-700",
429
- style: s,
424
+ style: o,
430
425
  children: [
431
- /* @__PURE__ */ m("div", { className: "absolute top-0 left-0 w-full h-1 z-50", children: [
426
+ /* @__PURE__ */ u("div", { className: "absolute top-0 left-0 w-full h-1 z-50", children: [
432
427
  /* @__PURE__ */ n("div", { className: "absolute top-0 left-0 w-full h-full bg-current opacity-10" }),
433
428
  /* @__PURE__ */ n(
434
429
  w.div,
@@ -441,7 +436,7 @@ function ce({ schema: e, onSubmit: i }) {
441
436
  }
442
437
  )
443
438
  ] }),
444
- /* @__PURE__ */ n("div", { className: "flex-1 flex flex-col items-center justify-center p-6 md:p-12 w-full max-w-5xl mx-auto z-10", children: /* @__PURE__ */ n(X, { mode: "wait", children: b && /* @__PURE__ */ n(
439
+ /* @__PURE__ */ n("div", { className: "flex-1 flex flex-col items-center justify-center p-6 md:p-12 w-full max-w-5xl mx-auto z-10", children: /* @__PURE__ */ n(J, { mode: "wait", children: v && /* @__PURE__ */ n(
445
440
  w.div,
446
441
  {
447
442
  initial: { opacity: 0, y: 40 },
@@ -449,15 +444,17 @@ function ce({ schema: e, onSubmit: i }) {
449
444
  exit: { opacity: 0, y: -40 },
450
445
  transition: { duration: 0.5, ease: [0.22, 1, 0.36, 1] },
451
446
  className: "w-full",
452
- children: /* @__PURE__ */ n(ne, { question: b })
447
+ children: /* @__PURE__ */ n(ie, { question: v })
453
448
  },
454
- b.id
449
+ v.id
455
450
  ) }) }),
456
- /* @__PURE__ */ m("div", { className: "w-full px-6 pt-6 pb-8 md:p-10 flex flex-col md:flex-row justify-between items-center z-20 gap-4", children: [
457
- t.showPoweredBy !== !1 && /* @__PURE__ */ m(
451
+ /* @__PURE__ */ u("div", { className: "w-full px-6 pt-6 pb-8 md:p-10 flex flex-col md:flex-row justify-between items-center z-20 gap-4", children: [
452
+ t.showPoweredBy !== !1 && /* @__PURE__ */ u(
458
453
  "a",
459
454
  {
460
- href: "#",
455
+ href: t.poweredByUrl || "#",
456
+ target: t.poweredByUrl ? "_blank" : void 0,
457
+ rel: t.poweredByUrl ? "noopener noreferrer" : void 0,
461
458
  className: "order-3 md:order-1 group flex items-center gap-2 px-3 py-1.5 rounded-md border border-white/10 bg-black/20 hover:border-sw-primary/50 hover:bg-black/40 transition-all duration-300 cursor-pointer no-underline backdrop-blur-sm",
462
459
  children: [
463
460
  /* @__PURE__ */ n("span", { className: "text-[10px] md:text-xs font-mono font-medium tracking-[0.2em] uppercase text-muted-foreground group-hover:text-muted-foreground/80 transition-colors", children: "Powered By" }),
@@ -472,7 +469,7 @@ function ce({ schema: e, onSubmit: i }) {
472
469
  ]
473
470
  }
474
471
  ),
475
- /* @__PURE__ */ m("div", { className: "flex items-center gap-4 order-2 md:order-3 ml-auto", children: [
472
+ /* @__PURE__ */ u("div", { className: "flex items-center gap-4 order-2 md:order-3 ml-auto", children: [
476
473
  /* @__PURE__ */ n(
477
474
  w.button,
478
475
  {
@@ -481,21 +478,21 @@ function ce({ schema: e, onSubmit: i }) {
481
478
  whileHover: { scale: 1.05 },
482
479
  whileTap: { scale: 0.95 },
483
480
  className: "w-12 h-12 md:w-14 md:h-14 flex items-center justify-center disabled:opacity-0 disabled:pointer-events-none transition-all hover:bg-white/5 rounded-full",
484
- style: c,
485
- children: /* @__PURE__ */ n(Y, { size: 24 })
481
+ style: m,
482
+ children: /* @__PURE__ */ n(Z, { size: 24 })
486
483
  }
487
484
  ),
488
- /* @__PURE__ */ m(
485
+ /* @__PURE__ */ u(
489
486
  w.button,
490
487
  {
491
488
  onClick: r.nextStep,
492
489
  whileHover: { scale: 1.02 },
493
490
  whileTap: { scale: 0.98 },
494
491
  className: "px-8 py-3 md:px-10 md:py-4 text-lg font-bold shadow-2xl flex items-center gap-3 transition-all rounded-lg",
495
- style: d,
492
+ style: c,
496
493
  children: [
497
- /* @__PURE__ */ n("span", { children: r.currentStepId === e.questions[e.questions.length - 1].id ? t.submitText || u.submit : u.next }),
498
- r.currentStepId !== e.questions[e.questions.length - 1].id && /* @__PURE__ */ n(Z, { size: 20, strokeWidth: 3 })
494
+ /* @__PURE__ */ n("span", { children: r.currentStepId === e.questions[e.questions.length - 1].id ? t.submitText || d.submit : d.next }),
495
+ r.currentStepId !== e.questions[e.questions.length - 1].id && /* @__PURE__ */ n(q, { size: 20, strokeWidth: 3 })
499
496
  ]
500
497
  }
501
498
  )
@@ -506,5 +503,5 @@ function ce({ schema: e, onSubmit: i }) {
506
503
  ) });
507
504
  }
508
505
  export {
509
- ce as FormRenderer
506
+ me as FormRenderer
510
507
  };
@@ -1,14 +1,14 @@
1
- (function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react/jsx-runtime"),require("react"),require("framer-motion"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","framer-motion","lucide-react"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n.SawabonaForms={},n.jsxRuntime,n.React,n.Motion,n.Lucide))})(this,(function(n,t,o,l,I){"use strict";var X=Object.defineProperty,J=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var $=(n,t,o)=>t in n?X(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,g=(n,t)=>{for(var o in t||(t={}))B.call(t,o)&&$(n,o,t[o]);if(P)for(var o of P(t))O.call(t,o)&&$(n,o,t[o]);return n},b=(n,t)=>J(n,Y(t));var _=n=>typeof n=="symbol"?n:n+"",D=(n,t)=>{var o={};for(var l in n)B.call(n,l)&&t.indexOf(l)<0&&(o[l]=n[l]);if(n!=null&&P)for(var l of P(n))t.indexOf(l)<0&&O.call(n,l)&&(o[l]=n[l]);return o};function Q({schema:e,onSubmit:m}){var C;const[s,r]=o.useState({answers:{},currentStepId:((C=e.questions[0])==null?void 0:C.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1}),x=o.useMemo(()=>e.questions.findIndex(a=>a.id===s.currentStepId),[e.questions,s.currentStepId]),i=e.questions[x],f=o.useCallback((a,d)=>{r(c=>b(g({},c),{answers:b(g({},c.answers),{[a]:d}),errors:b(g({},c.errors),{[a]:""})}))},[]),p=o.useCallback((a,d)=>{r(c=>{if(d===null){const A=c.errors,{[a]:N}=A,w=D(A,[_(a)]);return b(g({},c),{errors:w})}return b(g({},c),{errors:b(g({},c.errors),{[a]:d})})})},[]),u=o.useCallback(()=>{var c;if(!i)return!0;const a=s.answers[i.id],d=i.validation;return d&&d.required&&(a===void 0||a===""||Array.isArray(a)&&a.length===0)?(p(i.id,((c=e.i18n)==null?void 0:c.required)||"This field is required"),!1):!0},[i,s.answers,p,e.i18n]),y=o.useCallback(a=>{const d=e.questions.findIndex(c=>c.id===a.id);return d<e.questions.length-1?e.questions[d+1].id:"submit"},[e.questions]),h=o.useCallback(()=>{if(!u())return;const a=y(i);a==="submit"?(r(d=>b(g({},d),{isCompleted:!0})),m==null||m(s.answers)):r(d=>b(g({},d),{history:[...d.history,d.currentStepId],currentStepId:a}))},[i,s.answers,u,y,m]),v=o.useCallback(()=>{if(s.history.length===0)return;const a=s.history[s.history.length-1];r(d=>b(g({},d),{history:d.history.slice(0,-1),currentStepId:a}))},[s.history]),k=o.useCallback(a=>{if(!e.questions.some(c=>c.id===a)){console.warn(`Step ${a} does not exist`);return}r(c=>b(g({},c),{history:[...c.history,c.currentStepId],currentStepId:a}))},[e.questions]),E=o.useCallback(()=>{var a;r({answers:{},currentStepId:((a=e.questions[0])==null?void 0:a.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1})},[e.questions]);return b(g({},s),{setAnswer:f,nextStep:h,prevStep:v,jumpToStep:k,submitForm:()=>m==null?void 0:m(s.answers),resetForm:E,registerError:p,progress:x/e.questions.length*100})}const z=o.createContext(void 0),F=()=>{const e=o.useContext(z);if(!e)throw new Error("useFormContext must be used within a FormProvider");return e};function H({question:e}){var C,a,d,c,A;const{answers:m,setAnswer:s,nextStep:r,schema:x}=F(),i=m[e.id],f=i!=null?String(i):"",p=o.useRef(null),u=x.questions[0].id===e.id,y=!x.disableAutoFocus||!u;o.useEffect(()=>{if(y){const N=setTimeout(()=>{var w;(w=p.current)==null||w.focus()},500);return()=>clearTimeout(N)}},[e.id,y]);const h=N=>{var L;let w=N.target.value;const T=((L=e.validation)==null?void 0:L.maxLength)||2048;if(w.length>T&&(w=w.slice(0,T)),e.type==="number"){const j=w===""?"":parseFloat(w);s(e.id,j)}else s(e.id,w)},v=()=>{var N,w,T,L,j;if((N=e.validation)!=null&&N.required&&!f)return!1;if(f){if((w=e.validation)!=null&&w.minLength&&f.length<e.validation.minLength||e.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f))return!1;if((T=e.validation)!=null&&T.pattern)try{if(!new RegExp(e.validation.pattern).test(f))return!1}catch(S){console.error("Invalid regex pattern in schema",S)}if(e.type==="number"){const S=parseFloat(f);if(!isNaN(S)&&(((L=e.validation)==null?void 0:L.min)!==void 0&&S<e.validation.min||((j=e.validation)==null?void 0:j.max)!==void 0&&S>e.validation.max))return!1}}return!0},k=N=>{if(N.key==="Enter"&&!N.shiftKey){if(N.preventDefault(),!v()){const w=document.querySelector(".sawabona-form-container")||document.body;w.classList.add("shake-animation"),setTimeout(()=>w.classList.remove("shake-animation"),500);return}r()}};return t.jsxs("div",{className:"w-full relative group",children:[t.jsx("input",{ref:p,type:e.type,value:typeof f=="string"||typeof f=="number"?f:"",onChange:h,onKeyDown:k,placeholder:e.placeholder,minLength:(C=e.validation)==null?void 0:C.minLength,maxLength:((a=e.validation)==null?void 0:a.maxLength)||2048,min:(d=e.validation)==null?void 0:d.min,max:(c=e.validation)==null?void 0:c.max,pattern:(A=e.validation)==null?void 0:A.pattern,className:`
1
+ (function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react/jsx-runtime"),require("react"),require("framer-motion"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","framer-motion","lucide-react"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n.SawabonaForms={},n.jsxRuntime,n.React,n.Motion,n.Lucide))})(this,(function(n,t,o,l,I){"use strict";var J=Object.defineProperty,Y=Object.defineProperties;var Z=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var _=(n,t,o)=>t in n?J(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,g=(n,t)=>{for(var o in t||(t={}))$.call(t,o)&&_(n,o,t[o]);if(B)for(var o of B(t))O.call(t,o)&&_(n,o,t[o]);return n},b=(n,t)=>Y(n,Z(t));var D=n=>typeof n=="symbol"?n:n+"",Q=(n,t)=>{var o={};for(var l in n)$.call(n,l)&&t.indexOf(l)<0&&(o[l]=n[l]);if(n!=null&&B)for(var l of B(n))t.indexOf(l)<0&&O.call(n,l)&&(o[l]=n[l]);return o};function H({schema:e,onSubmit:m}){var N;const[s,r]=o.useState({answers:{},currentStepId:((N=e.questions[0])==null?void 0:N.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1}),p=o.useMemo(()=>e.questions.findIndex(a=>a.id===s.currentStepId),[e.questions,s.currentStepId]),i=e.questions[p],f=o.useCallback((a,d)=>{r(c=>b(g({},c),{answers:b(g({},c.answers),{[a]:d}),errors:b(g({},c.errors),{[a]:""})}))},[]),u=o.useCallback((a,d)=>{r(c=>{if(d===null){const E=c.errors,{[a]:z}=E,v=Q(E,[D(a)]);return b(g({},c),{errors:v})}return b(g({},c),{errors:b(g({},c.errors),{[a]:d})})})},[]),x=o.useCallback(()=>{var c;if(!i)return!0;const a=s.answers[i.id],d=i.validation;return d&&d.required&&(a===void 0||a===""||Array.isArray(a)&&a.length===0)?(u(i.id,((c=e.i18n)==null?void 0:c.required)||"This field is required"),!1):!0},[i,s.answers,u,e.i18n]),y=o.useCallback(a=>{const d=e.questions.findIndex(c=>c.id===a.id);return d<e.questions.length-1?e.questions[d+1].id:"submit"},[e.questions]),h=o.useCallback(()=>{if(!x())return;const a=y(i);a==="submit"?(r(d=>b(g({},d),{isCompleted:!0})),m==null||m(s.answers)):r(d=>b(g({},d),{history:[...d.history,d.currentStepId],currentStepId:a}))},[i,s.answers,x,y,m]),C=o.useCallback(()=>{if(s.history.length===0)return;const a=s.history[s.history.length-1];r(d=>b(g({},d),{history:d.history.slice(0,-1),currentStepId:a}))},[s.history]),k=o.useCallback(a=>{if(!e.questions.some(c=>c.id===a)){console.warn(`Step ${a} does not exist`);return}r(c=>b(g({},c),{history:[...c.history,c.currentStepId],currentStepId:a}))},[e.questions]),A=o.useCallback(()=>{var a;r({answers:{},currentStepId:((a=e.questions[0])==null?void 0:a.id)||"",history:[],isSubmitting:!1,errors:{},isCompleted:!1})},[e.questions]);return b(g({},s),{setAnswer:f,nextStep:h,prevStep:C,jumpToStep:k,submitForm:()=>m==null?void 0:m(s.answers),resetForm:A,registerError:u,progress:p/e.questions.length*100})}const P=o.createContext(void 0),F=()=>{const e=o.useContext(P);if(!e)throw new Error("useFormContext must be used within a FormProvider");return e};function K({question:e}){var N,a,d,c,E,z;const{answers:m,setAnswer:s,nextStep:r,schema:p}=F(),i=m[e.id],f=i!=null?String(i):"",u=o.useRef(null),x=p.questions[0].id===e.id,y=!p.disableAutoFocus||!x;o.useEffect(()=>{if(y){const v=setTimeout(()=>{var w;(w=u.current)==null||w.focus()},500);return()=>clearTimeout(v)}},[e.id,y]);const h=v=>{var L;let w=v.target.value;const T=((L=e.validation)==null?void 0:L.maxLength)||2048;if(w.length>T&&(w=w.slice(0,T)),e.type==="number"){const j=w===""?"":parseFloat(w);s(e.id,j)}else s(e.id,w)},C=()=>{var v,w,T,L,j;if((v=e.validation)!=null&&v.required&&!f)return!1;if(f){if((w=e.validation)!=null&&w.minLength&&f.length<e.validation.minLength||e.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f))return!1;if((T=e.validation)!=null&&T.pattern)try{if(!new RegExp(e.validation.pattern).test(f))return!1}catch(S){console.error("Invalid regex pattern in schema",S)}if(e.type==="number"){const S=parseFloat(f);if(!isNaN(S)&&(((L=e.validation)==null?void 0:L.min)!==void 0&&S<e.validation.min||((j=e.validation)==null?void 0:j.max)!==void 0&&S>e.validation.max))return!1}}return!0},k=v=>{if(v.key==="Enter"&&!v.shiftKey){if(v.preventDefault(),!C()){const w=document.querySelector(".sawabona-form-container")||document.body;w.classList.add("shake-animation"),setTimeout(()=>w.classList.remove("shake-animation"),500);return}r()}};return t.jsxs("div",{className:"w-full relative group",children:[t.jsx("input",{ref:u,type:e.type,value:typeof f=="string"||typeof f=="number"?f:"",onChange:h,onKeyDown:k,placeholder:e.placeholder,minLength:(N=e.validation)==null?void 0:N.minLength,maxLength:((a=e.validation)==null?void 0:a.maxLength)||2048,min:(d=e.validation)==null?void 0:d.min,max:(c=e.validation)==null?void 0:c.max,pattern:(E=e.validation)==null?void 0:E.pattern,className:`
2
2
  w-full bg-transparent border-b-2 border-sw-text-secondary/20
3
3
  py-4 text-2xl md:text-3xl font-medium outline-none transition-colors
4
4
  placeholder:text-sw-text-secondary/30
5
5
  focus:border-sw-primary
6
6
  font-sw-heading
7
- `}),void 0,t.jsxs("p",{className:"text-sm opacity-50 mt-4",children:[e.type==="email"&&"Press Enter to continue",e.type==="text"&&"Press Enter to continue",e.type==="number"&&"Press Enter to continue",e.type==="url"&&"Press Enter to continue"]})]})}function K({question:e}){var p;const{answers:m,setAnswer:s,nextStep:r}=F(),x=m[e.id]||"",i=u=>{s(e.id,u),setTimeout(()=>r(),400)},f="ABCDEFGHIJKLMNOPQRSTUVWXYZ";return o.useEffect(()=>{const u=y=>{var k;const h=y.key.toUpperCase(),v=f.indexOf(h);v>=0&&v<(((k=e.options)==null?void 0:k.length)||0)&&i(e.options[v].value)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e.options,e.id]),t.jsx("div",{className:"flex flex-col gap-3 w-full max-w-xl",children:(p=e.options)==null?void 0:p.map((u,y)=>{const h=Array.isArray(x)?x.includes(u.value):x===u.value;return t.jsxs(l.motion.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:y*.05},onClick:()=>i(u.value),className:`
7
+ `}),void 0,t.jsx("p",{className:"text-sm opacity-50 mt-4",children:(e.type==="email"||e.type==="text"||e.type==="number"||e.type==="url")&&(((z=p.i18n)==null?void 0:z.pressEnter)||"Press Enter to continue")})]})}function U({question:e}){var u;const{answers:m,setAnswer:s,nextStep:r}=F(),p=m[e.id]||"",i=x=>{s(e.id,x),setTimeout(()=>r(),400)},f="ABCDEFGHIJKLMNOPQRSTUVWXYZ";return o.useEffect(()=>{const x=y=>{var k;const h=y.key.toUpperCase(),C=f.indexOf(h);C>=0&&C<(((k=e.options)==null?void 0:k.length)||0)&&i(e.options[C].value)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[e.options,e.id]),t.jsx("div",{className:"flex flex-col gap-3 w-full max-w-xl",children:(u=e.options)==null?void 0:u.map((x,y)=>{const h=Array.isArray(p)?p.includes(x.value):p===x.value;return t.jsxs(l.motion.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:y*.05},onClick:()=>i(x.value),className:`
8
8
  w-full text-left p-4 rounded-lg border-2 transition-all duration-200
9
9
  flex items-center justify-between group
10
10
  ${h?"border-sw-primary bg-sw-primary/5 text-sw-primary":"border-sw-text-secondary/10 hover:border-sw-primary/50 hover:bg-sw-primary/5"}
11
11
  `,children:[t.jsxs("span",{className:"text-lg font-medium flex items-center gap-3",children:[t.jsx("span",{className:`
12
12
  w-6 h-6 rounded-full border-2 flex items-center justify-center transition-colors
13
13
  ${h?"border-sw-primary bg-sw-primary":"border-sw-text-secondary/30 group-hover:border-sw-primary/50"}
14
- `,children:h&&t.jsx(I.Check,{size:14,className:"text-sw-background"})}),u.label]}),t.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs font-mono uppercase tracking-widest text-sw-text-secondary/50",children:["Select ",t.jsxs("span",{className:"hidden md:inline",children:["Key ",y+1]})]})]},String(u.value))})})}function V({question:e}){var i;const{answers:m,setAnswer:s}=F(),r=m[e.id]||0,x=Math.min(((i=e.validation)==null?void 0:i.max)||5,20);return t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx("div",{className:"flex gap-4 flex-wrap",children:Array.from({length:x}).map((f,p)=>{const u=p+1,y=u<=r;return t.jsx(l.motion.button,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{delay:p*.05},onClick:()=>s(e.id,u),whileHover:{scale:1.2,rotate:5},whileTap:{scale:.9},className:"focus:outline-none",children:t.jsx(I.Star,{className:`w-12 h-12 md:w-16 md:h-16 transition-all duration-300 ${y?"fill-yellow-400 text-yellow-400 drop-shadow-[0_0_15px_rgba(250,204,21,0.4)]":"text-zinc-600 hover:text-yellow-400/50"}`,strokeWidth:1.5})},p)})}),t.jsxs("div",{className:"flex justify-between w-full max-w-[300px] md:max-w-[400px] px-2 items-center",children:[t.jsx("span",{className:"text-sm md:text-base font-medium text-sw-text-secondary/50 uppercase tracking-wide",children:e.minLabel||"Poor"}),t.jsx(l.motion.div,{initial:{opacity:0,scale:.8},animate:{opacity:r?1:0,scale:r?1:.8},className:"font-bold text-primary text-xl",children:r?`${r} / ${x}`:""}),t.jsx("span",{className:"text-sm md:text-base font-medium text-muted-foreground uppercase tracking-wide",children:e.maxLabel||"Excellent"})]})]})}function W({question:e}){const{schema:m}=F(),s=m.questions.findIndex(p=>p.id===e.id)+1,r=m.questions.length,x={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.5,ease:[.22,1,.36,1]}}},i=p=>p&&p.replace(/\{\{(\w+)\}\}/g,(u,y)=>{const h=f.answers[y];return h!=null?String(h):""}),f=F();return t.jsxs(l.motion.div,{className:"flex flex-col gap-8 w-full max-w-4xl mx-auto",initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.1}}},children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(l.motion.div,{variants:x,className:"flex gap-4 items-baseline",children:t.jsxs("span",{className:"flex items-center gap-2 text-sm md:text-base font-medium text-sw-primary/90 bg-sw-primary/10 px-3 py-1 rounded-full border border-sw-primary/20 backdrop-blur-sm",children:[t.jsx("span",{children:s}),t.jsx("span",{className:"opacity-40 text-xs",children:"/"}),t.jsx("span",{className:"opacity-60",children:r})]})}),t.jsxs(l.motion.h2,{variants:x,className:"text-3xl md:text-4xl lg:text-5xl font-bold leading-tight tracking-tight text-pretty mt-2 font-sw-heading",children:[i(e.title)," ",t.jsx("span",{className:"text-sw-primary",children:"*"})]}),e.description&&t.jsx(l.motion.p,{variants:x,className:"text-lg md:text-xl text-muted-foreground font-normal leading-relaxed max-w-2xl mt-2",children:i(e.description)})]}),t.jsx(l.motion.div,{variants:x,className:"w-full mt-6",children:e.type==="text"||e.type==="email"||e.type==="number"||e.type==="url"?t.jsx(H,{question:e}):e.type==="select"?t.jsx(K,{question:e}):e.type==="rating"?t.jsx(V,{question:e}):t.jsxs("div",{className:"p-4 bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 rounded",children:["Unsupported question type: ",e.type," (ID: ",e.id,")"]})})]})}const U={next:"Next",back:"Back",submit:"Submit",required:"Required",optional:"Optional",stepInfo:"Question {{current}} of {{total}}"};function G({schema:e,onSubmit:m}){var E;const s=Q({schema:e,onSubmit:m}),r=e.theme||{backgroundColor:"#ffffff",textColor:"#000000",primaryColor:"#000000",borderRadius:"8px"},x=g(g({},U),e.i18n),i={backgroundColor:r.backgroundColor,color:r.textColor,fontFamily:r.fontFamily,"--color-sw-primary":r.primaryColor,"--color-sw-background":r.backgroundColor,"--color-sw-text-primary":r.primaryColor,"--color-sw-text-secondary":r.textColor,"--font-sw-heading":r.fontFamily||"inherit","--font-sw-body":r.fontFamily||"inherit"},f=r.buttonVariant==="outline",p={backgroundColor:f?"transparent":r.primaryColor,color:f?r.primaryColor:r.textColor,border:f?`2px solid ${r.primaryColor}`:"none",borderRadius:r.borderRadius||"8px",fontWeight:600},u={color:r.primaryColor,borderRadius:r.borderRadius||"8px",fontWeight:600},{autoReload:y,reloadDelay:h=3e3}=e;if(o.useEffect(()=>{if(s.isCompleted&&y){const C=setTimeout(()=>{s.resetForm()},h);return()=>clearTimeout(C)}},[s.isCompleted,y,h,s.resetForm]),s.isCompleted)return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8 text-center relative overflow-hidden",style:i,children:[y&&t.jsx(l.motion.div,{initial:{width:"0%"},animate:{width:"100%"},transition:{duration:h/1e3,ease:"linear"},className:"absolute top-0 left-0 h-1 bg-green-500 z-50"}),t.jsxs(l.motion.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},transition:{duration:.6,ease:[.22,1,.36,1]},className:"flex flex-col items-center",children:[t.jsx("div",{className:"mb-6 p-4 rounded-full bg-green-500/20 text-green-500 w-24 h-24 flex items-center justify-center",children:t.jsx(I.Check,{size:48})}),t.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4 tracking-tight",children:"Obrigado!"}),t.jsx("p",{className:"text-xl opacity-70 max-w-md leading-relaxed",children:"Suas respostas foram enviadas com sucesso."})]})]});const v=e.questions.find(C=>C.id===s.currentStepId),k=(e.questions.findIndex(C=>C.id===s.currentStepId)+1)/e.questions.length*100;return t.jsx(z.Provider,{value:b(g({},s),{schema:e}),children:t.jsxs("div",{className:"w-full h-full flex flex-col relative overflow-hidden transition-colors duration-700",style:i,children:[t.jsxs("div",{className:"absolute top-0 left-0 w-full h-1 z-50",children:[t.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-current opacity-10"}),t.jsx(l.motion.div,{className:"h-full relative z-10",initial:{width:0},animate:{width:`${k}%`},transition:{duration:.5,ease:"easeInOut"},style:{backgroundColor:r.primaryColor}})]}),t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 md:p-12 w-full max-w-5xl mx-auto z-10",children:t.jsx(l.AnimatePresence,{mode:"wait",children:v&&t.jsx(l.motion.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.5,ease:[.22,1,.36,1]},className:"w-full",children:t.jsx(W,{question:v})},v.id)})}),t.jsxs("div",{className:"w-full px-6 pt-6 pb-8 md:p-10 flex flex-col md:flex-row justify-between items-center z-20 gap-4",children:[r.showPoweredBy!==!1&&t.jsxs("a",{href:"#",className:"order-3 md:order-1 group flex items-center gap-2 px-3 py-1.5 rounded-md border border-white/10 bg-black/20 hover:border-sw-primary/50 hover:bg-black/40 transition-all duration-300 cursor-pointer no-underline backdrop-blur-sm",children:[t.jsx("span",{className:"text-[10px] md:text-xs font-mono font-medium tracking-[0.2em] uppercase text-muted-foreground group-hover:text-muted-foreground/80 transition-colors",children:"Powered By"}),t.jsx("span",{className:"text-[10px] md:text-xs font-mono font-bold tracking-[0.2em] uppercase transition-colors shadow-sw-primary",style:{color:r.brandColor||r.primaryColor},children:((E=r.poweredBy)==null?void 0:E.replace("Powered by ",""))||"SAWABONA TECH"})]}),t.jsxs("div",{className:"flex items-center gap-4 order-2 md:order-3 ml-auto",children:[t.jsx(l.motion.button,{onClick:s.prevStep,disabled:s.history.length===0,whileHover:{scale:1.05},whileTap:{scale:.95},className:"w-12 h-12 md:w-14 md:h-14 flex items-center justify-center disabled:opacity-0 disabled:pointer-events-none transition-all hover:bg-white/5 rounded-full",style:u,children:t.jsx(I.ChevronLeft,{size:24})}),t.jsxs(l.motion.button,{onClick:s.nextStep,whileHover:{scale:1.02},whileTap:{scale:.98},className:"px-8 py-3 md:px-10 md:py-4 text-lg font-bold shadow-2xl flex items-center gap-3 transition-all rounded-lg",style:p,children:[t.jsx("span",{children:s.currentStepId===e.questions[e.questions.length-1].id?r.submitText||x.submit:x.next}),s.currentStepId!==e.questions[e.questions.length-1].id&&t.jsx(I.ChevronRight,{size:20,strokeWidth:3})]})]})]})]})})}n.FormRenderer=G,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
14
+ `,children:h&&t.jsx(I.Check,{size:14,className:"text-sw-background"})}),x.label]}),t.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs font-mono uppercase tracking-widest text-sw-text-secondary/50",children:["Select ",t.jsxs("span",{className:"hidden md:inline",children:["Key ",y+1]})]})]},String(x.value))})})}function V({question:e}){var i;const{answers:m,setAnswer:s}=F(),r=m[e.id]||0,p=Math.min(((i=e.validation)==null?void 0:i.max)||5,20);return t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx("div",{className:"flex gap-4 flex-wrap",children:Array.from({length:p}).map((f,u)=>{const x=u+1,y=x<=r;return t.jsx(l.motion.button,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{delay:u*.05},onClick:()=>s(e.id,x),whileHover:{scale:1.2,rotate:5},whileTap:{scale:.9},className:"focus:outline-none",children:t.jsx(I.Star,{className:`w-12 h-12 md:w-16 md:h-16 transition-all duration-300 ${y?"fill-yellow-400 text-yellow-400 drop-shadow-[0_0_15px_rgba(250,204,21,0.4)]":"text-zinc-600 hover:text-yellow-400/50"}`,strokeWidth:1.5})},u)})}),t.jsxs("div",{className:"flex justify-between w-full max-w-[300px] md:max-w-[400px] px-2 items-center",children:[t.jsx("span",{className:"text-sm md:text-base font-medium text-sw-text-secondary/50 uppercase tracking-wide",children:e.minLabel||"Poor"}),t.jsx(l.motion.div,{initial:{opacity:0,scale:.8},animate:{opacity:r?1:0,scale:r?1:.8},className:"font-bold text-primary text-xl",children:r?`${r} / ${p}`:""}),t.jsx("span",{className:"text-sm md:text-base font-medium text-muted-foreground uppercase tracking-wide",children:e.maxLabel||"Excellent"})]})]})}function W({question:e}){const{schema:m}=F(),s=m.questions.findIndex(u=>u.id===e.id)+1,r=m.questions.length,p={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.5,ease:[.22,1,.36,1]}}},i=u=>u&&u.replace(/\{\{(\w+)\}\}/g,(x,y)=>{const h=f.answers[y];return h!=null?String(h):""}),f=F();return t.jsxs(l.motion.div,{className:"flex flex-col gap-8 w-full max-w-4xl mx-auto",initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.1}}},children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(l.motion.div,{variants:p,className:"flex gap-4 items-baseline",children:t.jsxs("span",{className:"flex items-center gap-2 text-sm md:text-base font-medium text-sw-primary/90 bg-sw-primary/10 px-3 py-1 rounded-full border border-sw-primary/20 backdrop-blur-sm",children:[t.jsx("span",{children:s}),t.jsx("span",{className:"opacity-40 text-xs",children:"/"}),t.jsx("span",{className:"opacity-60",children:r})]})}),t.jsxs(l.motion.h2,{variants:p,className:"text-3xl md:text-4xl lg:text-5xl font-bold leading-tight tracking-tight text-pretty mt-2 font-sw-heading",children:[i(e.title)," ",t.jsx("span",{className:"text-sw-primary",children:"*"})]}),e.description&&t.jsx(l.motion.p,{variants:p,className:"text-lg md:text-xl text-muted-foreground font-normal leading-relaxed max-w-2xl mt-2",children:i(e.description)})]}),t.jsx(l.motion.div,{variants:p,className:"w-full mt-6",children:e.type==="text"||e.type==="email"||e.type==="number"||e.type==="url"?t.jsx(K,{question:e}):e.type==="select"?t.jsx(U,{question:e}):e.type==="rating"?t.jsx(V,{question:e}):t.jsxs("div",{className:"p-4 bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 rounded",children:["Unsupported question type: ",e.type," (ID: ",e.id,")"]})})]})}const G={next:"Next",back:"Back",submit:"Submit",required:"Required",optional:"Optional",stepInfo:"Question {{current}} of {{total}}"};function X({schema:e,onSubmit:m}){var A;const s=H({schema:e,onSubmit:m}),r=e.theme||{backgroundColor:"#ffffff",textColor:"#000000",primaryColor:"#000000",borderRadius:"8px"},p=g(g({},G),e.i18n),i={backgroundColor:r.backgroundColor,color:r.textColor,fontFamily:r.fontFamily,"--color-sw-primary":r.primaryColor,"--color-sw-background":r.backgroundColor,"--color-sw-text-primary":r.primaryColor,"--color-sw-text-secondary":r.textColor,"--font-sw-heading":r.fontFamily||"inherit","--font-sw-body":r.fontFamily||"inherit"},f=r.buttonVariant==="outline",u={backgroundColor:f?"transparent":r.primaryColor,color:f?r.primaryColor:r.textColor,border:f?`2px solid ${r.primaryColor}`:"none",borderRadius:r.borderRadius||"8px",fontWeight:600},x={color:r.primaryColor,borderRadius:r.borderRadius||"8px",fontWeight:600},{autoReload:y,reloadDelay:h=3e3}=e;if(o.useEffect(()=>{if(s.isCompleted&&y){const N=setTimeout(()=>{s.resetForm()},h);return()=>clearTimeout(N)}},[s.isCompleted,y,h,s.resetForm]),s.isCompleted)return t.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8 text-center relative overflow-hidden",style:i,children:[y&&t.jsx(l.motion.div,{initial:{width:"0%"},animate:{width:"100%"},transition:{duration:h/1e3,ease:"linear"},className:"absolute top-0 left-0 h-1 bg-green-500 z-50"}),t.jsxs(l.motion.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},transition:{duration:.6,ease:[.22,1,.36,1]},className:"flex flex-col items-center",children:[t.jsx("div",{className:"mb-6 p-4 rounded-full bg-green-500/20 text-green-500 w-24 h-24 flex items-center justify-center",children:t.jsx(I.Check,{size:48})}),t.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4 tracking-tight",children:"Obrigado!"}),t.jsx("p",{className:"text-xl opacity-70 max-w-md leading-relaxed",children:"Suas respostas foram enviadas com sucesso."})]})]});const C=e.questions.find(N=>N.id===s.currentStepId),k=(e.questions.findIndex(N=>N.id===s.currentStepId)+1)/e.questions.length*100;return t.jsx(P.Provider,{value:b(g({},s),{schema:e}),children:t.jsxs("div",{className:"w-full h-full flex flex-col relative overflow-hidden transition-colors duration-700",style:i,children:[t.jsxs("div",{className:"absolute top-0 left-0 w-full h-1 z-50",children:[t.jsx("div",{className:"absolute top-0 left-0 w-full h-full bg-current opacity-10"}),t.jsx(l.motion.div,{className:"h-full relative z-10",initial:{width:0},animate:{width:`${k}%`},transition:{duration:.5,ease:"easeInOut"},style:{backgroundColor:r.primaryColor}})]}),t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 md:p-12 w-full max-w-5xl mx-auto z-10",children:t.jsx(l.AnimatePresence,{mode:"wait",children:C&&t.jsx(l.motion.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.5,ease:[.22,1,.36,1]},className:"w-full",children:t.jsx(W,{question:C})},C.id)})}),t.jsxs("div",{className:"w-full px-6 pt-6 pb-8 md:p-10 flex flex-col md:flex-row justify-between items-center z-20 gap-4",children:[r.showPoweredBy!==!1&&t.jsxs("a",{href:r.poweredByUrl||"#",target:r.poweredByUrl?"_blank":void 0,rel:r.poweredByUrl?"noopener noreferrer":void 0,className:"order-3 md:order-1 group flex items-center gap-2 px-3 py-1.5 rounded-md border border-white/10 bg-black/20 hover:border-sw-primary/50 hover:bg-black/40 transition-all duration-300 cursor-pointer no-underline backdrop-blur-sm",children:[t.jsx("span",{className:"text-[10px] md:text-xs font-mono font-medium tracking-[0.2em] uppercase text-muted-foreground group-hover:text-muted-foreground/80 transition-colors",children:"Powered By"}),t.jsx("span",{className:"text-[10px] md:text-xs font-mono font-bold tracking-[0.2em] uppercase transition-colors shadow-sw-primary",style:{color:r.brandColor||r.primaryColor},children:((A=r.poweredBy)==null?void 0:A.replace("Powered by ",""))||"SAWABONA TECH"})]}),t.jsxs("div",{className:"flex items-center gap-4 order-2 md:order-3 ml-auto",children:[t.jsx(l.motion.button,{onClick:s.prevStep,disabled:s.history.length===0,whileHover:{scale:1.05},whileTap:{scale:.95},className:"w-12 h-12 md:w-14 md:h-14 flex items-center justify-center disabled:opacity-0 disabled:pointer-events-none transition-all hover:bg-white/5 rounded-full",style:x,children:t.jsx(I.ChevronLeft,{size:24})}),t.jsxs(l.motion.button,{onClick:s.nextStep,whileHover:{scale:1.02},whileTap:{scale:.98},className:"px-8 py-3 md:px-10 md:py-4 text-lg font-bold shadow-2xl flex items-center gap-3 transition-all rounded-lg",style:u,children:[t.jsx("span",{children:s.currentStepId===e.questions[e.questions.length-1].id?r.submitText||p.submit:p.next}),s.currentStepId!==e.questions[e.questions.length-1].id&&t.jsx(I.ChevronRight,{size:20,strokeWidth:3})]})]})]})]})})}n.FormRenderer=X,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sawabona/forms",
3
3
  "private": false,
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "type": "module",
6
6
  "main": "./dist/sawabona-forms.umd.js",
7
7
  "module": "./dist/sawabona-forms.es.js",