@scalemule/nextjs 0.1.0 → 0.1.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/dist/index.d.mts CHANGED
@@ -429,6 +429,14 @@ interface FeedbackWidgetProps {
429
429
  theme?: 'light' | 'dark' | 'auto';
430
430
  /** Optional class for the trigger button (use to override styling). */
431
431
  className?: string;
432
+ /** Show the 1–5 star rating row. Default `true`. Rating is stored as a
433
+ * `rating:N` tag on the feedback item — staff can filter on it from the
434
+ * dashboard inbox. Optional per submission; users who skip it just submit
435
+ * without a rating. */
436
+ enableRating?: boolean;
437
+ /** Label for the rating row when enabled. Default `How would you rate
438
+ * your experience?`. */
439
+ ratingLabel?: string;
432
440
  /** Called after a successful submit. */
433
441
  onSubmitted?: (item: FeedbackItem) => void;
434
442
  }
package/dist/index.d.ts CHANGED
@@ -429,6 +429,14 @@ interface FeedbackWidgetProps {
429
429
  theme?: 'light' | 'dark' | 'auto';
430
430
  /** Optional class for the trigger button (use to override styling). */
431
431
  className?: string;
432
+ /** Show the 1–5 star rating row. Default `true`. Rating is stored as a
433
+ * `rating:N` tag on the feedback item — staff can filter on it from the
434
+ * dashboard inbox. Optional per submission; users who skip it just submit
435
+ * without a rating. */
436
+ enableRating?: boolean;
437
+ /** Label for the rating row when enabled. Default `How would you rate
438
+ * your experience?`. */
439
+ ratingLabel?: string;
432
440
  /** Called after a successful submit. */
433
441
  onSubmitted?: (item: FeedbackItem) => void;
434
442
  }
package/dist/index.js CHANGED
@@ -9778,6 +9778,8 @@ function FeedbackWidget(props) {
9778
9778
  triggerLabel = "Feedback",
9779
9779
  theme = "auto",
9780
9780
  className,
9781
+ enableRating = true,
9782
+ ratingLabel = "How would you rate your experience?",
9781
9783
  onSubmitted
9782
9784
  } = props;
9783
9785
  const sm = useScaleMule();
@@ -9787,6 +9789,8 @@ function FeedbackWidget(props) {
9787
9789
  const [title, setTitle] = react.useState("");
9788
9790
  const [description, setDescription] = react.useState("");
9789
9791
  const [email, setEmail] = react.useState("");
9792
+ const [rating, setRating] = react.useState(null);
9793
+ const [hoverRating, setHoverRating] = react.useState(null);
9790
9794
  const [submitting, setSubmitting] = react.useState(false);
9791
9795
  const [errMsg, setErrMsg] = react.useState(null);
9792
9796
  const [done, setDone] = react.useState(false);
@@ -9797,6 +9801,8 @@ function FeedbackWidget(props) {
9797
9801
  setTitle("");
9798
9802
  setDescription("");
9799
9803
  setEmail("");
9804
+ setRating(null);
9805
+ setHoverRating(null);
9800
9806
  setErrMsg(null);
9801
9807
  setDone(false);
9802
9808
  }
@@ -9810,11 +9816,13 @@ function FeedbackWidget(props) {
9810
9816
  setSubmitting(true);
9811
9817
  setErrMsg(null);
9812
9818
  try {
9819
+ const tags = rating != null ? [`rating:${rating}`] : void 0;
9813
9820
  const item = await submit({
9814
9821
  type,
9815
9822
  title: title.trim(),
9816
9823
  description: description.trim(),
9817
- email: signedIn ? void 0 : email.trim() || void 0
9824
+ email: signedIn ? void 0 : email.trim() || void 0,
9825
+ tags
9818
9826
  });
9819
9827
  setDone(true);
9820
9828
  onSubmitted?.(item);
@@ -9873,6 +9881,53 @@ function FeedbackWidget(props) {
9873
9881
  }
9874
9882
  )
9875
9883
  ] }),
9884
+ enableRating && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
9885
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: STYLES.label, children: ratingLabel }),
9886
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: 4, marginTop: 4 }, children: [
9887
+ [1, 2, 3, 4, 5].map((n) => {
9888
+ const active = (hoverRating ?? rating ?? 0) >= n;
9889
+ return /* @__PURE__ */ jsxRuntime.jsx(
9890
+ "button",
9891
+ {
9892
+ type: "button",
9893
+ "aria-label": `${n} star${n === 1 ? "" : "s"}`,
9894
+ onClick: () => setRating(rating === n ? null : n),
9895
+ onMouseEnter: () => setHoverRating(n),
9896
+ onMouseLeave: () => setHoverRating(null),
9897
+ style: {
9898
+ background: "transparent",
9899
+ border: "none",
9900
+ cursor: "pointer",
9901
+ padding: 2,
9902
+ fontSize: 24,
9903
+ lineHeight: 1,
9904
+ color: active ? "#f59e0b" : "#cbd5e1",
9905
+ transition: "color 80ms ease"
9906
+ },
9907
+ children: active ? "\u2605" : "\u2606"
9908
+ },
9909
+ n
9910
+ );
9911
+ }),
9912
+ rating != null && /* @__PURE__ */ jsxRuntime.jsx(
9913
+ "button",
9914
+ {
9915
+ type: "button",
9916
+ onClick: () => setRating(null),
9917
+ style: {
9918
+ marginLeft: 8,
9919
+ background: "transparent",
9920
+ border: "none",
9921
+ color: "inherit",
9922
+ opacity: 0.6,
9923
+ fontSize: 12,
9924
+ cursor: "pointer"
9925
+ },
9926
+ children: "clear"
9927
+ }
9928
+ )
9929
+ ] })
9930
+ ] }),
9876
9931
  /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
