@plexui/ui 0.42.0 → 0.44.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/dist/es/components/Alert/Alert.js +12 -2
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorPicker.js +12 -10
- package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorWell.js +1 -1
- package/dist/es/components/ColorPicker/ColorWell.js.map +1 -1
- package/dist/es/components/ColorPicker/shared.js +5 -4
- package/dist/es/components/ColorPicker/shared.js.map +1 -1
- package/dist/es/components/ContextMenu/ContextMenu.js +9 -9
- package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/es/components/ContextMenu/shared.js +25 -5
- package/dist/es/components/ContextMenu/shared.js.map +1 -1
- package/dist/es/components/DatePicker/CalendarNavigationIcon.js +7 -6
- package/dist/es/components/DatePicker/CalendarNavigationIcon.js.map +1 -1
- package/dist/es/components/DatePicker/DatePicker.js +3 -3
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DatePicker/useCalendarCollisionPadding.js +25 -0
- package/dist/es/components/DatePicker/useCalendarCollisionPadding.js.map +1 -0
- package/dist/es/components/DateRangePicker/DateRangePicker.js +3 -3
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +39 -10
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +3 -1
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Icon/svg/FilterBadge.js +1 -1
- package/dist/es/components/Icon/svg/FilterBadge.js.map +1 -1
- package/dist/es/components/Input/Input.js +1 -1
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +15 -2
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/PhoneLayout/PhoneLayout.js +6 -1
- package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -1
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/ProgressSteps/ProgressSteps.js +1 -1
- package/dist/es/components/ProgressSteps/ProgressSteps.js.map +1 -1
- package/dist/es/components/ProgressSteps/index.js.map +1 -1
- package/dist/es/components/Select/Select.js +155 -25
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +1 -1
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +19 -12
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Sortable/Sortable.js +1 -1
- package/dist/es/components/Sortable/Sortable.js.map +1 -1
- package/dist/es/components/StatCard/index.js +5 -1
- package/dist/es/components/StatCard/index.js.map +1 -1
- package/dist/es/components/StatsCard/StatsCard.js +48 -0
- package/dist/es/components/StatsCard/StatsCard.js.map +1 -0
- package/dist/es/components/StatsCard/index.js +2 -0
- package/dist/es/components/StatsCard/index.js.map +1 -0
- package/dist/es/components/SwipeActions/SwipeActions.js +30 -8
- package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -1
- package/dist/es/components/TabBar/TabBar.js +11 -4
- package/dist/es/components/TabBar/TabBar.js.map +1 -1
- package/dist/es/components/Tabs/Tabs.js +200 -7
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +40 -3
- package/dist/es/lib/menuTriggerCover.js.map +1 -1
- package/dist/es/styles/geist-mono.css +1 -0
- package/dist/es/styles/inter.css +1 -0
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +3 -2
- package/dist/types/components/ColorPicker/shared.d.ts +5 -4
- package/dist/types/components/ContextMenu/shared.d.ts +28 -6
- package/dist/types/components/DatePicker/useCalendarCollisionPadding.d.ts +8 -0
- package/dist/types/components/Dialog/Dialog.d.ts +28 -9
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Dialog/sheetDrag.d.ts +2 -1
- package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +5 -0
- package/dist/types/components/Popover/Popover.d.ts +2 -2
- package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +11 -4
- package/dist/types/components/ProgressSteps/index.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +11 -3
- package/dist/types/components/StatCard/index.d.ts +5 -1
- package/dist/types/components/{StatCard/StatCard.d.ts → StatsCard/StatsCard.d.ts} +7 -7
- package/dist/types/components/StatsCard/index.d.ts +1 -0
- package/dist/types/components/SwipeActions/SwipeActions.d.ts +1 -1
- package/dist/types/components/TabBar/TabBar.d.ts +12 -2
- package/dist/types/components/Tabs/Tabs.d.ts +12 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/lib/menuTriggerCover.d.ts +16 -2
- package/package.json +2 -2
- package/dist/es/components/DatePicker/useCalendarGutter.js +0 -8
- package/dist/es/components/DatePicker/useCalendarGutter.js.map +0 -1
- package/dist/es/components/StatCard/StatCard.js +0 -39
- package/dist/es/components/StatCard/StatCard.js.map +0 -1
- package/dist/types/components/DatePicker/useCalendarGutter.d.ts +0 -1
|
@@ -53,6 +53,7 @@ export function SwipeActions({ leading = [], trailing = [], labelPlacement = "hi
|
|
|
53
53
|
const [full, setFull] = useState(false);
|
|
54
54
|
const [swiping, setSwiping] = useState(false);
|
|
55
55
|
const [rtl, setRtl] = useState(false);
|
|
56
|
+
const [round, setRound] = useState(false);
|
|
56
57
|
const root = useRef(null);
|
|
57
58
|
const sides = useRef({ leading: null, trailing: null });
|
|
58
59
|
const gesture = useRef(null);
|
|
@@ -76,7 +77,7 @@ export function SwipeActions({ leading = [], trailing = [], labelPlacement = "hi
|
|
|
76
77
|
return state;
|
|
77
78
|
};
|
|
78
79
|
/** The handlers of the latest render, for listeners and observers set up once. */
|
|
79
|
-
const latest = useRef({ close: () => { }, release, finish: () => { }, cancel: () => { }, sync: () => { } });
|
|
80
|
+
const latest = useRef({ close: () => { }, release, finish: () => { }, cancel: () => { }, sync: () => { }, fit: () => { } });
|
|
80
81
|
/** One function for the life of the row, so the list knows which row is open; another row that opens ends this one's gesture too. */
|
|
81
82
|
const closer = useRef(() => {
|
|
82
83
|
const state = latest.current.release();
|
|
@@ -119,6 +120,21 @@ export function SwipeActions({ leading = [], trailing = [], labelPlacement = "hi
|
|
|
119
120
|
if (target !== current.current.offset)
|
|
120
121
|
move(target);
|
|
121
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* A symbol that has grown as tall as its circle (its max-height) is one, as iOS draws a circle from there. The
|
|
125
|
+
* measure is a capsule that is laid out: a full swipe hides all but the first action of its side, and while none
|
|
126
|
+
* is laid out the shape stays.
|
|
127
|
+
*/
|
|
128
|
+
const fit = () => {
|
|
129
|
+
const capsules = [...(root.current?.querySelectorAll('[data-shape="symbol"] > :first-child') ?? [])];
|
|
130
|
+
if (capsules.length < 1)
|
|
131
|
+
return setRound(false);
|
|
132
|
+
const capsule = capsules.find((element) => element.getBoundingClientRect().height > 0);
|
|
133
|
+
if (!capsule)
|
|
134
|
+
return;
|
|
135
|
+
const max = parseFloat(getComputedStyle(capsule).maxHeight);
|
|
136
|
+
setRound(max > 0 && capsule.getBoundingClientRect().height >= max - 0.5);
|
|
137
|
+
};
|
|
122
138
|
const settle = (state) => {
|
|
123
139
|
const { offset: last, full: wasFull } = current.current;
|
|
124
140
|
const side = sideOf(last);
|
|
@@ -162,9 +178,10 @@ export function SwipeActions({ leading = [], trailing = [], labelPlacement = "hi
|
|
|
162
178
|
else
|
|
163
179
|
close();
|
|
164
180
|
};
|
|
165
|
-
latest.current = { close, release, finish, cancel, sync };
|
|
166
|
-
// After each render, and whenever the actions change size, an open row takes their width.
|
|
181
|
+
latest.current = { close, release, finish, cancel, sync, fit };
|
|
182
|
+
// After each render, and whenever the actions change size, an open row takes their width and a symbol its shape.
|
|
167
183
|
useEffect(() => {
|
|
184
|
+
latest.current.fit();
|
|
168
185
|
latest.current.sync();
|
|
169
186
|
for (const element of [sides.current.leading, sides.current.trailing])
|
|
170
187
|
if (element)
|
|
@@ -172,7 +189,10 @@ export function SwipeActions({ leading = [], trailing = [], labelPlacement = "hi
|
|
|
172
189
|
});
|
|
173
190
|
useEffect(() => {
|
|
174
191
|
if (typeof ResizeObserver !== "undefined")
|
|
175
|
-
observer.current = new ResizeObserver(() =>
|
|
192
|
+
observer.current = new ResizeObserver(() => {
|
|
193
|
+
latest.current.fit();
|
|
194
|
+
latest.current.sync();
|
|
195
|
+
});
|
|
176
196
|
for (const element of [sides.current.leading, sides.current.trailing])
|
|
177
197
|
if (element)
|
|
178
198
|
observer.current?.observe(element, BORDER_BOX);
|
|
@@ -311,11 +331,13 @@ export function SwipeActions({ leading = [], trailing = [], labelPlacement = "hi
|
|
|
311
331
|
sides.current[side] = element;
|
|
312
332
|
}, className: s.Actions, "data-side": side, "data-full": isFull ? "" : undefined, style: isFull ? { width: Math.abs(offset) } : undefined, children: shown.map((action) => {
|
|
313
333
|
const color = action.color ?? "secondary";
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
|
|
334
|
+
// A label alone (text), a symbol with its label inside (label), or a symbol with its label hidden or below.
|
|
335
|
+
const shape = !action.Icon ? "text" : labelPlacement === "inside" ? "label" : "symbol";
|
|
336
|
+
const labelInside = shape !== "symbol";
|
|
337
|
+
const labelBelow = shape === "symbol" && labelPlacement === "below";
|
|
338
|
+
return (_jsxs("button", { type: "button", className: s.Action, "data-color": color, "data-shape": shape, "data-first": action === actions[0] ? "" : undefined, "aria-label": labelInside || labelBelow ? undefined : action.label, onClick: (event) => select(action, event), children: [_jsxs("span", { className: s.Capsule, children: [action.Icon && _jsx(action.Icon, { className: s.Icon, "aria-hidden": "true" }), labelInside && _jsx("span", { className: s.Label, children: action.label })] }), labelBelow && _jsx("span", { className: s.Caption, children: action.label })] }, action.id));
|
|
317
339
|
}) }));
|
|
318
340
|
};
|
|
319
|
-
return (_jsxs("div", { ref: root, className: clsx(s.SwipeActions, className), "data-row": "", "data-swipe-actions": "", "data-label-placement": labelPlacement, "data-revealed": revealed, "data-swiping": swiping ? "" : undefined, onFocus: handleFocus, onBlur: handleBlur, children: [renderSide("leading", leading), _jsx("div", { className: s.Content, "data-swipe-content": "", style: offset !== 0 ? { "--swipe-actions-offset": `${rtl ? -offset : offset}px` } : undefined, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onLostPointerCapture: handleLostPointerCapture, onClickCapture: handleClickCapture, children: children }), renderSide("trailing", trailing)] }));
|
|
341
|
+
return (_jsxs("div", { ref: root, className: clsx(s.SwipeActions, className), "data-row": "", "data-swipe-actions": "", "data-label-placement": labelPlacement, "data-round": round ? "" : undefined, "data-revealed": revealed, "data-swiping": swiping ? "" : undefined, onFocus: handleFocus, onBlur: handleBlur, children: [renderSide("leading", leading), _jsx("div", { className: s.Content, "data-swipe-content": "", style: offset !== 0 ? { "--swipe-actions-offset": `${rtl ? -offset : offset}px` } : undefined, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onLostPointerCapture: handleLostPointerCapture, onClickCapture: handleClickCapture, children: children }), renderSide("trailing", trailing)] }));
|
|
320
342
|
}
|
|
321
343
|
//# sourceMappingURL=SwipeActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeActions.js","sourceRoot":"","sources":["../../../../src/components/SwipeActions/SwipeActions.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAQL,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,gEAAgE,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AA0C3D,gGAAgG;AAChG,MAAM,IAAI,GAAG,EAAE,CAAA;AAEf,uGAAuG;AACvG,MAAM,U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AC,KAAK,YAAG,MAAM,CAAC,KAAK,GAAQ,IAC1D,EACN,UAAU,IAAI,eAAM,SAAS,EAAE,CAAC,CAAC,OAAO,YAAG,MAAM,CAAC,KAAK,GAAQ,KAZ3D,MAAM,CAAC,EAAE,CAaP,CACV,CAAA;YACH,CAAC,CAAC,GACE,CACP,CAAA;IACH,CAAC,CAAA;IAED,OAAO,CACL,eACE,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC,cACjC,EAAE,wBACQ,EAAE,0BACC,cAAc,mBACrB,QAAQ,kBACT,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EACtC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,aAEjB,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,EAC/B,cACE,SAAS,EAAE,CAAC,CAAC,OAAO,wBACD,EAAE,EACrB,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,EAAmB,CAAC,CAAC,CAAC,SAAS,EAC9G,aAAa,EAAE,iBAAiB,EAChC,aAAa,EAAE,iBAAiB,EAChC,oBAAoB,EAAE,wBAAwB,EAC9C,cAAc,EAAE,kBAAkB,YAEjC,QAAQ,GACL,EACL,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,IAC7B,CACP,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n type ComponentType,\n type CSSProperties,\n type FocusEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type SVGProps,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport s from \"@plexui/styles/components/SwipeActions/SwipeActions.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\n\nexport type SwipeActionColor =\n | \"primary\"\n | \"secondary\"\n | \"danger\"\n | \"success\"\n | \"info\"\n | \"discovery\"\n | \"caution\"\n | \"warning\"\n\nexport type SwipeAction = {\n /** Unique ID of the action within its side */\n id: string\n /** Name of the action: shown with `labelPlacement` `\"inside\"` or `\"below\"` (and on an action without an icon), and its accessible name always */\n label: string\n /** Icon of the action */\n Icon?: ComponentType<SVGProps<SVGSVGElement>>\n /** Solid color of the action. @default \"secondary\" */\n color?: SwipeActionColor\n /** Called when the action is pressed, or by a full swipe when it is the first action of its side */\n onSelect?: () => void\n}\n\nexport type SwipeActionsSide = \"leading\" | \"trailing\"\n\nexport type SwipeActionsProps = {\n /** Actions revealed by a swipe toward the trailing edge, the first one at the leading edge */\n leading?: SwipeAction[]\n /** Actions revealed by a swipe toward the leading edge, the first one at the trailing edge */\n trailing?: SwipeAction[]\n /** Where the actions show their labels: `\"hidden\"` (symbols only), `\"inside\"` the capsule, or `\"below\"` it (for rows of 68px and taller). @default \"hidden\" */\n labelPlacement?: \"hidden\" | \"inside\" | \"below\"\n /** A swipe past the middle between the open actions and the far edge runs the first action of that side. @default true */\n fullSwipe?: boolean\n /** CSS classes applied to the row */\n className?: string\n /** The content of the row */\n children?: ReactNode\n}\n\n/** A finger has to travel this far, and farther across than down, before the row follows it. */\nconst SLOP = 10\n\n/** The width an open row moves by is the border box of its actions, edge and content gaps included. */\nconst BORDER_BOX: ResizeObserverOptions = { box: \"border-box\" }\n\n/** Controls that take a horizontal drag themselves. */\nconst OWN_DRAG = 'input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=\"slider\"]'\n\ntype Gesture = {\n pointerId: number\n x: number\n y: number\n start: number\n /** Undecided while within the slop, then a swipe (true) or a scroll (false). */\n swiping: boolean | undefined\n rtl: boolean\n widths: Record<SwipeActionsSide, number>\n rowWidth: number\n /** Removes the listeners for the end of the gesture. */\n detach: () => void\n}\n\n/** The open row: opening another one closes it, as a list keeps one row open. */\nlet closeOpenRow: (() => void) | null = null\n\n/** The row keeps the finger past its edges; a pointer that is no longer active (it lifted between events) cannot be held. */\nconst capture = (element: Element, pointerId: number) => {\n try {\n element.setPointerCapture?.(pointerId)\n } catch {\n // The swipe goes on with the events the row still gets.\n }\n}\n\nconst sideOf = (offset: number): SwipeActionsSide | undefined =>\n offset > 0 ? \"leading\" : offset < 0 ? \"trailing\" : undefined\n\n/**\n * Where the content goes for a swipe of `raw` px toward the trailing edge (negative: toward the leading edge), and\n * whether that is a full swipe. A side without actions stays shut. Past its actions the content follows the finger\n * where a full swipe is allowed, and a third as fast where it is not; past the middle between the open actions and\n * the far edge of the row the swipe is full.\n */\nexport const swipeActionsOffset = (\n raw: number,\n widths: Record<SwipeActionsSide, number>,\n rowWidth: number,\n fullSwipe: boolean,\n): { offset: number; full: boolean } => {\n const side = sideOf(raw)\n const width = side ? widths[side] : 0\n if (!side || !(width > 0)) return { offset: 0, full: false }\n const sign = Math.sign(raw)\n const distance = Math.abs(raw)\n if (distance <= width) return { offset: raw, full: false }\n if (!fullSwipe) return { offset: sign * (width + (distance - width) / 3), full: false }\n const travel = Math.min(distance, Math.max(width, rowWidth))\n return { offset: sign * travel, full: travel >= (width + rowWidth) / 2 }\n}\n\n/**\n * Actions behind a row of a list, as the swipe actions of an iOS list: a swipe toward the leading edge reveals the\n * trailing actions, a swipe toward the trailing edge the leading ones, and a full swipe runs the first action of\n * that side. The row is a `data-row` of a FieldGroup. Each action is also a button in the order of the screen, and\n * the focus on one shows its side.\n */\nexport function SwipeActions({\n leading = [],\n trailing = [],\n labelPlacement = \"hidden\",\n fullSwipe = true,\n className,\n children,\n}: SwipeActionsProps) {\n const [offset, setOffset] = useState(0)\n const [full, setFull] = useState(false)\n const [swiping, setSwiping] = useState(false)\n const [rtl, setRtl] = useState(false)\n const root = useRef<HTMLDivElement>(null)\n const sides = useRef<Record<SwipeActionsSide, HTMLDivElement | null>>({ leading: null, trailing: null })\n const gesture = useRef<Gesture | null>(null)\n const current = useRef({ offset: 0, full: false })\n const suppressClick = useRef(false)\n const observer = useRef<ResizeObserver | null>(null)\n const actionsRef = useLatestValue({ leading, trailing })\n const revealed = sideOf(offset)\n\n const widthOf = (side: SwipeActionsSide) => sides.current[side]?.getBoundingClientRect().width ?? 0\n\n const isRtl = () => !!root.current && getComputedStyle(root.current).direction === \"rtl\"\n\n const move = (next: number, nextFull = false) => {\n current.current = { offset: next, full: nextFull }\n setOffset(next)\n setFull(nextFull)\n }\n\n /** Lets go of the gesture: the listeners for its end go, and the row no longer follows the finger. */\n const release = () => {\n const state = gesture.current\n gesture.current = null\n state?.detach()\n return state\n }\n\n /** The handlers of the latest render, for listeners and observers set up once. */\n const latest = useRef({ close: () => {}, release, finish: () => {}, cancel: () => {}, sync: () => {} })\n\n /** One function for the life of the row, so the list knows which row is open; another row that opens ends this one's gesture too. */\n const closer = useRef(() => {\n const state = latest.current.release()\n if (state) {\n setSwiping(false)\n // The finger of the ended swipe still lifts over this row: its click is not a click on the content.\n if (state.swiping) suppressClick.current = true\n }\n latest.current.close()\n }).current\n\n const close = () => {\n if (closeOpenRow === closer) closeOpenRow = null\n move(0)\n }\n\n /** This row takes the place of the open one. */\n const claim = () => {\n if (closeOpenRow && closeOpenRow !== closer) closeOpenRow()\n closeOpenRow = closer\n }\n\n /** Shows a side as wide as its actions (`width` when known), or closes the row when that side has none (any more). */\n const open = (side: SwipeActionsSide, width = widthOf(side)) => {\n if (!(width > 0)) return close()\n claim()\n setRtl(isRtl())\n move(side === \"leading\" ? width : -width)\n }\n\n /** An open row follows its actions: more of them, other labels or another width move it to their new width. */\n const sync = () => {\n const side = sideOf(current.current.offset)\n if (!side || gesture.current?.swiping || current.current.full) return\n const width = widthOf(side)\n if (!(width > 0)) return close()\n const target = side === \"leading\" ? width : -width\n if (target !== current.current.offset) move(target)\n }\n\n const settle = (state: Gesture) => {\n const { offset: last, full: wasFull } = current.current\n const side = sideOf(last)\n if (!side) return close()\n if (wasFull) {\n actionsRef.current[side][0]?.onSelect?.()\n return close()\n }\n // The widths from the start of the swipe: a full swipe may have stretched the actions since.\n if (Math.abs(last) >= state.widths[side] / 2) open(side, state.widths[side])\n else close()\n }\n\n /** The finger lifted (anywhere): a swipe settles, a press on an open row closes it. */\n const finish = () => {\n const state = release()\n if (!state) return\n if (state.swiping) {\n suppressClick.current = true\n setSwiping(false)\n settle(state)\n } else if (state.start !== 0) {\n if (state.swiping === undefined) suppressClick.current = true\n close()\n }\n }\n\n /** The browser took the gesture (a scroll) or the row lost the finger: the row goes back to where it was. */\n const cancel = () => {\n const state = release()\n if (!state) return\n setSwiping(false)\n const side = sideOf(state.start)\n if (state.swiping && side) open(side, state.widths[side])\n else close()\n }\n\n latest.current = { close, release, finish, cancel, sync }\n\n // After each render, and whenever the actions change size, an open row takes their width.\n useEffect(() => {\n latest.current.sync()\n for (const element of [sides.current.leading, sides.current.trailing]) if (element) observer.current?.observe(element, BORDER_BOX)\n })\n\n useEffect(() => {\n if (typeof ResizeObserver !== \"undefined\") observer.current = new ResizeObserver(() => latest.current.sync())\n for (const element of [sides.current.leading, sides.current.trailing]) if (element) observer.current?.observe(element, BORDER_BOX)\n // The open row lets go of the list, and of the finger, when it goes away.\n return () => {\n observer.current?.disconnect()\n observer.current = null\n latest.current.release()\n if (closeOpenRow === closer) closeOpenRow = null\n }\n }, [closer, latest])\n\n // A press anywhere outside the open row closes it.\n useEffect(() => {\n if (!revealed || swiping) return\n const handlePointerDown = (event: globalThis.PointerEvent) => {\n if (event.target instanceof Node && root.current?.contains(event.target)) return\n latest.current.close()\n }\n document.addEventListener(\"pointerdown\", handlePointerDown, true)\n return () => document.removeEventListener(\"pointerdown\", handlePointerDown, true)\n }, [revealed, swiping, latest])\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0 || gesture.current) return\n // A new press of the primary pointer starts clean: a swipe that another row ended and that was then cancelled leaves\n // no click to swallow. Another finger's press keeps it, as only the primary pointer clicks.\n if (event.isPrimary) suppressClick.current = false\n if (leading.length < 1 && trailing.length < 1) return\n // A drag in a text field or along a slider belongs to that control.\n if (event.target instanceof Element && event.target.closest(OWN_DRAG)) return\n const pointerId = event.pointerId\n // The end of the gesture is heard wherever the finger lifts, inside the row or not.\n const handleUp = (end: globalThis.PointerEvent) => {\n if (end.pointerId === pointerId) latest.current.finish()\n }\n const handleCancel = (end: globalThis.PointerEvent) => {\n if (end.pointerId === pointerId) latest.current.cancel()\n }\n window.addEventListener(\"pointerup\", handleUp, true)\n window.addEventListener(\"pointercancel\", handleCancel, true)\n gesture.current = {\n pointerId,\n x: event.clientX,\n y: event.clientY,\n start: current.current.offset,\n swiping: undefined,\n rtl: isRtl(),\n widths: { leading: widthOf(\"leading\"), trailing: widthOf(\"trailing\") },\n rowWidth: root.current?.clientWidth ?? 0,\n detach: () => {\n window.removeEventListener(\"pointerup\", handleUp, true)\n window.removeEventListener(\"pointercancel\", handleCancel, true)\n },\n }\n }\n\n const handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {\n const state = gesture.current\n if (!state || state.pointerId !== event.pointerId || state.swiping === false) return\n const across = (event.clientX - state.x) * (state.rtl ? -1 : 1)\n const down = event.clientY - state.y\n if (state.swiping === undefined) {\n if (Math.abs(across) < SLOP && Math.abs(down) < SLOP) return\n if (Math.abs(across) <= Math.abs(down)) {\n state.swiping = false\n return\n }\n state.swiping = true\n capture(event.currentTarget, event.pointerId)\n window.getSelection?.()?.removeAllRanges()\n claim()\n setRtl(state.rtl)\n setSwiping(true)\n }\n const next = swipeActionsOffset(state.start + across, state.widths, state.rowWidth, fullSwipe)\n move(next.offset, next.full)\n }\n\n /** The content lost the finger it held. A child that loses the finger to the content (as a touch moves its implicit capture) ends nothing. */\n const handleLostPointerCapture = (event: PointerEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && gesture.current?.pointerId === event.pointerId) cancel()\n }\n\n /** A swipe or a press that closed the row is not a click on the content; a click from the keys still is. */\n const handleClickCapture = (event: MouseEvent<HTMLDivElement>) => {\n if (!suppressClick.current || event.detail === 0) return\n suppressClick.current = false\n event.preventDefault()\n event.stopPropagation()\n }\n\n /** The focus on an action shows its side; on the content it closes the row. */\n const handleFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (gesture.current?.swiping) return\n const side = ([\"leading\", \"trailing\"] as const).find((name) => sides.current[name]?.contains(event.target))\n if (side) {\n if (sideOf(current.current.offset) !== side) open(side)\n } else if (current.current.offset !== 0) {\n close()\n }\n }\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (gesture.current?.swiping) return\n if (event.relatedTarget instanceof Node && root.current?.contains(event.relatedTarget)) return\n if (current.current.offset !== 0) close()\n }\n\n const select = (action: SwipeAction, event: MouseEvent<HTMLButtonElement>) => {\n action.onSelect?.()\n // A press closes the row, as iOS does. From the keys the action keeps the focus, so its side stays open until\n // the focus leaves the row.\n if (event.detail === 0) return\n event.currentTarget.blur()\n close()\n }\n\n const renderSide = (side: SwipeActionsSide, actions: SwipeAction[]) => {\n if (actions.length < 1) return null\n const shown = side === \"leading\" ? actions : [...actions].reverse()\n const isFull = full && revealed === side\n return (\n <div\n ref={(element) => {\n sides.current[side] = element\n }}\n className={s.Actions}\n data-side={side}\n data-full={isFull ? \"\" : undefined}\n style={isFull ? { width: Math.abs(offset) } : undefined}\n >\n {shown.map((action) => {\n const color = action.color ?? \"secondary\"\n const labelInside = labelPlacement === \"inside\" || !action.Icon\n const labelBelow = labelPlacement === \"below\" && !!action.Icon\n return (\n <button\n key={action.id}\n type=\"button\"\n className={s.Action}\n data-color={color}\n data-first={action === actions[0] ? \"\" : undefined}\n aria-label={labelInside || labelBelow ? undefined : action.label}\n onClick={(event) => select(action, event)}\n >\n <span className={s.Capsule}>\n {action.Icon && <action.Icon className={s.Icon} aria-hidden=\"true\" />}\n {labelInside && <span className={s.Label}>{action.label}</span>}\n </span>\n {labelBelow && <span className={s.Caption}>{action.label}</span>}\n </button>\n )\n })}\n </div>\n )\n }\n\n return (\n <div\n ref={root}\n className={clsx(s.SwipeActions, className)}\n data-row=\"\"\n data-swipe-actions=\"\"\n data-label-placement={labelPlacement}\n data-revealed={revealed}\n data-swiping={swiping ? \"\" : undefined}\n onFocus={handleFocus}\n onBlur={handleBlur}\n >\n {renderSide(\"leading\", leading)}\n <div\n className={s.Content}\n data-swipe-content=\"\"\n style={offset !== 0 ? { \"--swipe-actions-offset\": `${rtl ? -offset : offset}px` } as CSSProperties : undefined}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onLostPointerCapture={handleLostPointerCapture}\n onClickCapture={handleClickCapture}\n >\n {children}\n </div>\n {renderSide(\"trailing\", trailing)}\n </div>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SwipeActions.js","sourceRoot":"","sources":["../../../../src/components/SwipeActions/SwipeActions.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAQL,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,gEAAgE,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AA0C3D,gGAAgG;AAChG,MAAM,IAAI,GAAG,EAAE,CAAA;AAEf,uGAAuG;AACvG,MAAM,UAAU,GAA0B,EAAE,GAAG,EAAE,YAAY,EAAE,CAAA;AAE/D,uDAAuD;AACvD,MAAM,QAAQ,GAAG,4FAA4F,CAAA;AAgB7G,iFAAiF;AACjF,IAAI,YAAY,GAAwB,IAAI,CAAA;AAE5C,6HAA6H;AAC7H,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAE,SAAiB,EAAE,EAAE;IACtD,IAAI,CAAC;QACH,OAAO,CAAC,iBAAiB,EAAE,CAAC,SAAS,CAAC,CAAA;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,wDAAwD;IAC1D,CAAC;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,CAAC,MAAc,EAAgC,EAAE,CAC9D,MAAM,GAAG,CAAC,CAAC,C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O,wBACD,EAAE,EACrB,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,EAAmB,CAAC,CAAC,CAAC,SAAS,EAC9G,aAAa,EAAE,iBAAiB,EAChC,aAAa,EAAE,iBAAiB,EAChC,oBAAoB,EAAE,wBAAwB,EAC9C,cAAc,EAAE,kBAAkB,YAEjC,QAAQ,GACL,EACL,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,IAC7B,CACP,CAAA;AACH,CAAC","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n type ComponentType,\n type CSSProperties,\n type FocusEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type SVGProps,\n useEffect,\n useRef,\n useState,\n} from \"react\"\nimport s from \"@plexui/styles/components/SwipeActions/SwipeActions.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\n\nexport type SwipeActionColor =\n | \"primary\"\n | \"secondary\"\n | \"danger\"\n | \"success\"\n | \"info\"\n | \"discovery\"\n | \"caution\"\n | \"warning\"\n\nexport type SwipeAction = {\n /** Unique ID of the action within its side */\n id: string\n /** Name of the action: shown with `labelPlacement` `\"inside\"` or `\"below\"` (and on an action without an icon), and its accessible name always */\n label: string\n /** Icon of the action */\n Icon?: ComponentType<SVGProps<SVGSVGElement>>\n /** Solid color of the action. @default \"secondary\" */\n color?: SwipeActionColor\n /** Called when the action is pressed, or by a full swipe when it is the first action of its side */\n onSelect?: () => void\n}\n\nexport type SwipeActionsSide = \"leading\" | \"trailing\"\n\nexport type SwipeActionsProps = {\n /** Actions revealed by a swipe toward the trailing edge, the first one at the leading edge */\n leading?: SwipeAction[]\n /** Actions revealed by a swipe toward the leading edge, the first one at the trailing edge */\n trailing?: SwipeAction[]\n /** Where the actions show their labels: `\"hidden\"` (symbols only), `\"inside\"` the capsule, or `\"below\"` it (for rows of 60px and taller, as iOS sets them). @default \"hidden\" */\n labelPlacement?: \"hidden\" | \"inside\" | \"below\"\n /** A swipe past the middle between the open actions and the far edge runs the first action of that side. @default true */\n fullSwipe?: boolean\n /** CSS classes applied to the row */\n className?: string\n /** The content of the row */\n children?: ReactNode\n}\n\n/** A finger has to travel this far, and farther across than down, before the row follows it. */\nconst SLOP = 10\n\n/** The width an open row moves by is the border box of its actions, edge and content gaps included. */\nconst BORDER_BOX: ResizeObserverOptions = { box: \"border-box\" }\n\n/** Controls that take a horizontal drag themselves. */\nconst OWN_DRAG = 'input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=\"slider\"]'\n\ntype Gesture = {\n pointerId: number\n x: number\n y: number\n start: number\n /** Undecided while within the slop, then a swipe (true) or a scroll (false). */\n swiping: boolean | undefined\n rtl: boolean\n widths: Record<SwipeActionsSide, number>\n rowWidth: number\n /** Removes the listeners for the end of the gesture. */\n detach: () => void\n}\n\n/** The open row: opening another one closes it, as a list keeps one row open. */\nlet closeOpenRow: (() => void) | null = null\n\n/** The row keeps the finger past its edges; a pointer that is no longer active (it lifted between events) cannot be held. */\nconst capture = (element: Element, pointerId: number) => {\n try {\n element.setPointerCapture?.(pointerId)\n } catch {\n // The swipe goes on with the events the row still gets.\n }\n}\n\nconst sideOf = (offset: number): SwipeActionsSide | undefined =>\n offset > 0 ? \"leading\" : offset < 0 ? \"trailing\" : undefined\n\n/**\n * Where the content goes for a swipe of `raw` px toward the trailing edge (negative: toward the leading edge), and\n * whether that is a full swipe. A side without actions stays shut. Past its actions the content follows the finger\n * where a full swipe is allowed, and a third as fast where it is not; past the middle between the open actions and\n * the far edge of the row the swipe is full.\n */\nexport const swipeActionsOffset = (\n raw: number,\n widths: Record<SwipeActionsSide, number>,\n rowWidth: number,\n fullSwipe: boolean,\n): { offset: number; full: boolean } => {\n const side = sideOf(raw)\n const width = side ? widths[side] : 0\n if (!side || !(width > 0)) return { offset: 0, full: false }\n const sign = Math.sign(raw)\n const distance = Math.abs(raw)\n if (distance <= width) return { offset: raw, full: false }\n if (!fullSwipe) return { offset: sign * (width + (distance - width) / 3), full: false }\n const travel = Math.min(distance, Math.max(width, rowWidth))\n return { offset: sign * travel, full: travel >= (width + rowWidth) / 2 }\n}\n\n/**\n * Actions behind a row of a list, as the swipe actions of an iOS list: a swipe toward the leading edge reveals the\n * trailing actions, a swipe toward the trailing edge the leading ones, and a full swipe runs the first action of\n * that side. The row is a `data-row` of a FieldGroup. Each action is also a button in the order of the screen, and\n * the focus on one shows its side.\n */\nexport function SwipeActions({\n leading = [],\n trailing = [],\n labelPlacement = \"hidden\",\n fullSwipe = true,\n className,\n children,\n}: SwipeActionsProps) {\n const [offset, setOffset] = useState(0)\n const [full, setFull] = useState(false)\n const [swiping, setSwiping] = useState(false)\n const [rtl, setRtl] = useState(false)\n const [round, setRound] = useState(false)\n const root = useRef<HTMLDivElement>(null)\n const sides = useRef<Record<SwipeActionsSide, HTMLDivElement | null>>({ leading: null, trailing: null })\n const gesture = useRef<Gesture | null>(null)\n const current = useRef({ offset: 0, full: false })\n const suppressClick = useRef(false)\n const observer = useRef<ResizeObserver | null>(null)\n const actionsRef = useLatestValue({ leading, trailing })\n const revealed = sideOf(offset)\n\n const widthOf = (side: SwipeActionsSide) => sides.current[side]?.getBoundingClientRect().width ?? 0\n\n const isRtl = () => !!root.current && getComputedStyle(root.current).direction === \"rtl\"\n\n const move = (next: number, nextFull = false) => {\n current.current = { offset: next, full: nextFull }\n setOffset(next)\n setFull(nextFull)\n }\n\n /** Lets go of the gesture: the listeners for its end go, and the row no longer follows the finger. */\n const release = () => {\n const state = gesture.current\n gesture.current = null\n state?.detach()\n return state\n }\n\n /** The handlers of the latest render, for listeners and observers set up once. */\n const latest = useRef({ close: () => {}, release, finish: () => {}, cancel: () => {}, sync: () => {}, fit: () => {} })\n\n /** One function for the life of the row, so the list knows which row is open; another row that opens ends this one's gesture too. */\n const closer = useRef(() => {\n const state = latest.current.release()\n if (state) {\n setSwiping(false)\n // The finger of the ended swipe still lifts over this row: its click is not a click on the content.\n if (state.swiping) suppressClick.current = true\n }\n latest.current.close()\n }).current\n\n const close = () => {\n if (closeOpenRow === closer) closeOpenRow = null\n move(0)\n }\n\n /** This row takes the place of the open one. */\n const claim = () => {\n if (closeOpenRow && closeOpenRow !== closer) closeOpenRow()\n closeOpenRow = closer\n }\n\n /** Shows a side as wide as its actions (`width` when known), or closes the row when that side has none (any more). */\n const open = (side: SwipeActionsSide, width = widthOf(side)) => {\n if (!(width > 0)) return close()\n claim()\n setRtl(isRtl())\n move(side === \"leading\" ? width : -width)\n }\n\n /** An open row follows its actions: more of them, other labels or another width move it to their new width. */\n const sync = () => {\n const side = sideOf(current.current.offset)\n if (!side || gesture.current?.swiping || current.current.full) return\n const width = widthOf(side)\n if (!(width > 0)) return close()\n const target = side === \"leading\" ? width : -width\n if (target !== current.current.offset) move(target)\n }\n\n /**\n * A symbol that has grown as tall as its circle (its max-height) is one, as iOS draws a circle from there. The\n * measure is a capsule that is laid out: a full swipe hides all but the first action of its side, and while none\n * is laid out the shape stays.\n */\n const fit = () => {\n const capsules = [...(root.current?.querySelectorAll<HTMLElement>('[data-shape=\"symbol\"] > :first-child') ?? [])]\n if (capsules.length < 1) return setRound(false)\n const capsule = capsules.find((element) => element.getBoundingClientRect().height > 0)\n if (!capsule) return\n const max = parseFloat(getComputedStyle(capsule).maxHeight)\n setRound(max > 0 && capsule.getBoundingClientRect().height >= max - 0.5)\n }\n\n const settle = (state: Gesture) => {\n const { offset: last, full: wasFull } = current.current\n const side = sideOf(last)\n if (!side) return close()\n if (wasFull) {\n actionsRef.current[side][0]?.onSelect?.()\n return close()\n }\n // The widths from the start of the swipe: a full swipe may have stretched the actions since.\n if (Math.abs(last) >= state.widths[side] / 2) open(side, state.widths[side])\n else close()\n }\n\n /** The finger lifted (anywhere): a swipe settles, a press on an open row closes it. */\n const finish = () => {\n const state = release()\n if (!state) return\n if (state.swiping) {\n suppressClick.current = true\n setSwiping(false)\n settle(state)\n } else if (state.start !== 0) {\n if (state.swiping === undefined) suppressClick.current = true\n close()\n }\n }\n\n /** The browser took the gesture (a scroll) or the row lost the finger: the row goes back to where it was. */\n const cancel = () => {\n const state = release()\n if (!state) return\n setSwiping(false)\n const side = sideOf(state.start)\n if (state.swiping && side) open(side, state.widths[side])\n else close()\n }\n\n latest.current = { close, release, finish, cancel, sync, fit }\n\n // After each render, and whenever the actions change size, an open row takes their width and a symbol its shape.\n useEffect(() => {\n latest.current.fit()\n latest.current.sync()\n for (const element of [sides.current.leading, sides.current.trailing]) if (element) observer.current?.observe(element, BORDER_BOX)\n })\n\n useEffect(() => {\n if (typeof ResizeObserver !== \"undefined\") observer.current = new ResizeObserver(() => {\n latest.current.fit()\n latest.current.sync()\n })\n for (const element of [sides.current.leading, sides.current.trailing]) if (element) observer.current?.observe(element, BORDER_BOX)\n // The open row lets go of the list, and of the finger, when it goes away.\n return () => {\n observer.current?.disconnect()\n observer.current = null\n latest.current.release()\n if (closeOpenRow === closer) closeOpenRow = null\n }\n }, [closer, latest])\n\n // A press anywhere outside the open row closes it.\n useEffect(() => {\n if (!revealed || swiping) return\n const handlePointerDown = (event: globalThis.PointerEvent) => {\n if (event.target instanceof Node && root.current?.contains(event.target)) return\n latest.current.close()\n }\n document.addEventListener(\"pointerdown\", handlePointerDown, true)\n return () => document.removeEventListener(\"pointerdown\", handlePointerDown, true)\n }, [revealed, swiping, latest])\n\n const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0 || gesture.current) return\n // A new press of the primary pointer starts clean: a swipe that another row ended and that was then cancelled leaves\n // no click to swallow. Another finger's press keeps it, as only the primary pointer clicks.\n if (event.isPrimary) suppressClick.current = false\n if (leading.length < 1 && trailing.length < 1) return\n // A drag in a text field or along a slider belongs to that control.\n if (event.target instanceof Element && event.target.closest(OWN_DRAG)) return\n const pointerId = event.pointerId\n // The end of the gesture is heard wherever the finger lifts, inside the row or not.\n const handleUp = (end: globalThis.PointerEvent) => {\n if (end.pointerId === pointerId) latest.current.finish()\n }\n const handleCancel = (end: globalThis.PointerEvent) => {\n if (end.pointerId === pointerId) latest.current.cancel()\n }\n window.addEventListener(\"pointerup\", handleUp, true)\n window.addEventListener(\"pointercancel\", handleCancel, true)\n gesture.current = {\n pointerId,\n x: event.clientX,\n y: event.clientY,\n start: current.current.offset,\n swiping: undefined,\n rtl: isRtl(),\n widths: { leading: widthOf(\"leading\"), trailing: widthOf(\"trailing\") },\n rowWidth: root.current?.clientWidth ?? 0,\n detach: () => {\n window.removeEventListener(\"pointerup\", handleUp, true)\n window.removeEventListener(\"pointercancel\", handleCancel, true)\n },\n }\n }\n\n const handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {\n const state = gesture.current\n if (!state || state.pointerId !== event.pointerId || state.swiping === false) return\n const across = (event.clientX - state.x) * (state.rtl ? -1 : 1)\n const down = event.clientY - state.y\n if (state.swiping === undefined) {\n if (Math.abs(across) < SLOP && Math.abs(down) < SLOP) return\n if (Math.abs(across) <= Math.abs(down)) {\n state.swiping = false\n return\n }\n state.swiping = true\n capture(event.currentTarget, event.pointerId)\n window.getSelection?.()?.removeAllRanges()\n claim()\n setRtl(state.rtl)\n setSwiping(true)\n }\n const next = swipeActionsOffset(state.start + across, state.widths, state.rowWidth, fullSwipe)\n move(next.offset, next.full)\n }\n\n /** The content lost the finger it held. A child that loses the finger to the content (as a touch moves its implicit capture) ends nothing. */\n const handleLostPointerCapture = (event: PointerEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget && gesture.current?.pointerId === event.pointerId) cancel()\n }\n\n /** A swipe or a press that closed the row is not a click on the content; a click from the keys still is. */\n const handleClickCapture = (event: MouseEvent<HTMLDivElement>) => {\n if (!suppressClick.current || event.detail === 0) return\n suppressClick.current = false\n event.preventDefault()\n event.stopPropagation()\n }\n\n /** The focus on an action shows its side; on the content it closes the row. */\n const handleFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (gesture.current?.swiping) return\n const side = ([\"leading\", \"trailing\"] as const).find((name) => sides.current[name]?.contains(event.target))\n if (side) {\n if (sideOf(current.current.offset) !== side) open(side)\n } else if (current.current.offset !== 0) {\n close()\n }\n }\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (gesture.current?.swiping) return\n if (event.relatedTarget instanceof Node && root.current?.contains(event.relatedTarget)) return\n if (current.current.offset !== 0) close()\n }\n\n const select = (action: SwipeAction, event: MouseEvent<HTMLButtonElement>) => {\n action.onSelect?.()\n // A press closes the row, as iOS does. From the keys the action keeps the focus, so its side stays open until\n // the focus leaves the row.\n if (event.detail === 0) return\n event.currentTarget.blur()\n close()\n }\n\n const renderSide = (side: SwipeActionsSide, actions: SwipeAction[]) => {\n if (actions.length < 1) return null\n const shown = side === \"leading\" ? actions : [...actions].reverse()\n const isFull = full && revealed === side\n return (\n <div\n ref={(element) => {\n sides.current[side] = element\n }}\n className={s.Actions}\n data-side={side}\n data-full={isFull ? \"\" : undefined}\n style={isFull ? { width: Math.abs(offset) } : undefined}\n >\n {shown.map((action) => {\n const color = action.color ?? \"secondary\"\n // A label alone (text), a symbol with its label inside (label), or a symbol with its label hidden or below.\n const shape = !action.Icon ? \"text\" : labelPlacement === \"inside\" ? \"label\" : \"symbol\"\n const labelInside = shape !== \"symbol\"\n const labelBelow = shape === \"symbol\" && labelPlacement === \"below\"\n return (\n <button\n key={action.id}\n type=\"button\"\n className={s.Action}\n data-color={color}\n data-shape={shape}\n data-first={action === actions[0] ? \"\" : undefined}\n aria-label={labelInside || labelBelow ? undefined : action.label}\n onClick={(event) => select(action, event)}\n >\n <span className={s.Capsule}>\n {action.Icon && <action.Icon className={s.Icon} aria-hidden=\"true\" />}\n {labelInside && <span className={s.Label}>{action.label}</span>}\n </span>\n {labelBelow && <span className={s.Caption}>{action.label}</span>}\n </button>\n )\n })}\n </div>\n )\n }\n\n return (\n <div\n ref={root}\n className={clsx(s.SwipeActions, className)}\n data-row=\"\"\n data-swipe-actions=\"\"\n data-label-placement={labelPlacement}\n data-round={round ? \"\" : undefined}\n data-revealed={revealed}\n data-swiping={swiping ? \"\" : undefined}\n onFocus={handleFocus}\n onBlur={handleBlur}\n >\n {renderSide(\"leading\", leading)}\n <div\n className={s.Content}\n data-swipe-content=\"\"\n style={offset !== 0 ? { \"--swipe-actions-offset\": `${rtl ? -offset : offset}px` } as CSSProperties : undefined}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onLostPointerCapture={handleLostPointerCapture}\n onClickCapture={handleClickCapture}\n >\n {children}\n </div>\n {renderSide(\"trailing\", trailing)}\n </div>\n )\n}\n"]}
|
|
@@ -21,7 +21,7 @@ function useTabBarContext(part) {
|
|
|
21
21
|
* search or prominent tab in a circle of its own. It minimizes to the selected tab while the content scrolls
|
|
22
22
|
* down. A desktop layout navigates with a Sidebar or Tabs, so the bar never renders from 768px up.
|
|
23
23
|
*/
|
|
24
|
-
function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, prominent, minimizeBehavior = "never", minimized: minimizedProp, defaultMinimized = false, onMinimizedChange, background = "soft", "aria-label": ariaLabel = "Tabs", children, className, ref, }) {
|
|
24
|
+
function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, prominent, minimizeBehavior = "never", minimized: minimizedProp, defaultMinimized = false, onMinimizedChange, background = "soft", accessory, "aria-label": ariaLabel = "Tabs", children, className, ref, }) {
|
|
25
25
|
const host = useContext(ToolbarHostContext);
|
|
26
26
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
27
27
|
const value = valueProp ?? internalValue;
|
|
@@ -90,10 +90,17 @@ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, pro
|
|
|
90
90
|
return () => { observer?.disconnect(); setHeight("bottom", undefined); };
|
|
91
91
|
}, [setHeight]);
|
|
92
92
|
const context = { value, minimized, select, expand };
|
|
93
|
-
|
|
93
|
+
// `accessory={playing && <NowPlaying />}` leaves no empty capsule when nothing plays.
|
|
94
|
+
const hasAccessory = accessory != null && typeof accessory !== "boolean" && accessory !== "";
|
|
95
|
+
const accessoryCapsule = hasAccessory && _jsx("div", { className: s.Accessory, children: accessory }, "accessory");
|
|
96
|
+
const tabs = (_jsxs("div", { className: s.Tabs, children: [children, search && prominent && _jsx(TabBarItem, { value: search.value, label: search.label ?? "Search", icon: _jsx(SearchIcon, {}) })] }, "tabs"));
|
|
97
|
+
const circle = prominent ? (_jsx(TabBarItem, { className: s.Prominent, value: prominent.value, label: prominent.label, icon: prominent.icon, hideLabel: true }, "prominent")) : search && (_jsx(TabBarItem, { className: s.Search, value: search.value, label: search.label ?? "Search", icon: _jsx(SearchIcon, {}), hideLabel: true }, "search"));
|
|
98
|
+
return (_jsx("nav", { ref: setRef, "aria-label": ariaLabel, className: clsx(s.TabBar, className), "data-host": host?.kind, "data-background": background, "data-content-below": host?.contentBelow ? "" : undefined, "data-minimized": minimized ? "" : undefined, "data-search": search && !prominent ? "" : undefined, "data-prominent": prominent ? "" : undefined, "data-accessory": hasAccessory ? "" : undefined, children: _jsx(TabBarContext.Provider, { value: context, children: minimized ? [tabs, accessoryCapsule, circle] : [accessoryCapsule, tabs, circle] }) }));
|
|
94
99
|
}
|
|
95
100
|
TabBarRoot.displayName = "TabBar";
|
|
96
|
-
|
|
101
|
+
/** A badge shows unless it is empty: nothing, false, an empty text or a count of 0 (iOS hides `.badge(0)`). */
|
|
102
|
+
const hasBadge = (badge) => badge != null && badge !== false && badge !== "" && badge !== 0;
|
|
103
|
+
function TabBarItem({ value, label, icon, badge, href, disabled = false, onClick, className, hideLabel = false }) {
|
|
97
104
|
const context = useTabBarContext("TabBar.Item");
|
|
98
105
|
const selected = context.value === value;
|
|
99
106
|
// A minimized bar shows the selected tab only; pressing it brings the other tabs back.
|
|
@@ -108,7 +115,7 @@ function TabBarItem({ value, label, icon, href, disabled = false, onClick, class
|
|
|
108
115
|
}
|
|
109
116
|
context.select(value);
|
|
110
117
|
};
|
|
111
|
-
const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: s.Icon, "aria-hidden": "true", children: icon }), !hideLabel && _jsx("span", { className: s.Label, children: label })] }));
|
|
118
|
+
const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: s.Icon, "aria-hidden": "true", children: icon }), !hideLabel && _jsx("span", { className: s.Label, children: label }), hasBadge(badge) && _jsxs(_Fragment, { children: [" ", _jsx("span", { className: s.Badge, children: badge })] })] }));
|
|
112
119
|
const props = {
|
|
113
120
|
"className": clsx(s.Item, className),
|
|
114
121
|
"aria-current": selected ? "page" : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../../../src/components/TabBar/TabBar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAsB,MAAM,oBAAoB,CAAA;AAE3E,2FAA2F;AAC3F,MAAM,cAAc,GAAG,CAAC,CAAA;AASxB,MAAM,aAAa,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAA;AAEpE,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IACzC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,6BAA6B,CAAC,CAAA;IACnE,OAAO,OAAO,CAAA;AAChB,CAAC;AAuDD;;;;;GAKG;AACH,SAAS,UAAU,CAAC,EAClB,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,aAAa,EACb,MAAM,EACN,SAAS,EACT,gBAAgB,G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vB,CAAA;IACD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,QAAQ;QAAE,OAAO,YAAG,IAAI,EAAE,IAAI,KAAM,KAAK,YAAG,OAAO,GAAK,CAAA;IACnF,OAAO,iBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,QAAQ,KAAM,KAAK,YAAG,OAAO,GAAU,CAAA;AAChF,CAAC;AACD,UAAU,CAAC,WAAW,GAAG,aAAa,CAAA;AAEtC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type MouseEvent,\n type ReactNode,\n type Ref,\n} from \"react\"\nimport s from \"@plexui/styles/components/TabBar/TabBar.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Search as SearchIcon } from \"../Icon\"\nimport { ToolbarHostContext, type BarBackground } from \"../Toolbar/Toolbar\"\n\n/** A scroll of at least this many pixels in one direction minimizes or expands the bar. */\nconst MINIMIZE_AFTER = 8\n\ntype TabBarContextValue = {\n value: string | undefined\n minimized: boolean\n select: (value: string) => void\n expand: () => void\n}\n\nconst TabBarContext = createContext<TabBarContextValue | null>(null)\n\nfunction useTabBarContext(part: string) {\n const context = useContext(TabBarContext)\n if (!context) throw new Error(`${part} must be used within TabBar`)\n return context\n}\n\nexport type TabBarSearch = {\n /** The value of the search tab. */\n value: string\n /** Accessible name of the search tab. @default \"Search\" */\n label?: string\n}\n\nexport type TabBarProminent = {\n /** The value of the prominent tab. */\n value: string\n /** Accessible name of the prominent tab: its circle shows the symbol only. */\n label: string\n /** The symbol, a PlexUI icon. */\n icon: ReactNode\n}\n\nexport type TabBarProps = {\n /** The controlled value of the selected tab. Use with `onValueChange`. */\n value?: string\n /** The selected tab when it is initially rendered. */\n defaultValue?: string\n /** Called with the value of the tab a person selects. */\n onValueChange?: (value: string) => void\n /** A search tab in a glass circle of its own at the trailing end, as the iOS 26 separate search tab. */\n search?: TabBarSearch\n /**\n * The one destination the app lifts out of the capsule, a cart or a library, in a glass circle of its own at\n * the trailing end, as the iOS 27 prominent tab role. It takes the circle of the search tab: with both, search\n * is the last tab of the capsule, as iOS gives search that place only when no other tab is prominent.\n */\n prominent?: TabBarProminent\n /**\n * `onScrollDown` minimizes the bar to the selected tab while the content of the `Page` scrolls down and\n * expands it when the content scrolls back up; a tap on the minimized tab expands it too. @default \"never\"\n */\n minimizeBehavior?: \"never\" | \"onScrollDown\"\n /** Controlled minimized state. Use with `onMinimizedChange`. */\n minimized?: boolean\n /** The minimized state when it is initially rendered. @default false */\n defaultMinimized?: boolean\n /** Called when the bar minimizes or expands. */\n onMinimizedChange?: (minimized: boolean) => void\n /** How the bar meets the content scrolled under it; see `BarBackground`. @default \"soft\" */\n background?: BarBackground\n /** Accessible name of the navigation. @default \"Tabs\" */\n \"aria-label\"?: string\n /** `TabBar.Item` elements. */\n children?: ReactNode\n /** CSS classes applied to the bar */\n className?: string\n ref?: Ref<HTMLElement>\n}\n\n/**\n * The tab bar of a phone screen after the iOS 26 kit Tab Bar - iPhone (507:24689): two to five tabs, each a\n * symbol over a label, in a floating glass capsule at the bottom, the selected tab on a pill, and an optional\n * search or prominent tab in a circle of its own. It minimizes to the selected tab while the content scrolls\n * down. A desktop layout navigates with a Sidebar or Tabs, so the bar never renders from 768px up.\n */\nfunction TabBarRoot({\n value: valueProp,\n defaultValue,\n onValueChange,\n search,\n prominent,\n minimizeBehavior = \"never\",\n minimized: minimizedProp,\n defaultMinimized = false,\n onMinimizedChange,\n background = \"soft\",\n \"aria-label\": ariaLabel = \"Tabs\",\n children,\n className,\n ref,\n}: TabBarProps) {\n const host = useContext(ToolbarHostContext)\n const [internalValue, setInternalValue] = useState(defaultValue)\n const value = valueProp ?? internalValue\n const [internalMinimized, setInternalMinimized] = useState(defaultMinimized)\n const minimized = minimizedProp ?? internalMinimized\n const onValueChangeRef = useLatestValue(onValueChange)\n const onMinimizedChangeRef = useLatestValue(onMinimizedChange)\n const minimizedRef = useLatestValue(minimized)\n const controlledMinimized = minimizedProp !== undefined\n\n const select = useCallback((next: string) => {\n if (valueProp === undefined) setInternalValue(next)\n onValueChangeRef.current?.(next)\n }, [valueProp, onValueChangeRef])\n\n const setMinimized = useCallback((next: boolean) => {\n if (next === minimizedRef.current) return\n // A controlled state changes only when the owner passes it back.\n if (!controlledMinimized) {\n minimizedRef.current = next\n setInternalMinimized(next)\n }\n onMinimizedChangeRef.current?.(next)\n }, [controlledMinimized, minimizedRef, onMinimizedChangeRef])\n\n const expand = useCallback(() => setMinimized(false), [setMinimized])\n\n // The bar follows the Page content: down by MINIMIZE_AFTER minimizes it, up by as much (or the top) expands it.\n const subscribeScroll = host?.subscribeScroll\n useEffect(() => {\n if (minimizeBehavior !== \"onScrollDown\" || !subscribeScroll) return\n let anchor = 0\n return subscribeScroll((scrollTop) => {\n if (scrollTop <= 0) {\n anchor = 0\n return setMinimized(false)\n }\n const delta = scrollTop - anchor\n if (minimizedRef.current ? delta < 0 : delta > 0) {\n if (Math.abs(delta) >= MINIMIZE_AFTER) {\n anchor = scrollTop\n setMinimized(!minimizedRef.current)\n }\n return\n }\n anchor = scrollTop\n })\n }, [minimizeBehavior, subscribeScroll, setMinimized, minimizedRef])\n\n const element = useRef<HTMLElement | null>(null)\n const setRef = useCallback((node: HTMLElement | null) => {\n element.current = node\n if (typeof ref === \"function\") return ref(node)\n if (ref) ref.current = node\n }, [ref])\n\n // Like a bottom Toolbar, the bar reserves its height on the Page; a desktop layout hides it.\n const setHeight = host?.setHeight\n useLayoutEffect(() => {\n const bar = element.current\n if (!bar || !setHeight) return\n const update = () => setHeight(\"bottom\", bar.offsetHeight || undefined)\n update()\n const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : undefined\n observer?.observe(bar, { box: \"border-box\" })\n return () => { observer?.disconnect(); setHeight(\"bottom\", undefined) }\n }, [setHeight])\n\n const context = { value, minimized, select, expand }\n\n return (\n <nav\n ref={setRef}\n aria-label={ariaLabel}\n className={clsx(s.TabBar, className)}\n data-host={host?.kind}\n data-background={background}\n data-content-below={host?.contentBelow ? \"\" : undefined}\n data-minimized={minimized ? \"\" : undefined}\n data-search={search && !prominent ? \"\" : undefined}\n data-prominent={prominent ? \"\" : undefined}\n >\n <TabBarContext.Provider value={context}>\n <div className={s.Tabs}>\n {children}\n {search && prominent && <TabBarItem value={search.value} label={search.label ?? \"Search\"} icon={<SearchIcon />} />}\n </div>\n {prominent ? (\n <TabBarItem className={s.Prominent} value={prominent.value} label={prominent.label} icon={prominent.icon} hideLabel />\n ) : search && (\n <TabBarItem className={s.Search} value={search.value} label={search.label ?? \"Search\"} icon={<SearchIcon />} hideLabel />\n )}\n </TabBarContext.Provider>\n </nav>\n )\n}\nTabBarRoot.displayName = \"TabBar\"\n\nexport type TabBarItemProps = {\n /** The value of the tab. */\n value: string\n /** The label under the symbol, and the accessible name of the tab. */\n label: string\n /** The symbol, a PlexUI icon. */\n icon: ReactNode\n /** Makes the tab a link to this URL. */\n href?: string\n /** When `true`, the tab cannot be selected. */\n disabled?: boolean\n /** Called when the tab is pressed, before it is selected. */\n onClick?: (event: MouseEvent<HTMLElement>) => void\n /** CSS classes applied to the tab */\n className?: string\n /** @internal The search and the prominent tab show their symbol only. */\n hideLabel?: boolean\n}\n\nfunction TabBarItem({ value, label, icon, href, disabled = false, onClick, className, hideLabel = false }: TabBarItemProps) {\n const context = useTabBarContext(\"TabBar.Item\")\n const selected = context.value === value\n // A minimized bar shows the selected tab only; pressing it brings the other tabs back.\n const collapsed = context.minimized && selected && !hideLabel\n const handleClick = (event: MouseEvent<HTMLElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled) return\n if (collapsed) {\n event.preventDefault()\n return context.expand()\n }\n context.select(value)\n }\n const content = (\n <>\n <span className={s.Icon} aria-hidden=\"true\">{icon}</span>\n {!hideLabel && <span className={s.Label}>{label}</span>}\n </>\n )\n const props = {\n \"className\": clsx(s.Item, className),\n \"aria-current\": selected ? (\"page\" as const) : undefined,\n \"aria-label\": hideLabel ? label : undefined,\n \"aria-expanded\": collapsed ? false : undefined,\n \"data-selected\": selected ? \"\" : undefined,\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-value\": value,\n \"onClick\": handleClick,\n }\n if (href !== undefined && !disabled) return <a href={href} {...props}>{content}</a>\n return <button type=\"button\" disabled={disabled} {...props}>{content}</button>\n}\nTabBarItem.displayName = \"TabBar.Item\"\n\nexport const TabBar = Object.assign(TabBarRoot, { Item: TabBarItem })\n"]}
|
|
1
|
+
{"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../../../src/components/TabBar/TabBar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAsB,MAAM,oBAAoB,CAAA;AAE3E,2FAA2F;AAC3F,MAAM,cAAc,GAAG,CAAC,CAAA;AASxB,MAAM,aAAa,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAA;AAEpE,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IACzC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,6BAA6B,CAAC,CAAA;IACnE,OAAO,OAAO,CAAA;AAChB,CAAC;AA4DD;;;;;GAKG;A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CAAA;AAEtC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type MouseEvent,\n type ReactNode,\n type Ref,\n} from \"react\"\nimport s from \"@plexui/styles/components/TabBar/TabBar.module.css\"\nimport { useLatestValue } from \"../../hooks/useLatestValue\"\nimport { Search as SearchIcon } from \"../Icon\"\nimport { ToolbarHostContext, type BarBackground } from \"../Toolbar/Toolbar\"\n\n/** A scroll of at least this many pixels in one direction minimizes or expands the bar. */\nconst MINIMIZE_AFTER = 8\n\ntype TabBarContextValue = {\n value: string | undefined\n minimized: boolean\n select: (value: string) => void\n expand: () => void\n}\n\nconst TabBarContext = createContext<TabBarContextValue | null>(null)\n\nfunction useTabBarContext(part: string) {\n const context = useContext(TabBarContext)\n if (!context) throw new Error(`${part} must be used within TabBar`)\n return context\n}\n\nexport type TabBarSearch = {\n /** The value of the search tab. */\n value: string\n /** Accessible name of the search tab. @default \"Search\" */\n label?: string\n}\n\nexport type TabBarProminent = {\n /** The value of the prominent tab. */\n value: string\n /** Accessible name of the prominent tab: its circle shows the symbol only. */\n label: string\n /** The symbol, a PlexUI icon. */\n icon: ReactNode\n}\n\nexport type TabBarProps = {\n /** The controlled value of the selected tab. Use with `onValueChange`. */\n value?: string\n /** The selected tab when it is initially rendered. */\n defaultValue?: string\n /** Called with the value of the tab a person selects. */\n onValueChange?: (value: string) => void\n /** A search tab in a glass circle of its own at the trailing end, as the iOS 26 separate search tab. */\n search?: TabBarSearch\n /**\n * The one destination the app lifts out of the capsule, a cart or a library, in a glass circle of its own at\n * the trailing end, as the iOS 27 prominent tab role. It takes the circle of the search tab: with both, search\n * is the last tab of the capsule, as iOS gives search that place only when no other tab is prominent.\n */\n prominent?: TabBarProminent\n /**\n * `onScrollDown` minimizes the bar to the selected tab while the content of the `Page` scrolls down and\n * expands it when the content scrolls back up; a tap on the minimized tab expands it too. @default \"never\"\n */\n minimizeBehavior?: \"never\" | \"onScrollDown\"\n /** Controlled minimized state. Use with `onMinimizedChange`. */\n minimized?: boolean\n /** The minimized state when it is initially rendered. @default false */\n defaultMinimized?: boolean\n /** Called when the bar minimizes or expands. */\n onMinimizedChange?: (minimized: boolean) => void\n /** How the bar meets the content scrolled under it; see `BarBackground`. @default \"soft\" */\n background?: BarBackground\n /**\n * Content in a glass capsule above the tabs, a now playing row or a status, as the iOS 27 bottom accessory;\n * minimized, it stands between the two circles. The bar grows by its height.\n */\n accessory?: ReactNode\n /** Accessible name of the navigation. @default \"Tabs\" */\n \"aria-label\"?: string\n /** `TabBar.Item` elements. */\n children?: ReactNode\n /** CSS classes applied to the bar */\n className?: string\n ref?: Ref<HTMLElement>\n}\n\n/**\n * The tab bar of a phone screen after the iOS 26 kit Tab Bar - iPhone (507:24689): two to five tabs, each a\n * symbol over a label, in a floating glass capsule at the bottom, the selected tab on a pill, and an optional\n * search or prominent tab in a circle of its own. It minimizes to the selected tab while the content scrolls\n * down. A desktop layout navigates with a Sidebar or Tabs, so the bar never renders from 768px up.\n */\nfunction TabBarRoot({\n value: valueProp,\n defaultValue,\n onValueChange,\n search,\n prominent,\n minimizeBehavior = \"never\",\n minimized: minimizedProp,\n defaultMinimized = false,\n onMinimizedChange,\n background = \"soft\",\n accessory,\n \"aria-label\": ariaLabel = \"Tabs\",\n children,\n className,\n ref,\n}: TabBarProps) {\n const host = useContext(ToolbarHostContext)\n const [internalValue, setInternalValue] = useState(defaultValue)\n const value = valueProp ?? internalValue\n const [internalMinimized, setInternalMinimized] = useState(defaultMinimized)\n const minimized = minimizedProp ?? internalMinimized\n const onValueChangeRef = useLatestValue(onValueChange)\n const onMinimizedChangeRef = useLatestValue(onMinimizedChange)\n const minimizedRef = useLatestValue(minimized)\n const controlledMinimized = minimizedProp !== undefined\n\n const select = useCallback((next: string) => {\n if (valueProp === undefined) setInternalValue(next)\n onValueChangeRef.current?.(next)\n }, [valueProp, onValueChangeRef])\n\n const setMinimized = useCallback((next: boolean) => {\n if (next === minimizedRef.current) return\n // A controlled state changes only when the owner passes it back.\n if (!controlledMinimized) {\n minimizedRef.current = next\n setInternalMinimized(next)\n }\n onMinimizedChangeRef.current?.(next)\n }, [controlledMinimized, minimizedRef, onMinimizedChangeRef])\n\n const expand = useCallback(() => setMinimized(false), [setMinimized])\n\n // The bar follows the Page content: down by MINIMIZE_AFTER minimizes it, up by as much (or the top) expands it.\n const subscribeScroll = host?.subscribeScroll\n useEffect(() => {\n if (minimizeBehavior !== \"onScrollDown\" || !subscribeScroll) return\n let anchor = 0\n return subscribeScroll((scrollTop) => {\n if (scrollTop <= 0) {\n anchor = 0\n return setMinimized(false)\n }\n const delta = scrollTop - anchor\n if (minimizedRef.current ? delta < 0 : delta > 0) {\n if (Math.abs(delta) >= MINIMIZE_AFTER) {\n anchor = scrollTop\n setMinimized(!minimizedRef.current)\n }\n return\n }\n anchor = scrollTop\n })\n }, [minimizeBehavior, subscribeScroll, setMinimized, minimizedRef])\n\n const element = useRef<HTMLElement | null>(null)\n const setRef = useCallback((node: HTMLElement | null) => {\n element.current = node\n if (typeof ref === \"function\") return ref(node)\n if (ref) ref.current = node\n }, [ref])\n\n // Like a bottom Toolbar, the bar reserves its height on the Page; a desktop layout hides it.\n const setHeight = host?.setHeight\n useLayoutEffect(() => {\n const bar = element.current\n if (!bar || !setHeight) return\n const update = () => setHeight(\"bottom\", bar.offsetHeight || undefined)\n update()\n const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : undefined\n observer?.observe(bar, { box: \"border-box\" })\n return () => { observer?.disconnect(); setHeight(\"bottom\", undefined) }\n }, [setHeight])\n\n const context = { value, minimized, select, expand }\n // `accessory={playing && <NowPlaying />}` leaves no empty capsule when nothing plays.\n const hasAccessory = accessory != null && typeof accessory !== \"boolean\" && accessory !== \"\"\n const accessoryCapsule = hasAccessory && <div key=\"accessory\" className={s.Accessory}>{accessory}</div>\n const tabs = (\n <div key=\"tabs\" className={s.Tabs}>\n {children}\n {search && prominent && <TabBarItem value={search.value} label={search.label ?? \"Search\"} icon={<SearchIcon />} />}\n </div>\n )\n const circle = prominent ? (\n <TabBarItem key=\"prominent\" className={s.Prominent} value={prominent.value} label={prominent.label} icon={prominent.icon} hideLabel />\n ) : search && (\n <TabBarItem key=\"search\" className={s.Search} value={search.value} label={search.label ?? \"Search\"} icon={<SearchIcon />} hideLabel />\n )\n\n return (\n <nav\n ref={setRef}\n aria-label={ariaLabel}\n className={clsx(s.TabBar, className)}\n data-host={host?.kind}\n data-background={background}\n data-content-below={host?.contentBelow ? \"\" : undefined}\n data-minimized={minimized ? \"\" : undefined}\n data-search={search && !prominent ? \"\" : undefined}\n data-prominent={prominent ? \"\" : undefined}\n data-accessory={hasAccessory ? \"\" : undefined}\n >\n <TabBarContext.Provider value={context}>\n {/* The accessory is read where it stands: above the tabs, and minimized between the two circles. The keys\n move it there without remounting its content. */}\n {minimized ? [tabs, accessoryCapsule, circle] : [accessoryCapsule, tabs, circle]}\n </TabBarContext.Provider>\n </nav>\n )\n}\nTabBarRoot.displayName = \"TabBar\"\n\nexport type TabBarItemProps = {\n /** The value of the tab. */\n value: string\n /** The label under the symbol, and the accessible name of the tab. */\n label: string\n /** The symbol, a PlexUI icon. */\n icon: ReactNode\n /**\n * A count or a short word in a red capsule over the symbol, as an iOS tab badge; it is read after the label.\n * A count of 0 shows none, as on iOS.\n */\n badge?: ReactNode\n /** Makes the tab a link to this URL. */\n href?: string\n /** When `true`, the tab cannot be selected. */\n disabled?: boolean\n /** Called when the tab is pressed, before it is selected. */\n onClick?: (event: MouseEvent<HTMLElement>) => void\n /** CSS classes applied to the tab */\n className?: string\n /** @internal The search and the prominent tab show their symbol only. */\n hideLabel?: boolean\n}\n\n/** A badge shows unless it is empty: nothing, false, an empty text or a count of 0 (iOS hides `.badge(0)`). */\nconst hasBadge = (badge: ReactNode) => badge != null && badge !== false && badge !== \"\" && badge !== 0\n\nfunction TabBarItem({ value, label, icon, badge, href, disabled = false, onClick, className, hideLabel = false }: TabBarItemProps) {\n const context = useTabBarContext(\"TabBar.Item\")\n const selected = context.value === value\n // A minimized bar shows the selected tab only; pressing it brings the other tabs back.\n const collapsed = context.minimized && selected && !hideLabel\n const handleClick = (event: MouseEvent<HTMLElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled) return\n if (collapsed) {\n event.preventDefault()\n return context.expand()\n }\n context.select(value)\n }\n const content = (\n <>\n <span className={s.Icon} aria-hidden=\"true\">{icon}</span>\n {!hideLabel && <span className={s.Label}>{label}</span>}\n {/* The space keeps the accessible name \"Inbox 3\", not \"Inbox3\". */}\n {hasBadge(badge) && <>{\" \"}<span className={s.Badge}>{badge}</span></>}\n </>\n )\n const props = {\n \"className\": clsx(s.Item, className),\n \"aria-current\": selected ? (\"page\" as const) : undefined,\n \"aria-label\": hideLabel ? label : undefined,\n \"aria-expanded\": collapsed ? false : undefined,\n \"data-selected\": selected ? \"\" : undefined,\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-value\": value,\n \"onClick\": handleClick,\n }\n if (href !== undefined && !disabled) return <a href={href} {...props}>{content}</a>\n return <button type=\"button\" disabled={disabled} {...props}>{content}</button>\n}\nTabBarItem.displayName = \"TabBar.Item\"\n\nexport const TabBar = Object.assign(TabBarRoot, { Item: TabBarItem })\n"]}
|