@discuss-ds/ui 0.20.0 → 0.21.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 +28 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -345,6 +345,12 @@ interface InlineEditProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'on
|
|
|
345
345
|
* message and `onValueChange` is not called. Return nothing (or `null`) to accept. Runs after `minLength`.
|
|
346
346
|
*/
|
|
347
347
|
validate?: (value: string) => string | null | undefined;
|
|
348
|
+
/**
|
|
349
|
+
* While editing, shows the allowed length under the field (from `minLength` and `maxLength`) with a live character
|
|
350
|
+
* counter. After a refused save the same line turns into the error state (error colour and icon) instead of a
|
|
351
|
+
* different message appears.
|
|
352
|
+
*/
|
|
353
|
+
showLimits?: boolean;
|
|
348
354
|
disabled?: boolean;
|
|
349
355
|
/** Called when editing starts or ends. */
|
|
350
356
|
onEditingChange?: (editing: boolean) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -345,6 +345,12 @@ interface InlineEditProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'on
|
|
|
345
345
|
* message and `onValueChange` is not called. Return nothing (or `null`) to accept. Runs after `minLength`.
|
|
346
346
|
*/
|
|
347
347
|
validate?: (value: string) => string | null | undefined;
|
|
348
|
+
/**
|
|
349
|
+
* While editing, shows the allowed length under the field (from `minLength` and `maxLength`) with a live character
|
|
350
|
+
* counter. After a refused save the same line turns into the error state (error colour and icon) instead of a
|
|
351
|
+
* different message appears.
|
|
352
|
+
*/
|
|
353
|
+
showLimits?: boolean;
|
|
348
354
|
disabled?: boolean;
|
|
349
355
|
/** Called when editing starts or ends. */
|
|
350
356
|
onEditingChange?: (editing: boolean) => void;
|
package/dist/index.js
CHANGED
|
@@ -1388,6 +1388,12 @@ FormMessage.displayName = "FormMessage";
|
|
|
1388
1388
|
import * as React24 from "react";
|
|
1389
1389
|
import { PencilSimple, WarningCircle as WarningCircle2 } from "@phosphor-icons/react";
|
|
1390
1390
|
import { Fragment as Fragment4, jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1391
|
+
function limitsText(min, max) {
|
|
1392
|
+
if (min !== void 0 && max !== void 0) return `${min}\u2013${max} characters`;
|
|
1393
|
+
if (min !== void 0) return `At least ${min} characters`;
|
|
1394
|
+
if (max !== void 0) return `Up to ${max} characters`;
|
|
1395
|
+
return "";
|
|
1396
|
+
}
|
|
1391
1397
|
var InlineEdit = React24.forwardRef(
|
|
1392
1398
|
({
|
|
1393
1399
|
className,
|
|
@@ -1400,6 +1406,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1400
1406
|
maxLength,
|
|
1401
1407
|
minLength,
|
|
1402
1408
|
validate,
|
|
1409
|
+
showLimits,
|
|
1403
1410
|
disabled,
|
|
1404
1411
|
onEditingChange,
|
|
1405
1412
|
onDraftChange,
|
|
@@ -1466,7 +1473,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1466
1473
|
"div",
|
|
1467
1474
|
{
|
|
1468
1475
|
ref,
|
|
1469
|
-
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && error && "flex-col gap-1.5", className),
|
|
1476
|
+
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error || showLimits) && "flex-col gap-1.5", className),
|
|
1470
1477
|
...props,
|
|
1471
1478
|
children: editing ? /* @__PURE__ */ jsxs16(Fragment4, { children: [
|
|
1472
1479
|
React24.createElement(multiline ? "textarea" : "input", {
|
|
@@ -1475,7 +1482,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1475
1482
|
maxLength,
|
|
1476
1483
|
"aria-label": ariaLabel,
|
|
1477
1484
|
"aria-invalid": error ? true : void 0,
|
|
1478
|
-
"aria-describedby": error ? errorId : void 0,
|
|
1485
|
+
"aria-describedby": error || showLimits ? errorId : void 0,
|
|
1479
1486
|
...multiline ? { rows: 1 } : { type: "text" },
|
|
1480
1487
|
className: cn(
|
|
1481
1488
|
"w-full px-3 py-1 outline-none",
|
|
@@ -1502,10 +1509,25 @@ var InlineEdit = React24.forwardRef(
|
|
|
1502
1509
|
if (!cancelled.current) finish(true, false);
|
|
1503
1510
|
}
|
|
1504
1511
|
}),
|
|
1505
|
-
error && /* @__PURE__ */ jsxs16(
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1512
|
+
(error || showLimits) && /* @__PURE__ */ jsxs16(
|
|
1513
|
+
"p",
|
|
1514
|
+
{
|
|
1515
|
+
id: errorId,
|
|
1516
|
+
role: error ? "alert" : void 0,
|
|
1517
|
+
className: cn("flex items-start justify-between gap-2 px-3 text-ui-caption", error ? "text-destructive" : "text-secondary-muted-foreground"),
|
|
1518
|
+
children: [
|
|
1519
|
+
/* @__PURE__ */ jsxs16("span", { className: "flex items-start gap-2", children: [
|
|
1520
|
+
error && /* @__PURE__ */ jsx25(WarningCircle2, { size: 16, "aria-hidden": true, className: "shrink-0" }),
|
|
1521
|
+
showLimits ? limitsText(minLength, maxLength) : error,
|
|
1522
|
+
showLimits && error && /* @__PURE__ */ jsx25("span", { className: "sr-only", children: error })
|
|
1523
|
+
] }),
|
|
1524
|
+
showLimits && /* @__PURE__ */ jsxs16("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
|
|
1525
|
+
draft.length,
|
|
1526
|
+
maxLength !== void 0 && `/${maxLength}`
|
|
1527
|
+
] })
|
|
1528
|
+
]
|
|
1529
|
+
}
|
|
1530
|
+
)
|
|
1509
1531
|
] }) : /* @__PURE__ */ jsxs16(
|
|
1510
1532
|
"button",
|
|
1511
1533
|
{
|