@discuss-ds/ui 0.3.5 → 0.4.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.cts CHANGED
@@ -734,8 +734,15 @@ interface QuestionOptionEditorProps {
734
734
  /** Called by the add (+) button. */
735
735
  onAdd?: () => void;
736
736
  className?: string;
737
+ /**
738
+ * Answer type. When set the row is quiet at rest: its normal border, the radio or checkbox indicator in front of the
739
+ * label, and the remove/add buttons hidden but still taking their space, so the row is the same width in every state.
740
+ * On hover or keyboard focus it becomes the editor: the shadow lifts, the drag handle replaces the indicator and the
741
+ * buttons appear. The border colour does not change. Omit it for an always-on editor row.
742
+ */
743
+ kind?: 'radio' | 'checkbox';
737
744
  }
738
- declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className }: QuestionOptionEditorProps): React.JSX.Element;
745
+ declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind }: QuestionOptionEditorProps): React.JSX.Element;
739
746
 
740
747
  interface RankItemData {
741
748
  id: string;
package/dist/index.d.ts CHANGED
@@ -734,8 +734,15 @@ interface QuestionOptionEditorProps {
734
734
  /** Called by the add (+) button. */
735
735
  onAdd?: () => void;
736
736
  className?: string;
737
+ /**
738
+ * Answer type. When set the row is quiet at rest: its normal border, the radio or checkbox indicator in front of the
739
+ * label, and the remove/add buttons hidden but still taking their space, so the row is the same width in every state.
740
+ * On hover or keyboard focus it becomes the editor: the shadow lifts, the drag handle replaces the indicator and the
741
+ * buttons appear. The border colour does not change. Omit it for an always-on editor row.
742
+ */
743
+ kind?: 'radio' | 'checkbox';
737
744
  }
738
- declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className }: QuestionOptionEditorProps): React.JSX.Element;
745
+ declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind }: QuestionOptionEditorProps): React.JSX.Element;
739
746
 
740
747
  interface RankItemData {
741
748
  id: string;
package/dist/index.js CHANGED
@@ -2832,22 +2832,63 @@ var QuestionOtherOption = React44.forwardRef(
2832
2832
  }
2833
2833
  );
2834
2834
  QuestionOtherOption.displayName = "QuestionOtherOption";
2835
- function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className }) {
2836
- return /* @__PURE__ */ jsxs31("div", { className: cn("flex w-full items-center gap-2", className), children: [
2837
- /* @__PURE__ */ jsxs31("div", { className: "flex h-11.5 min-w-0 flex-1 items-center gap-2 rounded-md border border-border bg-surface px-4 py-2 focus-within:border-input-accent hover:border-input hover:shadow-md", children: [
2838
- /* @__PURE__ */ jsx45(DotsSixVertical3, { size: 20, "aria-hidden": true, className: "shrink-0 text-surface-foreground" }),
2839
- /* @__PURE__ */ jsx45(
2840
- "input",
2841
- {
2842
- "aria-label": "Option label",
2843
- value: label,
2844
- onChange: (event) => onLabelChange?.(event.target.value),
2845
- className: "min-w-0 flex-1 bg-transparent text-body-base text-surface-foreground outline-none"
2846
- }
2847
- )
2848
- ] }),
2849
- /* @__PURE__ */ jsx45(Button, { type: "button", variant: "destructive", size: "icon-sm", "aria-label": "Remove option", onClick: onRemove, children: /* @__PURE__ */ jsx45(Trash4, { size: 16, "aria-hidden": true }) }),
2850
- /* @__PURE__ */ jsx45(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Add option", onClick: onAdd, children: /* @__PURE__ */ jsx45(Plus4, { size: 16, "aria-hidden": true }) })
2835
+ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind }) {
2836
+ const reveal = kind !== void 0;
2837
+ return /* @__PURE__ */ jsxs31("div", { className: cn("group/option flex w-full items-center gap-2", className), children: [
2838
+ /* @__PURE__ */ jsxs31(
2839
+ "div",
2840
+ {
2841
+ className: cn(
2842
+ "flex h-11.5 min-w-0 flex-1 items-center gap-2 rounded-md border bg-surface px-4 py-2 focus-within:border-input-accent",
2843
+ reveal ? (
2844
+ // The border is always visible and does not change on hover; only the shadow lifts the row. The field being edited keeps the accent.
2845
+ "border-border group-hover/option:shadow-md group-focus-within/option:shadow-md"
2846
+ ) : "border-border hover:border-input hover:shadow-md"
2847
+ ),
2848
+ children: [
2849
+ reveal ? /* @__PURE__ */ jsxs31("span", { "aria-hidden": "true", className: "relative flex size-5 shrink-0 items-center justify-center", children: [
2850
+ /* @__PURE__ */ jsx45(
2851
+ "span",
2852
+ {
2853
+ className: cn(
2854
+ "inline-flex size-4 border-2 border-input bg-surface group-hover/option:hidden group-focus-within/option:hidden",
2855
+ kind === "radio" ? "rounded-full" : "rounded-xxs"
2856
+ )
2857
+ }
2858
+ ),
2859
+ /* @__PURE__ */ jsx45(
2860
+ DotsSixVertical3,
2861
+ {
2862
+ size: 20,
2863
+ className: "hidden shrink-0 text-surface-foreground group-hover/option:block group-focus-within/option:block"
2864
+ }
2865
+ )
2866
+ ] }) : /* @__PURE__ */ jsx45(DotsSixVertical3, { size: 20, "aria-hidden": true, className: "shrink-0 text-surface-foreground" }),
2867
+ /* @__PURE__ */ jsx45(
2868
+ "input",
2869
+ {
2870
+ "aria-label": "Option label",
2871
+ value: label,
2872
+ onChange: (event) => onLabelChange?.(event.target.value),
2873
+ className: "min-w-0 flex-1 bg-transparent text-body-base text-surface-foreground outline-none"
2874
+ }
2875
+ )
2876
+ ]
2877
+ }
2878
+ ),
2879
+ /* @__PURE__ */ jsxs31(
2880
+ "div",
2881
+ {
2882
+ className: cn(
2883
+ "flex items-center gap-2",
2884
+ reveal && "opacity-0 transition-opacity group-hover/option:opacity-100 group-focus-within/option:opacity-100"
2885
+ ),
2886
+ children: [
2887
+ /* @__PURE__ */ jsx45(Button, { type: "button", variant: "destructive", size: "icon-sm", "aria-label": "Remove option", onClick: onRemove, children: /* @__PURE__ */ jsx45(Trash4, { size: 16, "aria-hidden": true }) }),
2888
+ /* @__PURE__ */ jsx45(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Add option", onClick: onAdd, children: /* @__PURE__ */ jsx45(Plus4, { size: 16, "aria-hidden": true }) })
2889
+ ]
2890
+ }
2891
+ )
2851
2892
  ] });
2852
2893
  }
2853
2894