@hook-sdk/template 0.4.0 → 0.4.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.
- package/dist/index.cjs +398 -356
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +362 -320
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ __export(index_exports, {
|
|
|
55
55
|
module.exports = __toCommonJS(index_exports);
|
|
56
56
|
|
|
57
57
|
// src/AppRoot.tsx
|
|
58
|
-
var
|
|
58
|
+
var import_react15 = require("react");
|
|
59
59
|
var import_sdk9 = require("@hook-sdk/sdk");
|
|
60
60
|
|
|
61
61
|
// src/internal/TemplateConfigContext.tsx
|
|
@@ -221,7 +221,7 @@ function PushPrompt() {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
// src/components/InstallGate/InstallGate.tsx
|
|
224
|
-
var
|
|
224
|
+
var import_react7 = require("react");
|
|
225
225
|
|
|
226
226
|
// src/hooks/useInstallPrompt.ts
|
|
227
227
|
var import_react5 = require("react");
|
|
@@ -458,15 +458,6 @@ function useInstallPrompt(slug) {
|
|
|
458
458
|
setIsDismissedPermanent(true);
|
|
459
459
|
track("pwa_install_permanent_dismiss", { slug, platform, prior_skip_count: skipCount });
|
|
460
460
|
}, [slug, platform, skipCount]);
|
|
461
|
-
const redirectToSafari = (0, import_react5.useCallback)(() => {
|
|
462
|
-
if (typeof location === "undefined") return;
|
|
463
|
-
track("pwa_install_redirect_to_safari", { slug });
|
|
464
|
-
const url = `safari-https://${location.host}${location.pathname}${location.search}${location.hash}`;
|
|
465
|
-
try {
|
|
466
|
-
window.location.href = url;
|
|
467
|
-
} catch {
|
|
468
|
-
}
|
|
469
|
-
}, [slug]);
|
|
470
461
|
const copyLink = (0, import_react5.useCallback)(async () => {
|
|
471
462
|
if (typeof navigator === "undefined" || typeof location === "undefined") return;
|
|
472
463
|
try {
|
|
@@ -505,7 +496,6 @@ function useInstallPrompt(slug) {
|
|
|
505
496
|
promptInstall,
|
|
506
497
|
dismissSession,
|
|
507
498
|
dismissPermanent,
|
|
508
|
-
redirectToSafari,
|
|
509
499
|
copyLink,
|
|
510
500
|
reset
|
|
511
501
|
};
|
|
@@ -565,12 +555,21 @@ var INSTALL_COPY = {
|
|
|
565
555
|
skipPermanent: "N\xE3o me pergunte mais"
|
|
566
556
|
},
|
|
567
557
|
iosOther: {
|
|
568
|
-
title: "
|
|
569
|
-
subtitle: "
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
558
|
+
title: "Adicione \xE0 sua Tela de In\xEDcio",
|
|
559
|
+
subtitle: "Siga os 3 passos",
|
|
560
|
+
step1: {
|
|
561
|
+
title: "Toque em Compartilhar",
|
|
562
|
+
subtitle: "Geralmente no topo ou no menu do navegador"
|
|
563
|
+
},
|
|
564
|
+
step2: {
|
|
565
|
+
title: 'Role e toque em "Adicionar \xE0 Tela de In\xEDcio"',
|
|
566
|
+
iconLabel: "Adicionar \xE0 Tela de In\xEDcio"
|
|
567
|
+
},
|
|
568
|
+
step3: {
|
|
569
|
+
title: 'Toque em "Adicionar" pra confirmar',
|
|
570
|
+
buttonLabel: "Adicionar"
|
|
571
|
+
},
|
|
572
|
+
skip: "Continuar no navegador",
|
|
574
573
|
skipPermanent: "N\xE3o me pergunte mais"
|
|
575
574
|
},
|
|
576
575
|
inApp: {
|
|
@@ -706,18 +705,6 @@ var primaryButtonStyle = {
|
|
|
706
705
|
cursor: "pointer",
|
|
707
706
|
marginBottom: 12
|
|
708
707
|
};
|
|
709
|
-
var secondaryButtonStyle = {
|
|
710
|
-
width: "100%",
|
|
711
|
-
padding: "12px 20px",
|
|
712
|
-
background: "transparent",
|
|
713
|
-
color: "var(--hook-color-primary)",
|
|
714
|
-
border: "1px solid var(--hook-color-primary)",
|
|
715
|
-
borderRadius: 999,
|
|
716
|
-
fontSize: 15,
|
|
717
|
-
fontWeight: 500,
|
|
718
|
-
cursor: "pointer",
|
|
719
|
-
marginBottom: 12
|
|
720
|
-
};
|
|
721
708
|
var skipLinkStyle = {
|
|
722
709
|
display: "block",
|
|
723
710
|
width: "100%",
|
|
@@ -964,22 +951,70 @@ function Step({ n, icon, children }) {
|
|
|
964
951
|
);
|
|
965
952
|
}
|
|
966
953
|
|
|
967
|
-
// src/components/InstallGate/
|
|
954
|
+
// src/components/InstallGate/Step.tsx
|
|
968
955
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
956
|
+
function Step2({
|
|
957
|
+
n,
|
|
958
|
+
title,
|
|
959
|
+
subtitle,
|
|
960
|
+
visual
|
|
961
|
+
}) {
|
|
962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
963
|
+
"div",
|
|
964
|
+
{
|
|
965
|
+
style: {
|
|
966
|
+
display: "flex",
|
|
967
|
+
alignItems: "flex-start",
|
|
968
|
+
gap: 12,
|
|
969
|
+
marginBottom: 16,
|
|
970
|
+
textAlign: "left"
|
|
971
|
+
},
|
|
972
|
+
children: [
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
974
|
+
"div",
|
|
975
|
+
{
|
|
976
|
+
style: {
|
|
977
|
+
width: 32,
|
|
978
|
+
height: 32,
|
|
979
|
+
borderRadius: 10,
|
|
980
|
+
background: "var(--hook-color-primary)",
|
|
981
|
+
color: "#fff",
|
|
982
|
+
display: "flex",
|
|
983
|
+
alignItems: "center",
|
|
984
|
+
justifyContent: "center",
|
|
985
|
+
fontSize: 15,
|
|
986
|
+
fontWeight: 700,
|
|
987
|
+
flexShrink: 0
|
|
988
|
+
},
|
|
989
|
+
children: n
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { flex: 1 }, children: [
|
|
993
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: { margin: 0, fontSize: 15, fontWeight: 500, color: "#111", lineHeight: 1.3 }, children: title }),
|
|
994
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: { margin: "4px 0 0 0", fontSize: 13, color: "#777" }, children: subtitle }),
|
|
995
|
+
visual
|
|
996
|
+
] })
|
|
997
|
+
]
|
|
998
|
+
}
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// src/components/InstallGate/variants/IOSafariVariant.tsx
|
|
1003
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
969
1004
|
function IOSafariVariant({
|
|
970
1005
|
state,
|
|
971
1006
|
actions
|
|
972
1007
|
}) {
|
|
973
1008
|
const copy = INSTALL_COPY.iosSafari;
|
|
974
1009
|
const showPermanent = shouldShowPermanentOption(state);
|
|
975
|
-
return /* @__PURE__ */ (0,
|
|
976
|
-
/* @__PURE__ */ (0,
|
|
1010
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(InstallSplash, { title: copy.title, subtitle: copy.subtitle, children: [
|
|
1011
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
977
1012
|
Step2,
|
|
978
1013
|
{
|
|
979
1014
|
n: 1,
|
|
980
1015
|
title: copy.step1.title,
|
|
981
1016
|
subtitle: copy.step1.subtitle,
|
|
982
|
-
visual: /* @__PURE__ */ (0,
|
|
1017
|
+
visual: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
983
1018
|
"div",
|
|
984
1019
|
{
|
|
985
1020
|
style: {
|
|
@@ -991,17 +1026,17 @@ function IOSafariVariant({
|
|
|
991
1026
|
padding: "12px 0",
|
|
992
1027
|
marginTop: 8
|
|
993
1028
|
},
|
|
994
|
-
children: /* @__PURE__ */ (0,
|
|
1029
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ShareIconIOS, { size: 32, style: { color: "var(--hook-color-primary)" } })
|
|
995
1030
|
}
|
|
996
1031
|
)
|
|
997
1032
|
}
|
|
998
1033
|
),
|
|
999
|
-
/* @__PURE__ */ (0,
|
|
1034
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1000
1035
|
Step2,
|
|
1001
1036
|
{
|
|
1002
1037
|
n: 2,
|
|
1003
1038
|
title: copy.step2.title,
|
|
1004
|
-
visual: /* @__PURE__ */ (0,
|
|
1039
|
+
visual: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1005
1040
|
"div",
|
|
1006
1041
|
{
|
|
1007
1042
|
style: {
|
|
@@ -1014,19 +1049,19 @@ function IOSafariVariant({
|
|
|
1014
1049
|
marginTop: 8
|
|
1015
1050
|
},
|
|
1016
1051
|
children: [
|
|
1017
|
-
/* @__PURE__ */ (0,
|
|
1018
|
-
/* @__PURE__ */ (0,
|
|
1052
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SquarePlusIcon, { size: 22, style: { color: "#555" } }),
|
|
1053
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { fontSize: 14, color: "#333" }, children: copy.step2.iconLabel })
|
|
1019
1054
|
]
|
|
1020
1055
|
}
|
|
1021
1056
|
)
|
|
1022
1057
|
}
|
|
1023
1058
|
),
|
|
1024
|
-
/* @__PURE__ */ (0,
|
|
1059
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1025
1060
|
Step2,
|
|
1026
1061
|
{
|
|
1027
1062
|
n: 3,
|
|
1028
1063
|
title: copy.step3.title,
|
|
1029
|
-
visual: /* @__PURE__ */ (0,
|
|
1064
|
+
visual: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1030
1065
|
"div",
|
|
1031
1066
|
{
|
|
1032
1067
|
style: {
|
|
@@ -1037,7 +1072,7 @@ function IOSafariVariant({
|
|
|
1037
1072
|
padding: "10px 14px",
|
|
1038
1073
|
marginTop: 8
|
|
1039
1074
|
},
|
|
1040
|
-
children: /* @__PURE__ */ (0,
|
|
1075
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1041
1076
|
"span",
|
|
1042
1077
|
{
|
|
1043
1078
|
style: {
|
|
@@ -1052,7 +1087,7 @@ function IOSafariVariant({
|
|
|
1052
1087
|
)
|
|
1053
1088
|
}
|
|
1054
1089
|
),
|
|
1055
|
-
/* @__PURE__ */ (0,
|
|
1090
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1056
1091
|
"button",
|
|
1057
1092
|
{
|
|
1058
1093
|
"data-testid": "install-prompt-skip-session",
|
|
@@ -1062,7 +1097,7 @@ function IOSafariVariant({
|
|
|
1062
1097
|
children: copy.skip
|
|
1063
1098
|
}
|
|
1064
1099
|
),
|
|
1065
|
-
showPermanent && /* @__PURE__ */ (0,
|
|
1100
|
+
showPermanent && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1066
1101
|
"button",
|
|
1067
1102
|
{
|
|
1068
1103
|
"data-testid": "install-prompt-skip-permanent",
|
|
@@ -1074,99 +1109,106 @@ function IOSafariVariant({
|
|
|
1074
1109
|
)
|
|
1075
1110
|
] });
|
|
1076
1111
|
}
|
|
1077
|
-
function Step2({
|
|
1078
|
-
n,
|
|
1079
|
-
title,
|
|
1080
|
-
subtitle,
|
|
1081
|
-
visual
|
|
1082
|
-
}) {
|
|
1083
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1084
|
-
"div",
|
|
1085
|
-
{
|
|
1086
|
-
style: {
|
|
1087
|
-
display: "flex",
|
|
1088
|
-
alignItems: "flex-start",
|
|
1089
|
-
gap: 12,
|
|
1090
|
-
marginBottom: 16,
|
|
1091
|
-
textAlign: "left"
|
|
1092
|
-
},
|
|
1093
|
-
children: [
|
|
1094
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1095
|
-
"div",
|
|
1096
|
-
{
|
|
1097
|
-
style: {
|
|
1098
|
-
width: 32,
|
|
1099
|
-
height: 32,
|
|
1100
|
-
borderRadius: 10,
|
|
1101
|
-
background: "var(--hook-color-primary)",
|
|
1102
|
-
color: "#fff",
|
|
1103
|
-
display: "flex",
|
|
1104
|
-
alignItems: "center",
|
|
1105
|
-
justifyContent: "center",
|
|
1106
|
-
fontSize: 15,
|
|
1107
|
-
fontWeight: 700,
|
|
1108
|
-
flexShrink: 0
|
|
1109
|
-
},
|
|
1110
|
-
children: n
|
|
1111
|
-
}
|
|
1112
|
-
),
|
|
1113
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { flex: 1 }, children: [
|
|
1114
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: { margin: 0, fontSize: 15, fontWeight: 500, color: "#111", lineHeight: 1.3 }, children: title }),
|
|
1115
|
-
subtitle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: { margin: "4px 0 0 0", fontSize: 13, color: "#777" }, children: subtitle }),
|
|
1116
|
-
visual
|
|
1117
|
-
] })
|
|
1118
|
-
]
|
|
1119
|
-
}
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
1112
|
|
|
1123
1113
|
// src/components/InstallGate/variants/IOSOtherVariant.tsx
|
|
1124
|
-
var
|
|
1125
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1114
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1126
1115
|
function IOSOtherVariant({
|
|
1127
1116
|
state,
|
|
1128
1117
|
actions
|
|
1129
1118
|
}) {
|
|
1130
1119
|
const copy = INSTALL_COPY.iosOther;
|
|
1131
1120
|
const showPermanent = shouldShowPermanentOption(state);
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
setCopied(true);
|
|
1136
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1137
|
-
};
|
|
1138
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(InstallSplash, { title: copy.title, subtitle: copy.subtitle, children: [
|
|
1139
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1140
|
-
"button",
|
|
1121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(InstallSplash, { title: copy.title, subtitle: copy.subtitle, children: [
|
|
1122
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1123
|
+
Step2,
|
|
1141
1124
|
{
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1125
|
+
n: 1,
|
|
1126
|
+
title: copy.step1.title,
|
|
1127
|
+
subtitle: copy.step1.subtitle,
|
|
1128
|
+
visual: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1129
|
+
"div",
|
|
1130
|
+
{
|
|
1131
|
+
style: {
|
|
1132
|
+
display: "flex",
|
|
1133
|
+
justifyContent: "center",
|
|
1134
|
+
alignItems: "center",
|
|
1135
|
+
background: "#f5f5f7",
|
|
1136
|
+
borderRadius: 12,
|
|
1137
|
+
padding: "12px 0",
|
|
1138
|
+
marginTop: 8
|
|
1139
|
+
},
|
|
1140
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ShareIconIOS, { size: 32, style: { color: "var(--hook-color-primary)" } })
|
|
1141
|
+
}
|
|
1142
|
+
)
|
|
1147
1143
|
}
|
|
1148
1144
|
),
|
|
1149
|
-
/* @__PURE__ */ (0,
|
|
1150
|
-
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1146
|
+
Step2,
|
|
1151
1147
|
{
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1148
|
+
n: 2,
|
|
1149
|
+
title: copy.step2.title,
|
|
1150
|
+
visual: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1151
|
+
"div",
|
|
1152
|
+
{
|
|
1153
|
+
style: {
|
|
1154
|
+
display: "flex",
|
|
1155
|
+
alignItems: "center",
|
|
1156
|
+
gap: 10,
|
|
1157
|
+
background: "#f5f5f7",
|
|
1158
|
+
borderRadius: 12,
|
|
1159
|
+
padding: "12px 14px",
|
|
1160
|
+
marginTop: 8
|
|
1161
|
+
},
|
|
1162
|
+
children: [
|
|
1163
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SquarePlusIcon, { size: 22, style: { color: "#555" } }),
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: { fontSize: 14, color: "#333" }, children: copy.step2.iconLabel })
|
|
1165
|
+
]
|
|
1166
|
+
}
|
|
1167
|
+
)
|
|
1157
1168
|
}
|
|
1158
1169
|
),
|
|
1159
|
-
/* @__PURE__ */ (0,
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1171
|
+
Step2,
|
|
1172
|
+
{
|
|
1173
|
+
n: 3,
|
|
1174
|
+
title: copy.step3.title,
|
|
1175
|
+
visual: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1176
|
+
"div",
|
|
1177
|
+
{
|
|
1178
|
+
style: {
|
|
1179
|
+
display: "flex",
|
|
1180
|
+
justifyContent: "flex-end",
|
|
1181
|
+
background: "#f5f5f7",
|
|
1182
|
+
borderRadius: 12,
|
|
1183
|
+
padding: "10px 14px",
|
|
1184
|
+
marginTop: 8
|
|
1185
|
+
},
|
|
1186
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1187
|
+
"span",
|
|
1188
|
+
{
|
|
1189
|
+
style: {
|
|
1190
|
+
color: "var(--hook-color-primary)",
|
|
1191
|
+
fontSize: 15,
|
|
1192
|
+
fontWeight: 600
|
|
1193
|
+
},
|
|
1194
|
+
children: copy.step3.buttonLabel
|
|
1195
|
+
}
|
|
1196
|
+
)
|
|
1197
|
+
}
|
|
1198
|
+
)
|
|
1199
|
+
}
|
|
1200
|
+
),
|
|
1201
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1160
1202
|
"button",
|
|
1161
1203
|
{
|
|
1162
1204
|
"data-testid": "install-prompt-skip-session",
|
|
1163
1205
|
type: "button",
|
|
1164
1206
|
onClick: actions.dismissSession,
|
|
1165
|
-
style: skipLinkStyle,
|
|
1207
|
+
style: { ...skipLinkStyle, marginTop: 16 },
|
|
1166
1208
|
children: copy.skip
|
|
1167
1209
|
}
|
|
1168
1210
|
),
|
|
1169
|
-
showPermanent && /* @__PURE__ */ (0,
|
|
1211
|
+
showPermanent && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1170
1212
|
"button",
|
|
1171
1213
|
{
|
|
1172
1214
|
"data-testid": "install-prompt-skip-permanent",
|
|
@@ -1180,8 +1222,8 @@ function IOSOtherVariant({
|
|
|
1180
1222
|
}
|
|
1181
1223
|
|
|
1182
1224
|
// src/components/InstallGate/variants/InAppBrowserVariant.tsx
|
|
1183
|
-
var
|
|
1184
|
-
var
|
|
1225
|
+
var import_react6 = require("react");
|
|
1226
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1185
1227
|
function InAppBrowserVariant({
|
|
1186
1228
|
state,
|
|
1187
1229
|
actions
|
|
@@ -1190,17 +1232,17 @@ function InAppBrowserVariant({
|
|
|
1190
1232
|
const appCopy = INSTALL_COPY.inApp[app] ?? INSTALL_COPY.inApp.other;
|
|
1191
1233
|
const copy = INSTALL_COPY.inApp;
|
|
1192
1234
|
const showPermanent = shouldShowPermanentOption(state);
|
|
1193
|
-
const [copied, setCopied] = (0,
|
|
1235
|
+
const [copied, setCopied] = (0, import_react6.useState)(false);
|
|
1194
1236
|
const handleCopy = async () => {
|
|
1195
1237
|
await actions.copyLink();
|
|
1196
1238
|
setCopied(true);
|
|
1197
1239
|
setTimeout(() => setCopied(false), 2e3);
|
|
1198
1240
|
};
|
|
1199
1241
|
const DotsIcon = app === "facebook" || app === "telegram" ? MenuDotsVerticalIcon : MenuDotsHorizontalIcon;
|
|
1200
|
-
return /* @__PURE__ */ (0,
|
|
1201
|
-
/* @__PURE__ */ (0,
|
|
1202
|
-
/* @__PURE__ */ (0,
|
|
1203
|
-
/* @__PURE__ */ (0,
|
|
1242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(InstallSplash, { title: appCopy.title, children: [
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Step3, { n: 1, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DotsIcon, { size: 20 }), children: appCopy.step1 }),
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Step3, { n: 2, icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ExternalLinkIcon, { size: 18 }), children: appCopy.step2 }),
|
|
1245
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1204
1246
|
"button",
|
|
1205
1247
|
{
|
|
1206
1248
|
"data-testid": "install-prompt-cta-inapp-copy",
|
|
@@ -1210,7 +1252,7 @@ function InAppBrowserVariant({
|
|
|
1210
1252
|
children: copied ? copy.copiedToast : copy.copy
|
|
1211
1253
|
}
|
|
1212
1254
|
),
|
|
1213
|
-
/* @__PURE__ */ (0,
|
|
1255
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1214
1256
|
"button",
|
|
1215
1257
|
{
|
|
1216
1258
|
"data-testid": "install-prompt-skip-session",
|
|
@@ -1220,7 +1262,7 @@ function InAppBrowserVariant({
|
|
|
1220
1262
|
children: copy.skip
|
|
1221
1263
|
}
|
|
1222
1264
|
),
|
|
1223
|
-
showPermanent && /* @__PURE__ */ (0,
|
|
1265
|
+
showPermanent && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1224
1266
|
"button",
|
|
1225
1267
|
{
|
|
1226
1268
|
"data-testid": "install-prompt-skip-permanent",
|
|
@@ -1237,7 +1279,7 @@ function Step3({
|
|
|
1237
1279
|
icon,
|
|
1238
1280
|
children
|
|
1239
1281
|
}) {
|
|
1240
|
-
return /* @__PURE__ */ (0,
|
|
1282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1241
1283
|
"div",
|
|
1242
1284
|
{
|
|
1243
1285
|
style: {
|
|
@@ -1251,7 +1293,7 @@ function Step3({
|
|
|
1251
1293
|
textAlign: "left"
|
|
1252
1294
|
},
|
|
1253
1295
|
children: [
|
|
1254
|
-
/* @__PURE__ */ (0,
|
|
1296
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1255
1297
|
"div",
|
|
1256
1298
|
{
|
|
1257
1299
|
style: {
|
|
@@ -1270,15 +1312,15 @@ function Step3({
|
|
|
1270
1312
|
children: n
|
|
1271
1313
|
}
|
|
1272
1314
|
),
|
|
1273
|
-
/* @__PURE__ */ (0,
|
|
1274
|
-
/* @__PURE__ */ (0,
|
|
1315
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { flex: 1, fontSize: 14, color: "#333" }, children }),
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { color: "#888", flexShrink: 0 }, children: icon })
|
|
1275
1317
|
]
|
|
1276
1318
|
}
|
|
1277
1319
|
);
|
|
1278
1320
|
}
|
|
1279
1321
|
|
|
1280
1322
|
// src/components/InstallGate/variants/DesktopVariant.tsx
|
|
1281
|
-
var
|
|
1323
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1282
1324
|
function DesktopVariant({
|
|
1283
1325
|
state,
|
|
1284
1326
|
actions
|
|
@@ -1287,21 +1329,21 @@ function DesktopVariant({
|
|
|
1287
1329
|
const copy = INSTALL_COPY.desktop;
|
|
1288
1330
|
const iconUrl = theme.icon_url || theme.logo_url || null;
|
|
1289
1331
|
if (!state.isInstallable) return null;
|
|
1290
|
-
return /* @__PURE__ */ (0,
|
|
1332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1291
1333
|
"div",
|
|
1292
1334
|
{
|
|
1293
1335
|
role: "complementary",
|
|
1294
1336
|
"aria-label": copy.title,
|
|
1295
1337
|
style: bannerStyle,
|
|
1296
1338
|
children: [
|
|
1297
|
-
iconUrl ? /* @__PURE__ */ (0,
|
|
1339
|
+
iconUrl ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1298
1340
|
"img",
|
|
1299
1341
|
{
|
|
1300
1342
|
src: iconUrl,
|
|
1301
1343
|
alt: "",
|
|
1302
1344
|
style: { width: 40, height: 40, borderRadius: 10, objectFit: "cover", flexShrink: 0 }
|
|
1303
1345
|
}
|
|
1304
|
-
) : /* @__PURE__ */ (0,
|
|
1346
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1305
1347
|
"div",
|
|
1306
1348
|
{
|
|
1307
1349
|
style: {
|
|
@@ -1320,11 +1362,11 @@ function DesktopVariant({
|
|
|
1320
1362
|
children: name.charAt(0).toUpperCase()
|
|
1321
1363
|
}
|
|
1322
1364
|
),
|
|
1323
|
-
/* @__PURE__ */ (0,
|
|
1324
|
-
/* @__PURE__ */ (0,
|
|
1325
|
-
/* @__PURE__ */ (0,
|
|
1365
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
1366
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { fontSize: 14, fontWeight: 600, color: "#111" }, children: copy.title }),
|
|
1367
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { fontSize: 12, color: "#666" }, children: copy.subtitle })
|
|
1326
1368
|
] }),
|
|
1327
|
-
/* @__PURE__ */ (0,
|
|
1369
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1328
1370
|
"button",
|
|
1329
1371
|
{
|
|
1330
1372
|
"data-testid": "install-prompt-cta-desktop",
|
|
@@ -1345,12 +1387,12 @@ function DesktopVariant({
|
|
|
1345
1387
|
flexShrink: 0
|
|
1346
1388
|
},
|
|
1347
1389
|
children: [
|
|
1348
|
-
/* @__PURE__ */ (0,
|
|
1390
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DownloadIcon, { size: 14 }),
|
|
1349
1391
|
copy.cta
|
|
1350
1392
|
]
|
|
1351
1393
|
}
|
|
1352
1394
|
),
|
|
1353
|
-
/* @__PURE__ */ (0,
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1354
1396
|
"button",
|
|
1355
1397
|
{
|
|
1356
1398
|
"data-testid": "install-prompt-desktop-close",
|
|
@@ -1365,7 +1407,7 @@ function DesktopVariant({
|
|
|
1365
1407
|
padding: 4,
|
|
1366
1408
|
flexShrink: 0
|
|
1367
1409
|
},
|
|
1368
|
-
children: /* @__PURE__ */ (0,
|
|
1410
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(XIcon, { size: 16 })
|
|
1369
1411
|
}
|
|
1370
1412
|
)
|
|
1371
1413
|
]
|
|
@@ -1389,14 +1431,14 @@ var bannerStyle = {
|
|
|
1389
1431
|
};
|
|
1390
1432
|
|
|
1391
1433
|
// src/components/InstallGate/InstallGate.tsx
|
|
1392
|
-
var
|
|
1434
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1393
1435
|
function InstallGate({ children }) {
|
|
1394
1436
|
const { slug, features_enabled } = useTemplateConfig();
|
|
1395
1437
|
const enabled = features_enabled.includes("install_prompt");
|
|
1396
1438
|
const installState = useInstallPrompt(slug);
|
|
1397
1439
|
const shouldBlock = enabled && shouldBlockInstall(installState);
|
|
1398
|
-
const trackedRef = (0,
|
|
1399
|
-
(0,
|
|
1440
|
+
const trackedRef = (0, import_react7.useRef)(null);
|
|
1441
|
+
(0, import_react7.useEffect)(() => {
|
|
1400
1442
|
if (!shouldBlock) return;
|
|
1401
1443
|
if (typeof window === "undefined") return;
|
|
1402
1444
|
const variantKey = `${slug}:${installState.variant}`;
|
|
@@ -1410,36 +1452,36 @@ function InstallGate({ children }) {
|
|
|
1410
1452
|
variant: installState.variant
|
|
1411
1453
|
});
|
|
1412
1454
|
}, [shouldBlock, slug, installState.variant, installState.platform, installState.iosBrowser, installState.androidBrowser, installState.inAppApp]);
|
|
1413
|
-
if (!enabled) return /* @__PURE__ */ (0,
|
|
1414
|
-
if (installState.isInstalled) return /* @__PURE__ */ (0,
|
|
1455
|
+
if (!enabled) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
|
|
1456
|
+
if (installState.isInstalled) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
|
|
1415
1457
|
if (installState.variant === "desktop") {
|
|
1416
|
-
return /* @__PURE__ */ (0,
|
|
1458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1417
1459
|
children,
|
|
1418
|
-
/* @__PURE__ */ (0,
|
|
1460
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DesktopVariant, { state: installState, actions: installState })
|
|
1419
1461
|
] });
|
|
1420
1462
|
}
|
|
1421
|
-
if (!shouldBlock) return /* @__PURE__ */ (0,
|
|
1463
|
+
if (!shouldBlock) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
|
|
1422
1464
|
switch (installState.variant) {
|
|
1423
1465
|
case "android-native":
|
|
1424
|
-
return /* @__PURE__ */ (0,
|
|
1466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AndroidNativeVariant, { state: installState, actions: installState });
|
|
1425
1467
|
case "android-manual":
|
|
1426
|
-
return /* @__PURE__ */ (0,
|
|
1468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AndroidManualVariant, { state: installState, actions: installState });
|
|
1427
1469
|
case "ios-safari":
|
|
1428
|
-
return /* @__PURE__ */ (0,
|
|
1470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(IOSafariVariant, { state: installState, actions: installState });
|
|
1429
1471
|
case "ios-other":
|
|
1430
|
-
return /* @__PURE__ */ (0,
|
|
1472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(IOSOtherVariant, { state: installState, actions: installState });
|
|
1431
1473
|
case "in-app":
|
|
1432
|
-
return /* @__PURE__ */ (0,
|
|
1474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InAppBrowserVariant, { state: installState, actions: installState });
|
|
1433
1475
|
case "none":
|
|
1434
1476
|
default:
|
|
1435
|
-
return /* @__PURE__ */ (0,
|
|
1477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
|
|
1436
1478
|
}
|
|
1437
1479
|
}
|
|
1438
1480
|
|
|
1439
1481
|
// src/defaults/ErrorBoundary.tsx
|
|
1440
|
-
var
|
|
1441
|
-
var
|
|
1442
|
-
var ErrorBoundary = class extends
|
|
1482
|
+
var import_react8 = require("react");
|
|
1483
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1484
|
+
var ErrorBoundary = class extends import_react8.Component {
|
|
1443
1485
|
state = { error: null };
|
|
1444
1486
|
static getDerivedStateFromError(error) {
|
|
1445
1487
|
return { error };
|
|
@@ -1449,17 +1491,17 @@ var ErrorBoundary = class extends import_react9.Component {
|
|
|
1449
1491
|
}
|
|
1450
1492
|
render() {
|
|
1451
1493
|
if (this.state.error) {
|
|
1452
|
-
return this.props.fallback ?? /* @__PURE__ */ (0,
|
|
1453
|
-
/* @__PURE__ */ (0,
|
|
1454
|
-
/* @__PURE__ */ (0,
|
|
1494
|
+
return this.props.fallback ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { role: "alert", style: { padding: 24, textAlign: "center" }, children: [
|
|
1495
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h2", { children: "Algo deu errado" }),
|
|
1496
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { style: { opacity: 0.7 }, children: "Recarregue a p\xE1gina pra tentar de novo." })
|
|
1455
1497
|
] });
|
|
1456
1498
|
}
|
|
1457
|
-
return /* @__PURE__ */ (0,
|
|
1499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: this.props.children });
|
|
1458
1500
|
}
|
|
1459
1501
|
};
|
|
1460
1502
|
|
|
1461
1503
|
// src/hooks/useLoginForm.ts
|
|
1462
|
-
var
|
|
1504
|
+
var import_react9 = require("react");
|
|
1463
1505
|
var import_sdk5 = require("@hook-sdk/sdk");
|
|
1464
1506
|
|
|
1465
1507
|
// src/errors.ts
|
|
@@ -1496,22 +1538,22 @@ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
|
1496
1538
|
var MIN_PASSWORD = 8;
|
|
1497
1539
|
function useLoginForm() {
|
|
1498
1540
|
const { auth } = (0, import_sdk5.useHook)();
|
|
1499
|
-
const [email, setEmail] = (0,
|
|
1500
|
-
const [password, setPassword] = (0,
|
|
1501
|
-
const [submitting, setSubmitting] = (0,
|
|
1502
|
-
const [error, setError] = (0,
|
|
1503
|
-
const emailError = (0,
|
|
1541
|
+
const [email, setEmail] = (0, import_react9.useState)("");
|
|
1542
|
+
const [password, setPassword] = (0, import_react9.useState)("");
|
|
1543
|
+
const [submitting, setSubmitting] = (0, import_react9.useState)(false);
|
|
1544
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1545
|
+
const emailError = (0, import_react9.useMemo)(() => {
|
|
1504
1546
|
if (email.length === 0) return null;
|
|
1505
1547
|
if (!EMAIL_RE.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
1506
1548
|
return null;
|
|
1507
1549
|
}, [email]);
|
|
1508
|
-
const passwordError = (0,
|
|
1550
|
+
const passwordError = (0, import_react9.useMemo)(() => {
|
|
1509
1551
|
if (password.length === 0) return null;
|
|
1510
1552
|
if (password.length < MIN_PASSWORD) return `M\xEDnimo de ${MIN_PASSWORD} caracteres.`;
|
|
1511
1553
|
return null;
|
|
1512
1554
|
}, [password]);
|
|
1513
1555
|
const canSubmit = email.length > 0 && password.length >= MIN_PASSWORD && emailError === null && passwordError === null && !submitting;
|
|
1514
|
-
const submit = (0,
|
|
1556
|
+
const submit = (0, import_react9.useCallback)(async () => {
|
|
1515
1557
|
if (!canSubmit) return false;
|
|
1516
1558
|
setSubmitting(true);
|
|
1517
1559
|
setError(null);
|
|
@@ -1541,13 +1583,13 @@ function useLoginForm() {
|
|
|
1541
1583
|
}
|
|
1542
1584
|
|
|
1543
1585
|
// src/internal/GoogleSignInButton.tsx
|
|
1544
|
-
var
|
|
1586
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1545
1587
|
function GoogleSignInButton({
|
|
1546
1588
|
onClick,
|
|
1547
1589
|
testId = "oauth-google",
|
|
1548
1590
|
label = "Continuar com Google"
|
|
1549
1591
|
}) {
|
|
1550
|
-
return /* @__PURE__ */ (0,
|
|
1592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1551
1593
|
"button",
|
|
1552
1594
|
{
|
|
1553
1595
|
"data-testid": testId,
|
|
@@ -1570,36 +1612,36 @@ function GoogleSignInButton({
|
|
|
1570
1612
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
1571
1613
|
},
|
|
1572
1614
|
children: [
|
|
1573
|
-
/* @__PURE__ */ (0,
|
|
1615
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(GoogleGlyph, {}),
|
|
1574
1616
|
label
|
|
1575
1617
|
]
|
|
1576
1618
|
}
|
|
1577
1619
|
);
|
|
1578
1620
|
}
|
|
1579
1621
|
function GoogleGlyph() {
|
|
1580
|
-
return /* @__PURE__ */ (0,
|
|
1581
|
-
/* @__PURE__ */ (0,
|
|
1622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 18 18", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1582
1624
|
"path",
|
|
1583
1625
|
{
|
|
1584
1626
|
d: "M17.64 9.2c0-.637-.057-1.251-.164-1.84H9v3.481h4.844a4.14 4.14 0 0 1-1.796 2.716v2.259h2.908c1.702-1.567 2.684-3.874 2.684-6.615z",
|
|
1585
1627
|
fill: "#4285F4"
|
|
1586
1628
|
}
|
|
1587
1629
|
),
|
|
1588
|
-
/* @__PURE__ */ (0,
|
|
1630
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1589
1631
|
"path",
|
|
1590
1632
|
{
|
|
1591
1633
|
d: "M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18z",
|
|
1592
1634
|
fill: "#34A853"
|
|
1593
1635
|
}
|
|
1594
1636
|
),
|
|
1595
|
-
/* @__PURE__ */ (0,
|
|
1637
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1596
1638
|
"path",
|
|
1597
1639
|
{
|
|
1598
1640
|
d: "M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.996 8.996 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332z",
|
|
1599
1641
|
fill: "#FBBC05"
|
|
1600
1642
|
}
|
|
1601
1643
|
),
|
|
1602
|
-
/* @__PURE__ */ (0,
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1603
1645
|
"path",
|
|
1604
1646
|
{
|
|
1605
1647
|
d: "M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 7.29C4.672 5.163 6.656 3.58 9 3.58z",
|
|
@@ -1610,8 +1652,8 @@ function GoogleGlyph() {
|
|
|
1610
1652
|
}
|
|
1611
1653
|
|
|
1612
1654
|
// src/internal/OAuthErrorBanner.tsx
|
|
1613
|
-
var
|
|
1614
|
-
var
|
|
1655
|
+
var import_react10 = require("react");
|
|
1656
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1615
1657
|
var ERROR_MESSAGES = {
|
|
1616
1658
|
invalid_state: "Sess\xE3o expirou, tente de novo.",
|
|
1617
1659
|
access_denied: "Voc\xEA cancelou o login com Google.",
|
|
@@ -1631,13 +1673,13 @@ function stripErrorFromUrl() {
|
|
|
1631
1673
|
window.history.replaceState({}, "", url.toString());
|
|
1632
1674
|
}
|
|
1633
1675
|
function OAuthErrorBanner() {
|
|
1634
|
-
const [code, setCode] = (0,
|
|
1635
|
-
(0,
|
|
1676
|
+
const [code, setCode] = (0, import_react10.useState)(() => readErrorCode());
|
|
1677
|
+
(0, import_react10.useEffect)(() => {
|
|
1636
1678
|
if (code !== null) stripErrorFromUrl();
|
|
1637
1679
|
}, [code]);
|
|
1638
1680
|
if (!code) return null;
|
|
1639
1681
|
const message = ERROR_MESSAGES[code] ?? "N\xE3o conseguimos conectar ao Google. Tente de novo.";
|
|
1640
|
-
return /* @__PURE__ */ (0,
|
|
1682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1641
1683
|
"div",
|
|
1642
1684
|
{
|
|
1643
1685
|
role: "alert",
|
|
@@ -1652,7 +1694,7 @@ function OAuthErrorBanner() {
|
|
|
1652
1694
|
},
|
|
1653
1695
|
children: [
|
|
1654
1696
|
message,
|
|
1655
|
-
/* @__PURE__ */ (0,
|
|
1697
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1656
1698
|
"button",
|
|
1657
1699
|
{
|
|
1658
1700
|
type: "button",
|
|
@@ -1677,16 +1719,16 @@ function OAuthErrorBanner() {
|
|
|
1677
1719
|
}
|
|
1678
1720
|
|
|
1679
1721
|
// src/defaults/DefaultLoginScreen.tsx
|
|
1680
|
-
var
|
|
1722
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1681
1723
|
function DefaultLoginScreen({ onNavigate }) {
|
|
1682
1724
|
const { name } = useTemplateConfig();
|
|
1683
1725
|
const f = useLoginForm();
|
|
1684
|
-
return /* @__PURE__ */ (0,
|
|
1685
|
-
/* @__PURE__ */ (0,
|
|
1686
|
-
/* @__PURE__ */ (0,
|
|
1687
|
-
/* @__PURE__ */ (0,
|
|
1688
|
-
/* @__PURE__ */ (0,
|
|
1689
|
-
/* @__PURE__ */ (0,
|
|
1726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
1728
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Entre na sua conta" }),
|
|
1729
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(OAuthErrorBanner, {}),
|
|
1730
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(GoogleSignInButton, { onClick: f.loginWithGoogle, testId: "login-oauth-google" }),
|
|
1731
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1690
1732
|
"div",
|
|
1691
1733
|
{
|
|
1692
1734
|
"aria-hidden": "true",
|
|
@@ -1699,19 +1741,19 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
1699
1741
|
fontSize: 12
|
|
1700
1742
|
},
|
|
1701
1743
|
children: [
|
|
1702
|
-
/* @__PURE__ */ (0,
|
|
1744
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } }),
|
|
1703
1745
|
"ou",
|
|
1704
|
-
/* @__PURE__ */ (0,
|
|
1746
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } })
|
|
1705
1747
|
]
|
|
1706
1748
|
}
|
|
1707
1749
|
),
|
|
1708
|
-
/* @__PURE__ */ (0,
|
|
1750
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("form", { onSubmit: (e) => {
|
|
1709
1751
|
e.preventDefault();
|
|
1710
1752
|
void f.submit();
|
|
1711
1753
|
}, children: [
|
|
1712
|
-
/* @__PURE__ */ (0,
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
1713
1755
|
"E-mail",
|
|
1714
|
-
/* @__PURE__ */ (0,
|
|
1756
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1715
1757
|
"input",
|
|
1716
1758
|
{
|
|
1717
1759
|
"data-testid": "login-email",
|
|
@@ -1721,11 +1763,11 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
1721
1763
|
style: { display: "block", width: "100%" }
|
|
1722
1764
|
}
|
|
1723
1765
|
),
|
|
1724
|
-
f.emailError && /* @__PURE__ */ (0,
|
|
1766
|
+
f.emailError && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { style: { color: "#c00" }, children: f.emailError })
|
|
1725
1767
|
] }),
|
|
1726
|
-
/* @__PURE__ */ (0,
|
|
1768
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
1727
1769
|
"Senha",
|
|
1728
|
-
/* @__PURE__ */ (0,
|
|
1770
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1729
1771
|
"input",
|
|
1730
1772
|
{
|
|
1731
1773
|
"data-testid": "login-password",
|
|
@@ -1735,10 +1777,10 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
1735
1777
|
style: { display: "block", width: "100%" }
|
|
1736
1778
|
}
|
|
1737
1779
|
),
|
|
1738
|
-
f.passwordError && /* @__PURE__ */ (0,
|
|
1780
|
+
f.passwordError && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { style: { color: "#c00" }, children: f.passwordError })
|
|
1739
1781
|
] }),
|
|
1740
|
-
f.error && /* @__PURE__ */ (0,
|
|
1741
|
-
/* @__PURE__ */ (0,
|
|
1782
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
1783
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1742
1784
|
"button",
|
|
1743
1785
|
{
|
|
1744
1786
|
"data-testid": "login-submit",
|
|
@@ -1757,42 +1799,42 @@ function DefaultLoginScreen({ onNavigate }) {
|
|
|
1757
1799
|
}
|
|
1758
1800
|
)
|
|
1759
1801
|
] }),
|
|
1760
|
-
/* @__PURE__ */ (0,
|
|
1761
|
-
/* @__PURE__ */ (0,
|
|
1762
|
-
/* @__PURE__ */ (0,
|
|
1802
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { marginTop: 16, display: "flex", justifyContent: "space-between" }, children: [
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { "data-testid": "login-goto-signup", type: "button", onClick: () => onNavigate("signup"), style: { background: "none", border: "none", cursor: "pointer" }, children: "Criar conta" }),
|
|
1804
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { "data-testid": "login-goto-forgot", type: "button", onClick: () => onNavigate("forgot"), style: { background: "none", border: "none", cursor: "pointer" }, children: "Esqueci senha" })
|
|
1763
1805
|
] })
|
|
1764
1806
|
] });
|
|
1765
1807
|
}
|
|
1766
1808
|
|
|
1767
1809
|
// src/hooks/useSignupForm.ts
|
|
1768
|
-
var
|
|
1810
|
+
var import_react11 = require("react");
|
|
1769
1811
|
var import_sdk6 = require("@hook-sdk/sdk");
|
|
1770
1812
|
var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1771
1813
|
var MIN_PASSWORD2 = 8;
|
|
1772
1814
|
function useSignupForm() {
|
|
1773
1815
|
const { auth } = (0, import_sdk6.useHook)();
|
|
1774
|
-
const [name, setName] = (0,
|
|
1775
|
-
const [email, setEmail] = (0,
|
|
1776
|
-
const [password, setPassword] = (0,
|
|
1777
|
-
const [submitting, setSubmitting] = (0,
|
|
1778
|
-
const [error, setError] = (0,
|
|
1779
|
-
const nameError = (0,
|
|
1816
|
+
const [name, setName] = (0, import_react11.useState)("");
|
|
1817
|
+
const [email, setEmail] = (0, import_react11.useState)("");
|
|
1818
|
+
const [password, setPassword] = (0, import_react11.useState)("");
|
|
1819
|
+
const [submitting, setSubmitting] = (0, import_react11.useState)(false);
|
|
1820
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
1821
|
+
const nameError = (0, import_react11.useMemo)(() => {
|
|
1780
1822
|
if (name.length === 0) return null;
|
|
1781
1823
|
if (name.trim().length < 2) return "Nome muito curto.";
|
|
1782
1824
|
return null;
|
|
1783
1825
|
}, [name]);
|
|
1784
|
-
const emailError = (0,
|
|
1826
|
+
const emailError = (0, import_react11.useMemo)(() => {
|
|
1785
1827
|
if (email.length === 0) return null;
|
|
1786
1828
|
if (!EMAIL_RE2.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
1787
1829
|
return null;
|
|
1788
1830
|
}, [email]);
|
|
1789
|
-
const passwordError = (0,
|
|
1831
|
+
const passwordError = (0, import_react11.useMemo)(() => {
|
|
1790
1832
|
if (password.length === 0) return null;
|
|
1791
1833
|
if (password.length < MIN_PASSWORD2) return `M\xEDnimo de ${MIN_PASSWORD2} caracteres.`;
|
|
1792
1834
|
return null;
|
|
1793
1835
|
}, [password]);
|
|
1794
1836
|
const canSubmit = name.trim().length >= 2 && email.length > 0 && password.length >= MIN_PASSWORD2 && nameError === null && emailError === null && passwordError === null && !submitting;
|
|
1795
|
-
const submit = (0,
|
|
1837
|
+
const submit = (0, import_react11.useCallback)(async () => {
|
|
1796
1838
|
if (!canSubmit) return false;
|
|
1797
1839
|
setSubmitting(true);
|
|
1798
1840
|
setError(null);
|
|
@@ -1825,16 +1867,16 @@ function useSignupForm() {
|
|
|
1825
1867
|
}
|
|
1826
1868
|
|
|
1827
1869
|
// src/defaults/DefaultSignupScreen.tsx
|
|
1828
|
-
var
|
|
1870
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1829
1871
|
function DefaultSignupScreen({ onNavigate }) {
|
|
1830
1872
|
const { name } = useTemplateConfig();
|
|
1831
1873
|
const f = useSignupForm();
|
|
1832
|
-
return /* @__PURE__ */ (0,
|
|
1833
|
-
/* @__PURE__ */ (0,
|
|
1834
|
-
/* @__PURE__ */ (0,
|
|
1835
|
-
/* @__PURE__ */ (0,
|
|
1836
|
-
/* @__PURE__ */ (0,
|
|
1837
|
-
/* @__PURE__ */ (0,
|
|
1874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
1876
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Criar sua conta" }),
|
|
1877
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(OAuthErrorBanner, {}),
|
|
1878
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(GoogleSignInButton, { onClick: f.loginWithGoogle, testId: "signup-oauth-google" }),
|
|
1879
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1838
1880
|
"div",
|
|
1839
1881
|
{
|
|
1840
1882
|
"aria-hidden": "true",
|
|
@@ -1847,55 +1889,55 @@ function DefaultSignupScreen({ onNavigate }) {
|
|
|
1847
1889
|
fontSize: 12
|
|
1848
1890
|
},
|
|
1849
1891
|
children: [
|
|
1850
|
-
/* @__PURE__ */ (0,
|
|
1892
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } }),
|
|
1851
1893
|
"ou",
|
|
1852
|
-
/* @__PURE__ */ (0,
|
|
1894
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { flex: 1, height: 1, background: "rgba(0,0,0,0.1)" } })
|
|
1853
1895
|
]
|
|
1854
1896
|
}
|
|
1855
1897
|
),
|
|
1856
|
-
/* @__PURE__ */ (0,
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("form", { onSubmit: (e) => {
|
|
1857
1899
|
e.preventDefault();
|
|
1858
1900
|
void f.submit();
|
|
1859
1901
|
}, children: [
|
|
1860
|
-
/* @__PURE__ */ (0,
|
|
1902
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
1861
1903
|
"Nome",
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
1863
|
-
f.nameError && /* @__PURE__ */ (0,
|
|
1904
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { "data-testid": "signup-name", value: f.name, onChange: (e) => f.setName(e.target.value), style: { display: "block", width: "100%" } }),
|
|
1905
|
+
f.nameError && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("small", { style: { color: "#c00" }, children: f.nameError })
|
|
1864
1906
|
] }),
|
|
1865
|
-
/* @__PURE__ */ (0,
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
1866
1908
|
"E-mail",
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
1868
|
-
f.emailError && /* @__PURE__ */ (0,
|
|
1909
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { "data-testid": "signup-email", type: "email", value: f.email, onChange: (e) => f.setEmail(e.target.value), style: { display: "block", width: "100%" } }),
|
|
1910
|
+
f.emailError && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("small", { style: { color: "#c00" }, children: f.emailError })
|
|
1869
1911
|
] }),
|
|
1870
|
-
/* @__PURE__ */ (0,
|
|
1912
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
1871
1913
|
"Senha",
|
|
1872
|
-
/* @__PURE__ */ (0,
|
|
1873
|
-
f.passwordError && /* @__PURE__ */ (0,
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("input", { "data-testid": "signup-password", type: "password", value: f.password, onChange: (e) => f.setPassword(e.target.value), style: { display: "block", width: "100%" } }),
|
|
1915
|
+
f.passwordError && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("small", { style: { color: "#c00" }, children: f.passwordError })
|
|
1874
1916
|
] }),
|
|
1875
|
-
f.error && /* @__PURE__ */ (0,
|
|
1876
|
-
/* @__PURE__ */ (0,
|
|
1917
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
1918
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { "data-testid": "signup-submit", type: "submit", disabled: !f.canSubmit, style: { width: "100%", padding: 12, background: "var(--hook-color-primary)", color: "#fff", border: "none", borderRadius: 8, opacity: f.canSubmit ? 1 : 0.5 }, children: f.submitting ? "Criando..." : "Criar conta" })
|
|
1877
1919
|
] }),
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
1920
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { "data-testid": "signup-goto-login", type: "button", onClick: () => onNavigate("login"), style: { background: "none", border: "none", cursor: "pointer" }, children: "J\xE1 tem conta? Entre" }) })
|
|
1879
1921
|
] });
|
|
1880
1922
|
}
|
|
1881
1923
|
|
|
1882
1924
|
// src/hooks/useForgotForm.ts
|
|
1883
|
-
var
|
|
1925
|
+
var import_react12 = require("react");
|
|
1884
1926
|
var import_sdk7 = require("@hook-sdk/sdk");
|
|
1885
1927
|
var EMAIL_RE3 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1886
1928
|
function useForgotForm() {
|
|
1887
1929
|
const { auth } = (0, import_sdk7.useHook)();
|
|
1888
|
-
const [email, setEmail] = (0,
|
|
1889
|
-
const [submitting, setSubmitting] = (0,
|
|
1890
|
-
const [sent, setSent] = (0,
|
|
1891
|
-
const [error, setError] = (0,
|
|
1892
|
-
const emailError = (0,
|
|
1930
|
+
const [email, setEmail] = (0, import_react12.useState)("");
|
|
1931
|
+
const [submitting, setSubmitting] = (0, import_react12.useState)(false);
|
|
1932
|
+
const [sent, setSent] = (0, import_react12.useState)(false);
|
|
1933
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
1934
|
+
const emailError = (0, import_react12.useMemo)(() => {
|
|
1893
1935
|
if (email.length === 0) return null;
|
|
1894
1936
|
if (!EMAIL_RE3.test(email)) return "Formato de e-mail inv\xE1lido.";
|
|
1895
1937
|
return null;
|
|
1896
1938
|
}, [email]);
|
|
1897
1939
|
const canSubmit = email.length > 0 && emailError === null && !submitting;
|
|
1898
|
-
const submit = (0,
|
|
1940
|
+
const submit = (0, import_react12.useCallback)(async () => {
|
|
1899
1941
|
if (!canSubmit) return false;
|
|
1900
1942
|
setSubmitting(true);
|
|
1901
1943
|
setError(null);
|
|
@@ -1923,66 +1965,66 @@ function useForgotForm() {
|
|
|
1923
1965
|
}
|
|
1924
1966
|
|
|
1925
1967
|
// src/defaults/DefaultForgotScreen.tsx
|
|
1926
|
-
var
|
|
1968
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1927
1969
|
function DefaultForgotScreen({ onNavigate }) {
|
|
1928
1970
|
const { name } = useTemplateConfig();
|
|
1929
1971
|
const f = useForgotForm();
|
|
1930
1972
|
if (f.sent) {
|
|
1931
|
-
return /* @__PURE__ */ (0,
|
|
1932
|
-
/* @__PURE__ */ (0,
|
|
1933
|
-
/* @__PURE__ */ (0,
|
|
1934
|
-
/* @__PURE__ */ (0,
|
|
1973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto", textAlign: "center" }, children: [
|
|
1974
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h1", { children: "Verifique seu e-mail" }),
|
|
1975
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { style: { opacity: 0.7 }, children: "Enviamos um link pra redefinir sua senha." }),
|
|
1976
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { "data-testid": "forgot-back-login", type: "button", onClick: () => onNavigate("login"), children: "Voltar pro login" })
|
|
1935
1977
|
] });
|
|
1936
1978
|
}
|
|
1937
|
-
return /* @__PURE__ */ (0,
|
|
1938
|
-
/* @__PURE__ */ (0,
|
|
1939
|
-
/* @__PURE__ */ (0,
|
|
1940
|
-
/* @__PURE__ */ (0,
|
|
1979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
1980
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
1981
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Redefinir senha" }),
|
|
1982
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("form", { onSubmit: (e) => {
|
|
1941
1983
|
e.preventDefault();
|
|
1942
1984
|
void f.submit();
|
|
1943
1985
|
}, children: [
|
|
1944
|
-
/* @__PURE__ */ (0,
|
|
1986
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
1945
1987
|
"E-mail",
|
|
1946
|
-
/* @__PURE__ */ (0,
|
|
1947
|
-
f.emailError && /* @__PURE__ */ (0,
|
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { "data-testid": "forgot-email", type: "email", value: f.email, onChange: (e) => f.setEmail(e.target.value), style: { display: "block", width: "100%" } }),
|
|
1989
|
+
f.emailError && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("small", { style: { color: "#c00" }, children: f.emailError })
|
|
1948
1990
|
] }),
|
|
1949
|
-
f.error && /* @__PURE__ */ (0,
|
|
1950
|
-
/* @__PURE__ */ (0,
|
|
1991
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
1992
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { "data-testid": "forgot-submit", type: "submit", disabled: !f.canSubmit, style: { width: "100%", padding: 12, background: "var(--hook-color-primary)", color: "#fff", border: "none", borderRadius: 8, opacity: f.canSubmit ? 1 : 0.5 }, children: f.submitting ? "Enviando..." : "Enviar link" })
|
|
1951
1993
|
] }),
|
|
1952
|
-
/* @__PURE__ */ (0,
|
|
1994
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { "data-testid": "forgot-goto-login", type: "button", onClick: () => onNavigate("login"), style: { background: "none", border: "none", cursor: "pointer" }, children: "Voltar pro login" }) })
|
|
1953
1995
|
] });
|
|
1954
1996
|
}
|
|
1955
1997
|
|
|
1956
1998
|
// src/hooks/useResetForm.ts
|
|
1957
|
-
var
|
|
1999
|
+
var import_react13 = require("react");
|
|
1958
2000
|
var import_sdk8 = require("@hook-sdk/sdk");
|
|
1959
2001
|
var MIN_PASSWORD3 = 12;
|
|
1960
2002
|
function useResetForm() {
|
|
1961
2003
|
const { auth } = (0, import_sdk8.useHook)();
|
|
1962
|
-
const [token, setToken] = (0,
|
|
1963
|
-
const [password, setPassword] = (0,
|
|
1964
|
-
const [confirm, setConfirm] = (0,
|
|
1965
|
-
const [submitting, setSubmitting] = (0,
|
|
1966
|
-
const [done, setDone] = (0,
|
|
1967
|
-
const [error, setError] = (0,
|
|
1968
|
-
(0,
|
|
2004
|
+
const [token, setToken] = (0, import_react13.useState)(null);
|
|
2005
|
+
const [password, setPassword] = (0, import_react13.useState)("");
|
|
2006
|
+
const [confirm, setConfirm] = (0, import_react13.useState)("");
|
|
2007
|
+
const [submitting, setSubmitting] = (0, import_react13.useState)(false);
|
|
2008
|
+
const [done, setDone] = (0, import_react13.useState)(false);
|
|
2009
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
2010
|
+
(0, import_react13.useEffect)(() => {
|
|
1969
2011
|
if (typeof window === "undefined") return;
|
|
1970
2012
|
const params = new URLSearchParams(window.location.search);
|
|
1971
2013
|
const t = params.get("token");
|
|
1972
2014
|
setToken(t && t.length > 0 ? t : null);
|
|
1973
2015
|
}, []);
|
|
1974
|
-
const passwordError = (0,
|
|
2016
|
+
const passwordError = (0, import_react13.useMemo)(() => {
|
|
1975
2017
|
if (password.length === 0) return null;
|
|
1976
2018
|
if (password.length < MIN_PASSWORD3) return `M\xEDnimo de ${MIN_PASSWORD3} caracteres.`;
|
|
1977
2019
|
return null;
|
|
1978
2020
|
}, [password]);
|
|
1979
|
-
const confirmError = (0,
|
|
2021
|
+
const confirmError = (0, import_react13.useMemo)(() => {
|
|
1980
2022
|
if (confirm.length === 0) return null;
|
|
1981
2023
|
if (confirm !== password) return "Senhas n\xE3o coincidem.";
|
|
1982
2024
|
return null;
|
|
1983
2025
|
}, [confirm, password]);
|
|
1984
2026
|
const canSubmit = token !== null && password.length >= MIN_PASSWORD3 && confirm === password && passwordError === null && confirmError === null && !submitting && !done;
|
|
1985
|
-
const submit = (0,
|
|
2027
|
+
const submit = (0, import_react13.useCallback)(async () => {
|
|
1986
2028
|
if (!canSubmit || token === null) return;
|
|
1987
2029
|
setSubmitting(true);
|
|
1988
2030
|
setError(null);
|
|
@@ -2018,67 +2060,67 @@ function useResetForm() {
|
|
|
2018
2060
|
}
|
|
2019
2061
|
|
|
2020
2062
|
// src/defaults/DefaultResetScreen.tsx
|
|
2021
|
-
var
|
|
2063
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2022
2064
|
function DefaultResetScreen({ onNavigate }) {
|
|
2023
2065
|
const { name } = useTemplateConfig();
|
|
2024
2066
|
const f = useResetForm();
|
|
2025
2067
|
if (f.done) {
|
|
2026
|
-
return /* @__PURE__ */ (0,
|
|
2027
|
-
/* @__PURE__ */ (0,
|
|
2028
|
-
/* @__PURE__ */ (0,
|
|
2029
|
-
/* @__PURE__ */ (0,
|
|
2068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto", textAlign: "center" }, children: [
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h1", { children: "Senha alterada" }),
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { style: { opacity: 0.7 }, children: "Agora \xE9 s\xF3 fazer login com a nova senha." }),
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { "data-testid": "reset-back-login", type: "button", onClick: () => onNavigate("login"), children: "Ir pro login" })
|
|
2030
2072
|
] });
|
|
2031
2073
|
}
|
|
2032
2074
|
if (f.token === null) {
|
|
2033
|
-
return /* @__PURE__ */ (0,
|
|
2034
|
-
/* @__PURE__ */ (0,
|
|
2035
|
-
/* @__PURE__ */ (0,
|
|
2036
|
-
/* @__PURE__ */ (0,
|
|
2075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto", textAlign: "center" }, children: [
|
|
2076
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h1", { children: "Link inv\xE1lido" }),
|
|
2077
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { style: { opacity: 0.7 }, children: "Pe\xE7a um novo link de reset." }),
|
|
2078
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { "data-testid": "reset-goto-forgot", type: "button", onClick: () => onNavigate("forgot"), children: "Pedir novo link" })
|
|
2037
2079
|
] });
|
|
2038
2080
|
}
|
|
2039
|
-
return /* @__PURE__ */ (0,
|
|
2040
|
-
/* @__PURE__ */ (0,
|
|
2041
|
-
/* @__PURE__ */ (0,
|
|
2042
|
-
/* @__PURE__ */ (0,
|
|
2081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("main", { style: { padding: 24, maxWidth: 360, margin: "0 auto" }, children: [
|
|
2082
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h1", { style: { marginBottom: 8 }, children: name }),
|
|
2083
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: "Escolha uma nova senha" }),
|
|
2084
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("form", { onSubmit: (e) => {
|
|
2043
2085
|
e.preventDefault();
|
|
2044
2086
|
void f.submit();
|
|
2045
2087
|
}, children: [
|
|
2046
|
-
/* @__PURE__ */ (0,
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
2047
2089
|
"Nova senha",
|
|
2048
|
-
/* @__PURE__ */ (0,
|
|
2049
|
-
f.passwordError && /* @__PURE__ */ (0,
|
|
2090
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { "data-testid": "reset-password", type: "password", value: f.password, onChange: (e) => f.setPassword(e.target.value), style: { display: "block", width: "100%" }, autoComplete: "new-password" }),
|
|
2091
|
+
f.passwordError && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("small", { style: { color: "#c00" }, children: f.passwordError })
|
|
2050
2092
|
] }),
|
|
2051
|
-
/* @__PURE__ */ (0,
|
|
2093
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { style: { display: "block", marginBottom: 12 }, children: [
|
|
2052
2094
|
"Confirmar senha",
|
|
2053
|
-
/* @__PURE__ */ (0,
|
|
2054
|
-
f.confirmError && /* @__PURE__ */ (0,
|
|
2095
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { "data-testid": "reset-confirm", type: "password", value: f.confirm, onChange: (e) => f.setConfirm(e.target.value), style: { display: "block", width: "100%" }, autoComplete: "new-password" }),
|
|
2096
|
+
f.confirmError && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("small", { style: { color: "#c00" }, children: f.confirmError })
|
|
2055
2097
|
] }),
|
|
2056
|
-
f.error && /* @__PURE__ */ (0,
|
|
2057
|
-
/* @__PURE__ */ (0,
|
|
2098
|
+
f.error && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: f.error.message }),
|
|
2099
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { "data-testid": "reset-submit", type: "submit", disabled: !f.canSubmit, style: { width: "100%", padding: 12, background: "var(--hook-color-primary)", color: "#fff", border: "none", borderRadius: 8, opacity: f.canSubmit ? 1 : 0.5 }, children: f.submitting ? "Alterando..." : "Alterar senha" })
|
|
2058
2100
|
] })
|
|
2059
2101
|
] });
|
|
2060
2102
|
}
|
|
2061
2103
|
|
|
2062
2104
|
// src/defaults/DefaultPaywall.tsx
|
|
2063
|
-
var
|
|
2064
|
-
var
|
|
2105
|
+
var import_react14 = require("react");
|
|
2106
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2065
2107
|
function DefaultPaywall() {
|
|
2066
2108
|
const config = useTemplateConfig();
|
|
2067
2109
|
const { checkout, opening, error } = usePaywallState();
|
|
2068
2110
|
const p = config.subscription.paywall_config;
|
|
2069
|
-
const [cpf, setCpf] = (0,
|
|
2111
|
+
const [cpf, setCpf] = (0, import_react14.useState)("");
|
|
2070
2112
|
const cpfDigits = cpf.replace(/\D/g, "");
|
|
2071
2113
|
const canCheckout = cpfDigits.length === 11 && !opening;
|
|
2072
|
-
return /* @__PURE__ */ (0,
|
|
2073
|
-
/* @__PURE__ */ (0,
|
|
2074
|
-
p.subtitle && /* @__PURE__ */ (0,
|
|
2075
|
-
/* @__PURE__ */ (0,
|
|
2076
|
-
/* @__PURE__ */ (0,
|
|
2077
|
-
/* @__PURE__ */ (0,
|
|
2114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("main", { style: { padding: 24, maxWidth: 440, margin: "0 auto", textAlign: "center" }, children: [
|
|
2115
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h1", { style: { marginBottom: 8 }, children: p.title }),
|
|
2116
|
+
p.subtitle && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { style: { opacity: 0.7, marginBottom: 24 }, children: p.subtitle }),
|
|
2117
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("ul", { style: { listStyle: "none", padding: 0, textAlign: "left", marginBottom: 24 }, children: p.benefits.map((b) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("li", { style: { padding: "8px 0", display: "flex", alignItems: "center" }, children: [
|
|
2118
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "aria-hidden": true, style: { marginRight: 8 }, children: "\u2713" }),
|
|
2119
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: b })
|
|
2078
2120
|
] }, b)) }),
|
|
2079
|
-
/* @__PURE__ */ (0,
|
|
2080
|
-
/* @__PURE__ */ (0,
|
|
2081
|
-
/* @__PURE__ */ (0,
|
|
2121
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { style: { textAlign: "left", marginBottom: 16 }, children: [
|
|
2122
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("label", { style: { display: "block", fontSize: 14, opacity: 0.7, marginBottom: 4 }, children: "Seu CPF (pra emiss\xE3o de recibo)" }),
|
|
2123
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2082
2124
|
"input",
|
|
2083
2125
|
{
|
|
2084
2126
|
"data-testid": "paywall-cpf",
|
|
@@ -2091,8 +2133,8 @@ function DefaultPaywall() {
|
|
|
2091
2133
|
}
|
|
2092
2134
|
)
|
|
2093
2135
|
] }),
|
|
2094
|
-
error && /* @__PURE__ */ (0,
|
|
2095
|
-
/* @__PURE__ */ (0,
|
|
2136
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { role: "alert", style: { color: "#c00", marginBottom: 12 }, children: error.message }),
|
|
2137
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2096
2138
|
"button",
|
|
2097
2139
|
{
|
|
2098
2140
|
"data-testid": "paywall-cta",
|
|
@@ -2113,21 +2155,21 @@ function DefaultPaywall() {
|
|
|
2113
2155
|
children: opening ? "Abrindo..." : p.cta
|
|
2114
2156
|
}
|
|
2115
2157
|
),
|
|
2116
|
-
p.priceHint && /* @__PURE__ */ (0,
|
|
2117
|
-
p.footerNote && /* @__PURE__ */ (0,
|
|
2158
|
+
p.priceHint && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { style: { opacity: 0.6, marginTop: 12 }, children: p.priceHint }),
|
|
2159
|
+
p.footerNote && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { style: { opacity: 0.5, marginTop: 16, fontSize: 12 }, children: p.footerNote })
|
|
2118
2160
|
] });
|
|
2119
2161
|
}
|
|
2120
2162
|
|
|
2121
2163
|
// src/AppRoot.tsx
|
|
2122
|
-
var
|
|
2164
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2123
2165
|
var BACKOFF_MS = [2e3, 5e3, 1e4, 2e4, 4e4];
|
|
2124
2166
|
function PaymentReturnHandler({ children }) {
|
|
2125
2167
|
const { subscription } = (0, import_sdk9.useHook)();
|
|
2126
|
-
const subRef = (0,
|
|
2168
|
+
const subRef = (0, import_react15.useRef)(subscription);
|
|
2127
2169
|
subRef.current = subscription;
|
|
2128
|
-
const runIdRef = (0,
|
|
2129
|
-
const [state, setState] = (0,
|
|
2130
|
-
const runPoll = (0,
|
|
2170
|
+
const runIdRef = (0, import_react15.useRef)(0);
|
|
2171
|
+
const [state, setState] = (0, import_react15.useState)("idle");
|
|
2172
|
+
const runPoll = (0, import_react15.useCallback)(() => {
|
|
2131
2173
|
const runId = ++runIdRef.current;
|
|
2132
2174
|
setState("confirming");
|
|
2133
2175
|
let attempts = 0;
|
|
@@ -2156,7 +2198,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
2156
2198
|
};
|
|
2157
2199
|
void tick();
|
|
2158
2200
|
}, []);
|
|
2159
|
-
(0,
|
|
2201
|
+
(0, import_react15.useEffect)(() => {
|
|
2160
2202
|
if (typeof window === "undefined") return;
|
|
2161
2203
|
const url = new URL(window.location.href);
|
|
2162
2204
|
if (url.searchParams.get("paymentReturn") !== "1") return;
|
|
@@ -2166,7 +2208,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
2166
2208
|
};
|
|
2167
2209
|
}, [runPoll]);
|
|
2168
2210
|
if (state === "confirming") {
|
|
2169
|
-
return /* @__PURE__ */ (0,
|
|
2211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2170
2212
|
"div",
|
|
2171
2213
|
{
|
|
2172
2214
|
role: "status",
|
|
@@ -2177,9 +2219,9 @@ function PaymentReturnHandler({ children }) {
|
|
|
2177
2219
|
);
|
|
2178
2220
|
}
|
|
2179
2221
|
if (state === "waiting") {
|
|
2180
|
-
return /* @__PURE__ */ (0,
|
|
2181
|
-
/* @__PURE__ */ (0,
|
|
2182
|
-
/* @__PURE__ */ (0,
|
|
2222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { role: "status", "aria-live": "polite", style: overlayStyle2, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { maxWidth: 320, textAlign: "center", lineHeight: 1.5 }, children: [
|
|
2223
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { style: { marginBottom: 16 }, children: "Pagamento aceito. Estamos confirmando com o banco \u2014 pode levar alguns minutos." }),
|
|
2224
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2183
2225
|
"button",
|
|
2184
2226
|
{
|
|
2185
2227
|
type: "button",
|
|
@@ -2190,7 +2232,7 @@ function PaymentReturnHandler({ children }) {
|
|
|
2190
2232
|
)
|
|
2191
2233
|
] }) });
|
|
2192
2234
|
}
|
|
2193
|
-
return /* @__PURE__ */ (0,
|
|
2235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
|
|
2194
2236
|
}
|
|
2195
2237
|
var overlayStyle2 = {
|
|
2196
2238
|
position: "fixed",
|
|
@@ -2223,14 +2265,14 @@ function AppRoot({
|
|
|
2223
2265
|
Reset = DefaultResetScreen,
|
|
2224
2266
|
Paywall = DefaultPaywall
|
|
2225
2267
|
}) {
|
|
2226
|
-
return /* @__PURE__ */ (0,
|
|
2268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(PaymentReturnHandler, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TemplateConfigProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(InstallGate, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(AuthGate, { Login, Signup, Forgot, Reset, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(PersistedKeysPrefetch, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(SubscriptionGate, { Paywall, children: [
|
|
2227
2269
|
children,
|
|
2228
|
-
/* @__PURE__ */ (0,
|
|
2270
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(PushPrompt, {})
|
|
2229
2271
|
] }) }) }) }) }) }) }) });
|
|
2230
2272
|
}
|
|
2231
2273
|
|
|
2232
2274
|
// src/hooks/usePush.ts
|
|
2233
|
-
var
|
|
2275
|
+
var import_react16 = require("react");
|
|
2234
2276
|
var import_sdk10 = require("@hook-sdk/sdk");
|
|
2235
2277
|
function detectIosNeedsInstall() {
|
|
2236
2278
|
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
@@ -2258,11 +2300,11 @@ function deriveState(push) {
|
|
|
2258
2300
|
}
|
|
2259
2301
|
function usePush() {
|
|
2260
2302
|
const { push } = (0, import_sdk10.useHook)();
|
|
2261
|
-
const [state, setState] = (0,
|
|
2262
|
-
(0,
|
|
2303
|
+
const [state, setState] = (0, import_react16.useState)(() => deriveState(push));
|
|
2304
|
+
(0, import_react16.useEffect)(() => {
|
|
2263
2305
|
setState(deriveState(push));
|
|
2264
2306
|
}, [push]);
|
|
2265
|
-
const subscribe = (0,
|
|
2307
|
+
const subscribe = (0, import_react16.useCallback)(async () => {
|
|
2266
2308
|
try {
|
|
2267
2309
|
await push.subscribe();
|
|
2268
2310
|
setState({ kind: "subscribed" });
|
|
@@ -2274,7 +2316,7 @@ function usePush() {
|
|
|
2274
2316
|
throw e;
|
|
2275
2317
|
}
|
|
2276
2318
|
}, [push]);
|
|
2277
|
-
const unsubscribe = (0,
|
|
2319
|
+
const unsubscribe = (0, import_react16.useCallback)(async () => {
|
|
2278
2320
|
try {
|
|
2279
2321
|
await push.unsubscribe();
|
|
2280
2322
|
setState({ kind: "prompt" });
|
|
@@ -2287,31 +2329,31 @@ function usePush() {
|
|
|
2287
2329
|
}
|
|
2288
2330
|
|
|
2289
2331
|
// src/components/PushPrompt.tsx
|
|
2290
|
-
var
|
|
2332
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2291
2333
|
function PushPrompt2({ texts, onSubscribed, onDeclined, onInstallRequested, className }) {
|
|
2292
2334
|
const { state, subscribe } = usePush();
|
|
2293
2335
|
if (state.kind === "subscribed") return null;
|
|
2294
2336
|
if (state.kind === "ios_needs_install") {
|
|
2295
|
-
return /* @__PURE__ */ (0,
|
|
2296
|
-
/* @__PURE__ */ (0,
|
|
2297
|
-
/* @__PURE__ */ (0,
|
|
2298
|
-
onInstallRequested && texts.iosInstallCta && /* @__PURE__ */ (0,
|
|
2337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, role: "region", "aria-label": texts.iosInstallTitle, children: [
|
|
2338
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h3", { children: texts.iosInstallTitle }),
|
|
2339
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { children: texts.iosInstallBody }),
|
|
2340
|
+
onInstallRequested && texts.iosInstallCta && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { onClick: onInstallRequested, children: texts.iosInstallCta })
|
|
2299
2341
|
] });
|
|
2300
2342
|
}
|
|
2301
2343
|
if (state.kind === "denied") {
|
|
2302
|
-
return /* @__PURE__ */ (0,
|
|
2303
|
-
/* @__PURE__ */ (0,
|
|
2304
|
-
/* @__PURE__ */ (0,
|
|
2344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, role: "region", "aria-label": texts.deniedTitle, children: [
|
|
2345
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h3", { children: texts.deniedTitle }),
|
|
2346
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { children: texts.deniedBody })
|
|
2305
2347
|
] });
|
|
2306
2348
|
}
|
|
2307
2349
|
if (state.kind === "unsupported") {
|
|
2308
|
-
return /* @__PURE__ */ (0,
|
|
2350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, role: "region", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { children: texts.unsupportedBody }) });
|
|
2309
2351
|
}
|
|
2310
2352
|
if (state.kind === "error") {
|
|
2311
|
-
return /* @__PURE__ */ (0,
|
|
2353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, role: "region", "aria-label": "error", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { children: state.message }) });
|
|
2312
2354
|
}
|
|
2313
|
-
return /* @__PURE__ */ (0,
|
|
2314
|
-
/* @__PURE__ */ (0,
|
|
2355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, role: "region", children: [
|
|
2356
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2315
2357
|
"button",
|
|
2316
2358
|
{
|
|
2317
2359
|
type: "button",
|
|
@@ -2325,27 +2367,27 @@ function PushPrompt2({ texts, onSubscribed, onDeclined, onInstallRequested, clas
|
|
|
2325
2367
|
children: texts.cta
|
|
2326
2368
|
}
|
|
2327
2369
|
),
|
|
2328
|
-
onDeclined && /* @__PURE__ */ (0,
|
|
2370
|
+
onDeclined && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", onClick: onDeclined, children: texts.declineCta })
|
|
2329
2371
|
] });
|
|
2330
2372
|
}
|
|
2331
2373
|
|
|
2332
2374
|
// src/defaults/EmptyState.tsx
|
|
2333
|
-
var
|
|
2375
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2334
2376
|
function EmptyState({ title, description, action }) {
|
|
2335
|
-
return /* @__PURE__ */ (0,
|
|
2336
|
-
/* @__PURE__ */ (0,
|
|
2337
|
-
description && /* @__PURE__ */ (0,
|
|
2338
|
-
action && /* @__PURE__ */ (0,
|
|
2377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { role: "status", style: { padding: 32, textAlign: "center" }, children: [
|
|
2378
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h2", { style: { marginBottom: 8 }, children: title }),
|
|
2379
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { style: { opacity: 0.7 }, children: description }),
|
|
2380
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { style: { marginTop: 16 }, children: action })
|
|
2339
2381
|
] });
|
|
2340
2382
|
}
|
|
2341
2383
|
|
|
2342
2384
|
// src/hooks/useAuthPrimitives.ts
|
|
2343
|
-
var
|
|
2385
|
+
var import_react17 = require("react");
|
|
2344
2386
|
var import_sdk11 = require("@hook-sdk/sdk");
|
|
2345
2387
|
var warned = false;
|
|
2346
2388
|
function useAuthPrimitives() {
|
|
2347
2389
|
const { auth } = (0, import_sdk11.useHook)();
|
|
2348
|
-
(0,
|
|
2390
|
+
(0, import_react17.useEffect)(() => {
|
|
2349
2391
|
if (!warned && process.env.NODE_ENV !== "production") {
|
|
2350
2392
|
warned = true;
|
|
2351
2393
|
console.warn(
|
|
@@ -2376,14 +2418,14 @@ function useSubscription() {
|
|
|
2376
2418
|
}
|
|
2377
2419
|
|
|
2378
2420
|
// src/hooks/useReminders.ts
|
|
2379
|
-
var
|
|
2421
|
+
var import_react18 = require("react");
|
|
2380
2422
|
var import_sdk13 = require("@hook-sdk/sdk");
|
|
2381
2423
|
function useReminders() {
|
|
2382
2424
|
const { push } = (0, import_sdk13.useHook)();
|
|
2383
2425
|
const r = push.reminders;
|
|
2384
|
-
const [reminders, setReminders] = (0,
|
|
2385
|
-
const [loading, setLoading] = (0,
|
|
2386
|
-
const reload = (0,
|
|
2426
|
+
const [reminders, setReminders] = (0, import_react18.useState)([]);
|
|
2427
|
+
const [loading, setLoading] = (0, import_react18.useState)(true);
|
|
2428
|
+
const reload = (0, import_react18.useCallback)(async () => {
|
|
2387
2429
|
setLoading(true);
|
|
2388
2430
|
try {
|
|
2389
2431
|
const next = await r.list();
|
|
@@ -2392,38 +2434,38 @@ function useReminders() {
|
|
|
2392
2434
|
setLoading(false);
|
|
2393
2435
|
}
|
|
2394
2436
|
}, [r]);
|
|
2395
|
-
(0,
|
|
2437
|
+
(0, import_react18.useEffect)(() => {
|
|
2396
2438
|
void reload();
|
|
2397
2439
|
}, [reload]);
|
|
2398
|
-
const setReminder = (0,
|
|
2440
|
+
const setReminder = (0, import_react18.useCallback)(async (input) => {
|
|
2399
2441
|
await r.set(input);
|
|
2400
2442
|
await reload();
|
|
2401
2443
|
}, [r, reload]);
|
|
2402
|
-
const deleteReminder = (0,
|
|
2444
|
+
const deleteReminder = (0, import_react18.useCallback)(async (slot) => {
|
|
2403
2445
|
await r.delete(slot);
|
|
2404
2446
|
await reload();
|
|
2405
2447
|
}, [r, reload]);
|
|
2406
|
-
const schedule = (0,
|
|
2448
|
+
const schedule = (0, import_react18.useCallback)(async (items) => {
|
|
2407
2449
|
return r.schedule(items);
|
|
2408
2450
|
}, [r]);
|
|
2409
|
-
const setFallbacks = (0,
|
|
2451
|
+
const setFallbacks = (0, import_react18.useCallback)(async (items) => {
|
|
2410
2452
|
return r.setFallbacks(items);
|
|
2411
2453
|
}, [r]);
|
|
2412
2454
|
return { reminders, loading, setReminder, deleteReminder, schedule, setFallbacks };
|
|
2413
2455
|
}
|
|
2414
2456
|
|
|
2415
2457
|
// src/hooks/useToast.ts
|
|
2416
|
-
var
|
|
2458
|
+
var import_react19 = require("react");
|
|
2417
2459
|
function useToast() {
|
|
2418
|
-
const [items, setItems] = (0,
|
|
2419
|
-
const show = (0,
|
|
2460
|
+
const [items, setItems] = (0, import_react19.useState)([]);
|
|
2461
|
+
const show = (0, import_react19.useCallback)((message, kind = "info") => {
|
|
2420
2462
|
const id = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2421
2463
|
setItems((prev) => [...prev, { id, message, kind }]);
|
|
2422
2464
|
setTimeout(() => {
|
|
2423
2465
|
setItems((prev) => prev.filter((t) => t.id !== id));
|
|
2424
2466
|
}, 4e3);
|
|
2425
2467
|
}, []);
|
|
2426
|
-
const dismiss = (0,
|
|
2468
|
+
const dismiss = (0, import_react19.useCallback)((id) => {
|
|
2427
2469
|
setItems((prev) => prev.filter((t) => t.id !== id));
|
|
2428
2470
|
}, []);
|
|
2429
2471
|
return { items, show, dismiss };
|