@discuss-ds/ui 0.24.0 → 0.25.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.25.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
9
+ ## 0.24.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#92](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/92) [`6477868`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/6477868c4a29e522791868b1a91f637be6c6306e) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `InlineEdit`: the read text now shows the text cursor on hover (it showed the default arrow), as editable text should. A disabled field keeps the not-allowed cursor.
14
+
3
15
  ## 0.24.0
4
16
 
5
17
  ### Minor 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) => {
@@ -1699,7 +1754,8 @@ var InlineEdit = React24.forwardRef(
1699
1754
  // one. The extra 1px of bottom padding keeps the height identical so the text never jumps.
1700
1755
  selected ? "rounded-none border-b-2 border-accent-foreground py-1" : "rounded-none border-b border-transparent pb-1.25 pt-1 enabled:hover:border-input-muted enabled:focus-visible:border-input-muted"
1701
1756
  ) : "rounded-md border border-transparent py-1 enabled:focus-visible:border-input-accent",
1702
- "enabled:hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-50",
1757
+ // The text is editable in place, so hovering it shows the text cursor.
1758
+ "enabled:cursor-text enabled:hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-50",
1703
1759
  textClasses
1704
1760
  ),
1705
1761
  children: [