@discuss-ds/ui 0.24.1 → 0.26.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @discuss-ds/ui
2
2
 
3
+ ## 0.26.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#96](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/96) [`b7cb516`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/b7cb516418206054de5f26c4c10d2fb3e7e9edb5) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `ToastInline` takes an optional `actions` slot (for example a ghost "Dismiss" and an outline "Fix" `Button size="sm"`) shown after the message, and a new quiet `variant="neutral"` (secondary background, standard border) for suggestions. Existing variants and the `onClose` button are unchanged.
8
+
9
+ ## 0.25.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#94](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/94) [`bc9d1fb`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/bc9d1fbe954c7bfbb419b46317f800ffcb1b8d13) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `TabNavigation` / `TabItem`: in the `filter` and `toggle` variants the selected tab's background is now a single indicator that slides to the newly selected tab (200ms; it jumps with reduced motion), instead of each tab painting its own. The tabs themselves keep their size, hover and disabled looks; the `underline` variant is unchanged. A tab that overrides its own background with a class still does.
14
+
3
15
  ## 0.24.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1210,8 +1210,9 @@ var TabNavigationContext = React19.createContext("filter");
1210
1210
  var tabNavigationVariants = (0, import_class_variance_authority3.cva)("inline-flex items-start gap-1 p-0.5", {
1211
1211
  variants: {
1212
1212
  variant: {
1213
- filter: "rounded-full border border-border bg-surface",
1214
- toggle: "rounded-md bg-secondary bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5",
1213
+ // `relative`: the sliding indicator is positioned against the list.
1214
+ filter: "relative rounded-full border border-border bg-surface",
1215
+ toggle: "relative rounded-md bg-secondary bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5",
1215
1216
  underline: "items-stretch p-0"
1216
1217
  }
1217
1218
  },
@@ -1219,16 +1220,70 @@ var tabNavigationVariants = (0, import_class_variance_authority3.cva)("inline-fl
1219
1220
  });
1220
1221
  var Tabs = import_radix_ui9.Tabs.Root;
1221
1222
  var TabsContent = import_radix_ui9.Tabs.Content;
1223
+ var indicatorClasses = {
1224
+ filter: "rounded-full bg-secondary bg-linear-to-r from-overlay-dark-5 to-overlay-dark-5",
1225
+ toggle: "rounded-sm bg-surface"
1226
+ };
1222
1227
  var TabNavigation = React19.forwardRef(
1223
- ({ className, variant = "filter", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TabNavigationContext.Provider, { value: variant ?? "filter", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_radix_ui9.Tabs.List, { ref, className: cn(tabNavigationVariants({ variant }), className), ...props }) })
1228
+ ({ className, variant = "filter", children, ...props }, forwardedRef) => {
1229
+ const kind = variant ?? "filter";
1230
+ const slides = kind !== "underline";
1231
+ const listRef = React19.useRef(null);
1232
+ const [box, setBox] = React19.useState(null);
1233
+ const [animate, setAnimate] = React19.useState(false);
1234
+ const setRefs = React19.useCallback(
1235
+ (node) => {
1236
+ listRef.current = node;
1237
+ if (typeof forwardedRef === "function") forwardedRef(node);
1238
+ else if (forwardedRef) forwardedRef.current = node;
1239
+ },
1240
+ [forwardedRef]
1241
+ );
1242
+ React19.useLayoutEffect(() => {
1243
+ const list = listRef.current;
1244
+ if (!slides || !list) return;
1245
+ const measure = () => {
1246
+ const active = list.querySelector('[role="tab"][data-state="active"]');
1247
+ const next = active ? { left: active.offsetLeft, top: active.offsetTop, width: active.offsetWidth, height: active.offsetHeight } : null;
1248
+ setBox((prev) => prev && next && prev.left === next.left && prev.top === next.top && prev.width === next.width && prev.height === next.height ? prev : next);
1249
+ };
1250
+ measure();
1251
+ const mutations = new MutationObserver(measure);
1252
+ mutations.observe(list, { attributes: true, attributeFilter: ["data-state"], subtree: true, childList: true });
1253
+ const resizes = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
1254
+ resizes?.observe(list);
1255
+ const frame = requestAnimationFrame(() => setAnimate(true));
1256
+ return () => {
1257
+ mutations.disconnect();
1258
+ resizes?.disconnect();
1259
+ cancelAnimationFrame(frame);
1260
+ };
1261
+ }, [slides]);
1262
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TabNavigationContext.Provider, { value: kind, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_radix_ui9.Tabs.List, { ref: setRefs, className: cn(tabNavigationVariants({ variant }), className), ...props, children: [
1263
+ slides && box && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1264
+ "span",
1265
+ {
1266
+ "aria-hidden": true,
1267
+ "data-slot": "tab-indicator",
1268
+ className: cn(
1269
+ "pointer-events-none absolute",
1270
+ indicatorClasses[kind],
1271
+ animate && "transition-[left,top,width,height] duration-200 ease-out motion-reduce:transition-none"
1272
+ ),
1273
+ style: { left: box.left, top: box.top, width: box.width, height: box.height }
1274
+ }
1275
+ ),
1276
+ children
1277
+ ] }) });
1278
+ }
1224
1279
  );
