@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.
- package/README.md +187 -41
- package/dist/components/molecules/Carousel/Carousel.cjs +1 -1
- package/dist/components/molecules/Carousel/Carousel.d.ts +65 -3
- package/dist/components/molecules/Carousel/Carousel.js +376 -225
- package/dist/components/molecules/Carousel/carousel-math.cjs +1 -1
- package/dist/components/molecules/Carousel/carousel-math.d.ts +16 -0
- package/dist/components/molecules/Carousel/carousel-math.js +63 -44
- package/dist/components/molecules/Carousel/carousel-selection.cjs +1 -0
- package/dist/components/molecules/Carousel/carousel-selection.d.ts +28 -0
- package/dist/components/molecules/Carousel/carousel-selection.js +23 -0
- package/dist/components/molecules/LiquidTabs/LiquidCount.d.ts +2 -2
- package/dist/components/molecules/LiquidTabs/LiquidTabPanel.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/LiquidTabPanel.d.ts +10 -49
- package/dist/components/molecules/LiquidTabs/LiquidTabPanel.js +5 -28
- package/dist/components/molecules/LiquidTabs/LiquidTabs.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/LiquidTabs.d.ts +13 -40
- package/dist/components/molecules/LiquidTabs/LiquidTabs.js +5 -95
- package/dist/components/molecules/LiquidTabs/liquid-count.d.ts +7 -5
- package/dist/components/molecules/LiquidTabs/liquid-tab-id.cjs +1 -1
- package/dist/components/molecules/LiquidTabs/liquid-tab-id.d.ts +4 -9
- package/dist/components/molecules/LiquidTabs/liquid-tab-id.js +3 -4
- package/dist/components/molecules/Tabs/TabPanel.cjs +1 -0
- package/dist/components/molecules/Tabs/TabPanel.d.ts +53 -0
- package/dist/components/molecules/Tabs/TabPanel.js +32 -0
- package/dist/components/molecules/Tabs/Tabs.cjs +1 -0
- package/dist/components/molecules/Tabs/Tabs.d.ts +118 -0
- package/dist/components/molecules/Tabs/Tabs.js +145 -0
- package/dist/components/molecules/Tabs/tab-id.cjs +1 -0
- package/dist/components/molecules/Tabs/tab-id.d.ts +13 -0
- package/dist/components/molecules/Tabs/tab-id.js +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/internal/dev.cjs +1 -0
- package/dist/internal/dev.d.ts +10 -0
- package/dist/internal/dev.js +10 -0
- package/dist/meta.json +3 -3
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +116 -110
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
function
|
|
1
|
+
const L = 6, h = 1;
|
|
2
|
+
function u(t) {
|
|
3
3
|
return Math.max(0, t.scrollWidth - t.clientWidth);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return
|
|
5
|
+
function R(t) {
|
|
6
|
+
return u(t) > 1;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function A(t) {
|
|
9
9
|
return t.scrollLeft > 1;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return t.scrollLeft <
|
|
11
|
+
function O(t) {
|
|
12
|
+
return t.scrollLeft < u(t) - 1;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
const r = t.align === "start" ?
|
|
18
|
-
return Math.min(Math.max(0, r),
|
|
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
|
|
21
|
-
const
|
|
22
|
-
return t.items.forEach((i,
|
|
23
|
-
i.start >=
|
|
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
|
|
27
|
-
let
|
|
26
|
+
function E(t) {
|
|
27
|
+
let n = 0, e = 1 / 0;
|
|
28
28
|
return t.items.forEach((r, i) => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
}),
|
|
29
|
+
const c = Math.abs(l(t, i) - t.scrollLeft);
|
|
30
|
+
c < e && (n = i, e = c);
|
|
31
|
+
}), n;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
-
const r =
|
|
41
|
-
let
|
|
42
|
-
for (;
|
|
43
|
-
|
|
44
|
-
return
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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 {
|
|
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:
|
|
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
|
|
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 {
|
|
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
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
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
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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(
|
|
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
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
+
t as LiquidTabPanel
|
|
32
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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 {
|
|
4
|
-
export type {
|
|
5
|
-
export
|
|
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<
|
|
45
|
+
labels?: Partial<TabsLabels>;
|
|
68
46
|
}
|
|
69
47
|
/**
|
|
70
48
|
* A controlled tab strip with a liquid sliding indicator.
|
|
71
49
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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
|
-
*
|
|
84
|
-
*
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <LiquidTabs variant="filled" … /> // before
|
|
56
|
+
* <Tabs variant="liquid" liquidStyle="filled" … /> // after
|
|
57
|
+
* ```
|
|
85
58
|
*
|
|
86
|
-
*
|
|
59
|
+
* `LiquidTabs` keeps working, unchanged.
|
|
87
60
|
*/
|
|
88
|
-
export declare function LiquidTabs({
|
|
61
|
+
export declare function LiquidTabs({ variant, ...rest }: LiquidTabsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,99 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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`
|
|
3
|
-
* about them. Internal; the type is exported from `
|
|
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
|
|
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
|
-
|
|
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:
|
|
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"});
|
|
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
|
|
2
|
+
* The `id` a tab renders with, for a panel's `aria-labelledby`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
|
7
|
+
export declare const liquidTabId: (listId: string, tab: string) => string;
|
|
@@ -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;
|