@discuss-ds/ui 0.16.0 → 0.17.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
@@ -663,6 +663,8 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
663
663
  note?: React.ReactNode;
664
664
  /** Makes the "Question N" tag a drag handle for reordering. See `QuestionHeader`'s `dragHandleProps`. */
665
665
  dragHandleProps?: React.ComponentPropsWithRef<'span'>;
666
+ /** Whether the grip icon shows in the "Question N" tag on hover. Defaults to true; set false when the card can't be moved. See `QuestionHeader`. */
667
+ showDragHandle?: boolean;
666
668
  }
667
669
  declare const QuestionEditorCard: React.ForwardRefExoticComponent<QuestionEditorCardProps & React.RefAttributes<HTMLDivElement>>;
668
670
 
@@ -696,6 +698,11 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
696
698
  * pass your own `aria-label`. Omit it for the plain tag.
697
699
  */
698
700
  dragHandleProps?: React.ComponentPropsWithRef<'span'>;
701
+ /**
702
+ * Whether the grip icon appears in the "Question N" tag on hover or focus. Defaults to true. Set it to false when the question
703
+ * can't be moved (for example while a translation is being edited), so the tag doesn't suggest dragging.
704
+ */
705
+ showDragHandle?: boolean;
699
706
  }
700
707
  declare const QuestionHeader: React.ForwardRefExoticComponent<QuestionHeaderProps & React.RefAttributes<HTMLDivElement>>;
701
708
 
@@ -714,6 +721,11 @@ interface QuestionNavItemProps extends React.ButtonHTMLAttributes<HTMLButtonElem
714
721
  error?: boolean;
715
722
  /** Render the child element instead of a `<button>` (e.g. a router link). */
716
723
  asChild?: boolean;
724
+ /**
725
+ * Whether hovering swaps the type icon for the drag grip. Defaults to true. Set it to false when the row can't be moved (for
726
+ * example while a translation is being edited), so the icon stays and the row doesn't suggest dragging.
727
+ */
728
+ showDragHandle?: boolean;
717
729
  }
718
730
  declare const QuestionNavItem: React.ForwardRefExoticComponent<QuestionNavItemProps & React.RefAttributes<HTMLButtonElement>>;
719
731
 
package/dist/index.d.ts CHANGED
@@ -663,6 +663,8 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
663
663
  note?: React.ReactNode;
664
664
  /** Makes the "Question N" tag a drag handle for reordering. See `QuestionHeader`'s `dragHandleProps`. */
665
665
  dragHandleProps?: React.ComponentPropsWithRef<'span'>;
666
+ /** Whether the grip icon shows in the "Question N" tag on hover. Defaults to true; set false when the card can't be moved. See `QuestionHeader`. */
667
+ showDragHandle?: boolean;
666
668
  }
667
669
  declare const QuestionEditorCard: React.ForwardRefExoticComponent<QuestionEditorCardProps & React.RefAttributes<HTMLDivElement>>;
668
670
 
@@ -696,6 +698,11 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
696
698
  * pass your own `aria-label`. Omit it for the plain tag.
697
699
  */
698
700
  dragHandleProps?: React.ComponentPropsWithRef<'span'>;
701
+ /**
702
+ * Whether the grip icon appears in the "Question N" tag on hover or focus. Defaults to true. Set it to false when the question
703
+ * can't be moved (for example while a translation is being edited), so the tag doesn't suggest dragging.
704
+ */
705
+ showDragHandle?: boolean;
699
706
  }
700
707
  declare const QuestionHeader: React.ForwardRefExoticComponent<QuestionHeaderProps & React.RefAttributes<HTMLDivElement>>;
701
708
 
@@ -714,6 +721,11 @@ interface QuestionNavItemProps extends React.ButtonHTMLAttributes<HTMLButtonElem
714
721
  error?: boolean;
715
722
  /** Render the child element instead of a `<button>` (e.g. a router link). */
716
723
  asChild?: boolean;
724
+ /**
725
+ * Whether hovering swaps the type icon for the drag grip. Defaults to true. Set it to false when the row can't be moved (for
726
+ * example while a translation is being edited), so the icon stays and the row doesn't suggest dragging.
727
+ */
728
+ showDragHandle?: boolean;
717
729
  }
718
730
  declare const QuestionNavItem: React.ForwardRefExoticComponent<QuestionNavItemProps & React.RefAttributes<HTMLButtonElement>>;
719
731
 
package/dist/index.js CHANGED
@@ -2532,7 +2532,7 @@ import { DotsSixVertical } from "@phosphor-icons/react";
2532
2532
  import { jsx as jsx41, jsxs as jsxs28 } from "react/jsx-runtime";
2533
2533
  var eyebrow = "text-ui-caption uppercase text-secondary-muted-foreground";
