@discuss-ds/ui 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -674,6 +674,10 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
674
674
  titlePlaceholderTone?: 'muted' | 'regular';
675
675
  /** Shortest title (in characters) that may be saved. Turns on the title guardrail: see `QuestionHeader`'s `titleMinLength`. */
676
676
  titleMinLength?: number;
677
+ /** A title longer than this many characters switches to the regular 16px body style and shows `titleRecommendedNote` under it. See `QuestionHeader`. */
678
+ titleRecommendedMax?: number;
679
+ /** The recommendation shown under a title that is longer than `titleRecommendedMax`. */
680
+ titleRecommendedNote?: React.ReactNode;
677
681
  /** The question is being edited: accent border, counter and footer are shown. */
678
682
  active?: boolean;
679
683
  /**
@@ -731,6 +735,13 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
731
735
  * saved (the field stays open and says why), and the always-on counter is replaced by that line.
732
736
  */
733
737
  titleMinLength?: number;
738
+ /**
739
+ * Editor mode: a title longer than this many characters (counted live while it is typed) switches to the regular 16px body style
740
+ * instead of the heading style and shows `titleRecommendedNote` under it. Both need to be set.
741
+ */
742
+ titleRecommendedMax?: number;
743
+ /** Editor mode: the recommendation shown under a title that is longer than `titleRecommendedMax`. */
744
+ titleRecommendedNote?: React.ReactNode;
734
745
  /** Editor mode: action buttons (copy, delete, preview, AI) revealed on hover or focus. */
735
746
  actions?: React.ReactNode;
736
747
  /** Editor mode: content shown right beside the "Question N" tag, e.g. the time allowed for the question. */
package/dist/index.d.ts CHANGED
@@ -674,6 +674,10 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
674
674
  titlePlaceholderTone?: 'muted' | 'regular';
675
675
  /** Shortest title (in characters) that may be saved. Turns on the title guardrail: see `QuestionHeader`'s `titleMinLength`. */
676
676
  titleMinLength?: number;
677
+ /** A title longer than this many characters switches to the regular 16px body style and shows `titleRecommendedNote` under it. See `QuestionHeader`. */
678
+ titleRecommendedMax?: number;
679
+ /** The recommendation shown under a title that is longer than `titleRecommendedMax`. */
680
+ titleRecommendedNote?: React.ReactNode;
677
681
  /** The question is being edited: accent border, counter and footer are shown. */
678
682
  active?: boolean;
679
683
  /**
@@ -731,6 +735,13 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
731
735
  * saved (the field stays open and says why), and the always-on counter is replaced by that line.
732
736
  */
733
737
  titleMinLength?: number;
738
+ /**
739
+ * Editor mode: a title longer than this many characters (counted live while it is typed) switches to the regular 16px body style
740
+ * instead of the heading style and shows `titleRecommendedNote` under it. Both need to be set.
741
+ */
742
+ titleRecommendedMax?: number;
743
+ /** Editor mode: the recommendation shown under a title that is longer than `titleRecommendedMax`. */
744
+ titleRecommendedNote?: React.ReactNode;
734
745
  /** Editor mode: action buttons (copy, delete, preview, AI) revealed on hover or focus. */
735
746
  actions?: React.ReactNode;
736
747
  /** Editor mode: content shown right beside the "Question N" tag, e.g. the time allowed for the question. */
package/dist/index.js CHANGED
@@ -2663,13 +2663,14 @@ import { DotsSixVertical } from "@phosphor-icons/react";
2663
2663
  import { jsx as jsx41, jsxs as jsxs29 } from "react/jsx-runtime";
2664
2664
  var eyebrow = "text-ui-caption uppercase text-secondary-muted-foreground";
