@discuss-ds/ui 0.28.0 → 0.29.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 +6 -0
- package/dist/index.cjs +133 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +134 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -328,8 +328,10 @@ interface InlineEditProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'on
|
|
|
328
328
|
defaultValue?: string;
|
|
329
329
|
/** Called when an edit is committed (Enter, blur or the commit key for multiline) with a changed value. */
|
|
330
330
|
onValueChange?: (value: string) => void;
|
|
331
|
-
/** Shown in read mode
|
|
331
|
+
/** Shown in read mode while the value is empty, muted unless `placeholderTone` says otherwise. */
|
|
332
332
|
placeholder?: string;
|
|
333
|
+
/** `regular` shows the placeholder in the normal text colour instead of the muted one, for hints that read as real content. Default `muted`. */
|
|
334
|
+
placeholderTone?: 'muted' | 'regular';
|
|
333
335
|
/** Accessible name for the read button and the field. Required: there is no visible label. */
|
|
334
336
|
'aria-label': string;
|
|
335
337
|
/** Use a textarea. Enter inserts a line break; Cmd/Ctrl+Enter commits. */
|
|
@@ -668,6 +670,10 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
668
670
|
onTitleChange?: (title: string) => void;
|
|
669
671
|
/** Shown while the title is empty. Defaults to "Click to write the question text". */
|
|
670
672
|
titlePlaceholder?: string;
|
|
673
|
+
/** `regular` shows the title placeholder in the normal text colour instead of the muted one. Default `muted`. */
|
|
674
|
+
titlePlaceholderTone?: 'muted' | 'regular';
|
|
675
|
+
/** Shortest title (in characters) that may be saved. Turns on the title guardrail: see `QuestionHeader`'s `titleMinLength`. */
|
|
676
|
+
titleMinLength?: number;
|
|
671
677
|
/** The question is being edited: accent border, counter and footer are shown. */
|
|
672
678
|
active?: boolean;
|
|
673
679
|
/**
|
|
@@ -717,6 +723,14 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
717
723
|
onTitleChange?: (title: string) => void;
|
|
718
724
|
/** Editor mode: shown while the title is empty. Defaults to "Click to write the question text". */
|
|
719
725
|
titlePlaceholder?: string;
|
|
726
|
+
/** Editor mode: `regular` shows the title placeholder in the normal text colour instead of the muted one. Default `muted`. */
|
|
727
|
+
titlePlaceholderTone?: 'muted' | 'regular';
|
|
728
|
+
/**
|
|
729
|
+
* Editor mode: shortest title (in characters) that may be saved. When set, the title's limits guardrail turns on: while the title
|
|
730
|
+
* is being edited a line under it shows the allowed range and the live count (using `maxLength`), a title that is too short is not
|
|
731
|
+
* saved (the field stays open and says why), and the always-on counter is replaced by that line.
|
|
732
|
+
*/
|
|
733
|
+
titleMinLength?: number;
|
|
720
734
|
/** Editor mode: action buttons (copy, delete, preview, AI) revealed on hover or focus. */
|
|
721
735
|
actions?: React.ReactNode;
|
|
722
736
|
/** Editor mode: content shown right beside the "Question N" tag, e.g. the time allowed for the question. */
|
|
@@ -803,6 +817,18 @@ interface QuestionOptionEditorProps {
|
|
|
803
817
|
onAdd?: () => void;
|
|
804
818
|
/** Shown while the option is empty, for example "Option 1". */
|
|
805
819
|
placeholder?: string;
|
|
820
|
+
/** `regular` shows the placeholder in the normal text colour instead of the muted one. Default `muted`. */
|
|
821
|
+
placeholderTone?: 'muted' | 'regular';
|
|
822
|
+
/**
|
|
823
|
+
* Shortest label (in characters, ignoring surrounding spaces) that may be saved. With `minLength` or `maxLength` the label is
|
|
824
|
+
* guarded like an `InlineEdit`: typing only changes a draft, Enter or leaving the field saves it through `onLabelChange`, a label
|
|
825
|
+
* that is too short is not saved (the field stays open and says why), Escape reverts, and while it is being edited a line under
|
|
826
|
+
* the row shows the allowed range and the live count. An unchanged label is never refused. Without either, `onLabelChange` is
|
|
827
|
+
* called on every keystroke as before.
|
|
828
|
+
*/
|
|
829
|
+
minLength?: number;
|
|
830
|
+
/** Longest label (in characters). See `minLength`. */
|
|
831
|
+
maxLength?: number;
|
|
806
832
|
/** Disables the trash button, for example when the question is already at its minimum number of options. */
|
|
807
833
|
removeDisabled?: boolean;
|
|
808
834
|
/** Disables the add (+) button, for example when the question is already at its maximum number of options. */
|
|
@@ -838,7 +864,7 @@ interface QuestionOptionEditorProps {
|
|
|
838
864
|
*/
|
|
839
865
|
locked?: boolean;
|
|
840
866
|
}
|
|
841
|
-
declare function QuestionOptionEditor({ label, onLabelChange, placeholder, onRemove, onAdd, removeDisabled, addDisabled, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
867
|
+
declare function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTone, minLength, maxLength, onRemove, onAdd, removeDisabled, addDisabled, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
842
868
|
|
|
843
869
|
interface RankItemData {
|
|
844
870
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -328,8 +328,10 @@ interface InlineEditProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'on
|
|
|
328
328
|
defaultValue?: string;
|
|
329
329
|
/** Called when an edit is committed (Enter, blur or the commit key for multiline) with a changed value. */
|
|
330
330
|
onValueChange?: (value: string) => void;
|
|
331
|
-
/** Shown in read mode
|
|
331
|
+
/** Shown in read mode while the value is empty, muted unless `placeholderTone` says otherwise. */
|
|
332
332
|
placeholder?: string;
|
|
333
|
+
/** `regular` shows the placeholder in the normal text colour instead of the muted one, for hints that read as real content. Default `muted`. */
|
|
334
|
+
placeholderTone?: 'muted' | 'regular';
|
|
333
335
|
/** Accessible name for the read button and the field. Required: there is no visible label. */
|
|
334
336
|
'aria-label': string;
|
|
335
337
|
/** Use a textarea. Enter inserts a line break; Cmd/Ctrl+Enter commits. */
|
|
@@ -668,6 +670,10 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
668
670
|
onTitleChange?: (title: string) => void;
|
|
669
671
|
/** Shown while the title is empty. Defaults to "Click to write the question text". */
|
|
670
672
|
titlePlaceholder?: string;
|
|
673
|
+
/** `regular` shows the title placeholder in the normal text colour instead of the muted one. Default `muted`. */
|
|
674
|
+
titlePlaceholderTone?: 'muted' | 'regular';
|
|
675
|
+
/** Shortest title (in characters) that may be saved. Turns on the title guardrail: see `QuestionHeader`'s `titleMinLength`. */
|
|
676
|
+
titleMinLength?: number;
|
|
671
677
|
/** The question is being edited: accent border, counter and footer are shown. */
|
|
672
678
|
active?: boolean;
|
|
673
679
|
/**
|
|
@@ -717,6 +723,14 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
717
723
|
onTitleChange?: (title: string) => void;
|
|
718
724
|
/** Editor mode: shown while the title is empty. Defaults to "Click to write the question text". */
|
|
719
725
|
titlePlaceholder?: string;
|
|
726
|
+
/** Editor mode: `regular` shows the title placeholder in the normal text colour instead of the muted one. Default `muted`. */
|
|
727
|
+
titlePlaceholderTone?: 'muted' | 'regular';
|
|
728
|
+
/**
|
|
729
|
+
* Editor mode: shortest title (in characters) that may be saved. When set, the title's limits guardrail turns on: while the title
|
|
730
|
+
* is being edited a line under it shows the allowed range and the live count (using `maxLength`), a title that is too short is not
|
|
731
|
+
* saved (the field stays open and says why), and the always-on counter is replaced by that line.
|
|
732
|
+
*/
|
|
733
|
+
titleMinLength?: number;
|
|
720
734
|
/** Editor mode: action buttons (copy, delete, preview, AI) revealed on hover or focus. */
|
|
721
735
|
actions?: React.ReactNode;
|
|
722
736
|
/** Editor mode: content shown right beside the "Question N" tag, e.g. the time allowed for the question. */
|
|
@@ -803,6 +817,18 @@ interface QuestionOptionEditorProps {
|
|
|
803
817
|
onAdd?: () => void;
|
|
804
818
|
/** Shown while the option is empty, for example "Option 1". */
|
|
805
819
|
placeholder?: string;
|
|
820
|
+
/** `regular` shows the placeholder in the normal text colour instead of the muted one. Default `muted`. */
|
|
821
|
+
placeholderTone?: 'muted' | 'regular';
|
|
822
|
+
/**
|
|
823
|
+
* Shortest label (in characters, ignoring surrounding spaces) that may be saved. With `minLength` or `maxLength` the label is
|
|
824
|
+
* guarded like an `InlineEdit`: typing only changes a draft, Enter or leaving the field saves it through `onLabelChange`, a label
|
|
825
|
+
* that is too short is not saved (the field stays open and says why), Escape reverts, and while it is being edited a line under
|
|
826
|
+
* the row shows the allowed range and the live count. An unchanged label is never refused. Without either, `onLabelChange` is
|
|
827
|
+
* called on every keystroke as before.
|
|
828
|
+
*/
|
|
829
|
+
minLength?: number;
|
|
830
|
+
/** Longest label (in characters). See `minLength`. */
|
|
831
|
+
maxLength?: number;
|
|
806
832
|
/** Disables the trash button, for example when the question is already at its minimum number of options. */
|
|
807
833
|
removeDisabled?: boolean;
|
|
808
834
|
/** Disables the add (+) button, for example when the question is already at its maximum number of options. */
|
|
@@ -838,7 +864,7 @@ interface QuestionOptionEditorProps {
|
|
|
838
864
|
*/
|
|
839
865
|
locked?: boolean;
|
|
840
866
|
}
|
|
841
|
-
declare function QuestionOptionEditor({ label, onLabelChange, placeholder, onRemove, onAdd, removeDisabled, addDisabled, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
867
|
+
declare function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTone, minLength, maxLength, onRemove, onAdd, removeDisabled, addDisabled, className, kind, rank, dragHandleProps, lifted, locked }: QuestionOptionEditorProps): React.JSX.Element;
|
|
842
868
|
|
|
843
869
|
interface RankItemData {
|
|
844
870
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -1444,8 +1444,7 @@ import * as React24 from "react";
|
|
|
1444
1444
|
import { PencilSimple, WarningCircle as WarningCircle2 } from "@phosphor-icons/react";
|
|
1445
1445
|
import { Fragment as Fragment4, jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1446
1446
|
function limitsText(min, max) {
|
|
1447
|
-
if (min !== void 0
|
|
1448
|
-
if (min !== void 0) return `At least ${min} characters`;
|
|
1447
|
+
if (min !== void 0) return `${min} ${min === 1 ? "character" : "characters"} required`;
|
|
1449
1448
|
if (max !== void 0) return `Up to ${max} characters`;
|
|
1450
1449
|
return "";
|
|
1451
1450
|
}
|
|
@@ -1457,6 +1456,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1457
1456
|
defaultValue = "",
|
|
1458
1457
|
onValueChange,
|
|
1459
1458
|
placeholder = "Click to edit",
|
|
1459
|
+
placeholderTone = "muted",
|
|
1460
1460
|
multiline,
|
|
1461
1461
|
maxLength,
|
|
1462
1462
|
minLength,
|
|
@@ -1605,7 +1605,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1605
1605
|
textClasses
|
|
1606
1606
|
),
|
|
1607
1607
|
children: [
|
|
1608
|
-
/* @__PURE__ */ jsx25("span", { className: cn("min-w-0", multiline ? "whitespace-pre-wrap" : "truncate", fill && "flex-1", !value && "text-muted-foreground"), children: value || placeholder }),
|
|
1608
|
+
/* @__PURE__ */ jsx25("span", { className: cn("min-w-0", multiline ? "whitespace-pre-wrap" : "truncate", fill && "flex-1", !value && placeholderTone === "muted" && "text-muted-foreground"), children: value || placeholder }),
|
|
1609
1609
|
!fill && /* @__PURE__ */ jsx25(
|
|
1610
1610
|
PencilSimple,
|
|
1611
1611
|
{
|
|
@@ -2663,7 +2663,7 @@ import { DotsSixVertical } from "@phosphor-icons/react";
|
|
|
2663
2663
|
import { jsx as jsx41, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
2664
2664
|
var eyebrow = "text-ui-caption uppercase text-secondary-muted-foreground";
|
|
2665
2665
|
var QuestionHeader = React40.forwardRef(
|
|
2666
|
-
({ className, number, title, required, error, onDismissError, editor, onTitleChange, titlePlaceholder = "Click to write the question text", actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, ...props }, ref) => {
|
|
2666
|
+
({ className, number, title, required, error, onDismissError, editor, onTitleChange, titlePlaceholder = "Click to write the question text", titlePlaceholderTone, titleMinLength, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, ...props }, ref) => {
|
|
2667
2667
|
const [draft, setDraft] = React40.useState(null);
|
|
2668
2668
|
const label = String(number).padStart(2, "0");
|
|
2669
2669
|
const showError = error !== void 0 && error !== false;
|
|
@@ -2718,6 +2718,9 @@ var QuestionHeader = React40.forwardRef(
|
|
|
2718
2718
|
className: "-mx-3 w-auto",
|
|
2719
2719
|
"aria-label": "Question title",
|
|
2720
2720
|
placeholder: titlePlaceholder,
|
|
2721
|
+
placeholderTone: titlePlaceholderTone,
|
|
2722
|
+
minLength: titleMinLength,
|
|
2723
|
+
showLimits: titleMinLength !== void 0,
|
|
2721
2724
|
value: text,
|
|
2722
2725
|
maxLength,
|
|
2723
2726
|
onValueChange: onTitleChange,
|
|
@@ -2728,7 +2731,7 @@ var QuestionHeader = React40.forwardRef(
|
|
|
2728
2731
|
textClassName: "text-heading-h4"
|
|
2729
2732
|
}
|
|
2730
2733
|
),
|
|
2731
|
-
showCounter && /* @__PURE__ */ jsxs29("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
2734
|
+
showCounter && titleMinLength === void 0 && /* @__PURE__ */ jsxs29("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
2732
2735
|
count,
|
|
2733
2736
|
"/",
|
|
2734
2737
|
maxLength,
|
|
@@ -2761,6 +2764,8 @@ var QuestionEditorCard = React41.forwardRef(
|
|
|
2761
2764
|
title,
|
|
2762
2765
|
onTitleChange,
|
|
2763
2766
|
titlePlaceholder,
|
|
2767
|
+
titlePlaceholderTone,
|
|
2768
|
+
titleMinLength,
|
|
2764
2769
|
active,
|
|
2765
2770
|
hovered,
|
|
2766
2771
|
maxLength,
|
|
@@ -2807,6 +2812,8 @@ var QuestionEditorCard = React41.forwardRef(
|
|
|
2807
2812
|
title,
|
|
2808
2813
|
onTitleChange,
|
|
2809
2814
|
titlePlaceholder,
|
|
2815
|
+
titlePlaceholderTone,
|
|
2816
|
+
titleMinLength,
|
|
2810
2817
|
active,
|
|
2811
2818
|
showCounter: !!active,
|
|
2812
2819
|
dragHandleProps,
|
|
@@ -2969,7 +2976,7 @@ QuestionNavItem.displayName = "QuestionNavItem";
|
|
|
2969
2976
|
|
|
2970
2977
|
// src/components/Question Types/QuestionOption.tsx
|
|
2971
2978
|
import * as React44 from "react";
|
|
2972
|
-
import { Check as Check4, DotsSixVertical as DotsSixVertical3, Plus as Plus4, Trash as Trash4 } from "@phosphor-icons/react";
|
|
2979
|
+
import { Check as Check4, DotsSixVertical as DotsSixVertical3, Plus as Plus4, Trash as Trash4, WarningCircle as WarningCircle4 } from "@phosphor-icons/react";
|
|
2973
2980
|
import { Fragment as Fragment9, jsx as jsx45, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
2974
2981
|
var optionClasses = "flex w-full max-w-150 cursor-pointer items-center gap-2 rounded-md border border-border bg-surface px-4 py-2 text-body-base text-surface-foreground transition-colors hover:bg-accent-soft hover:shadow-md has-[[data-state=checked]]:border-accent-foreground has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50";
|
|
2975
2982
|
function QuestionOption(props) {
|
|
@@ -3024,8 +3031,34 @@ var QuestionOtherOption = React44.forwardRef(
|
|
|
3024
3031
|
}
|
|
3025
3032
|
);
|
|
3026
3033
|
QuestionOtherOption.displayName = "QuestionOtherOption";
|
|
3027
|
-
function
|
|
3034
|
+
function limitsText2(min, max) {
|
|
3035
|
+
if (min !== void 0) return `${min} ${min === 1 ? "character" : "characters"} required`;
|
|
3036
|
+
if (max !== void 0) return `Up to ${max} characters`;
|
|
3037
|
+
return "";
|
|
3038
|
+
}
|
|
3039
|
+
function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTone = "muted", minLength, maxLength, onRemove, onAdd, removeDisabled, addDisabled, className, kind, rank, dragHandleProps, lifted, locked }) {
|
|
3028
3040
|
const reveal = kind !== void 0;
|
|
3041
|
+
const guarded = minLength !== void 0 || maxLength !== void 0;
|
|
3042
|
+
const [draft, setDraft] = React44.useState(null);
|
|
3043
|
+
const [error, setError] = React44.useState(null);
|
|
3044
|
+
const helperId = React44.useId();
|
|
3045
|
+
const fieldRef = React44.useRef(null);
|
|
3046
|
+
const skipBlur = React44.useRef(false);
|
|
3047
|
+
const problemWith = (text) => minLength !== void 0 && text.trim().length < minLength ? `Enter at least ${minLength} ${minLength === 1 ? "character" : "characters"}.` : null;
|
|
3048
|
+
const save = () => {
|
|
3049
|
+
if (draft === null) return true;
|
|
3050
|
+
if (draft !== label) {
|
|
3051
|
+
const problem = problemWith(draft);
|
|
3052
|
+
if (problem) {
|
|
3053
|
+
setError(problem);
|
|
3054
|
+
return false;
|
|
3055
|
+
}
|
|
3056
|
+
onLabelChange?.(draft);
|
|
3057
|
+
}
|
|
3058
|
+
setDraft(null);
|
|
3059
|
+
setError(null);
|
|
3060
|
+
return true;
|
|
3061
|
+
};
|
|
3029
3062
|
const gripProps = dragHandleProps ? {
|
|
3030
3063
|
"aria-label": rank ? `Reorder option ${rank}` : "Reorder option",
|
|
3031
3064
|
...dragHandleProps,
|
|
@@ -3037,55 +3070,113 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, onRemove, onA
|
|
|
3037
3070
|
"div",
|
|
3038
3071
|
{
|
|
3039
3072
|
className: cn(
|
|
3040
|
-
"flex h-11.5 min-w-0 flex-1
|
|
3073
|
+
"flex min-h-11.5 min-w-0 flex-1 flex-col justify-center gap-1 rounded-md border bg-surface px-4 py-2 focus-within:border-input-accent",
|
|
3041
3074
|
reveal ? (
|
|
3042
3075
|
// The border is always visible and does not change on hover; only the shadow lifts the row. The field being edited keeps the accent.
|
|
3043
3076
|
cn("border-border group-hover/option:shadow-md group-focus-within/option:shadow-md", lifted && "shadow-md")
|
|
3044
3077
|
) : "border-border hover:border-input-muted hover:shadow-md"
|
|
3045
3078
|
),
|
|
3046
3079
|
children: [
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
/* @__PURE__ */ jsx45(
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3080
|
+
/* @__PURE__ */ jsxs32("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
3081
|
+
kind === "rank" ? /* @__PURE__ */ jsxs32(Fragment9, { children: [
|
|
3082
|
+
!locked && grip,
|
|
3083
|
+
/* @__PURE__ */ jsx45(
|
|
3084
|
+
"span",
|
|
3085
|
+
{
|
|
3086
|
+
"aria-hidden": "true",
|
|
3087
|
+
className: "flex size-6 shrink-0 items-center justify-center rounded-full border border-border bg-background bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5 text-ui-caption text-surface-foreground",
|
|
3088
|
+
children: rank
|
|
3089
|
+
}
|
|
3090
|
+
)
|
|
3091
|
+
] }) : 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__ */ jsxs32("span", { ...gripProps, className: cn("relative flex size-5 shrink-0 items-center justify-center", gripProps.className), children: [
|
|
3092
|
+
/* @__PURE__ */ jsx45(
|
|
3093
|
+
"span",
|
|
3094
|
+
{
|
|
3095
|
+
"aria-hidden": "true",
|
|
3096
|
+
className: cn(
|
|
3097
|
+
"inline-flex size-4 border-2 border-input bg-surface group-hover/option:hidden group-focus-within/option:hidden",
|
|
3098
|
+
lifted && "hidden",
|
|
3099
|
+
kind === "radio" ? "rounded-full" : "rounded-xxs"
|
|
3100
|
+
)
|
|
3101
|
+
}
|
|
3102
|
+
),
|
|
3103
|
+
/* @__PURE__ */ jsx45(
|
|
3104
|
+
DotsSixVertical3,
|
|
3105
|
+
{
|
|
3106
|
+
size: 20,
|
|
3107
|
+
"aria-hidden": true,
|
|
3108
|
+
className: cn(
|
|
3109
|
+
"hidden shrink-0 text-surface-foreground group-hover/option:block group-focus-within/option:block",
|
|
3110
|
+
lifted && "block"
|
|
3111
|
+
)
|
|
3112
|
+
}
|
|
3113
|
+
)
|
|
3114
|
+
] }) : locked ? null : grip,
|
|
3069
3115
|
/* @__PURE__ */ jsx45(
|
|
3070
|
-
|
|
3116
|
+
"input",
|
|
3071
3117
|
{
|
|
3072
|
-
|
|
3073
|
-
"aria-
|
|
3118
|
+
ref: fieldRef,
|
|
3119
|
+
"aria-label": "Option label",
|
|
3120
|
+
"aria-invalid": error ? true : void 0,
|
|
3121
|
+
"aria-describedby": guarded && draft !== null ? helperId : void 0,
|
|
3122
|
+
placeholder,
|
|
3123
|
+
maxLength,
|
|
3124
|
+
value: guarded ? draft ?? label : label,
|
|
3125
|
+
onFocus: () => {
|
|
3126
|
+
if (guarded && draft === null) setDraft(label);
|
|
3127
|
+
},
|
|
3128
|
+
onChange: (event) => {
|
|
3129
|
+
if (!guarded) return onLabelChange?.(event.target.value);
|
|
3130
|
+
setDraft(event.target.value);
|
|
3131
|
+
if (error) setError(problemWith(event.target.value));
|
|
3132
|
+
},
|
|
3133
|
+
onKeyDown: (event) => {
|
|
3134
|
+
if (!guarded) return;
|
|
3135
|
+
if (event.key === "Escape") {
|
|
3136
|
+
skipBlur.current = true;
|
|
3137
|
+
setDraft(null);
|
|
3138
|
+
setError(null);
|
|
3139
|
+
fieldRef.current?.blur();
|
|
3140
|
+
} else if (event.key === "Enter") {
|
|
3141
|
+
event.preventDefault();
|
|
3142
|
+
if (save()) {
|
|
3143
|
+
skipBlur.current = true;
|
|
3144
|
+
fieldRef.current?.blur();
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
},
|
|
3148
|
+
onBlur: () => {
|
|
3149
|
+
if (!guarded) return;
|
|
3150
|
+
if (skipBlur.current) {
|
|
3151
|
+
skipBlur.current = false;
|
|
3152
|
+
return;
|
|
3153
|
+
}
|
|
3154
|
+
save();
|
|
3155
|
+
},
|
|
3074
3156
|
className: cn(
|
|
3075
|
-
"
|
|
3076
|
-
|
|
3157
|
+
"min-w-0 flex-1 bg-transparent text-body-base text-surface-foreground outline-none",
|
|
3158
|
+
placeholderTone === "regular" ? "placeholder:text-surface-foreground" : "placeholder:text-muted-foreground"
|
|
3077
3159
|
)
|
|
3078
3160
|
}
|
|
3079
3161
|
)
|
|
3080
|
-
] })
|
|
3081
|
-
/* @__PURE__ */
|
|
3082
|
-
"
|
|
3162
|
+
] }),
|
|
3163
|
+
guarded && draft !== null && /* @__PURE__ */ jsxs32(
|
|
3164
|
+
"p",
|
|
3083
3165
|
{
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3166
|
+
id: helperId,
|
|
3167
|
+
role: error ? "alert" : void 0,
|
|
3168
|
+
className: cn("flex items-start justify-between gap-2 text-ui-caption", error ? "text-destructive" : "text-secondary-muted-foreground"),
|
|
3169
|
+
children: [
|
|
3170
|
+
/* @__PURE__ */ jsxs32("span", { className: "flex items-start gap-2", children: [
|
|
3171
|
+
error && /* @__PURE__ */ jsx45(WarningCircle4, { size: 16, "aria-hidden": true, className: "shrink-0" }),
|
|
3172
|
+
limitsText2(minLength, maxLength),
|
|
3173
|
+
error && /* @__PURE__ */ jsx45("span", { className: "sr-only", children: error })
|
|
3174
|
+
] }),
|
|
3175
|
+
/* @__PURE__ */ jsxs32("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
|
|
3176
|
+
draft.length,
|
|
3177
|
+
maxLength !== void 0 && `/${maxLength}`
|
|
3178
|
+
] })
|
|
3179
|
+
]
|
|
3089
3180
|
}
|
|
3090
3181
|
)
|
|
3091
3182
|
]
|