@discuss-ds/ui 0.20.0 → 0.22.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 +12 -0
- package/dist/index.cjs +30 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +30 -7
- 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.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#86](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/86) [`33207c1`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/33207c1d978d213ad8c430ecc70be4583996df24) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `InlineEdit`: new optional `submitOnEnter` prop for `multiline` fields. Enter saves the edit (a refused edit stays open and focused with its message) and Shift+Enter inserts a line break; Cmd/Ctrl+Enter keeps saving. Off by default, so multiline fields behave as before unless it is set.
|
|
8
|
+
|
|
9
|
+
## 0.21.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#84](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/84) [`da5c71d`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/da5c71d53726b8ba0f5836fadc8bb4f77dd18b47) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `InlineEdit`: new optional `showLimits` prop. While editing it shows the allowed length under the field (for example "150–500 characters", from `minLength` and `maxLength`) with a live character counter. After a refused save that same line turns into the error state (error colour and icon). Off by default, so nothing changes unless it is set.
|
|
14
|
+
|
|
3
15
|
## 0.20.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1542,6 +1542,12 @@ FormMessage.displayName = "FormMessage";
|
|
|
1542
1542
|
var React24 = __toESM(require("react"), 1);
|
|
1543
1543
|
var import_react11 = require("@phosphor-icons/react");
|
|
1544
1544
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1545
|
+
function limitsText(min, max) {
|
|
1546
|
+
if (min !== void 0 && max !== void 0) return `${min}\u2013${max} characters`;
|
|
1547
|
+
if (min !== void 0) return `At least ${min} characters`;
|
|
1548
|
+
if (max !== void 0) return `Up to ${max} characters`;
|
|
1549
|
+
return "";
|
|
1550
|
+
}
|
|
1545
1551
|
var InlineEdit = React24.forwardRef(
|
|
1546
1552
|
({
|
|
1547
1553
|
className,
|
|
@@ -1554,6 +1560,8 @@ var InlineEdit = React24.forwardRef(
|
|
|
1554
1560
|
maxLength,
|
|
1555
1561
|
minLength,
|
|
1556
1562
|
validate,
|
|
1563
|
+
showLimits,
|
|
1564
|
+
submitOnEnter,
|
|
1557
1565
|
disabled,
|
|
1558
1566
|
onEditingChange,
|
|
1559
1567
|
onDraftChange,
|
|
@@ -1620,7 +1628,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1620
1628
|
"div",
|
|
1621
1629
|
{
|
|
1622
1630
|
ref,
|
|
1623
|
-
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),
|
|
1631
|
+
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),
|
|
1624
1632
|
...props,
|
|
1625
1633
|
children: editing ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
1626
1634
|
React24.createElement(multiline ? "textarea" : "input", {
|
|
@@ -1629,7 +1637,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1629
1637
|
maxLength,
|
|
1630
1638
|
"aria-label": ariaLabel,
|
|
1631
1639
|
"aria-invalid": error ? true : void 0,
|
|
1632
|
-
"aria-describedby": error ? errorId : void 0,
|
|
1640
|
+
"aria-describedby": error || showLimits ? errorId : void 0,
|
|
1633
1641
|
...multiline ? { rows: 1 } : { type: "text" },
|
|
1634
1642
|
className: cn(
|
|
1635
1643
|
"w-full px-3 py-1 outline-none",
|
|
@@ -1647,7 +1655,7 @@ var InlineEdit = React24.forwardRef(
|
|
|
1647
1655
|
cancelled.current = true;
|
|
1648
1656
|
setError(null);
|
|
1649
1657
|
finish(false, true);
|
|
1650
|
-
} else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey || question && !event.shiftKey)) {
|
|
1658
|
+
} else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey || (question || submitOnEnter) && !event.shiftKey)) {
|
|
1651
1659
|
event.preventDefault();
|
|
1652
1660
|
finish(true, true);
|
|
1653
1661
|
}
|
|
@@ -1656,10 +1664,25 @@ var InlineEdit = React24.forwardRef(
|
|
|
1656
1664
|
if (!cancelled.current) finish(true, false);
|
|
1657
1665
|
}
|
|
1658
1666
|
}),
|
|
1659
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1667
|
+
(error || showLimits) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
1668
|
+
"p",
|
|
1669
|
+
{
|
|
1670
|
+
id: errorId,
|
|
1671
|
+
role: error ? "alert" : void 0,
|
|
1672
|
+
className: cn("flex items-start justify-between gap-2 px-3 text-ui-caption", error ? "text-destructive" : "text-secondary-muted-foreground"),
|
|
1673
|
+
children: [
|
|
1674
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex items-start gap-2", children: [
|
|
1675
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react11.WarningCircle, { size: 16, "aria-hidden": true, className: "shrink-0" }),
|
|
1676
|
+
showLimits ? limitsText(minLength, maxLength) : error,
|
|
1677
|
+
showLimits && error && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "sr-only", children: error })
|
|
1678
|
+
] }),
|
|
1679
|
+
showLimits && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { "aria-hidden": true, className: "shrink-0 tabular-nums", children: [
|
|
1680
|
+
draft.length,
|
|
1681
|
+
maxLength !== void 0 && `/${maxLength}`
|
|
1682
|
+
] })
|
|
1683
|
+
]
|
|
1684
|
+
}
|
|
1685
|
+
)
|
|
1663
1686
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
1664
1687
|
"button",
|
|
1665
1688
|
{
|