@discuss-ds/ui 0.8.2 → 0.9.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 +49 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +48 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @discuss-ds/ui
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#49](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/49) [`1931730`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/19317303f60cfe751925bdb7e84747f8a68b78b3) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `ImagePreview`: with an image, the preview area now hugs it (full width, the image's own height, at most 336px) instead of a fixed 336px area with bars above and below. The empty placeholder keeps the fixed height.
|
|
8
|
+
|
|
9
|
+
## 0.9.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#47](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/47) [`d3b3a44`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/d3b3a442602a7c398972449ebb23db7229b92573) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `StimulusCard`: follows the updated Figma for responsiveness. The card has a minimum height of 86px, the thumbnail is square and as tall as the text beside it (so it grows when the caption wraps onto more lines, from 80px up to 240px), and the text column is centred with 8px of vertical padding. New `maxLength` and `showCounter` props add the same live "n/2000 characters" counter the question text has, under an editable caption. A one-line caption looks the same as before. The thumbnail is sized from the measured text height because that is circular in plain CSS.
|
|
14
|
+
|
|
3
15
|
## 0.8.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -2403,7 +2403,17 @@ function MediaInfo({ name, details, onRemove, removeLabel, large, className, ...
|
|
|
2403
2403
|
}
|
|
2404
2404
|
var ImagePreview = React37.forwardRef(
|
|
2405
2405
|
({ className, children, name, details, onRemove, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ref, className: cn("flex w-full flex-col overflow-hidden rounded-lg border border-border", className), ...props, children: [
|
|
2406
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2406
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2407
|
+
"div",
|
|
2408
|
+
{
|
|
2409
|
+
className: cn(
|
|
2410
|
+
"flex w-full items-center justify-center bg-accent-soft",
|
|
2411
|
+
// With an image the area hugs it (full width, its own height, at most 336px tall); the empty placeholder keeps the fixed height.
|
|
2412
|
+
children ? "[&>img]:block [&>img]:h-auto [&>img]:max-h-84 [&>img]:w-full [&>img]:object-contain" : "h-84"
|
|
2413
|
+
),
|
|
2414
|
+
children
|
|
2415
|
+
}
|
|
2416
|
+
),
|
|
2407
2417
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(MediaInfo, { name, details, onRemove, large: true })
|
|
2408
2418
|
] })
|
|
2409
2419
|
);
|
|
@@ -3198,7 +3208,12 @@ RatingScale.displayName = "RatingScale";
|
|
|
3198
3208
|
// src/components/Question Types/StimulusCard.tsx
|
|
3199
3209
|
var React47 = __toESM(require("react"), 1);
|
|
3200
3210
|
var import_react25 = require("@phosphor-icons/react");
|
|
3201
|
-
var import_jsx_runtime48 =
|
|
3211
|
+
var import_jsx_runtime48 = (
|
|
3212
|
+
// Out of flow, so the image's own size never sets the thumbnail's size.
|
|
3213
|
+
require("react/jsx-runtime")
|
|
3214
|
+
);
|
|
3215
|
+
var MIN_THUMBNAIL = 80;
|
|
3216
|
+
var MAX_THUMBNAIL = 240;
|
|
3202
3217
|
var StimulusCard = React47.forwardRef(
|
|
3203
3218
|
({
|
|
3204
3219
|
className,
|
|
@@ -3210,6 +3225,8 @@ var StimulusCard = React47.forwardRef(
|
|
|
3210
3225
|
caption,
|
|
3211
3226
|
onCaptionChange,
|
|
3212
3227
|
captionPlaceholder = "Click to write what the AI moderator says",
|
|
3228
|
+
maxLength,
|
|
3229
|
+
showCounter = true,
|
|
3213
3230
|
onRemove,
|
|
3214
3231
|
removeLabel = "Remove stimulus",
|
|
3215
3232
|
...props
|
|
@@ -3217,27 +3234,41 @@ var StimulusCard = React47.forwardRef(
|
|
|
3217
3234
|
const [failedSrc, setFailedSrc] = React47.useState();
|
|
3218
3235
|
const error = status === "error" || thumbnail !== void 0 && failedSrc === thumbnail;
|
|
3219
3236
|
const showImage = thumbnail !== void 0 && !error;
|
|
3237
|
+
const [draft, setDraft] = React47.useState(null);
|
|
3238
|
+
const count = (draft ?? caption ?? "").length;
|
|
3239
|
+
const textRef = React47.useRef(null);
|
|
3240
|
+
const [thumbnailSize, setThumbnailSize] = React47.useState(MIN_THUMBNAIL);
|
|
3241
|
+
React47.useEffect(() => {
|
|
3242
|
+
const el = textRef.current;
|
|
3243
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
3244
|
+
const observer = new ResizeObserver(() => {
|
|
3245
|
+
setThumbnailSize(Math.min(MAX_THUMBNAIL, Math.max(MIN_THUMBNAIL, Math.ceil(el.getBoundingClientRect().height))));
|
|
3246
|
+
});
|
|
3247
|
+
observer.observe(el);
|
|
3248
|
+
return () => observer.disconnect();
|
|
3249
|
+
}, []);
|
|
3220
3250
|
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
|
|
3221
3251
|
"div",
|
|
3222
3252
|
{
|
|
3223
3253
|
ref,
|
|
3224
3254
|
"data-status": error ? "error" : "default",
|
|
3225
|
-
className: cn("flex w-full items-center gap-4 rounded-md border border-border p-0.5 pr-4", className),
|
|
3255
|
+
className: cn("flex min-h-21.5 w-full items-center gap-4 rounded-md border border-border p-0.5 pr-4", className),
|
|
3226
3256
|
...props,
|
|
3227
3257
|
children: [
|
|
3228
3258
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-4", children: [
|
|
3229
3259
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
3230
3260
|
"span",
|
|
3231
3261
|
{
|
|
3262
|
+
style: { width: thumbnailSize, height: thumbnailSize },
|
|
3232
3263
|
className: cn(
|
|
3233
|
-
"flex
|
|
3264
|
+
"relative flex shrink-0 items-center justify-center overflow-hidden rounded-sm border",
|
|
3234
3265
|
error ? "border-destructive-soft-border bg-destructive-soft bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5 text-destructive" : "border-border bg-background bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5 text-surface-foreground",
|
|
3235
3266
|
showImage && "bg-none"
|
|
3236
3267
|
),
|
|
3237
|
-
children: showImage ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("img", { src: thumbnail, alt: thumbnailAlt, className: "size-full object-cover", onError: () => setFailedSrc(thumbnail) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react25.ImageBroken, { size: 24, "aria-hidden": true }) : icon ?? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react25.Image, { size: 24, "aria-hidden": true })
|
|
3268
|
+
children: showImage ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("img", { src: thumbnail, alt: thumbnailAlt, className: "absolute inset-0 size-full object-cover", onError: () => setFailedSrc(thumbnail) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react25.ImageBroken, { size: 24, "aria-hidden": true }) : icon ?? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react25.Image, { size: 24, "aria-hidden": true })
|
|
3238
3269
|
}
|
|
3239
3270
|
),
|
|
3240
|
-
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-2 text-surface-foreground", children: [
|
|
3271
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { ref: textRef, className: "flex min-w-0 flex-1 flex-col justify-center gap-2 py-2 text-surface-foreground", children: [
|
|
3241
3272
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "w-full text-ui-label", children: label }),
|
|
3242
3273
|
onCaptionChange ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
3243
3274
|
InlineEdit,
|
|
@@ -3248,10 +3279,21 @@ var StimulusCard = React47.forwardRef(
|
|
|
3248
3279
|
"aria-label": "Stimulus caption",
|
|
3249
3280
|
value: caption ?? "",
|
|
3250
3281
|
placeholder: captionPlaceholder,
|
|
3282
|
+
maxLength,
|
|
3251
3283
|
onValueChange: onCaptionChange,
|
|
3284
|
+
onDraftChange: setDraft,
|
|
3285
|
+
onEditingChange: (editing) => {
|
|
3286
|
+
if (!editing) setDraft(null);
|
|
3287
|
+
},
|
|
3252
3288
|
textClassName: "text-body-base"
|
|
3253
3289
|
}
|
|
3254
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "w-full text-body-base [word-break:break-word]", children: caption })
|
|
3290
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "w-full text-body-base [word-break:break-word]", children: caption }),
|
|
3291
|
+
onCaptionChange && showCounter && maxLength !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: [
|
|
3292
|
+
count,
|
|
3293
|
+
"/",
|
|
3294
|
+
maxLength,
|
|
3295
|
+
" characters"
|
|
3296
|
+
] })
|
|
3255
3297
|
] })
|
|
3256
3298
|
] }),
|
|
3257
3299
|
onRemove && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Button, { type: "button", variant: "destructive", size: "icon-sm", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react25.Trash, { size: 16, "aria-hidden": true }) })
|