@discuss-ds/ui 0.3.5 → 0.4.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,11 @@
1
1
  # @discuss-ds/ui
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#21](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/21) [`a7ebe02`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/a7ebe02f16a57fd1e40115e9a949484f23e1103a) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `QuestionOptionEditor` gets an optional `kind` (`radio` | `checkbox`). With it the row is quiet at rest (no border, the radio or checkbox indicator in front of the label) and turns into the editor on hover or keyboard focus: border and shadow, the drag handle replaces the indicator, and the remove and add buttons appear. The buttons keep their space while hidden, so the row is the same width in every state. Without `kind` the row is the same always-on editor as before.
8
+
3
9
  ## 0.3.5
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -2978,22 +2978,64 @@ var QuestionOtherOption = React44.forwardRef(
2978
2978
  }
2979
2979
  );
2980
2980
  QuestionOtherOption.displayName = "QuestionOtherOption";
2981
- function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className }) {
2982
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: cn("flex w-full items-center gap-2", className), children: [
2983
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("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: [
2984
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.DotsSixVertical, { size: 20, "aria-hidden": true, className: "shrink-0 text-surface-foreground" }),
2985
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
2986
- "input",
2987
- {
2988
- "aria-label": "Option label",
2989
- value: label,
2990
- onChange: (event) => onLabelChange?.(event.target.value),
2991
- className: "min-w-0 flex-1 bg-transparent text-body-base text-surface-foreground outline-none"
2992
- }
2993
- )
2994
- ] }),
2995
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { type: "button", variant: "destructive", size: "icon-sm", "aria-label": "Remove option", onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.Trash, { size: 16, "aria-hidden": true }) }),
2996
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Add option", onClick: onAdd, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.Plus, { size: 16, "aria-hidden": true }) })
2981
+ function QuestionOptionEditor({ label, onLabelChange, onRemove, onAdd, className, kind }) {
2982
+ const reveal = kind !== void 0;
2983
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: cn("group/option flex w-full items-center gap-2", className), children: [
2984
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
2985
+ "div",
2986
+ {
2987
+ className: cn(
2988
+ "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",
2989
+ reveal ? [
2990
+ // Hover or focus anywhere in the row shows the border; the field being edited keeps the accent.
2991
+ "border-transparent group-hover/option:not-focus-within:border-border group-focus-within/option:not-focus-within:border-border",
2992
+ "group-hover/option:shadow-md group-focus-within/option:shadow-md"
2993
+ ] : "border-border hover:border-input hover:shadow-md"
2994
+ ),
2995
+ children: [
2996
+ reveal ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { "aria-hidden": "true", className: "relative flex size-5 shrink-0 items-center justify-center", children: [
2997
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
2998
+ "span",
2999
+ {
3000
+ className: cn(
3001
+ "inline-flex size-4 border-2 border-input bg-surface group-hover/option:hidden group-focus-within/option:hidden",
3002
+ kind === "radio" ? "rounded-full" : "rounded-xxs"
3003
+ )
3004
+ }
3005
+ ),
3006
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3007
+ import_react23.DotsSixVertical,
3008
+ {
3009
+ size: 20,
3010
+ className: "hidden shrink-0 text-surface-foreground group-hover/option:block group-focus-within/option:block"
3011
+ }
3012
+ )
3013
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.DotsSixVertical, { size: 20, "aria-hidden": true, className: "shrink-0 text-surface-foreground" }),
3014
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3015
+ "input",
3016
+ {
3017
+ "aria-label": "Option label",
3018
+ value: label,
3019
+ onChange: (event) => onLabelChange?.(event.target.value),
3020
+ className: "min-w-0 flex-1 bg-transparent text-body-base text-surface-foreground outline-none"
3021
+ }
3022
+ )
3023
+ ]
3024
+ }
3025
+ ),
3026
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
3027
+ "div",
3028
+ {
3029
+ className: cn(
3030
+ "flex items-center gap-2",
3031
+ reveal && "opacity-0 transition-opacity group-hover/option:opacity-100 group-focus-within/option:opacity-100"
3032
+ ),
3033
+ children: [
3034
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { type: "button", variant: "destructive", size: "icon-sm", "aria-label": "Remove option", onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.Trash, { size: 16, "aria-hidden": true }) }),
3035
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Add option", onClick: onAdd, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react23.Plus, { size: 16, "aria-hidden": true }) })
3036
+ ]
3037
+ }
3038
+ )
2997
3039
  ] });
2998
3040
  }
2999
3041