@blakesteve/roster 5.13.0 → 5.15.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.
Files changed (39) hide show
  1. package/README.md +187 -41
  2. package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
  3. package/dist/components/molecules/Carousel/Carousel.d.ts +65 -3
  4. package/dist/components/molecules/Carousel/Carousel.js +376 -225
  5. package/dist/components/molecules/Carousel/carousel-math.cjs +1 -1
  6. package/dist/components/molecules/Carousel/carousel-math.d.ts +16 -0
  7. package/dist/components/molecules/Carousel/carousel-math.js +63 -44
  8. package/dist/components/molecules/Carousel/carousel-selection.cjs +1 -0
  9. package/dist/components/molecules/Carousel/carousel-selection.d.ts +28 -0
  10. package/dist/components/molecules/Carousel/carousel-selection.js +23 -0
  11. package/dist/components/molecules/LiquidTabs/LiquidCount.d.ts +2 -2
  12. package/dist/components/molecules/LiquidTabs/LiquidTabPanel.cjs +1 -1
  13. package/dist/components/molecules/LiquidTabs/LiquidTabPanel.d.ts +10 -49
  14. package/dist/components/molecules/LiquidTabs/LiquidTabPanel.js +5 -28
  15. package/dist/components/molecules/LiquidTabs/LiquidTabs.cjs +1 -1
  16. package/dist/components/molecules/LiquidTabs/LiquidTabs.d.ts +13 -40
  17. package/dist/components/molecules/LiquidTabs/LiquidTabs.js +5 -95
  18. package/dist/components/molecules/LiquidTabs/liquid-count.d.ts +7 -5
  19. package/dist/components/molecules/LiquidTabs/liquid-tab-id.cjs +1 -1
  20. package/dist/components/molecules/LiquidTabs/liquid-tab-id.d.ts +4 -9
  21. package/dist/components/molecules/LiquidTabs/liquid-tab-id.js +3 -4
  22. package/dist/components/molecules/Tabs/TabPanel.cjs +1 -0
  23. package/dist/components/molecules/Tabs/TabPanel.d.ts +53 -0
  24. package/dist/components/molecules/Tabs/TabPanel.js +32 -0
  25. package/dist/components/molecules/Tabs/Tabs.cjs +1 -0
  26. package/dist/components/molecules/Tabs/Tabs.d.ts +118 -0
  27. package/dist/components/molecules/Tabs/Tabs.js +145 -0
  28. package/dist/components/molecules/Tabs/tab-id.cjs +1 -0
  29. package/dist/components/molecules/Tabs/tab-id.d.ts +13 -0
  30. package/dist/components/molecules/Tabs/tab-id.js +6 -0
  31. package/dist/index.d.ts +3 -0
  32. package/dist/internal/dev.cjs +1 -0
  33. package/dist/internal/dev.d.ts +10 -0
  34. package/dist/internal/dev.js +10 -0
  35. package/dist/meta.json +3 -3
  36. package/dist/roster.cjs +1 -1
  37. package/dist/roster.css +1 -1
  38. package/dist/roster.js +116 -110
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=6,i=1;function a(t){return Math.max(0,t.scrollWidth-t.clientWidth)}function h(t){return a(t)>i}function S(t){return t.scrollLeft>i}function L(t){return t.scrollLeft<a(t)-i}function s(t,e){const n=t.items[e];if(!n)return 0;const r=t.align==="start"?n.start-t.paddingStart:(n.start+n.end)/2-(t.paddingStart+(t.clientWidth-t.paddingStart-t.paddingEnd)/2);return Math.min(Math.max(0,r),a(t))}function u(t){const e=t.scrollLeft-i,n=t.scrollLeft+t.clientWidth+i,r=[];return t.items.forEach((l,c)=>{l.start>=e&&l.end<=n&&r.push(c)}),r}function f(t){let e=0,n=1/0;return t.items.forEach((r,l)=>{const c=Math.abs(s(t,l)-t.scrollLeft);c<n&&(e=l,n=c)}),e}function m(t){const e=u(t);return e.length?e[0]:f(t)}function x(t,e){const n=t.items.length;if(!n)return 0;const r=u(t),l=r.length?r[0]:f(t),c=Math.max(1,r.length);let o=Math.min(n-1,Math.max(0,l+e*c));for(;o>0&&o<n-1&&Math.abs(s(t,o)-t.scrollLeft)<=i;)o+=e;return s(t,o)}exports.CAROUSEL_DRAG_THRESHOLD=d;exports.CAROUSEL_TOLERANCE=i;exports.canScrollNext=L;exports.canScrollPrev=S;exports.currentIndex=m;exports.fullyVisible=u;exports.maxScroll=a;exports.nearestIndex=f;exports.overflows=h;exports.pageTarget=x;exports.snapPosition=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=6,a=1;function u(t){return Math.max(0,t.scrollWidth-t.clientWidth)}function m(t){return u(t)>a}function L(t){return t.scrollLeft>a}function x(t){return t.scrollLeft<u(t)-a}function o(t,n){const e=t.items[n];if(!e)return 0;const r=t.align==="start"?e.start-t.paddingStart:(e.start+e.end)/2-(t.paddingStart+(t.clientWidth-t.paddingStart-t.paddingEnd)/2);return Math.min(Math.max(0,r),u(t))}function f(t){const n=t.scrollLeft-a,e=t.scrollLeft+t.clientWidth+a,r=[];return t.items.forEach((i,l)=>{i.start>=n&&i.end<=e&&r.push(l)}),r}function h(t){let n=0,e=1/0;return t.items.forEach((r,i)=>{const l=Math.abs(o(t,i)-t.scrollLeft);l<e&&(n=i,e=l)}),n}function E(t){const n=f(t);return n.length?n[0]:h(t)}function b(t,n){const e=t.items.length;if(!e)return 0;const r=f(t),i=r.length?r[0]:h(t),l=Math.max(1,r.length);let c=Math.min(e-1,Math.max(0,i+n*l));for(;c>0&&c<e-1&&Math.abs(o(t,c)-t.scrollLeft)<=a;)c+=n;return o(t,c)}function v(t){return Math.max(1,f(t).length)}function M(t,n,e=t.scrollLeft){const r=t.items[n];if(!r)return null;const i=s=>[s+t.paddingStart-a,s+t.clientWidth-t.paddingEnd+a],[l,c]=i(e);if(r.start>=l&&r.end<=c)return null;if(t.align==="center"||r.start<l)return o(t,n);for(let s=0;s<=n;s++){const d=o(t,s);if(d<e)continue;const[,S]=i(d);if(r.end<=S)return d}return o(t,n)}exports.CAROUSEL_DRAG_THRESHOLD=p;exports.CAROUSEL_TOLERANCE=a;exports.canScrollNext=x;exports.canScrollPrev=L;exports.currentIndex=E;exports.fullyVisible=f;exports.maxScroll=u;exports.nearestIndex=h;exports.overflows=m;exports.pageStep=v;exports.pageTarget=b;exports.revealTarget=M;exports.snapPosition=o;
@@ -58,3 +58,19 @@ export declare function currentIndex(g: CarouselGeometry): number;
58
58
  * Returns the target `scrollLeft`.
