@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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @discuss-ds/ui
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#72](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/72) [`8956850`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/89568503fd76b323d9af660ed59ad1b41f9b3fd1) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - QuestionHeader, QuestionEditorCard and QuestionNavItem: new optional `showDragHandle` prop (default true). Set it to false when the question or row can't be moved, so the grip icon is not shown on hover and the tag or row doesn't shift to make room for it. Nothing changes for existing callers.
8
+
9
+ ## 0.16.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#70](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/70) [`d0d0a23`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/d0d0a23de66894ce7d569f13c5129faad72e83d9) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - QuestionOptionEditor: new optional `locked` prop keeps the label editable but removes the drag grip and the remove and add buttons, for editing a translation of options that are shared with the original. Nothing changes for existing callers.
14
+
3
15
  ## 0.15.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -2678,7 +2678,7 @@ var import_react19 = require("@phosphor-icons/react");
2678
2678
  var import_jsx_runtime41 = require("react/jsx-runtime");
2679
2679
  var eyebrow = "text-ui-caption uppercase text-secondary-muted-foreground";
2680
2680
  var QuestionHeader = React40.forwardRef(
2681
- ({ className, number, title, required, error, onDismissError, editor, onTitleChange, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, ...props }, ref) => {
2681
+ ({ className, number, title, required, error, onDismissError, editor, onTitleChange, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, ...props }, ref) => {
2682
2682
  const [draft, setDraft] = React40.useState(null);
2683
2683
  const label = String(number).padStart(2, "0");
2684
2684
  const showError = error !== void 0 && error !== false;
@@ -2694,15 +2694,16 @@ var QuestionHeader = React40.forwardRef(
2694
2694
  "aria-label": dragHandleProps ? `Reorder question ${number}` : void 0,
2695
2695
  ...dragHandleProps,
2696
2696
  className: cn(
2697
- "group/handle inline-flex h-6 items-center gap-1 rounded-sm px-2.5 text-ui-caption hover:pl-1",
2698
- // Inside a QuestionEditorCard the tag takes its hover look whenever the card is hovered.
2699
- "group-hover/editor:pl-1",
2697
+ "group/handle inline-flex h-6 items-center gap-1 rounded-sm px-2.5 text-ui-caption",
2698
+ // The tag makes room for the grip on hover, and inside a QuestionEditorCard whenever the card is hovered.
2699
+ showDragHandle && "hover:pl-1 group-hover/editor:pl-1",
2700
2700
  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",
2701
- dragHandleProps && "cursor-grab touch-none select-none focus-visible:pl-1",
2701
+ dragHandleProps && "cursor-grab touch-none select-none",
2702
+ dragHandleProps && showDragHandle && "focus-visible:pl-1",
2702
2703
  dragHandleProps?.className
2703
2704
  ),
2704
2705
  children: [
2705
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2706
+ showDragHandle && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2706
2707
  import_react19.DotsSixVertical,
2707
2708
  {
2708
2709
  size: 16,
@@ -2788,6 +2789,7 @@ var QuestionEditorCard = React41.forwardRef(
2788
2789
  error,
2789
2790
  meta,
2790
2791
  dragHandleProps,
2792
+ showDragHandle,
2791
2793
  children,
2792
2794
  ...props
2793
2795
  }, ref) => {
@@ -2819,6 +2821,7 @@ var QuestionEditorCard = React41.forwardRef(
2819
2821
  active,
2820
2822
  showCounter: !!active,
2821
2823
  dragHandleProps,
2824
+ showDragHandle,
2822
2825
  meta,
2823
2826
  maxLength,
2824
2827
  actions: actions ?? /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
@@ -2934,7 +2937,7 @@ function QuestionTypeIcon({ type, size = 22.5, className, ...props }) {
2934
2937
  // src/components/Question Types/QuestionNavItem.tsx
2935
2938
  var import_jsx_runtime44 = require("react/jsx-runtime");
2936
2939
  var QuestionNavItem = React43.forwardRef(
2937
- ({ className, questionType = "select-one", selected, error, asChild, children, ...props }, ref) => {
2940
+ ({ className, questionType = "select-one", selected, error, asChild, showDragHandle = true, children, ...props }, ref) => {
2938
2941
  const Comp = asChild ? import_radix_ui21.Slot.Root : "button";
2939
2942
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
2940
2943
  Comp,
@@ -2954,8 +2957,8 @@ var QuestionNavItem = React43.forwardRef(
2954
2957
  ...props,
2955
2958
  children: [
2956
2959
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { "aria-hidden": "true", className: "relative flex size-4 shrink-0 items-center justify-center", children: [
2957
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react22.DotsSixVertical, { size: 16, className: "hidden group-hover/nav:block" }),
2958
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "group-hover/nav:hidden", children: error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react22.Warning, { size: 16, className: "text-destructive-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2960
+ showDragHandle && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react22.DotsSixVertical, { size: 16, className: "hidden group-hover/nav:block" }),
2961
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: showDragHandle ? "group-hover/nav:hidden" : void 0, children: error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react22.Warning, { size: 16, className: "text-destructive-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2959
2962
  QuestionTypeIcon,
2960
2963
  {
2961
2964
  type: questionType,
@@ -3030,7 +3033,7 @@ var QuestionOtherOption = React44.forwardRef(
3030
3033
  }
3031
3034
  );
3032
3035
  QuestionOtherOption.displayName = "QuestionOtherOption";
3033
- function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted }) {
3036
+ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind, rank, dragHandleProps, lifted, locked }) {
3034
3037
  const reveal = kind !== void 0;
3035
3038
  const gripProps = dragHandleProps ? {
3036
3039
  "aria-label": rank ? `Reorder option ${rank}` : "Reorder option",
@@ -3051,7 +3054,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
3051
3054
  ),
3052
3055
  children: [
3053
3056
  kind === "rank" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
3054
- grip,
3057
+ !locked && grip,
3055
3058
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3056
3059
  "span",
3057
3060
  {
@@ -3060,7 +3063,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
3060
3063
  children: rank
3061
3064
  }
3062
3065
  )
3063
- ] }) : reveal ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { ...gripProps, className: cn("relative flex size-5 shrink-0 items-center justify-center", gripProps.className), children: [
3066
+ ] }) : reveal && locked ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { "aria-hidden": "true", className: "relative flex size-5 shrink-0 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: cn("inline-flex size-4 border-2 border-input bg-surface", kind === "radio" ? "rounded-full" : "rounded-xxs") }) }) : reveal ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { ...gripProps, className: cn("relative flex size-5 shrink-0 items-center justify-center", gripProps.className), children: [
3064
3067
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3065
3068
  "span",
3066
3069
  {
@@ -3083,7 +3086,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
3083
3086
  )
3084
3087
  }
3085
3088
  )
3086
- ] }) : grip,
3089
+ ] }) : locked ? null : grip,
3087
3090
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3088
3091
  "input",
3089
3092
  {
@@ -3096,7 +3099,7 @@ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className
3096
3099
  ]
3097
3100
  }
3098
3101
  ),
3099
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
3102
+ !locked && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
3100
3103
  "div",
3101
3104
  {
3102
3105
  className: cn(