@sidebandai/sideband-react 1.4.5 → 1.4.6-rc.1
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/README.md
CHANGED
|
@@ -4,18 +4,19 @@ Sideband adds in-app Pulse prompts and event tracking to React apps.
|
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
|
-
- React 19
|
|
7
|
+
- React 18.3 or React 19, with React DOM of the same version
|
|
8
8
|
- A Sideband API key
|
|
9
9
|
- Your application's version
|
|
10
10
|
|
|
11
|
-
For React
|
|
11
|
+
For a site without React, or to start the SDK outside the React tree, use
|
|
12
|
+
[`@sidebandai/sideband-web`](https://www.npmjs.com/package/@sidebandai/sideband-web),
|
|
12
13
|
which has no framework dependency. Its README has a server-rendered React 18
|
|
13
14
|
example that starts the SDK once per page load under StrictMode.
|
|
14
15
|
|
|
15
16
|
## Install
|
|
16
17
|
|
|
17
18
|
```bash
|
|
18
|
-
npm install @sidebandai/sideband-react
|
|
19
|
+
npm install @sidebandai/sideband-react
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
## Configure
|
|
@@ -644,7 +644,7 @@ function q() {
|
|
|
644
644
|
})
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function se() {
|
|
648
648
|
return /* @__PURE__ */ h("svg", {
|
|
649
649
|
viewBox: "0 0 35.5556 35.5556",
|
|
650
650
|
"aria-hidden": "true",
|
|
@@ -654,7 +654,7 @@ function J() {
|
|
|
654
654
|
})
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
|
-
function
|
|
657
|
+
function ce() {
|
|
658
658
|
return /* @__PURE__ */ h("span", {
|
|
659
659
|
className: "sb-spark-ring",
|
|
660
660
|
"aria-hidden": "true",
|
|
@@ -664,23 +664,23 @@ function se() {
|
|
|
664
664
|
}, t))
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function le({ question: e, store: t, isSentiment: n }) {
|
|
668
668
|
let i = t.currentDraft(), a = t.getState(), o = !!(a?.isBusy || a?.isCompleting), s = e.answers?.find((e) => e.id === i?.answer_key);
|
|
669
|
-
return s && r(s) ? /* @__PURE__ */ h(
|
|
669
|
+
return s && r(s) ? /* @__PURE__ */ h(pe, {
|
|
670
670
|
store: t,
|
|
671
671
|
disabled: o,
|
|
672
672
|
placeholder: s.label,
|
|
673
673
|
autoFocus: !0,
|
|
674
674
|
ariaLabel: "Other response",
|
|
675
675
|
isOther: !0
|
|
676
|
-
}) : n ? /* @__PURE__ */ h(
|
|
676
|
+
}) : n ? /* @__PURE__ */ h(ue, {
|
|
677
677
|
store: t,
|
|
678
678
|
disabled: o || !!a?.sentimentSelectionLocked
|
|
679
|
-
}) : e.type === "yes_no" || e.type === "multiple_choice" ? /* @__PURE__ */ h(
|
|
679
|
+
}) : e.type === "yes_no" || e.type === "multiple_choice" ? /* @__PURE__ */ h(de, {
|
|
680
680
|
question: e,
|
|
681
681
|
store: t,
|
|
682
682
|
disabled: o
|
|
683
|
-
}) : /* @__PURE__ */ h(
|
|
683
|
+
}) : /* @__PURE__ */ h(pe, {
|
|
684
684
|
store: t,
|
|
685
685
|
disabled: o,
|
|
686
686
|
placeholder: e.free_text_placeholder ?? "Please explain more... (Optional)",
|
|
@@ -688,7 +688,7 @@ function ce({ question: e, store: t, isSentiment: n }) {
|
|
|
688
688
|
ariaLabel: e.prompt
|
|
689
689
|
});
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function ue({ store: e, disabled: t }) {
|
|
692
692
|
let r = e.currentDraft();
|
|
693
693
|
return /* @__PURE__ */ h("div", {
|
|
694
694
|
className: "sb-question sb-question--sentiment",
|
|
@@ -696,7 +696,7 @@ function le({ store: e, disabled: t }) {
|
|
|
696
696
|
let a = n(i), o = r?.answer_key === i.id;
|
|
697
697
|
return /* @__PURE__ */ g("span", {
|
|
698
698
|
className: "sb-sentiment-control",
|
|
699
|
-
children: [o && a ? /* @__PURE__ */ h(
|
|
699
|
+
children: [o && a ? /* @__PURE__ */ h(ce, {}) : null, /* @__PURE__ */ h("button", {
|
|
700
700
|
type: "button",
|
|
701
701
|
className: `sb-yesno ${o ? "sb-yesno--selected" : ""}`,
|
|
702
702
|
"data-choice-value": i.id,
|
|
@@ -706,14 +706,14 @@ function le({ store: e, disabled: t }) {
|
|
|
706
706
|
"aria-pressed": o,
|
|
707
707
|
children: /* @__PURE__ */ h("span", {
|
|
708
708
|
className: "sb-yesno__icon",
|
|
709
|
-
children: h(a ? q :
|
|
709
|
+
children: h(a ? q : se, {})
|
|
710
710
|
})
|
|
711
711
|
})]
|
|
712
712
|
}, i.id);
|
|
713
713
|
})
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function de({ question: e, store: t, disabled: n }) {
|
|
717
717
|
let i = e.answers ?? oe, a = t.currentDraft(), o = u(null), [c, l] = d(() => i.every((e) => e.label.trim().length < 20));
|
|
718
718
|
return s(() => {
|
|
719
719
|
let e = () => {
|
|
@@ -736,7 +736,7 @@ function ue({ question: e, store: t, disabled: n }) {
|
|
|
736
736
|
className: `sb-question sb-question--choices ${c ? "sb-question--choices-grid" : "sb-question--choices-list"}`,
|
|
737
737
|
children: /* @__PURE__ */ h("div", {
|
|
738
738
|
className: `sb-options-scroll ${(c ? Math.ceil(i.length / 2) : i.length) >= 5 ? "sb-options-scroll--scrolling" : ""}`,
|
|
739
|
-
children: i.map((e) => /* @__PURE__ */ h(
|
|
739
|
+
children: i.map((e) => /* @__PURE__ */ h(fe, {
|
|
740
740
|
choice: e,
|
|
741
741
|
selected: a?.answer_key === e.id,
|
|
742
742
|
disabled: n,
|
|
@@ -745,7 +745,7 @@ function ue({ question: e, store: t, disabled: n }) {
|
|
|
745
745
|
})
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
|
-
function
|
|
748
|
+
function fe({ choice: e, selected: n, disabled: i, store: a }) {
|
|
749
749
|
let o = r(e);
|
|
750
750
|
return /* @__PURE__ */ h("button", {
|
|
751
751
|
type: "button",
|
|
@@ -768,7 +768,7 @@ function de({ choice: e, selected: n, disabled: i, store: a }) {
|
|
|
768
768
|
})
|
|
769
769
|
});
|
|
770
770
|
}
|
|
771
|
-
function
|
|
771
|
+
function pe({ store: e, disabled: t, placeholder: n, autoFocus: r, ariaLabel: i, isOther: a = !1 }) {
|
|
772
772
|
let o = u(null);
|
|
773
773
|
return s(() => {
|
|
774
774
|
r && !t && o.current?.focus({ preventScroll: !0 });
|
|
@@ -792,7 +792,7 @@ function fe({ store: e, disabled: t, placeholder: n, autoFocus: r, ariaLabel: i,
|
|
|
792
792
|
}
|
|
793
793
|
//#endregion
|
|
794
794
|
//#region src/lib/components/SurveyThankYou.tsx
|
|
795
|
-
function
|
|
795
|
+
function me({ completion: e, store: t, isBusy: n, headingId: r, bodyId: i }) {
|
|
796
796
|
let a = u(null), [o, c] = d(!1);
|
|
797
797
|
return s(() => {
|
|
798
798
|
let e = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1, t = setTimeout(() => c(!0), e ? 0 : 890);
|
|
@@ -845,7 +845,7 @@ function pe({ completion: e, store: t, isBusy: n, headingId: r, bodyId: i }) {
|
|
|
845
845
|
}
|
|
846
846
|
//#endregion
|
|
847
847
|
//#region src/lib/components/SurveySheet.tsx
|
|
848
|
-
var
|
|
848
|
+
var he = a(function({ session: e, store: t, modal: n, rootRef: r, interactive: i = !0 }) {
|
|
849
849
|
let a = e.currentNodeId ? e.survey.questions[e.currentNodeId] : void 0, o = !!(a && t.isSentimentStep()), l = a?.answers?.find((e) => e.id === t.currentDraft()?.answer_key), d = l?.comment?.trim() || null, f = l?.id === "system_other", p = u(null), _ = c();
|
|
850
850
|
s(() => {
|
|
851
851
|
if (!i) return;
|
|
@@ -884,7 +884,7 @@ var me = a(function({ session: e, store: t, modal: n, rootRef: r, interactive: i
|
|
|
884
884
|
"aria-labelledby": v,
|
|
885
885
|
"aria-describedby": e.completion?.body ? y : void 0,
|
|
886
886
|
"aria-busy": e.isCompleting || void 0,
|
|
887
|
-
children: e.completion ? /* @__PURE__ */ h(
|
|
887
|
+
children: e.completion ? /* @__PURE__ */ h(me, {
|
|
888
888
|
completion: e.completion,
|
|
889
889
|
store: t,
|
|
890
890
|
isBusy: e.isBusy,
|
|
@@ -913,7 +913,7 @@ var me = a(function({ session: e, store: t, modal: n, rootRef: r, interactive: i
|
|
|
913
913
|
"aria-live": o && d ? "polite" : void 0,
|
|
914
914
|
children: o && d ? d : a.prompt
|
|
915
915
|
})]
|
|
916
|
-
}), /* @__PURE__ */ h(
|
|
916
|
+
}), /* @__PURE__ */ h(le, {
|
|
917
917
|
question: a,
|
|
918
918
|
store: t,
|
|
919
919
|
isSentiment: o
|
|
@@ -943,11 +943,15 @@ var me = a(function({ session: e, store: t, modal: n, rootRef: r, interactive: i
|
|
|
943
943
|
}, `${a.node_id}:${f ? "text" : "options"}`)] }) : null
|
|
944
944
|
})]
|
|
945
945
|
});
|
|
946
|
-
}),
|
|
947
|
-
|
|
946
|
+
}), ge = typeof window > "u" ? s : l, _e = (e) => {
|
|
947
|
+
e && (e.inert = !0, e.toggleAttribute("inert", !0));
|
|
948
|
+
}, ve = (e) => {
|
|
949
|
+
e && (e.inert = !1, e.toggleAttribute("inert", !1));
|
|
950
|
+
}, J = (e) => e ? _e : ve, Y = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1;
|
|
951
|
+
function ye(e, t, n, r) {
|
|
948
952
|
t.current === r || document.visibilityState === "hidden" || (t.current = r, n.current?.(), n.current = null, e.confirmPresentation("expanded_fab", r));
|
|
949
953
|
}
|
|
950
|
-
function
|
|
954
|
+
function be({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
951
955
|
let c = u(null), l = u(null), f = u(null), [p, v] = d("entering"), { presentationId: y, survey: b, snackbar: x, isOpen: S } = e, C = e.sentimentPresentation === "bar", w = C ? e.barPosition : void 0, T = o ? "exiting" : S && (p === "entering" || p === "compact") ? "widening" : p, E = b.questions[b.root_node_id], D = i(E, b.fab), O = b.fab?.timerStyle ?? "none", k = C && e.barBehavior === "dismiss" && x?.selectedKey != null, [A, j] = d(!1);
|
|
952
956
|
s(() => {
|
|
953
957
|
if (o) return;
|
|
@@ -968,7 +972,7 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
968
972
|
C,
|
|
969
973
|
o
|
|
970
974
|
]);
|
|
971
|
-
let M = () =>
|
|
975
|
+
let M = () => ye(t, l, f, y), N = () => {
|
|
972
976
|
M(), t.closeSurvey();
|
|
973
977
|
};
|
|
974
978
|
s(() => {
|
|
@@ -984,7 +988,7 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
984
988
|
y,
|
|
985
989
|
t,
|
|
986
990
|
o
|
|
987
|
-
]),
|
|
991
|
+
]), ge(() => {
|
|
988
992
|
let e = c.current;
|
|
989
993
|
if (!e || o) return;
|
|
990
994
|
let t = () => {
|
|
@@ -1046,7 +1050,7 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
1046
1050
|
]), s(() => {
|
|
1047
1051
|
if (S || o) return;
|
|
1048
1052
|
let e = (e) => {
|
|
1049
|
-
e.key === "Escape" && c.current?.contains(document.activeElement) && (
|
|
1053
|
+
e.key === "Escape" && c.current?.contains(document.activeElement) && (ye(t, l, f, y), t.closeSurvey());
|
|
1050
1054
|
};
|
|
1051
1055
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
1052
1056
|
}, [
|
|
@@ -1077,7 +1081,7 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
1077
1081
|
onClick: () => {
|
|
1078
1082
|
M(), t.answerSnackbar(y, e.id);
|
|
1079
1083
|
},
|
|
1080
|
-
children: n(e) ? /* @__PURE__ */ h(q, {}) : /* @__PURE__ */ h(
|
|
1084
|
+
children: n(e) ? /* @__PURE__ */ h(q, {}) : /* @__PURE__ */ h(se, {})
|
|
1081
1085
|
}, e.id))
|
|
1082
1086
|
})] });
|
|
1083
1087
|
return /* @__PURE__ */ g("div", {
|
|
@@ -1117,7 +1121,7 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
1117
1121
|
role: "group",
|
|
1118
1122
|
"aria-label": E.prompt,
|
|
1119
1123
|
"aria-hidden": S || T === "entering" || o,
|
|
1120
|
-
|
|
1124
|
+
ref: J(S || T === "entering" || o),
|
|
1121
1125
|
children: [
|
|
1122
1126
|
O === "fill" || C && O === "bar" ? G : null,
|
|
1123
1127
|
C ? null : /* @__PURE__ */ g("span", {
|
|
@@ -1140,7 +1144,7 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
1140
1144
|
}),
|
|
1141
1145
|
C ? /* @__PURE__ */ h("div", {
|
|
1142
1146
|
className: "sb-bar-content",
|
|
1143
|
-
|
|
1147
|
+
ref: J(B),
|
|
1144
1148
|
"aria-hidden": B,
|
|
1145
1149
|
children: K
|
|
1146
1150
|
}) : K,
|
|
@@ -1162,9 +1166,9 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
1162
1166
|
]
|
|
1163
1167
|
}), S ? /* @__PURE__ */ h("div", {
|
|
1164
1168
|
className: "sb-snackbar-card",
|
|
1165
|
-
|
|
1169
|
+
ref: J(T !== "ready"),
|
|
1166
1170
|
"aria-hidden": T !== "ready",
|
|
1167
|
-
children: /* @__PURE__ */ h(
|
|
1171
|
+
children: /* @__PURE__ */ h(he, {
|
|
1168
1172
|
session: e,
|
|
1169
1173
|
store: t,
|
|
1170
1174
|
modal: a,
|
|
@@ -1193,44 +1197,44 @@ function _e({ session: e, store: t, placement: r, modal: a, exiting: o = !1 }) {
|
|
|
1193
1197
|
}
|
|
1194
1198
|
//#endregion
|
|
1195
1199
|
//#region src/lib/components/SurveyRenderer.tsx
|
|
1196
|
-
var X = typeof window > "u" ? s : l,
|
|
1197
|
-
function
|
|
1200
|
+
var X = typeof window > "u" ? s : l, xe = 1969.207, Se = 2169.207, Ce = 856.839, Z = 450;
|
|
1201
|
+
function Q(e) {
|
|
1198
1202
|
let t = Number.parseFloat(e);
|
|
1199
1203
|
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
1200
1204
|
}
|
|
1201
|
-
function
|
|
1205
|
+
function we(e) {
|
|
1202
1206
|
let t = 0;
|
|
1203
1207
|
for (let n of e) t += /[MW@#%&]/.test(n) ? 11 : /[ilI1.,' ]/.test(n) ? 4 : 7.5;
|
|
1204
1208
|
return Math.ceil(t);
|
|
1205
1209
|
}
|
|
1206
|
-
function
|
|
1210
|
+
function $() {
|
|
1207
1211
|
return typeof window < "u" && (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1);
|
|
1208
1212
|
}
|
|
1209
|
-
function
|
|
1213
|
+
function Te(e) {
|
|
1210
1214
|
if (!e) return null;
|
|
1211
1215
|
let { pulse_id: t, version: n, impression_id: r } = e.survey;
|
|
1212
1216
|
return typeof r == "string" ? `${t}:${n}:${r}` : `${t}:${n}`;
|
|
1213
1217
|
}
|
|
1214
|
-
function
|
|
1218
|
+
function Ee(e) {
|
|
1215
1219
|
if (!e) return;
|
|
1216
1220
|
let t = getComputedStyle(e), n = Number.parseFloat(t.width) || e.offsetWidth || 86, r = Number.parseFloat(e.style.getPropertyValue("--sb-fab-expanded-width")) || n, i = Number.parseFloat(e.style.getPropertyValue("--sb-fab-anchor-offset")) || 0, a = r === 60 ? 0 : i / (r - 60), o = e.querySelector(".sb-fab__label"), s = e.querySelector(".sb-fab__timer");
|
|
1217
1221
|
e.style.setProperty("--sb-fab-exit-width", `${n}px`), e.style.setProperty("--sb-fab-exit-offset", `${(r - n) * a}px`), e.style.setProperty("--sb-fab-exit-scale", t.getPropertyValue("scale") || "1"), e.style.setProperty("--sb-fab-exit-label-opacity", o ? getComputedStyle(o).opacity : "0"), e.style.setProperty("--sb-fab-exit-timer-opacity", s ? getComputedStyle(s).opacity : "0");
|
|
1218
1222
|
}
|
|
1219
|
-
function
|
|
1220
|
-
let [i, a] = d(e), [o, c] = d(null), l =
|
|
1223
|
+
function De({ session: e, store: t, fabRef: n, onClick: r }) {
|
|
1224
|
+
let [i, a] = d(e), [o, c] = d(null), l = Te(e), u = e?.survey.fab, f = (u?.timerStyle === "bar" || u?.timerStyle === "fill") && typeof u.expandedTimeout == "number" && Number.isFinite(u.expandedTimeout) && u.expandedTimeout > 0, p = e ?? i;
|
|
1221
1225
|
return X(() => {
|
|
1222
1226
|
e && a(e);
|
|
1223
1227
|
}, [e]), X(() => {
|
|
1224
|
-
!e && i &&
|
|
1228
|
+
!e && i && Ee(n.current);
|
|
1225
1229
|
}, [
|
|
1226
1230
|
n,
|
|
1227
1231
|
i,
|
|
1228
1232
|
e
|
|
1229
1233
|
]), s(() => {
|
|
1230
1234
|
if (!l) return;
|
|
1231
|
-
let e =
|
|
1235
|
+
let e = $(), n = setTimeout(() => {
|
|
1232
1236
|
t.confirmPresentation("expanded_fab"), t.confirmFabEntranceCompleted();
|
|
1233
|
-
}, e ? 0 :
|
|
1237
|
+
}, e ? 0 : xe), r = setTimeout(() => c(l), e ? 0 : f ? Se : xe);
|
|
1234
1238
|
return () => {
|
|
1235
1239
|
clearTimeout(n), clearTimeout(r);
|
|
1236
1240
|
};
|
|
@@ -1240,7 +1244,7 @@ function we({ session: e, store: t, fabRef: n, onClick: r }) {
|
|
|
1240
1244
|
t
|
|
1241
1245
|
]), s(() => {
|
|
1242
1246
|
if (e || !i) return;
|
|
1243
|
-
let t = setTimeout(() => a(null),
|
|
1247
|
+
let t = setTimeout(() => a(null), $() ? 0 : Ce);
|
|
1244
1248
|
return () => clearTimeout(t);
|
|
1245
1249
|
}, [i, e]), p ? /* @__PURE__ */ h(ie, {
|
|
1246
1250
|
session: p,
|
|
@@ -1249,7 +1253,7 @@ function we({ session: e, store: t, fabRef: n, onClick: r }) {
|
|
|
1249
1253
|
animationState: e ? o === l ? "visible" : "entering" : "exiting"
|
|
1250
1254
|
}) : null;
|
|
1251
1255
|
}
|
|
1252
|
-
function
|
|
1256
|
+
function Oe({ session: e, store: t, modal: n }) {
|
|
1253
1257
|
let [r, i] = d(e), a = u(null), o = e ?? r;
|
|
1254
1258
|
return X(() => {
|
|
1255
1259
|
e && i(e);
|
|
@@ -1260,24 +1264,24 @@ function Te({ session: e, store: t, modal: n }) {
|
|
|
1260
1264
|
}));
|
|
1261
1265
|
}, [e]), s(() => {
|
|
1262
1266
|
if (e || !r) return;
|
|
1263
|
-
let t = setTimeout(() => i(null),
|
|
1267
|
+
let t = setTimeout(() => i(null), $() ? 0 : Z);
|
|
1264
1268
|
return () => clearTimeout(t);
|
|
1265
|
-
}, [r, e]), o ? /* @__PURE__ */ h(
|
|
1269
|
+
}, [r, e]), o ? /* @__PURE__ */ h(he, {
|
|
1266
1270
|
session: o,
|
|
1267
1271
|
store: t,
|
|
1268
1272
|
modal: n,
|
|
1269
1273
|
rootRef: a
|
|
1270
|
-
},
|
|
1274
|
+
}, Te(o)) : null;
|
|
1271
1275
|
}
|
|
1272
|
-
function
|
|
1276
|
+
function ke({ session: e, store: t, placement: n, modal: r }) {
|
|
1273
1277
|
let [i, a] = d(e), o = e ?? i;
|
|
1274
1278
|
return X(() => {
|
|
1275
1279
|
e && a(e);
|
|
1276
1280
|
}, [e]), s(() => {
|
|
1277
1281
|
if (e || !i) return;
|
|
1278
|
-
let t = i.sentimentPresentation === "bar" ?
|
|
1282
|
+
let t = i.sentimentPresentation === "bar" ? $() ? z.reduced : z.removal : 0, n = setTimeout(() => a(null), t);
|
|
1279
1283
|
return () => clearTimeout(n);
|
|
1280
|
-
}, [e, i]), !o || !e && o.sentimentPresentation !== "bar" ? null : /* @__PURE__ */ h(
|
|
1284
|
+
}, [e, i]), !o || !e && o.sentimentPresentation !== "bar" ? null : /* @__PURE__ */ h(be, {
|
|
1281
1285
|
session: o,
|
|
1282
1286
|
store: t,
|
|
1283
1287
|
placement: n,
|
|
@@ -1285,7 +1289,7 @@ function Ee({ session: e, store: t, placement: n, modal: r }) {
|
|
|
1285
1289
|
exiting: !e
|
|
1286
1290
|
}, o.presentationId);
|
|
1287
1291
|
}
|
|
1288
|
-
function
|
|
1292
|
+
function Ae({ store: e, portal: t = !0, placement: n = "fixed" }) {
|
|
1289
1293
|
let r = f(o((t) => e.subscribe(t), [e]), o(() => e.getSnapshot(), [e]), o(() => e.getServerSnapshot(), [e])).state, i = u(null), a = u(null), c = u(null), l = u(null), d = r ? r.completion ? "completion" : r.isOpen ? `sheet:${r.currentNodeId}` : `fab:${r.fabState}` : "none";
|
|
1290
1294
|
X(() => {
|
|
1291
1295
|
if (!r || !i.current) return;
|
|
@@ -1294,10 +1298,10 @@ function De({ store: e, portal: t = !0, placement: n = "fixed" }) {
|
|
|
1294
1298
|
}, [r]), s(() => {
|
|
1295
1299
|
let t = e.getState();
|
|
1296
1300
|
if (!t) {
|
|
1297
|
-
let e = i.current?.querySelector("[data-presentation=\"bar\"][data-exiting=\"true\"]"), t = i.current?.querySelector(".sb-fab--exiting") ?
|
|
1301
|
+
let e = i.current?.querySelector("[data-presentation=\"bar\"][data-exiting=\"true\"]"), t = i.current?.querySelector(".sb-fab--exiting") ? Ce : Z, n = setTimeout(() => {
|
|
1298
1302
|
let e = l.current;
|
|
1299
1303
|
e?.isConnected ? e.focus() : e && i.current?.focus(), l.current = null;
|
|
1300
|
-
}, e ?
|
|
1304
|
+
}, e ? $() ? z.reduced : z.removal : $() ? 0 : t);
|
|
1301
1305
|
return () => clearTimeout(n);
|
|
1302
1306
|
}
|
|
1303
1307
|
if (t.isOpen || t.completion) {
|
|
@@ -1312,11 +1316,11 @@ function De({ store: e, portal: t = !0, placement: n = "fixed" }) {
|
|
|
1312
1316
|
let e = a.current;
|
|
1313
1317
|
if (!e || !c.current) return;
|
|
1314
1318
|
let i = window.visualViewport, o = n === "inline" ? t.getBoundingClientRect() : null, s = n === "inline" ? t.clientWidth || o.width : i?.width && i.width > 0 ? i.width : window.innerWidth, l = n === "inline" ? t.clientHeight || o.height : i?.height && i.height > 0 ? i.height : window.innerHeight, u = e.getBoundingClientRect(), d = getComputedStyle(c.current), f = {
|
|
1315
|
-
top:
|
|
1316
|
-
right:
|
|
1317
|
-
bottom:
|
|
1318
|
-
left:
|
|
1319
|
-
}, p = Math.max(0, s - f.left - f.right), m = e.querySelector(".sb-fab__label"), h = m ? m.scrollWidth || m.getBoundingClientRect().width ||
|
|
1319
|
+
top: Q(d.paddingTop),
|
|
1320
|
+
right: Q(d.paddingRight),
|
|
1321
|
+
bottom: Q(d.paddingBottom),
|
|
1322
|
+
left: Q(d.paddingLeft)
|
|
1323
|
+
}, p = Math.max(0, s - f.left - f.right), m = e.querySelector(".sb-fab__label"), h = m ? m.scrollWidth || m.getBoundingClientRect().width || we(m.textContent ?? "") : 0, g = Math.min(p, Math.max(86, 86 + Math.ceil(h))), _ = e.offsetHeight || u.height || 60;
|
|
1320
1324
|
e.style.setProperty("--sb-fab-expanded-width", `${g}px`), e.style.setProperty("--sb-fab-label-width", `${Math.max(0, g - 86)}px`);
|
|
1321
1325
|
let v = Math.max(0, Math.min(1, r.survey.fab?.placement?.anchor.x ?? 1));
|
|
1322
1326
|
e.style.setProperty("--sb-fab-anchor-offset", `${(g - 60) * v}px`);
|
|
@@ -1367,21 +1371,21 @@ function De({ store: e, portal: t = !0, placement: n = "fixed" }) {
|
|
|
1367
1371
|
ref: c,
|
|
1368
1372
|
className: "sb-safe-area-probe"
|
|
1369
1373
|
}),
|
|
1370
|
-
/* @__PURE__ */ h(
|
|
1374
|
+
/* @__PURE__ */ h(ke, {
|
|
1371
1375
|
session: r?.snackbar ? r : null,
|
|
1372
1376
|
store: e,
|
|
1373
1377
|
placement: n,
|
|
1374
1378
|
modal: t
|
|
1375
1379
|
}),
|
|
1376
|
-
/* @__PURE__ */ h(
|
|
1380
|
+
/* @__PURE__ */ h(De, {
|
|
1377
1381
|
session: r && !r.snackbar && !r.isOpen && !r.completion && r.fabState === "expanded" ? r : null,
|
|
1378
1382
|
store: e,
|
|
1379
1383
|
fabRef: a,
|
|
1380
1384
|
onClick: () => {
|
|
1381
|
-
|
|
1385
|
+
Ee(a.current), l.current = a.current, e.openSurvey();
|
|
1382
1386
|
}
|
|
1383
1387
|
}),
|
|
1384
|
-
/* @__PURE__ */ h(
|
|
1388
|
+
/* @__PURE__ */ h(Oe, {
|
|
1385
1389
|
session: r && !r.snackbar && (r.isOpen || r.completion) ? r : null,
|
|
1386
1390
|
store: e,
|
|
1387
1391
|
modal: t
|
|
@@ -1391,4 +1395,4 @@ function De({ store: e, portal: t = !0, placement: n = "fixed" }) {
|
|
|
1391
1395
|
return t && typeof document < "u" ? p(m, document.body) : m;
|
|
1392
1396
|
}
|
|
1393
1397
|
//#endregion
|
|
1394
|
-
export {
|
|
1398
|
+
export { Ae as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveySnackbar.d.ts","sourceRoot":"","sources":["../../src/lib/components/SurveySnackbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0D,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"SurveySnackbar.d.ts","sourceRoot":"","sources":["../../src/lib/components/SurveySnackbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0D,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AA+BpJ,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAe,EAAE,EAAE;IACpF,OAAO,EAAE,kBAAkB,CAAA;IAC3B,KAAK,EAAE,kBAAkB,CAAA;IACzB,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC7B,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,+BA+LA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./SurveyRenderer-
|
|
1
|
+
import { t as e } from "./SurveyRenderer-BhNcL0CG.js";
|
|
2
2
|
import { PendingInteractionStorageError as t, SidebandApiError as n, SurveySessionStore as r, SurveySessionStore as i, buildFabTitle as a, createSidebandClient as o, createSidebandClient as s, createSidebandRuntime as c, getChoiceValue as l } from "@sidebandai/sideband-core";
|
|
3
3
|
import { createContext as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h, useState as g, useSyncExternalStore as _ } from "react";
|
|
4
4
|
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
@@ -42,7 +42,7 @@ function k(e, t) {
|
|
|
42
42
|
}
|
|
43
43
|
}), a = c({
|
|
44
44
|
...e,
|
|
45
|
-
libraryVersion: "1.4.
|
|
45
|
+
libraryVersion: "1.4.6-rc.1",
|
|
46
46
|
onSyncResponse: (e) => r.handleSyncResponse(e)
|
|
47
47
|
});
|
|
48
48
|
return n.current = a, {
|
package/dist/preview.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./SurveyRenderer-
|
|
1
|
+
import { t as e } from "./SurveyRenderer-BhNcL0CG.js";
|
|
2
2
|
import { SurveySessionStore as t } from "@sidebandai/sideband-core";
|
|
3
3
|
import { createElement as n } from "react";
|
|
4
4
|
import { flushSync as r } from "react-dom";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sidebandai/sideband-react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6-rc.1",
|
|
4
4
|
"description": "React SDK for Sideband client sync surveys and prompts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"react": "^19.0.0",
|
|
39
|
-
"react-dom": "^19.0.0"
|
|
38
|
+
"react": "^18.3.0 || ^19.0.0",
|
|
39
|
+
"react-dom": "^18.3.0 || ^19.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sidebandai/sideband-core": "1.4.
|
|
42
|
+
"@sidebandai/sideband-core": "1.4.6-rc.1"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "vite build --config ../../vite.react.config.ts && tsc -p tsconfig.lib.json && node ../../scripts/prepare-react-package.mjs",
|