@discuss-ds/ui 0.15.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/CHANGELOG.md +12 -0
- package/dist/index.cjs +17 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +17 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
|
@@ -772,8 +784,14 @@ interface QuestionOptionEditorProps {
|
|
|
772
784
|
* the pointer; the row left behind in the list is dimmed by the caller.
|
|
773
785
|
*/
|
|
774
786
|
lifted?: boolean;
|
|
787
|
+
/**
|
|
788
|
+
* Locks the row's place in the list: the label stays editable, but there is no drag grip (hover keeps the radio or checkbox
|
|
789
|
+
* indicator; a ranking row keeps its number) and no remove or add buttons. For editing a translation, where the options themselves
|
|
790
|
+
* are shared with the original.
|
|
791
|
+
*/
|
|
792
|
+
locked?: boolean;
|
|
775
793
|
}
|
|
776
|
-
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted }: QuestionOptionEditorProps): React.JSX.Element;
|
|
794
|
+
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
777
795
|
|
|
778
796
|
interface RankItemData {
|
|
779
797
|
id: string;
|
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
|
|
|
@@ -772,8 +784,14 @@ interface QuestionOptionEditorProps {
|
|
|
772
784
|
* the pointer; the row left behind in the list is dimmed by the caller.
|
|
773
785
|
*/
|
|
774
786
|
lifted?: boolean;
|
|
787
|
+
/**
|
|
788
|
+
* Locks the row's place in the list: the label stays editable, but there is no drag grip (hover keeps the radio or checkbox
|
|
789
|
+
* indicator; a ranking row keeps its number) and no remove or add buttons. For editing a translation, where the options themselves
|
|
790
|
+
* are shared with the original.
|
|
791
|
+
*/
|
|
792
|
+
locked?: boolean;
|
|
775
793
|
}
|
|
776
|
-
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted }: QuestionOptionEditorProps): React.JSX.Element;
|
|
794
|
+
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
777
795
|
|
|
778
796
|
interface RankItemData {
|
|
779
797
|
id: string;
|
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
|
|
2552
|
-
//
|
|
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
|
|
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,
|
|
@@ -2884,7 +2887,7 @@ var QuestionOtherOption = React44.forwardRef(
|
|
|
2884
2887
|
}
|
|
2885
2888
|
);
|
|
2886
2889
|
QuestionOtherOption.displayName = "QuestionOtherOption";
|
|
2887
|
-
function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted }) {
|
|
2890
|
+
function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted, locked }) {
|
|
2888
2891
|
const reveal = kind !== void 0;
|
|
2889
2892
|
const gripProps = dragHandleProps ? {
|
|
2890
2893
|
"aria-label": rank ? `Reorder option ${rank}` : "Reorder option",
|
|
@@ -2905,7 +2908,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2905
2908
|
),
|
|
2906
2909
|
children: [
|
|
2907
2910
|
kind === "rank" ? /* @__PURE__ */ jsxs31(Fragment8, { children: [
|
|
2908
|
-
grip,
|
|
2911
|
+
!locked && grip,
|
|
2909
2912
|
/* @__PURE__ */ jsx45(
|
|
2910
2913
|
"span",
|
|
2911
2914
|
{
|
|
@@ -2914,7 +2917,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2914
2917
|
children: rank
|
|
2915
2918
|
}
|
|
2916
2919
|
)
|
|
2917
|
-
] }) : reveal ? /* @__PURE__ */ jsxs31("span", { ...gripProps, className: cn("relative flex size-5 shrink-0 items-center justify-center", gripProps.className), children: [
|
|
2920
|
+
] }) : 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__ */ jsxs31("span", { ...gripProps, className: cn("relative flex size-5 shrink-0 items-center justify-center", gripProps.className), children: [
|
|
2918
2921
|
/* @__PURE__ */ jsx45(
|
|
2919
2922
|
"span",
|
|
2920
2923
|
{
|
|
@@ -2937,7 +2940,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2937
2940
|
)
|
|
2938
2941
|
}
|
|
2939
2942
|
)
|
|
2940
|
-
] }) : grip,
|
|
2943
|
+
] }) : locked ? null : grip,
|
|
2941
2944
|
/* @__PURE__ */ jsx45(
|
|
2942
2945
|
"input",
|
|
2943
2946
|
{
|
|
@@ -2950,7 +2953,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2950
2953
|
]
|
|
2951
2954
|
}
|
|
2952
2955
|
),
|
|
2953
|
-
/* @__PURE__ */ jsxs31(
|
|
2956
|
+
!locked && /* @__PURE__ */ jsxs31(
|
|
2954
2957
|
"div",
|
|
2955
2958
|
{
|
|
2956
2959
|
className: cn(
|