2534
2534
  var QuestionHeader = React40.forwardRef(
2535
- ({ className, number, title, required, error, onDismissError, editor, onTitleChange, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, ...props }, ref) => {
2535
+ ({ className, number, title, required, error, onDismissError, editor, onTitleChange, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, ...props }, ref) => {
2536
2536
  const [draft, setDraft] = React40.useState(null);
2537
2537
  const label = String(number).padStart(2, "0");
2538
2538
  const showError = error !== void 0 && error !== false;
@@ -2548,15 +2548,16 @@ var QuestionHeader = React40.forwardRef(
2548
2548
  "aria-label": dragHandleProps ? `Reorder question ${number}` : void 0,
2549
2549
  ...dragHandleProps,
2550
2550
  className: cn(
2551
- "group/handle inline-flex h-6 items-center gap-1 rounded-sm px-2.5 text-ui-caption hover:pl-1",
2552
- // Inside a QuestionEditorCard the tag takes its hover look whenever the card is hovered.
2553
- "group-hover/editor:pl-1",
2551
+ "group/handle inline-flex h-6 items-center gap-1 rounded-sm px-2.5 text-ui-caption",
2552
+ // The tag makes room for the grip on hover, and inside a QuestionEditorCard whenever the card is hovered.
2553
+ showDragHandle && "hover:pl-1 group-hover/editor:pl-1",
2554
2554
  active ? "bg-accent-soft text-accent-soft-foreground" : "bg-secondary bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5 text-surface-foreground",
2555
- dragHandleProps && "cursor-grab touch-none select-none focus-visible:pl-1",
2555
+ dragHandleProps && "cursor-grab touch-none select-none",
2556
+ dragHandleProps && showDragHandle && "focus-visible:pl-1",
2556
2557
  dragHandleProps?.className
2557
2558
  ),
2558
2559
  children: [
2559
- /* @__PURE__ */ jsx41(
2560
+ showDragHandle && /* @__PURE__ */ jsx41(
2560
2561
  DotsSixVertical,
2561
2562
  {
2562
2563
  size: 16,
@@ -2642,6 +2643,7 @@ var QuestionEditorCard = React41.forwardRef(
2642
2643
  error,
2643
2644
  meta,
2644
2645
  dragHandleProps,
2646
+ showDragHandle,
2645
2647
  children,
2646
2648
  ...props
2647
2649
  }, ref) => {
@@ -2673,6 +2675,7 @@ var QuestionEditorCard = React41.forwardRef(
2673
2675
  active,
2674
2676
  showCounter: !!active,
2675
2677
  dragHandleProps,
2678
+ showDragHandle,
2676
2679
  meta,
2677
2680
  maxLength,
2678
2681
  actions: actions ?? /* @__PURE__ */ jsxs29(Fragment7, { children: [
@@ -2788,7 +2791,7 @@ function QuestionTypeIcon({ type, size = 22.5, className, ...props }) {
2788
2791
  // src/components/Question Types/QuestionNavItem.tsx
2789
2792
  import { jsx as jsx44, jsxs as jsxs30 } from "react/jsx-runtime";
2790
2793
  var QuestionNavItem = React43.forwardRef(
2791
- ({ className, questionType = "select-one", selected, error, asChild, children, ...props }, ref) => {
2794
+ ({ className, questionType = "select-one", selected, error, asChild, showDragHandle = true, children, ...props }, ref) => {
2792
2795
  const Comp = asChild ? Slot3.Root : "button";
2793
2796
  return /* @__PURE__ */ jsxs30(
2794
2797
  Comp,
@@ -2808,8 +2811,8 @@ var QuestionNavItem = React43.forwardRef(
2808
2811
  ...props,
2809
2812
  children: [
2810
2813
  /* @__PURE__ */ jsxs30("span", { "aria-hidden": "true", className: "relative flex size-4 shrink-0 items-center justify-center", children: [
2811
- /* @__PURE__ */ jsx44(DotsSixVertical2, { size: 16, className: "hidden group-hover/nav:block" }),
2812
- /* @__PURE__ */ jsx44("span", { className: "group-hover/nav:hidden", children: error ? /* @__PURE__ */ jsx44(Warning3, { size: 16, className: "text-destructive-foreground" }) : /* @__PURE__ */ jsx44(
2814
+ showDragHandle && /* @__PURE__ */ jsx44(DotsSixVertical2, { size: 16, className: "hidden group-hover/nav:block" }),
2815
+ /* @__PURE__ */ jsx44("span", { className: showDragHandle ? "group-hover/nav:hidden" : void 0, children: error ? /* @__PURE__ */ jsx44(Warning3, { size: 16, className: "text-destructive-foreground" }) : /* @__PURE__ */ jsx44(
2813
2816
  QuestionTypeIcon,
2814
2817
  {
2815
2818
  type: questionType,