@discuss-ds/ui 0.38.0 → 0.39.1
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 +20 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -372,6 +372,12 @@ interface InlineEditProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'on
|
|
|
372
372
|
*/
|
|
373
373
|
submitOnEnter?: boolean;
|
|
374
374
|
disabled?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Opens the field for editing when it turns `true` (or is `true` on mount), as if the read button was clicked, for example when the
|
|
377
|
+
* row or card it belongs to is selected. The field is focused without scrolling the page. Editing still ends the usual way (Enter,
|
|
378
|
+
* blur or Escape) and `onEditingChange` reports it; set `editing` back to `false` before asking again. Leave it out to open on click only.
|
|
379
|
+
*/
|
|
380
|
+
editing?: boolean;
|
|
375
381
|
/** Called when editing starts or ends. */
|
|
376
382
|
onEditingChange?: (editing: boolean) => void;
|
|
377
383
|
/** Called on every keystroke while editing (and with the saved value when editing ends), e.g. for a live character counter. */
|
|
@@ -792,6 +798,8 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
792
798
|
onTitleMarkApply?: (mark: InlineEditMark, replacement: string) => void;
|
|
793
799
|
/** Called when a mark is dismissed from its card. */
|
|
794
800
|
onTitleMarkDismiss?: (mark: InlineEditMark) => void;
|
|
801
|
+
/** Opens the question text for editing when it turns true, for example when the card is selected by a click. See `QuestionHeader`'s `titleEditing`. */
|
|
802
|
+
titleEditing?: boolean;
|
|
795
803
|
}
|
|
796
804
|
declare const QuestionEditorCard: React.ForwardRefExoticComponent<QuestionEditorCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
797
805
|
|
|
@@ -858,6 +866,8 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
858
866
|
onTitleMarkApply?: (mark: InlineEditMark, replacement: string) => void;
|
|
859
867
|
/** Editor mode: called when a mark is dismissed from its card. See `InlineEdit`'s `onMarkDismiss`. */
|
|
860
868
|
onTitleMarkDismiss?: (mark: InlineEditMark) => void;
|
|
869
|
+
/** Editor mode: opens the title for editing when it turns true, for example when the question is selected. See `InlineEdit`'s `editing`. */
|
|
870
|
+
titleEditing?: boolean;
|
|
861
871
|
}
|
|
862
872
|
declare const QuestionHeader: React.ForwardRefExoticComponent<QuestionHeaderProps & React.RefAttributes<HTMLDivElement>>;
|
|
863
873
|
|
package/dist/index.d.ts
CHANGED
|
@@ -372,6 +372,12 @@ interface InlineEditProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'on
|
|
|
372
372
|
*/
|
|
373
373
|
submitOnEnter?: boolean;
|
|
374
374
|
disabled?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Opens the field for editing when it turns `true` (or is `true` on mount), as if the read button was clicked, for example when the
|
|
377
|
+
* row or card it belongs to is selected. The field is focused without scrolling the page. Editing still ends the usual way (Enter,
|
|
378
|
+
* blur or Escape) and `onEditingChange` reports it; set `editing` back to `false` before asking again. Leave it out to open on click only.
|
|
379
|
+
*/
|
|
380
|
+
editing?: boolean;
|
|
375
381
|
/** Called when editing starts or ends. */
|
|
376
382
|
onEditingChange?: (editing: boolean) => void;
|
|
377
383
|
/** Called on every keystroke while editing (and with the saved value when editing ends), e.g. for a live character counter. */
|
|
@@ -792,6 +798,8 @@ interface QuestionEditorCardProps extends Omit<React.HTMLAttributes<HTMLDivEleme
|
|
|
792
798
|
onTitleMarkApply?: (mark: InlineEditMark, replacement: string) => void;
|
|
793
799
|
/** Called when a mark is dismissed from its card. */
|
|
794
800
|
onTitleMarkDismiss?: (mark: InlineEditMark) => void;
|
|
801
|
+
/** Opens the question text for editing when it turns true, for example when the card is selected by a click. See `QuestionHeader`'s `titleEditing`. */
|
|
802
|
+
titleEditing?: boolean;
|
|
795
803
|
}
|
|
796
804
|
declare const QuestionEditorCard: React.ForwardRefExoticComponent<QuestionEditorCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
797
805
|
|
|
@@ -858,6 +866,8 @@ interface QuestionHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
858
866
|
onTitleMarkApply?: (mark: InlineEditMark, replacement: string) => void;
|
|
859
867
|
/** Editor mode: called when a mark is dismissed from its card. See `InlineEdit`'s `onMarkDismiss`. */
|
|
860
868
|
onTitleMarkDismiss?: (mark: InlineEditMark) => void;
|
|
869
|
+
/** Editor mode: opens the title for editing when it turns true, for example when the question is selected. See `InlineEdit`'s `editing`. */
|
|
870
|
+
titleEditing?: boolean;
|
|
861
871
|
}
|
|
862
872
|
declare const QuestionHeader: React.ForwardRefExoticComponent<QuestionHeaderProps & React.RefAttributes<HTMLDivElement>>;
|
|
863
873
|
|
package/dist/index.js
CHANGED
|
@@ -335,9 +335,9 @@ var Checkbox = React8.forwardRef(
|
|
|
335
335
|
className: cn(
|
|
336
336
|
"peer inline-flex size-4 shrink-0 items-center justify-center rounded-xxs border-2 border-input bg-surface transition-colors",
|
|
337
337
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
338
|
-
//
|
|
339
|
-
"data-[state=checked]:border-
|
|
340
|
-
"data-[state=indeterminate]:border-
|
|
338
|
+
// Selected controls use the accent foreground, the same colour as the other accent icons and text (they used the lighter `ring` before).
|
|
339
|
+
"data-[state=checked]:border-accent-foreground data-[state=checked]:bg-accent-foreground data-[state=checked]:text-label",
|
|
340
|
+
"data-[state=indeterminate]:border-accent-foreground data-[state=indeterminate]:bg-accent-foreground data-[state=indeterminate]:text-label",
|
|
341
341
|
className
|
|
342
342
|
),
|
|
343
343
|
...props,
|
|
@@ -393,12 +393,12 @@ var RadioGroupItem = React9.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
393
393
|
className: cn(
|
|
394
394
|
"peer inline-flex size-4 shrink-0 items-center justify-center rounded-full border-2 border-input bg-surface transition-colors",
|
|
395
395
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
396
|
-
//
|
|
397
|
-
"data-[state=checked]:border-
|
|
396
|
+
// Selected controls use the accent foreground, the same colour as the other accent icons and text (they used the lighter `ring` before).
|
|
397
|
+
"data-[state=checked]:border-accent-foreground",
|
|
398
398
|
className
|
|
399
399
|
),
|
|
400
400
|
...props,
|
|
401
|
-
children: /* @__PURE__ */ jsx9(RadioGroupPrimitive.Indicator, { className: "size-2 rounded-full bg-
|
|
401
|
+
children: /* @__PURE__ */ jsx9(RadioGroupPrimitive.Indicator, { className: "size-2 rounded-full bg-accent-foreground" })
|
|
402
402
|
}
|
|
403
403
|
));
|
|
404
404
|
RadioGroupItem.displayName = "RadioGroupItem";
|
|
@@ -1671,6 +1671,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1671
1671
|
showLimits,
|
|
1672
1672
|
submitOnEnter,
|
|
1673
1673
|
disabled,
|
|
1674
|
+
editing: openRequested,
|
|
1674
1675
|
onEditingChange,
|
|
1675
1676
|
onDraftChange,
|
|
1676
1677
|
variant = "default",
|
|
@@ -1691,9 +1692,11 @@ var InlineEdit = React25.forwardRef(
|
|
|
1691
1692
|
const readRef = React25.useRef(null);
|
|
1692
1693
|
const cancelled = React25.useRef(false);
|
|
1693
1694
|
const restoreFocus = React25.useRef(false);
|
|
1695
|
+
const openedByProp = React25.useRef(false);
|
|
1694
1696
|
React25.useEffect(() => {
|
|
1695
1697
|
if (editing) {
|
|
1696
|
-
fieldRef.current?.focus();
|
|
1698
|
+
fieldRef.current?.focus(openedByProp.current ? { preventScroll: true } : void 0);
|
|
1699
|
+
openedByProp.current = false;
|
|
1697
1700
|
fieldRef.current?.select();
|
|
1698
1701
|
} else if (restoreFocus.current) {
|
|
1699
1702
|
restoreFocus.current = false;
|
|
@@ -1715,6 +1718,12 @@ var InlineEdit = React25.forwardRef(
|
|
|
1715
1718
|
setEditing(true);
|
|
1716
1719
|
onEditingChange?.(true);
|
|
1717
1720
|
};
|
|
1721
|
+
React25.useEffect(() => {
|
|
1722
|
+
if (openRequested && !editing && !disabled) {
|
|
1723
|
+
openedByProp.current = true;
|
|
1724
|
+
start();
|
|
1725
|
+
}
|
|
1726
|
+
}, [openRequested]);
|
|
1718
1727
|
const finish = (commit, refocus) => {
|
|
1719
1728
|
if (commit && draft !== value) {
|
|
1720
1729
|
const problem = problemWith(draft);
|
|
@@ -3060,7 +3069,7 @@ QuestionNumberTag.displayName = "QuestionNumberTag";
|
|
|
3060
3069
|
import { jsx as jsx45, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
3061
3070
|
var eyebrow = "text-ui-caption uppercase text-secondary-muted-foreground";
|
|
3062
3071
|
var QuestionHeader = React44.forwardRef(
|
|
3063
|
-
({ className, number, title, required, error, onDismissError, editor, onTitleChange, titlePlaceholder = "Click to write the question text", titlePlaceholderTone, titleMinLength, titleRecommendedMax, titleRecommendedNote, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, questionType, titleMarks, onTitleMarkApply, onTitleMarkDismiss, ...props }, ref) => {
|
|
3072
|
+
({ className, number, title, required, error, onDismissError, editor, onTitleChange, titlePlaceholder = "Click to write the question text", titlePlaceholderTone, titleMinLength, titleRecommendedMax, titleRecommendedNote, actions, meta, maxLength = 2e3, active, showCounter = true, dragHandleProps, showDragHandle = true, questionType, titleMarks, onTitleMarkApply, onTitleMarkDismiss, titleEditing, ...props }, ref) => {
|
|
3064
3073
|
const [draft, setDraft] = React44.useState(null);
|
|
3065
3074
|
const label = String(number).padStart(2, "0");
|
|
3066
3075
|
const showError = error !== void 0 && error !== false;
|
|
@@ -3086,6 +3095,7 @@ var QuestionHeader = React44.forwardRef(
|
|
|
3086
3095
|
variant: "question",
|
|
3087
3096
|
multiline: true,
|
|
3088
3097
|
selected: active,
|
|
3098
|
+
editing: titleEditing,
|
|
3089
3099
|
className: "-mx-3 w-auto",
|
|
3090
3100
|
"aria-label": "Question title",
|
|
3091
3101
|
placeholder: titlePlaceholder,
|
|
@@ -3163,6 +3173,7 @@ var QuestionEditorCard = React45.forwardRef(
|
|
|
3163
3173
|
titleMarks,
|
|
3164
3174
|
onTitleMarkApply,
|
|
3165
3175
|
onTitleMarkDismiss,
|
|
3176
|
+
titleEditing,
|
|
3166
3177
|
children,
|
|
3167
3178
|
...props
|
|
3168
3179
|
}, ref) => {
|
|
@@ -3209,6 +3220,7 @@ var QuestionEditorCard = React45.forwardRef(
|
|
|
3209
3220
|
titleMarks,
|
|
3210
3221
|
onTitleMarkApply,
|
|
3211
3222
|
onTitleMarkDismiss,
|
|
3223
|
+
titleEditing,
|
|
3212
3224
|
meta,
|
|
3213
3225
|
maxLength,
|
|
3214
3226
|
actions: actions ?? /* @__PURE__ */ jsxs33(Fragment11, { children: [
|