@discuss-ds/ui 0.14.1 → 0.16.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 +19 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -761,8 +761,25 @@ interface QuestionOptionEditorProps {
|
|
|
761
761
|
* its drag handle and number at rest and, like the other kinds, becomes the editor on hover or keyboard focus.
|
|
762
762
|
*/
|
|
763
763
|
rank?: number;
|
|
764
|
+
/**
|
|
765
|
+
* Makes the grip a drag handle for reordering (spread the handle props of your drag library, e.g. dnd-kit's `attributes` and
|
|
766
|
+
* `listeners`, with its `setActivatorNodeRef` as `ref`). The grip gets a grab cursor and is focusable; it is labelled
|
|
767
|
+
* "Reorder option N" (N from `rank`) unless you pass your own `aria-label`. Omit it for a plain, decorative grip.
|
|
768
|
+
*/
|
|
769
|
+
dragHandleProps?: React.ComponentPropsWithRef<'span'>;
|
|
770
|
+
/**
|
|
771
|
+
* The look of the row while it is being dragged: lifted shadow and the grip showing, as on hover. Use it on the copy that follows
|
|
772
|
+
* the pointer; the row left behind in the list is dimmed by the caller.
|
|
773
|
+
*/
|
|
774
|
+
lifted?: boolean;
|
|
775
|
+
/**
|
|
776
|
+
* Locks the row's place in the list: the label stays editable, but there is no drag grip (hover keeps the radio or checkbox
|
|
777
|
+
* indicator; a ranking row keeps its number) and no remove or add buttons. For editing a translation, where the options themselves
|
|
778
|
+
* are shared with the original.
|
|
779
|
+
*/
|
|
780
|
+
locked?: boolean;
|
|
764
781
|
}
|
|
765
|
-
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank }: QuestionOptionEditorProps): React.JSX.Element;
|
|
782
|
+
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
766
783
|
|
|
767
784
|
interface RankItemData {
|
|
768
785
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -761,8 +761,25 @@ interface QuestionOptionEditorProps {
|
|
|
761
761
|
* its drag handle and number at rest and, like the other kinds, becomes the editor on hover or keyboard focus.
|
|
762
762
|
*/
|
|
763
763
|
rank?: number;
|
|
764
|
+
/**
|
|
765
|
+
* Makes the grip a drag handle for reordering (spread the handle props of your drag library, e.g. dnd-kit's `attributes` and
|
|
766
|
+
* `listeners`, with its `setActivatorNodeRef` as `ref`). The grip gets a grab cursor and is focusable; it is labelled
|
|
767
|
+
* "Reorder option N" (N from `rank`) unless you pass your own `aria-label`. Omit it for a plain, decorative grip.
|
|
768
|
+
*/
|
|
769
|
+
dragHandleProps?: React.ComponentPropsWithRef<'span'>;
|
|
770
|
+
/**
|
|
771
|
+
* The look of the row while it is being dragged: lifted shadow and the grip showing, as on hover. Use it on the copy that follows
|
|
772
|
+
* the pointer; the row left behind in the list is dimmed by the caller.
|
|
773
|
+
*/
|
|
774
|
+
lifted?: boolean;
|
|
775
|
+
/**
|
|
776
|
+
* Locks the row's place in the list: the label stays editable, but there is no drag grip (hover keeps the radio or checkbox
|
|
777
|
+
* indicator; a ranking row keeps its number) and no remove or add buttons. For editing a translation, where the options themselves
|
|
778
|
+
* are shared with the original.
|
|
779
|
+
*/
|
|
780
|
+
locked?: boolean;
|
|
764
781
|
}
|
|
765
|
-
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank }: QuestionOptionEditorProps): React.JSX.Element;
|
|
782
|
+
declare function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
766
783
|
|
|
767
784
|
interface RankItemData {
|
|
768
785
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -2884,8 +2884,14 @@ var QuestionOtherOption = React44.forwardRef(
|
|
|
2884
2884
|
}
|
|
2885
2885
|
);
|
|
2886
2886
|
QuestionOtherOption.displayName = "QuestionOtherOption";
|
|
2887
|
-
function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank }) {
|
|
2887
|
+
function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted, locked }) {
|
|
2888
2888
|
const reveal = kind !== void 0;
|
|
2889
|
+
const gripProps = dragHandleProps ? {
|
|
2890
|
+
"aria-label": rank ? `Reorder option ${rank}` : "Reorder option",
|
|
2891
|
+
...dragHandleProps,
|
|
2892
|
+
className: cn("cursor-grab touch-none select-none", dragHandleProps.className)
|
|
2893
|
+
} : { "aria-hidden": true };
|
|
2894
|
+
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" });
|
|
2889
2895
|
return /* @__PURE__ */ jsxs31("div", { className: cn("group/option flex w-full items-center gap-2", className), children: [
|
|
2890
2896
|
/* @__PURE__ */ jsxs31(
|
|
2891
2897
|
"div",
|
|
@@ -2894,12 +2900,12 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2894
2900
|
"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",
|
|
2895
2901
|
reveal ? (
|
|
2896
2902
|
// The border is always visible and does not change on hover; only the shadow lifts the row. The field being edited keeps the accent.
|
|
2897
|
-
"border-border group-hover/option:shadow-md group-focus-within/option:shadow-md"
|
|
2903
|
+
cn("border-border group-hover/option:shadow-md group-focus-within/option:shadow-md", lifted && "shadow-md")
|
|
2898
2904
|
) : "border-border hover:border-input hover:shadow-md"
|
|
2899
2905
|
),
|
|
2900
2906
|
children: [
|
|
2901
2907
|
kind === "rank" ? /* @__PURE__ */ jsxs31(Fragment8, { children: [
|
|
2902
|
-
|
|
2908
|
+
!locked && grip,
|
|
2903
2909
|
/* @__PURE__ */ jsx45(
|
|
2904
2910
|
"span",
|
|
2905
2911
|
{
|
|
@@ -2908,12 +2914,14 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2908
2914
|
children: rank
|
|
2909
2915
|
}
|
|
2910
2916
|
)
|
|
2911
|
-
] }) : reveal ? /* @__PURE__ */
|
|
2917
|
+
] }) : 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: [
|
|
2912
2918
|
/* @__PURE__ */ jsx45(
|
|
2913
2919
|
"span",
|
|
2914
2920
|
{
|
|
2921
|
+
"aria-hidden": "true",
|
|
2915
2922
|
className: cn(
|
|
2916
2923
|
"inline-flex size-4 border-2 border-input bg-surface group-hover/option:hidden group-focus-within/option:hidden",
|
|
2924
|
+
lifted && "hidden",
|
|
2917
2925
|
kind === "radio" ? "rounded-full" : "rounded-xxs"
|
|
2918
2926
|
)
|
|
2919
2927
|
}
|
|
@@ -2922,10 +2930,14 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2922
2930
|
DotsSixVertical3,
|
|
2923
2931
|
{
|
|
2924
2932
|
size: 20,
|
|
2925
|
-
|
|
2933
|
+
"aria-hidden": true,
|
|
2934
|
+
className: cn(
|
|
2935
|
+
"hidden shrink-0 text-surface-foreground group-hover/option:block group-focus-within/option:block",
|
|
2936
|
+
lifted && "block"
|
|
2937
|
+
)
|
|
2926
2938
|
}
|
|
2927
2939
|
)
|
|
2928
|
-
] }) :
|
|
2940
|
+
] }) : locked ? null : grip,
|
|
2929
2941
|
/* @__PURE__ */ jsx45(
|
|
2930
2942
|
"input",
|
|
2931
2943
|
{
|
|
@@ -2938,7 +2950,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
|
|
|
2938
2950
|
]
|
|
2939
2951
|
}
|
|
2940
2952
|
),
|
|
2941
|
-
/* @__PURE__ */ jsxs31(
|
|
2953
|
+
!locked && /* @__PURE__ */ jsxs31(
|
|
2942
2954
|
"div",
|
|
2943
2955
|
{
|
|
2944
2956
|
className: cn(
|