1225
1280
  TabNavigation.displayName = "TabNavigation";
1226
1281
 
1227
1282
  // src/components/Navigation/TabItem.tsx
1228
1283
  var import_jsx_runtime21 = require("react/jsx-runtime");
1229
1284
  var base = "inline-flex h-7 items-center justify-center gap-1 whitespace-nowrap px-2.5 py-1 text-ui-label transition-colors disabled:pointer-events-none disabled:opacity-50";
1230
- var filter = "rounded-full text-surface-foreground hover:text-accent data-[state=active]:bg-secondary data-[state=active]:bg-linear-to-r data-[state=active]:from-overlay-dark-5 data-[state=active]:to-overlay-dark-5 data-[state=active]:hover:bg-accent-soft data-[state=active]:hover:bg-none data-[state=active]:hover:text-accent-soft-foreground disabled:text-muted-foreground";
1231
- var toggle = "rounded-sm text-secondary-muted-foreground hover:text-surface-foreground data-[state=active]:bg-surface data-[state=active]:text-surface-foreground";
1285
+ var filter = "relative rounded-full text-surface-foreground hover:text-accent data-[state=active]:hover:bg-accent-soft data-[state=active]:hover:text-accent-soft-foreground disabled:text-muted-foreground";
1286
+ var toggle = "relative rounded-sm text-secondary-muted-foreground hover:text-surface-foreground data-[state=active]:text-surface-foreground";
1232
1287
  var underline = "relative h-full rounded-none px-4 py-3 font-medium text-secondary-muted-foreground hover:text-surface-foreground data-[state=active]:font-semibold data-[state=active]:text-surface-foreground after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 data-[state=active]:after:bg-accent";
1233
1288
  var TabItem = React20.forwardRef(
1234
1289
  ({ className, ...props }, ref) => {
@@ -2205,6 +2260,18 @@ var toastVariants = (0, import_class_variance_authority4.cva)("border", {
2205
2260
  },
2206
2261
  defaultVariants: { variant: "info" }
2207
2262
  });
2263
+ var inlineVariants = (0, import_class_variance_authority4.cva)("border", {
2264
+ variants: {
2265
+ variant: {
2266
+ neutral: "border-border bg-secondary",
2267
+ info: "border-info-border bg-surface",
2268
+ success: "border-success-soft-border bg-success-soft",
2269
+ warning: "border-warning-soft-border bg-warning-soft",
2270
+ destructive: "border-destructive-soft-border bg-destructive-soft"
2271
+ }
2272
+ },
2273
+ defaultVariants: { variant: "info" }
2274
+ });
2208
2275
  var iconColour = {
2209
2276
  info: "text-surface-foreground",
2210
2277
  success: "text-success-soft-foreground",
@@ -2269,18 +2336,19 @@ var Toast = React33.forwardRef(
2269
2336
  Toast.displayName = "Toast";
2270
2337
  var ToastAction = import_radix_ui17.Toast.Action;
2271
2338
  var ToastInline = React33.forwardRef(
2272
- ({ className, variant = "info", onClose, closeLabel = "Close", children, ...props }, ref) => {
2339
+ ({ className, variant = "info", actions, onClose, closeLabel = "Close", children, ...props }, ref) => {
2273
2340
  const v = variant ?? "info";
2274
2341
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
2275
2342
  "div",
2276
2343
  {
2277
2344
  ref,
2278
2345
  role: v === "destructive" ? "alert" : "status",
2279
- className: cn("flex items-center gap-2 rounded-sm px-2 py-1.5", toastVariants({ variant: v }), className),
2346
+ className: cn("flex items-center gap-2 rounded-sm px-2 py-1.5", inlineVariants({ variant: v }), className),
2280
2347
  ...props,
2281
2348
  children: [
2282
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(VariantIcon, { variant: v, size: 16 }),
2349
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(VariantIcon, { variant: v === "neutral" ? "info" : v, size: 16 }),
2283
2350
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "min-w-0 flex-1 text-body-small text-secondary-muted-foreground", children }),
2351
+ actions && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "flex shrink-0 items-center gap-2", children: actions }),
2284
2352
  onClose && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": closeLabel, onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react16.X, { size: 16, "aria-hidden": true }) })
2285
2353
  ]
2286
2354
  }