2665
2665
  var QuestionHeader = React40.forwardRef(
2666
- ({ className, number, title, required, error, onDismissError, editor, onTitleChange, titlePlaceholder = "Click to write the question text", titlePlaceholderTone, titleMinLength, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, ...props }, ref) => {
2666
+ ({ className, number, title, required, error, onDismissError, editor, onTitleChange, titlePlaceholder = "Click to write the question text", titlePlaceholderTone, titleMinLength, titleRecommendedMax, titleRecommendedNote, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, ...props }, ref) => {
2667
2667
  const [draft, setDraft] = React40.useState(null);
2668
2668
  const label = String(number).padStart(2, "0");
2669
2669
  const showError = error !== void 0 && error !== false;
2670
2670
  if (editor) {
2671
2671
  const text = typeof title === "string" ? title : "";
2672
2672
  const count = (draft ?? text).length;
2673
+ const long = titleRecommendedMax !== void 0 && titleRecommendedNote != null && count > titleRecommendedMax;
2673
2674
  return /* @__PURE__ */ jsxs29("div", { ref, className: cn("group/header flex w-full flex-col gap-2", className), ...props, children: [
2674
2675
  /* @__PURE__ */ jsxs29("div", { className: "flex items-center justify-between", children: [
2675
2676
  /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-2", children: [
@@ -2728,9 +2729,10 @@ var QuestionHeader = React40.forwardRef(
2728
2729
  onEditingChange: (editing) => {
2729
2730
  if (!editing) setDraft(null);
2730
2731
  },
2731
- textClassName: "text-heading-h4"
2732
+ textClassName: long ? "text-body-base" : "text-heading-h4"
2732
2733
  }
2733
2734
  ),
2735
+ long && /* @__PURE__ */ jsx41("p", { className: "text-ui-caption text-secondary-muted-foreground", children: titleRecommendedNote }),
2734
2736
  showCounter && titleMinLength === void 0 && /* @__PURE__ */ jsxs29("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
2735
2737
  count,
2736
2738
  "/",
@@ -2766,6 +2768,8 @@ var QuestionEditorCard = React41.forwardRef(
2766
2768
  titlePlaceholder,
2767
2769
  titlePlaceholderTone,
2768
2770
  titleMinLength,
2771
+ titleRecommendedMax,
2772
+ titleRecommendedNote,
2769
2773
  active,
2770
2774
  hovered,
2771
2775
  maxLength,
@@ -2814,6 +2818,8 @@ var QuestionEditorCard = React41.forwardRef(
2814
2818
  titlePlaceholder,
2815
2819
  titlePlaceholderTone,
2816
2820
  titleMinLength,
2821
+ titleRecommendedMax,
2822
+ titleRecommendedNote,
2817
2823
  active,
2818
2824
  showCounter: !!active,
2819
2825
  dragHandleProps,
@@ -3066,7 +3072,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3066
3072
  } : { "aria-hidden": true };
3067
3073
  const grip = dragHandleProps ? /* @__PURE__ */ jsx45("span", { ...gripProps, className: cn("shrink-0", gripProps.className), children: /* @__PURE__ */ jsx45(DotsSixVertical3, { size: 20, "aria-hidden": true, className: "text-surface-foreground" }) }) : /* @__PURE__ */ jsx45(DotsSixVertical3, { size: 20, "aria-hidden": true, className: "shrink-0 text-surface-foreground" });
3068
3074
  return /* @__PURE__ */ jsxs32("div", { className: cn("group/option flex w-full items-center gap-2", className), children: [
3069
- /* @__PURE__ */ jsxs32(
3075
+ /* @__PURE__ */ jsx45(
3070
3076
  "div",
3071
3077
  {
3072
3078
  className: cn(
@@ -3076,42 +3082,42 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3076
3082
  cn("border-border group-hover/option:shadow-md group-focus-within/option:shadow-md", lifted && "shadow-md")
3077
3083
  ) : "border-border hover:border-input-muted hover:shadow-md"
3078
3084
  ),
3079
- children: [
3080
- /* @__PURE__ */ jsxs32("div", { className: "flex min-w-0 items-center gap-2", children: [
3081
- kind === "rank" ? /* @__PURE__ */ jsxs32(Fragment9, { children: [
3082
- !locked && grip,
3083
- /* @__PURE__ */ jsx45(
3084
- "span",
3085
- {
3086
- "aria-hidden": "true",
3087
- className: "flex size-6 shrink-0 items-center justify-center rounded-full border border-border bg-background bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5 text-ui-caption text-surface-foreground",
3088
- children: rank
3089
- }
3090
- )
3091
- ] }) : reveal && locked ? /* @__PURE__ */ jsx45("span", { "aria-hidden": "true", className: "relative flex size-5 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx45("span", { className: cn("inline-flex size-4 border-2 border-input bg-surface", kind === "radio" ? "rounded-full" : "rounded-xxs") }) }) : reveal ? /* @__PURE__ */ jsxs32("span", { ...gripProps, className: cn("relative flex size-5 shrink-0 items-center justify-center", gripProps.className), children: [
3092
- /* @__PURE__ */ jsx45(
3093
- "span",
3094
- {
3095
- "aria-hidden": "true",
3096
- className: cn(
3097
- "inline-flex size-4 border-2 border-input bg-surface group-hover/option:hidden group-focus-within/option:hidden",
3098
- lifted && "hidden",
3099
- kind === "radio" ? "rounded-full" : "rounded-xxs"
3100
- )
3101
- }
3102
- ),
3103
- /* @__PURE__ */ jsx45(
3104
- DotsSixVertical3,
3105
- {
3106
- size: 20,
3107
- "aria-hidden": true,
3108
- className: cn(
3109
- "hidden shrink-0 text-surface-foreground group-hover/option:block group-focus-within/option:block",
3110
- lifted && "block"
3111
- )
3112
- }
3113
- )
3114
- ] }) : locked ? null : grip,
3085
+ children: /* @__PURE__ */ jsxs32("div", { className: "flex min-w-0 items-start gap-2", children: [
3086
+ (kind !== void 0 || !locked) && /* @__PURE__ */ jsx45("div", { className: "flex h-7 shrink-0 items-center gap-2", children: kind === "rank" ? /* @__PURE__ */ jsxs32(Fragment9, { children: [
3087
+ !locked && grip,
3088
+ /* @__PURE__ */ jsx45(
3089
+ "span",
3090
+ {
3091
+ "aria-hidden": "true",
3092
+ className: "flex size-6 shrink-0 items-center justify-center rounded-full border border-border bg-background bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5 text-ui-caption text-surface-foreground",
3093
+ children: rank
3094
+ }
3095
+ )
3096
+ ] }) : reveal && locked ? /* @__PURE__ */ jsx45("span", { "aria-hidden": "true", className: "relative flex size-5 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx45("span", { className: cn("inline-flex size-4 border-2 border-input bg-surface", kind === "radio" ? "rounded-full" : "rounded-xxs") }) }) : reveal ? /* @__PURE__ */ jsxs32("span", { ...gripProps, className: cn("relative flex size-5 shrink-0 items-center justify-center", gripProps.className), children: [
3097
+ /* @__PURE__ */ jsx45(
3098
+ "span",
3099
+ {
3100
+ "aria-hidden": "true",
3101
+ className: cn(
3102
+ "inline-flex size-4 border-2 border-input bg-surface group-hover/option:hidden group-focus-within/option:hidden",
3103
+ lifted && "hidden",
3104
+ kind === "radio" ? "rounded-full" : "rounded-xxs"
3105
+ )
3106
+ }
3107
+ ),
3108
+ /* @__PURE__ */ jsx45(
3109
+ DotsSixVertical3,
3110
+ {
3111
+ size: 20,
3112
+ "aria-hidden": true,
3113
+ className: cn(
3114
+ "hidden shrink-0 text-surface-foreground group-hover/option:block group-focus-within/option:block",
3115
+ lifted && "block"
3116
+ )
3117
+ }
3118
+ )
3119
+ ] }) : locked ? null : grip }),
3120
+ /* @__PURE__ */ jsxs32("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
3115
3121
  /* @__PURE__ */ jsx45(
3116
3122
  "input",
3117
3123
  {
@@ -3158,28 +3164,28 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
3158
3164
  placeholderTone === "regular" ? "placeholder:text-surface-foreground" : "placeholder:text-muted-foreground"
3159
3165
  )
3160
3166
  }
3167
+ ),
3168
+ guarded && draft !== null && /* @__PURE__ */ jsxs32(
3169
+ "p",
3170
+ {
3171
+ id: helperId,
3172
+ role: error ? "alert" : void 0,
3173
+ className: cn("flex items-start justify-between gap-2 text-ui-caption", error ? "text-destructive" : "text-secondary-muted-foreground"),
3174
+ children: [
3175
+ /* @__PURE__ */ jsxs32("span", { className: "flex items-start gap-2", children: [
3176
+ error && /* @__PURE__ */ jsx45(WarningCircle4, { size: 16, "aria-hidden": true, className: "shrink-0" }),
3177
+ limitsText2(minLength, maxLength),
3178
+ error && /* @__PURE__ */ jsx45("span", { className: "sr-only", children: error })
3179
+ ] }),
3180
+ /* @__PURE__ */ jsxs32("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
3181
+ draft.length,
3182
+ maxLength !== void 0 && `/${maxLength}`
3183
+ ] })
3184
+ ]
3185
+ }
3161
3186
  )
3162
- ] }),
3163
- guarded && draft !== null && /* @__PURE__ */ jsxs32(
3164
- "p",
3165
- {
3166
- id: helperId,
3167
- role: error ? "alert" : void 0,
3168
- className: cn("flex items-start justify-between gap-2 text-ui-caption", error ? "text-destructive" : "text-secondary-muted-foreground"),
3169
- children: [
3170
- /* @__PURE__ */ jsxs32("span", { className: "flex items-start gap-2", children: [
3171
- error && /* @__PURE__ */ jsx45(WarningCircle4, { size: 16, "aria-hidden": true, className: "shrink-0" }),
3172
- limitsText2(minLength, maxLength),
3173
- error && /* @__PURE__ */ jsx45("span", { className: "sr-only", children: error })
3174
- ] }),
3175
- /* @__PURE__ */ jsxs32("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
3176
- draft.length,
3177
- maxLength !== void 0 && `/${maxLength}`
3178
- ] })
3179
- ]
3180
- }
3181
- )
3182
- ]
3187
+ ] })
3188
+ ] })
3183
3189
  }
3184
3190
  ),
3185
3191
  !locked && /* @__PURE__ */ jsxs32(