59
59
  */
60
60
  export declare function pageTarget(g: CarouselGeometry, direction: 1 | -1): number;
61
+ /**
62
+ * How far Page Up and Page Down move in selection mode: as many options as
63
+ * are wholly in view, at least one.
64
+ */
65
+ export declare function pageStep(g: CarouselGeometry): number;
66
+ /**
67
+ * The `scrollLeft` that brings item `i` wholly into view, measured from
68
+ * `from` (where the row is, or where a glide is taking it), or `null` when it
69
+ * already is. Inside the scroll padding, so a revealed item clears the gutter.
70
+ *
71
+ * The row moves as little as it can and always lands on a snap point, which
72
+ * the browser would snap it to anyway: an item off the leading side snaps to
73
+ * its own place; one off the trailing side lands on the first snap point that
74
+ * shows it whole. With `center`, an item out of view is centered.
75
+ */
76
+ export declare function revealTarget(g: CarouselGeometry, i: number, from?: number): number | null;
@@ -1,58 +1,77 @@
1
- const E = 6, u = 1;
2
- function a(t) {
1
+ const L = 6, h = 1;
2
+ function u(t) {
3
3
  return Math.max(0, t.scrollWidth - t.clientWidth);
4
4
  }
5
- function L(t) {
6
- return a(t) > 1;
5
+ function R(t) {
6
+ return u(t) > 1;
7
7
  }
8
- function h(t) {
8
+ function A(t) {
9
9
  return t.scrollLeft > 1;
10
10
  }
11
- function d(t) {
12
- return t.scrollLeft < a(t) - 1;
11
+ function O(t) {
12
+ return t.scrollLeft < u(t) - 1;
13
13
  }
14
- function o(t, e) {
15
- const n = t.items[e];
16
- if (!n) return 0;
17
- const r = t.align === "start" ? n.start - t.paddingStart : (n.start + n.end) / 2 - (t.paddingStart + (t.clientWidth - t.paddingStart - t.paddingEnd) / 2);
18
- return Math.min(Math.max(0, r), a(t));
14
+ function l(t, n) {
15
+ const e = t.items[n];
16
+ if (!e) return 0;
17
+ const r = t.align === "start" ? e.start - t.paddingStart : (e.start + e.end) / 2 - (t.paddingStart + (t.clientWidth - t.paddingStart - t.paddingEnd) / 2);
18
+ return Math.min(Math.max(0, r), u(t));
19
19
  }
20
- function l(t) {
21
- const e = t.scrollLeft - 1, n = t.scrollLeft + t.clientWidth + 1, r = [];
22
- return t.items.forEach((i, s) => {
23
- i.start >= e && i.end <= n && r.push(s);
20
+ function f(t) {
21
+ const n = t.scrollLeft - 1, e = t.scrollLeft + t.clientWidth + 1, r = [];
22
+ return t.items.forEach((i, c) => {
23
+ i.start >= n && i.end <= e && r.push(c);
24
24
  }), r;
25
25
  }
26
- function f(t) {
27
- let e = 0, n = 1 / 0;
26
+ function E(t) {
27
+ let n = 0, e = 1 / 0;
28
28
  return t.items.forEach((r, i) => {
29
- const s = Math.abs(o(t, i) - t.scrollLeft);
30
- s < n && (e = i, n = s);
31
- }), e;
29
+ const c = Math.abs(l(t, i) - t.scrollLeft);
30
+ c < e && (n = i, e = c);
31
+ }), n;
32
32
  }
33
- function R(t) {
34
- const e = l(t);
35
- return e.length ? e[0] : f(t);
36
- }
37
- function A(t, e) {
38
- const n = t.items.length;
39
- if (!n) return 0;
40
- const r = l(t), i = r.length ? r[0] : f(t), s = Math.max(1, r.length);
41
- let c = Math.min(n - 1, Math.max(0, i + e * s));
42
- for (; c > 0 && c < n - 1 && Math.abs(o(t, c) - t.scrollLeft) <= 1; )
43
- c += e;
44
- return o(t, c);
33
+ function C(t) {
34
+ const n = f(t);
35
+ return n.length ? n[0] : E(t);
36
+ }
37
+ function S(t, n) {
38
+ const e = t.items.length;
39
+ if (!e) return 0;
40
+ const r = f(t), i = r.length ? r[0] : E(t), c = Math.max(1, r.length);
41
+ let s = Math.min(e - 1, Math.max(0, i + n * c));
42
+ for (; s > 0 && s < e - 1 && Math.abs(l(t, s) - t.scrollLeft) <= 1; )
43
+ s += n;
44
+ return l(t, s);
45
+ }
46
+ function m(t) {
47
+ return Math.max(1, f(t).length);
48
+ }
49
+ function p(t, n, e = t.scrollLeft) {
50
+ const r = t.items[n];
51
+ if (!r) return null;
52
+ const i = (a) => [a + t.paddingStart - 1, a + t.clientWidth - t.paddingEnd + 1], [c, s] = i(e);
53
+ if (r.start >= c && r.end <= s) return null;
54
+ if (t.align === "center" || r.start < c) return l(t, n);
55
+ for (let a = 0; a <= n; a++) {
56
+ const o = l(t, a);
57
+ if (o < e) continue;
58
+ const [, d] = i(o);
59
+ if (r.end <= d) return o;
60
+ }
61
+ return l(t, n);
45
62
  }
46
63
  export {
47
- E as CAROUSEL_DRAG_THRESHOLD,
48
- u as CAROUSEL_TOLERANCE,
49
- d as canScrollNext,
50
- h as canScrollPrev,
51
- R as currentIndex,
52
- l as fullyVisible,
53
- a as maxScroll,
54
- f as nearestIndex,
55
- L as overflows,
56
- A as pageTarget,
57
- o as snapPosition
64
+ L as CAROUSEL_DRAG_THRESHOLD,
65
+ h as CAROUSEL_TOLERANCE,
66
+ O as canScrollNext,
67
+ A as canScrollPrev,
68
+ C as currentIndex,
69
+ f as fullyVisible,
70
+ u as maxScroll,
71
+ E as nearestIndex,
72
+ R as overflows,
73
+ m as pageStep,
74
+ S as pageTarget,
75
+ p as revealTarget,
76
+ l as snapPosition
58
77
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=700;function d(r,t,n,i){if(!r||!n)return-1;const e=[...n].every(l=>l===n[0]),f=e?n[0]:n,u=e?t+1:t;for(let l=0;l<r;l++){const a=((u+l)%r+r)%r;if(i(a).trim().toLowerCase().startsWith(f))return a}return-1}function h(r,t,n){if(n===null)return null;const i=r.indexOf(n);if(i===-1)return null;for(let e=i+1;e<r.length;e++)if(t.has(r[e]))return r[e];for(let e=i-1;e>=0;e--)if(t.has(r[e]))return r[e];return null}exports.TYPEAHEAD_RESET_MS=s;exports.survivingNeighbor=h;exports.typeaheadIndex=d;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Selection mode's decisions that need no DOM: which option type-ahead lands
3
+ * on, and where the active option goes when the one it was on leaves.
4
+ *
5
+ * Pure, so they're tested with literals; the stories drive the real keys.
6
+ */
7
+ /** How long a pause starts type-ahead over, in ms. */
8
+ export declare const TYPEAHEAD_RESET_MS = 700;
9
+ /**
10
+ * The option type-ahead lands on, or -1 for none.
11
+ *
12
+ * `text` is everything typed since the last pause, lowercased. One letter, or
13
+ * the same letter again and again, steps through the options starting with
14
+ * it, beginning after `from` and wrapping, so pressing "g" three times visits
15
+ * the third option starting with "g". Anything longer matches from `from`
16
+ * itself, so "gl" typed after "g" stays put when the active option already
17
+ * starts with "gl".
18
+ *
19
+ * `labelAt(i)` is option `i`'s text, read only as far as the search goes.
20
+ */
21
+ export declare function typeaheadIndex(count: number, from: number, text: string, labelAt: (index: number) => string): number;
22
+ /**
23
+ * Where the active option goes when its own has left the row: the nearest
24
+ * option after it that's still there, in the order before the change, else
25
+ * the nearest before it. `null` when none of its old neighbors is left, or
26
+ * when it wasn't in the old order at all.
27
+ */
28
+ export declare function survivingNeighbor(previous: readonly string[], present: ReadonlySet<string>, lost: string | null): string | null;
@@ -0,0 +1,23 @@
1
+ const u = 700;
2
+ function h(r, e, t, i) {
3
+ if (!r || !t) return -1;
4
+ const n = [...t].every((f) => f === t[0]), a = n ? t[0] : t, s = n ? e + 1 : e;
5
+ for (let f = 0; f < r; f++) {
6
+ const l = ((s + f) % r + r) % r;
7
+ if (i(l).trim().toLowerCase().startsWith(a)) return l;
8
+ }
9
+ return -1;
10
+ }
11
+ function c(r, e, t) {
12
+ if (t === null) return null;
13
+ const i = r.indexOf(t);
14
+ if (i === -1) return null;
15
+ for (let n = i + 1; n < r.length; n++) if (e.has(r[n])) return r[n];
16
+ for (let n = i - 1; n >= 0; n--) if (e.has(r[n])) return r[n];
17
+ return null;
18
+ }
19
+ export {
20
+ u as TYPEAHEAD_RESET_MS,
21
+ c as survivingNeighbor,
22
+ h as typeaheadIndex
23
+ };
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { LiquidTabsLabels } from './liquid-count';
2
+ import { TabsLabels } from './liquid-count';
3
3
  /**
4
4
  * A tab's or a link's label, with its count beside it when it has one.
5
5
  *
@@ -25,5 +25,5 @@ import { LiquidTabsLabels } from './liquid-count';
25
25
  export declare function LiquidCount({ label, count, labels }: {
26
26
  label: ReactNode;
27
27
  count: number | undefined;
28
- labels: LiquidTabsLabels;
28
+ labels: TabsLabels;
29
29
  }): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),t=require("react"),y=require("./liquid-tab-id.cjs"),p='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), iframe, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';function x({tabsId:d,id:l,tab:n,activeTab:a,keepMounted:u=!1,tabIndex:b,children:c,...f}){const i=t.useRef(null),r=a===void 0||a===n,[h,q]=t.useState(!1);return t.useLayoutEffect(()=>{const e=i.current;if(!e)return;const o=()=>q(!!e.querySelector(p));if(o(),typeof MutationObserver>"u")return;const s=new MutationObserver(o);return s.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled","tabindex","href","contenteditable"]}),()=>s.disconnect()},[]),v.jsx("div",{...f,ref:i,role:"tabpanel",id:l,"aria-labelledby":y.liquidTabId(d,n),hidden:!r,tabIndex:b??(h?void 0:0),"data-tab-panel":"",children:r||u?c:null})}exports.LiquidTabPanel=x;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("../Tabs/TabPanel.cjs");function t(e){return n.jsx(i.TabPanel,{...e})}exports.LiquidTabPanel=t;
@@ -1,52 +1,13 @@
1
- import { HTMLAttributes, ReactNode } from 'react';
2
- export interface LiquidTabPanelProps extends Omit<HTMLAttributes<HTMLDivElement>, "id" | "role" | "hidden" | "children"> {
3
- /** The `id` of the `LiquidTabs` this panel belongs to (its `id` prop). */
4
- tabsId: string;
5
- /** This panel's `id`: the `panelId` its tab carries, or every tab, for one panel that swaps its content. */
6
- id: string;
7
- /**
8
- * The tab that names this panel. For one panel that swaps its content, the
9
- * selected tab: the panel's name follows the selection. For a panel per tab,
10
- * its own tab.
11
- */
12
- tab: string;
13
- /**
14
- * For a panel per tab: the selected tab. The panel shows when it is `tab`,
15
- * and is hidden otherwise. Leave it out for one panel that swaps its
16
- * content, which always shows.
17
- */
18
- activeTab?: string;
19
- /**
20
- * For a panel per tab: keep the content mounted while the panel is hidden,
21
- * so what's in it (a half-filled form, a scroll position) survives a switch
22
- * away and back. By default a hidden panel renders no content. The panel
23
- * element itself always stays, hidden, so its tab's `aria-controls` points
24
- * at something.
25
- */
26
- keepMounted?: boolean;
27
- children?: ReactNode;
28
- }
1
+ import { TabPanelProps } from '../Tabs/TabPanel';
29
2
  /**
30
- * The panel a `LiquidTabs` tab controls, paired with it by construction:
31
- * `role="tabpanel"`, its `id` the tab's `panelId`, and `aria-labelledby`
32
- * pointing at the tab through `liquidTabId`, so it's named for its tab.
33
- *
34
- * ```tsx
35
- * <LiquidTabs id="views" tabs={[{ id: "open", label: "Open", panelId: "views-panel" }, …]} … />
36
- * <LiquidTabPanel tabsId="views" id="views-panel" tab={view}>…</LiquidTabPanel>
37
- * ```
38
- *
39
- * Two ways to lay it out. **One panel that swaps its content:** every tab
40
- * carries the same `panelId`, and `tab` is the selected tab. **A panel per
41
- * tab:** each tab has its own `panelId`, each panel its own `tab`, and every
42
- * panel gets `activeTab`, so only the selected one shows.
3
+ * @deprecated Renamed `TabPanelProps`; the props are the same.
4
+ */
5
+ export type LiquidTabPanelProps = TabPanelProps;
6
+ /**
7
+ * The panel a tab controls, named for its tab by construction.
43
8
  *
44
- * The WAI tabs pattern puts the panel in the tab order when nothing inside it
45
- * can take focus, so a keyboard user can reach and scroll what was just
46
- * selected. Whether the content holds anything focusable isn't known until it
47
- * renders, and it can change as content loads, so the panel starts reachable
48
- * (`tabIndex={0}`) and leaves the tab order once its content holds something
49
- * that can be Tabbed to, rechecking as the content changes. Pass `tabIndex`
50
- * to decide it yourself.
9
+ * @deprecated Renamed `TabPanel`, which this renders, for `Tabs` of every
10
+ * variant and for `LiquidTabs`. Replace the name; nothing else changes. This
11
+ * name keeps working.
51
12
  */
52
- export declare function LiquidTabPanel({ tabsId, id, tab, activeTab, keepMounted, tabIndex, children, ...rest }: LiquidTabPanelProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function LiquidTabPanel(props: LiquidTabPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -1,32 +1,9 @@
1
1
  "use client";
2
- import { jsx as p } from "react/jsx-runtime";
3
- import { useRef as m, useState as v, useLayoutEffect as x } from "react";
4
- import { liquidTabId as y } from "./liquid-tab-id.js";
5
- const L = 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), iframe, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';
6
- function w({ tabsId: d, id: s, tab: t, activeTab: n, keepMounted: l = !1, tabIndex: b, children: u, ...c }) {
7
- const r = m(null), a = n === void 0 || n === t, [f, h] = v(!1);
8
- return x(() => {
9
- const e = r.current;
10
- if (!e) return;
11
- const o = () => h(!!e.querySelector(L));
12
- if (o(), typeof MutationObserver > "u") return;
13
- const i = new MutationObserver(o);
14
- return i.observe(e, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["disabled", "tabindex", "href", "contenteditable"] }), () => i.disconnect();
15
- }, []), /* @__PURE__ */ p(
16
- "div",
17
- {
18
- ...c,
19
- ref: r,
20
- role: "tabpanel",
21
- id: s,
22
- "aria-labelledby": y(d, t),
23
- hidden: !a,
24
- tabIndex: b ?? (f ? void 0 : 0),
25
- "data-tab-panel": "",
26
- children: a || l ? u : null
27
- }
28
- );
2
+ import { jsx as e } from "react/jsx-runtime";
3
+ import { TabPanel as i } from "../Tabs/TabPanel.js";
4
+ function t(r) {
5
+ return /* @__PURE__ */ e(i, { ...r });
29
6
  }
30
7
  export {
31
- w as LiquidTabPanel
8
+ t as LiquidTabPanel
32
9
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),d=require("react"),o=require("./liquid-pill.cjs"),U=require("./liquid-tab-id.cjs"),O=require("./LiquidCount.cjs"),m=require("./liquid-count.cjs"),Q=require("../../../lib/labels.cjs"),B=require("../../../internal/key-focus.cjs");function K({tabs:t,activeTab:r,onChange:C,variant:c="pill",fullWidth:y=!1,size:A="md",activation:R="automatic",id:h,"aria-label":w,"aria-labelledby":N,className:j,labels:k}){B.useKeyFocus();const L=Q.withLabels(m.LIQUID_COUNT_LABELS,k),a=d.useRef(null),I=d.useRef(null),x=d.useId(),p=h??x;o.useLiquidPill(a,I,r,t.map(e=>e.id).join("\0"));const b=e=>{e!==r&&C(e)},[f,S]=d.useState(null),T=t.some(e=>e.id===r),P=f!==null&&t.some(e=>e.id===f)?f:T?r:t[0]?.id,_=e=>{e.currentTarget.contains(e.relatedTarget)||S(null)},D=e=>{const i=a.current;if(!i)return;const l=Array.from(i.querySelectorAll('[role="tab"]')),n=l.indexOf(e.target);if(n===-1)return;const q=l.length-1,g=getComputedStyle(i).direction==="rtl",E=g?"ArrowLeft":"ArrowRight",F=g?"ArrowRight":"ArrowLeft";let s;if(e.key===E)s=n===q?0:n+1;else if(e.key===F)s=n===0?q:n-1;else if(e.key==="Home")s=0;else if(e.key==="End")s=q;else return;e.preventDefault(),l[s].focus(),R==="automatic"&&b(t[s].id)};return u.jsxs("div",{ref:a,id:p,role:"tablist","aria-label":w,"aria-labelledby":N,"data-testid":"liquid-tabs",style:o.LIQUID_STRIP_STYLE,className:o.liquidStripClassName(c,y,j),onKeyDown:D,onBlur:_,children:[u.jsx("div",{ref:I,"aria-hidden":!0,"data-testid":"liquid-tabs-pill",className:o.liquidPillClassName(c),style:o.LIQUID_PILL_STYLE}),t.map(e=>{const i=e.id===r,l=typeof e.label=="function"?e.label(i):e.label;return u.jsx("button",{type:"button",role:"tab",id:U.liquidTabId(p,e.id),"aria-selected":i,"aria-controls":e.panelId,"aria-label":m.countName(l,e.count,L),tabIndex:e.id===P?0:-1,"data-tab-id":e.id,"data-testid":`liquid-tab-${e.id}`,onClick:()=>b(e.id),onFocus:()=>S(e.id),className:o.liquidItemClassName({variant:c,fullWidth:y,size:A,isActive:i}),children:m.shownCount(e.count)?u.jsx(O.LiquidCount,{label:l,count:e.count,labels:L}):l},e.id)})]})}exports.LiquidTabs=K;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("../Tabs/Tabs.cjs");function r({variant:i="pill",...e}){return t.jsx(u.Tabs,{...e,variant:"liquid",liquidStyle:i})}exports.LiquidTabs=r;
@@ -1,29 +1,7 @@
1
- import { ReactNode } from 'react';
2
1
  import { LiquidSize, LiquidVariant } from './liquid-pill';
3
- import { LiquidTabsLabels } from './liquid-count';
4
- export type { LiquidTabsLabels };
5
- export interface TabItem {
6
- id: string;
7
- /** Static label, or a render function that receives whether this tab is active. */
8
- label: ReactNode | ((isActive: boolean) => ReactNode);
9
- /**
10
- * The `id` of the panel this tab controls, which sets `aria-controls`. Give
11
- * every tab the same id when one panel swaps its content.
12
- */
13
- panelId?: string;
14
- /**
15
- * A number in a small mark beside the label, read as part of the tab's
16
- * name: "Open, 12 items" (`labels.count` says it).
17
- *
18
- * **Zero shows**, as "0" and "0 items": a count that vanished at zero would
19
- * change the tab's width and move every tab after it, and an empty list is
20
- * worth saying. To hide it, pass `undefined` for zero. `undefined` means no
21
- * count and no mark. A negative or fractional count isn't shown at all,
22
- * never rounded or clamped. Large counts aren't abbreviated: 12,345 shows
23
- * as "12,345" unless `labels.countMark` writes it shorter.
24
- */
25
- count?: number;
26
- }
2
+ import { TabItem, TabsLabels } from '../Tabs/Tabs';
3
+ export type { TabItem };
4
+ export type { LiquidTabsLabels } from './liquid-count';
27
5
  export interface LiquidTabsProps {
28
6
  tabs: TabItem[];
29
7
  /** The `id` of the currently active tab. */
@@ -64,25 +42,20 @@ export interface LiquidTabsProps {
64
42
  /** Extra classes applied to the outer container. */
65
43
  className?: string;
66
44
  /** Every word a count says, with English defaults: see `TabItem.count`. */
67
- labels?: Partial<LiquidTabsLabels>;
45
+ labels?: Partial<TabsLabels>;
68
46
  }
69
47
  /**
70
48
  * A controlled tab strip with a liquid sliding indicator.
71
49
  *
72
- * Follows the WAI tabs pattern: only the selected tab is in the tab order,
73
- * Left and Right move between tabs and wrap, Home and End go to the ends. If
74
- * `activeTab` matches no tab, the first tab takes the tab stop and no pill
75
- * shows.
76
- *
77
- * Until script has measured the pill, the active tab paints the pill's color
78
- * itself, so server-rendered HTML shows the selection too.
79
- *
80
- * The pill follows `activeTab`, never the click, so a change the consumer
81
- * vetoes, or one that waits on navigation, never leaves it on the wrong tab.
50
+ * @deprecated Use `Tabs` with `variant="liquid"`, which renders exactly this:
51
+ * the same markup, styles, keys and pill. `variant` becomes `liquidStyle`, and
52
+ * every other prop is the same:
82
53
  *
83
- * A tab can carry a `count`, and a panel pairs with its tab by construction
84
- * through `LiquidTabPanel`.
54
+ * ```tsx
55
+ * <LiquidTabs variant="filled" … /> // before
56
+ * <Tabs variant="liquid" liquidStyle="filled" … /> // after
57
+ * ```
85
58
  *
86
- * For navigation between routes, use `LiquidNav`, which renders links.
59
+ * `LiquidTabs` keeps working, unchanged.
87
60
  */
88
- export declare function LiquidTabs({ tabs, activeTab, onChange, variant, fullWidth, size, activation, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className, labels, }: LiquidTabsProps): import("react/jsx-runtime").JSX.Element;
61
+ export declare function LiquidTabs({ variant, ...rest }: LiquidTabsProps): import("react/jsx-runtime").JSX.Element;
@@ -1,99 +1,9 @@
1
1
  "use client";
2
- import { jsxs as U, jsx as c } from "react/jsx-runtime";
3
- import { useRef as A, useId as j, useState as F } from "react";
4
- import { useLiquidPill as Q, LIQUID_STRIP_STYLE as B, LIQUID_PILL_STYLE as K, liquidPillClassName as O, liquidItemClassName as Y, liquidStripClassName as H } from "./liquid-pill.js";
5
- import { liquidTabId as $ } from "./liquid-tab-id.js";
6
- import { LiquidCount as z } from "./LiquidCount.js";
7
- import { shownCount as G, countName as J, LIQUID_COUNT_LABELS as M } from "./liquid-count.js";
8
- import { withLabels as V } from "../../../lib/labels.js";
9
- import { useKeyFocus as X } from "../../../internal/key-focus.js";
10
- function re({
11
- tabs: l,
12
- activeTab: r,
13
- onChange: S,
14
- variant: n = "pill",
15
- fullWidth: m = !1,
16
- size: g = "md",
17
- activation: h = "automatic",
18
- id: w,
19
- "aria-label": C,
20
- "aria-labelledby": N,
21
- className: k,
22
- labels: R
23
- }) {
24
- X();
25
- const f = V(M, R), d = A(null), p = A(null), _ = j(), y = w ?? _;
26
- Q(d, p, r, l.map((e) => e.id).join("\0"));
27
- const I = (e) => {
28
- e !== r && S(e);
29
- }, [u, L] = F(null), b = l.some((e) => e.id === r), x = u !== null && l.some((e) => e.id === u) ? u : b ? r : l[0]?.id, D = (e) => {
30
- e.currentTarget.contains(e.relatedTarget) || L(null);
31
- }, E = (e) => {
32
- const i = d.current;
33
- if (!i) return;
34
- const t = Array.from(
35
- i.querySelectorAll('[role="tab"]')
36
- ), s = t.indexOf(e.target);
37
- if (s === -1) return;
38
- const a = t.length - 1, q = getComputedStyle(i).direction === "rtl", P = q ? "ArrowLeft" : "ArrowRight", T = q ? "ArrowRight" : "ArrowLeft";
39
- let o;
40
- if (e.key === P) o = s === a ? 0 : s + 1;
41
- else if (e.key === T) o = s === 0 ? a : s - 1;
42
- else if (e.key === "Home") o = 0;
43
- else if (e.key === "End") o = a;
44
- else return;
45
- e.preventDefault(), t[o].focus(), h === "automatic" && I(l[o].id);
46
- };
47
- return /* @__PURE__ */ U(
48
- "div",
49
- {
50
- ref: d,
51
- id: y,
52
- role: "tablist",
53
- "aria-label": C,
54
- "aria-labelledby": N,
55
- "data-testid": "liquid-tabs",
56
- style: B,
57
- className: H(n, m, k),
58
- onKeyDown: E,
59
- onBlur: D,
60
- children: [
61
- /* @__PURE__ */ c(
62
- "div",
63
- {
64
- ref: p,
65
- "aria-hidden": !0,
66
- "data-testid": "liquid-tabs-pill",
67
- className: O(n),
68
- style: K
69
- }
70
- ),
71
- l.map((e) => {
72
- const i = e.id === r, t = typeof e.label == "function" ? e.label(i) : e.label;
73
- return /* @__PURE__ */ c(
74
- "button",
75
- {
76
- type: "button",
77
- role: "tab",
78
- id: $(y, e.id),
79
- "aria-selected": i,
80
- "aria-controls": e.panelId,
81
- "aria-label": J(t, e.count, f),
82
- tabIndex: e.id === x ? 0 : -1,
83
- "data-tab-id": e.id,
84
- "data-testid": `liquid-tab-${e.id}`,
85
- onClick: () => I(e.id),
86
- onFocus: () => L(e.id),
87
- className: Y({ variant: n, fullWidth: m, size: g, isActive: i }),
88
- children: G(e.count) ? /* @__PURE__ */ c(z, { label: t, count: e.count, labels: f }) : t
89
- },
90
- e.id
91
- );
92
- })
93
- ]
94
- }
95
- );
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { Tabs as l } from "../Tabs/Tabs.js";
4
+ function e({ variant: i = "pill", ...r }) {
5
+ return /* @__PURE__ */ t(l, { ...r, variant: "liquid", liquidStyle: i });
96
6
  }
97
7
  export {
98
- re as LiquidTabs
8
+ e as LiquidTabs
99
9
  };
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Counts on a tab or a nav link: what `LiquidTabs` and `LiquidNav` share
3
- * about them. Internal; the type is exported from `LiquidTabs`.
2
+ * Counts on a tab or a nav link: what `Tabs`, `LiquidTabs` and `LiquidNav`
3
+ * share about them. Internal; the type is exported from `Tabs`.
4
4
  */
5
5
  /** Every word a count says. Pass any of them in `labels` to replace it. */
6
- export interface LiquidTabsLabels {
6
+ export interface TabsLabels {
7
7
  /**
8
8
  * What a count says after the label, as part of the tab's accessible name:
9
9
  * "12 items", so the tab reads "Open, 12 items". Name your own noun, with
@@ -19,7 +19,9 @@ export interface LiquidTabsLabels {
19
19
  */
20
20
  countMark: (count: number) => string;
21
21
  }
22
- export declare const LIQUID_COUNT_LABELS: LiquidTabsLabels;
22
+ /** @deprecated Renamed `TabsLabels`; the words are the same. */
23
+ export type LiquidTabsLabels = TabsLabels;
24
+ export declare const LIQUID_COUNT_LABELS: TabsLabels;
23
25
  /**
24
26
  * Whether a count gets a mark: a whole number, zero or more. `undefined`
25
27
  * means no count. A negative or fractional count, or `NaN`, isn't shown at
@@ -34,4 +36,4 @@ export declare const shownCount: (count: number | undefined) => count is number;
34
36
  * visually hidden part, so the hidden ", 12 items" reads "Open , 12 items".
35
37
  * A label that's a node keeps that content name, which is spoken the same.
36
38
  */
37
- export declare const countName: (label: unknown, count: number | undefined, labels: LiquidTabsLabels) => string | undefined;
39
+ export declare const countName: (label: unknown, count: number | undefined, labels: TabsLabels) => string | undefined;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(t,e){return`${t}-tab-${e}`}exports.liquidTabId=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../Tabs/tab-id.cjs"),e=t.tabId;exports.liquidTabId=e;
@@ -1,12 +1,7 @@
1
1
  /**
2
- * The `id` a `LiquidTabs` tab renders with, for a panel's `aria-labelledby`.
2
+ * The `id` a tab renders with, for a panel's `aria-labelledby`.
3
3
  *
4
- * ```tsx
5
- * <LiquidTabs id="views" tabs={tabs} activeTab={view} onChange={setView} />
6
- * <div role="tabpanel" id="views-panel" aria-labelledby={liquidTabId("views", view)}>
7
- * ```
8
- *
9
- * The tab's own `id` is used verbatim, so keep it free of whitespace. A module
10
- * of its own, with no React in it, so a server component can call it too.
4
+ * @deprecated Renamed `tabId`, which is the same function: `Tabs` and
5
+ * `LiquidTabs` give their tabs the same ids. This name keeps working.
11
6
  */
12
- export declare function liquidTabId(listId: string, tabId: string): string;
7
+ export declare const liquidTabId: (listId: string, tab: string) => string;
@@ -1,6 +1,5 @@
1
- function n(t, i) {
2
- return `${t}-tab-${i}`;
3
- }
1
+ import { tabId as o } from "../Tabs/tab-id.js";
2
+ const d = o;
4
3
  export {
5
- n as liquidTabId
4
+ d as liquidTabId
6
5
  };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),t=require("react"),p=require("./tab-id.cjs"),x='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), iframe, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';function m({tabsId:d,id:l,tab:n,activeTab:a,keepMounted:b=!1,tabIndex:u,children:c,...f}){const r=t.useRef(null),o=a===void 0||a===n,[h,v]=t.useState(!1);return t.useLayoutEffect(()=>{const e=r.current;if(!e)return;const s=()=>v(!!e.querySelector(x));if(s(),typeof MutationObserver>"u")return;const i=new MutationObserver(s);return i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled","tabindex","href","contenteditable"]}),()=>i.disconnect()},[]),y.jsx("div",{...f,ref:r,role:"tabpanel",id:l,"aria-labelledby":p.tabId(d,n),hidden:!o,tabIndex:u??(h?void 0:0),"data-tab-panel":"",children:o||b?c:null})}exports.TabPanel=m;