9877
9932
  /* @__PURE__ */ jsxRuntime.jsx("div", { style: STYLES.label, children: "Type" }),
9878
9933
  /* @__PURE__ */ jsxRuntime.jsx(
package/dist/index.mjs CHANGED
@@ -9777,6 +9777,8 @@ function FeedbackWidget(props) {
9777
9777
  triggerLabel = "Feedback",
9778
9778
  theme = "auto",
9779
9779
  className,
9780
+ enableRating = true,
9781
+ ratingLabel = "How would you rate your experience?",
9780
9782
  onSubmitted
9781
9783
  } = props;
9782
9784
  const sm = useScaleMule();
@@ -9786,6 +9788,8 @@ function FeedbackWidget(props) {
9786
9788
  const [title, setTitle] = useState("");
9787
9789
  const [description, setDescription] = useState("");
9788
9790
  const [email, setEmail] = useState("");
9791
+ const [rating, setRating] = useState(null);
9792
+ const [hoverRating, setHoverRating] = useState(null);
9789
9793
  const [submitting, setSubmitting] = useState(false);
9790
9794
  const [errMsg, setErrMsg] = useState(null);
9791
9795
  const [done, setDone] = useState(false);
@@ -9796,6 +9800,8 @@ function FeedbackWidget(props) {
9796
9800
  setTitle("");
9797
9801
  setDescription("");
9798
9802
  setEmail("");
9803
+ setRating(null);
9804
+ setHoverRating(null);
9799
9805
  setErrMsg(null);
9800
9806
  setDone(false);
9801
9807
  }
@@ -9809,11 +9815,13 @@ function FeedbackWidget(props) {
9809
9815
  setSubmitting(true);
9810
9816
  setErrMsg(null);
9811
9817
  try {
9818
+ const tags = rating != null ? [`rating:${rating}`] : void 0;
9812
9819
  const item = await submit({
9813
9820
  type,
9814
9821
  title: title.trim(),
9815
9822
  description: description.trim(),
9816
- email: signedIn ? void 0 : email.trim() || void 0
9823
+ email: signedIn ? void 0 : email.trim() || void 0,
9824
+ tags
9817
9825
  });
9818
9826
  setDone(true);
9819
9827
  onSubmitted?.(item);
@@ -9872,6 +9880,53 @@ function FeedbackWidget(props) {
9872
9880
  }
9873
9881
  )
9874
9882
  ] }),
9883
+ enableRating && /* @__PURE__ */ jsxs("div", { children: [
9884
+ /* @__PURE__ */ jsx("div", { style: STYLES.label, children: ratingLabel }),
9885
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 4, marginTop: 4 }, children: [
9886
+ [1, 2, 3, 4, 5].map((n) => {
9887
+ const active = (hoverRating ?? rating ?? 0) >= n;
9888
+ return /* @__PURE__ */ jsx(
9889
+ "button",
9890
+ {
9891
+ type: "button",
9892
+ "aria-label": `${n} star${n === 1 ? "" : "s"}`,
9893
+ onClick: () => setRating(rating === n ? null : n),
9894
+ onMouseEnter: () => setHoverRating(n),
9895
+ onMouseLeave: () => setHoverRating(null),
9896
+ style: {
9897
+ background: "transparent",
9898
+ border: "none",
9899
+ cursor: "pointer",
9900
+ padding: 2,
9901
+ fontSize: 24,
9902
+ lineHeight: 1,
9903
+ color: active ? "#f59e0b" : "#cbd5e1",
9904
+ transition: "color 80ms ease"
9905
+ },
9906
+ children: active ? "\u2605" : "\u2606"
9907
+ },
9908
+ n
9909
+ );
9910
+ }),
9911
+ rating != null && /* @__PURE__ */ jsx(
9912
+ "button",
9913
+ {
9914
+ type: "button",
9915
+ onClick: () => setRating(null),
9916
+ style: {
9917
+ marginLeft: 8,
9918
+ background: "transparent",
9919
+ border: "none",
9920
+ color: "inherit",
9921
+ opacity: 0.6,
9922
+ fontSize: 12,
9923
+ cursor: "pointer"
9924
+ },
9925
+ children: "clear"
9926
+ }
9927
+ )
9928
+ ] })
9929
+ ] }),
9875
9930
  /* @__PURE__ */ jsxs("label", { children: [
9876
9931
  /* @__PURE__ */ jsx("div", { style: STYLES.label, children: "Type" }),
9877
9932
  /* @__PURE__ */ jsx(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/nextjs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "ScaleMule SDK for Next.js applications - authentication, storage, and user management",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",