@multiplatform.one/components 7.75.0 → 7.76.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/cjs/Accordion/index.cjs +23 -37
- package/dist/cjs/Accordion/index.native.js +33 -47
- package/dist/cjs/Accordion/index.native.js.map +1 -1
- package/dist/cjs/CardHeader.cjs +1 -0
- package/dist/cjs/CardHeader.native.js +1 -0
- package/dist/cjs/CardHeader.native.js.map +1 -1
- package/dist/cjs/layouts/page.cjs +119 -2
- package/dist/cjs/layouts/page.native.js +122 -2
- package/dist/cjs/layouts/page.native.js.map +1 -1
- package/dist/cjs/layouts/screenScroll.cjs +20 -0
- package/dist/cjs/layouts/screenScroll.native.js +29 -0
- package/dist/cjs/layouts/screenScroll.native.js.map +1 -1
- package/dist/cjs/layouts/sidebar.cjs +26 -4
- package/dist/cjs/layouts/sidebar.native.js +30 -5
- package/dist/cjs/layouts/sidebar.native.js.map +1 -1
- package/dist/cjs/views/ListRow.cjs +2 -1
- package/dist/cjs/views/ListRow.native.js +2 -1
- package/dist/cjs/views/ListRow.native.js.map +1 -1
- package/dist/esm/Accordion/index.mjs +23 -37
- package/dist/esm/Accordion/index.mjs.map +1 -1
- package/dist/esm/Accordion/index.native.js +33 -47
- package/dist/esm/Accordion/index.native.js.map +1 -1
- package/dist/esm/AnimateHeight/index.native.js.map +1 -1
- package/dist/esm/Avatar/getInitials.native.js.map +1 -1
- package/dist/esm/Avatar/index.native.js.map +1 -1
- package/dist/esm/Badge/index.native.js.map +1 -1
- package/dist/esm/Button.native.js.map +1 -1
- package/dist/esm/CardHeader.mjs +1 -0
- package/dist/esm/CardHeader.mjs.map +1 -1
- package/dist/esm/CardHeader.native.js +1 -0
- package/dist/esm/CardHeader.native.js.map +1 -1
- package/dist/esm/Carousel/index.native.js.map +1 -1
- package/dist/esm/Chip/index.native.js.map +1 -1
- package/dist/esm/Collapsible.native.js.map +1 -1
- package/dist/esm/ContextMenu/index.native.js.map +1 -1
- package/dist/esm/CopyField/index.native.js.map +1 -1
- package/dist/esm/Dialog.native.js.map +1 -1
- package/dist/esm/DotIndicator/index.native.js.map +1 -1
- package/dist/esm/DropdownMenu/index.native.js.map +1 -1
- package/dist/esm/DropdownMenu/menuSettle.native.js.map +1 -1
- package/dist/esm/ErrorBoundary/index.native.js.map +1 -1
- package/dist/esm/Heading.native.js.map +1 -1
- package/dist/esm/Kbd/index.native.js.map +1 -1
- package/dist/esm/Kbd/keys.native.js.map +1 -1
- package/dist/esm/Lightbox/MediaControl.native.js.map +1 -1
- package/dist/esm/Lightbox/index.gnome.native.js.map +1 -1
- package/dist/esm/Lightbox/shared.native.js.map +1 -1
- package/dist/esm/Lightbox/useLightbox.native.js.map +1 -1
- package/dist/esm/Material/index.native.js.map +1 -1
- package/dist/esm/Meter/index.native.js.map +1 -1
- package/dist/esm/Meter/meter.native.js.map +1 -1
- package/dist/esm/OverflowRow/index.native.js.map +1 -1
- package/dist/esm/Pagination.native.js.map +1 -1
- package/dist/esm/Popover.native.js.map +1 -1
- package/dist/esm/ProgressSteps/index.native.js.map +1 -1
- package/dist/esm/Quote/index.native.js.map +1 -1
- package/dist/esm/SchemeToggle/index.native.js.map +1 -1
- package/dist/esm/ScrollView/revealFocusedField.native.js.map +1 -1
- package/dist/esm/Separator/index.native.js.map +1 -1
- package/dist/esm/Sheet.native.js.map +1 -1
- package/dist/esm/SheetModal/SheetHeader.native.js.map +1 -1
- package/dist/esm/SheetModal/SheetNavigation.native.js.map +1 -1
- package/dist/esm/SheetModal/detents.native.js.map +1 -1
- package/dist/esm/SheetModal/useSheetFrameFocus.native.js.map +1 -1
- package/dist/esm/Skeleton/index.native.js.map +1 -1
- package/dist/esm/SkipLink/index.native.js.map +1 -1
- package/dist/esm/SortableList/SortableHandle.native.js.map +1 -1
- package/dist/esm/SortableList/index.native.js.map +1 -1
- package/dist/esm/SortableList/useSortableRows.native.js.map +1 -1
- package/dist/esm/Tabs/index.native.js.map +1 -1
- package/dist/esm/Text.native.js.map +1 -1
- package/dist/esm/ThemePresetPicker/index.native.js.map +1 -1
- package/dist/esm/Toast/index.native.js.map +1 -1
- package/dist/esm/Toast/store.native.js.map +1 -1
- package/dist/esm/Tooltip/nativePress.native.js.map +1 -1
- package/dist/esm/Tooltip/tooltipShared.native.js.map +1 -1
- package/dist/esm/TreeSelect/index.native.js.map +1 -1
- package/dist/esm/TreeSelect/treeSelectModel.native.js.map +1 -1
- package/dist/esm/Video/PlayerChrome.native.js.map +1 -1
- package/dist/esm/Video/VideoFrame.native.js.map +1 -1
- package/dist/esm/Video/types.native.js.map +1 -1
- package/dist/esm/Wheel/index.native.js.map +1 -1
- package/dist/esm/Wizard/index.native.js.map +1 -1
- package/dist/esm/actions/ActionBar.native.js.map +1 -1
- package/dist/esm/actions/DangerSection.native.js.map +1 -1
- package/dist/esm/actions/DestructiveAction.native.js.map +1 -1
- package/dist/esm/actions/HeaderActions.native.js.map +1 -1
- package/dist/esm/actions/StandardAction.native.js.map +1 -1
- package/dist/esm/actions/devWarn.native.js.map +1 -1
- package/dist/esm/actions/index.native.js.map +1 -1
- package/dist/esm/actions/severity.native.js.map +1 -1
- package/dist/esm/appShell/Dock.native.js.map +1 -1
- package/dist/esm/appShell/MpoTabHost.native.js.map +1 -1
- package/dist/esm/appShell/ScopeMenu.native.js.map +1 -1
- package/dist/esm/appShell/SettingsSplit.native.js.map +1 -1
- package/dist/esm/appShell/Springboard.native.js.map +1 -1
- package/dist/esm/appShell/SystemBar.native.js.map +1 -1
- package/dist/esm/appShell/TabBar.native.js.map +1 -1
- package/dist/esm/appShell/appTile.native.js.map +1 -1
- package/dist/esm/appShell/bottomChrome.native.js.map +1 -1
- package/dist/esm/appShell/index.native.js.map +1 -1
- package/dist/esm/charts/Axis.native.js.map +1 -1
- package/dist/esm/charts/BarChart.native.js.map +1 -1
- package/dist/esm/charts/ChartDataView.native.js.map +1 -1
- package/dist/esm/charts/ChartSurface.native.js.map +1 -1
- package/dist/esm/charts/LineChart.native.js.map +1 -1
- package/dist/esm/charts/PieChart.native.js.map +1 -1
- package/dist/esm/charts/Sparkline.native.js.map +1 -1
- package/dist/esm/charts/accessibility.native.js.map +1 -1
- package/dist/esm/charts/chartHeight.native.js.map +1 -1
- package/dist/esm/charts/composeChart.native.js.map +1 -1
- package/dist/esm/charts/index.native.js.map +1 -1
- package/dist/esm/charts/math.native.js.map +1 -1
- package/dist/esm/charts/series.native.js.map +1 -1
- package/dist/esm/charts/svg.native.js.map +1 -1
- package/dist/esm/charts/types.native.js.map +1 -1
- package/dist/esm/charts/useChartTheme.native.js.map +1 -1
- package/dist/esm/code/Code/index.native.js.map +1 -1
- package/dist/esm/code/CodeBlock/index.native.js.map +1 -1
- package/dist/esm/code/HighlightedCode/index.native.js.map +1 -1
- package/dist/esm/code/Highlighter/houseSyntaxTheme.native.js.map +1 -1
- package/dist/esm/code/Highlighter/index.native.js.map +1 -1
- package/dist/esm/code/Highlighter/namedGroupMatchAll.native.js.map +1 -1
- package/dist/esm/code/Pre/index.native.js.map +1 -1
- package/dist/esm/code/index.native.js.map +1 -1
- package/dist/esm/componentColors.native.js.map +1 -1
- package/dist/esm/feedback/ConfirmDialog.native.js.map +1 -1
- package/dist/esm/feedback/NotifyHost.native.js.map +1 -1
- package/dist/esm/feedback/copy.native.js.map +1 -1
- package/dist/esm/feedback/index.native.js.map +1 -1
- package/dist/esm/feedback/notify.native.js.map +1 -1
- package/dist/esm/feedback/route.native.js.map +1 -1
- package/dist/esm/feedback/store.native.js.map +1 -1
- package/dist/esm/formLayouts/FormLayouts.native.js.map +1 -1
- package/dist/esm/formLayouts/PreferencePanel.native.js.map +1 -1
- package/dist/esm/formLayouts/index.native.js.map +1 -1
- package/dist/esm/hooks/index.native.js.map +1 -1
- package/dist/esm/hooks/useClipboard.native.js.map +1 -1
- package/dist/esm/hooks/useDocumentTitle.native.js.map +1 -1
- package/dist/esm/hooks/useHoldCue.native.js.map +1 -1
- package/dist/esm/icons/CheckRegular.native.js.map +1 -1
- package/dist/esm/icons/MinusRegular.native.js.map +1 -1
- package/dist/esm/icons/index.native.js.map +1 -1
- package/dist/esm/icons/lucide.native.js.map +1 -1
- package/dist/esm/icons/themed.native.js.map +1 -1
- package/dist/esm/images/Image/ImageFrame.native.js.map +1 -1
- package/dist/esm/images/Image/framing.native.js.map +1 -1
- package/dist/esm/images/Image/mediaRadius.native.js.map +1 -1
- package/dist/esm/images/Image/shared.native.js.map +1 -1
- package/dist/esm/images/Image/types.native.js.map +1 -1
- package/dist/esm/images/index.native.js.map +1 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/knobImmuneExports.native.js.map +1 -1
- package/dist/esm/layouts/AsyncBoundary.native.js.map +1 -1
- package/dist/esm/layouts/Debug/index.native.js.map +1 -1
- package/dist/esm/layouts/EmptyState.native.js.map +1 -1
- package/dist/esm/layouts/IdentityPlate.native.js.map +1 -1
- package/dist/esm/layouts/KeyboardAvoidingWrapper/behavior.native.js.map +1 -1
- package/dist/esm/layouts/PageTemplates.native.js.map +1 -1
- package/dist/esm/layouts/PaneScaffold.native.js.map +1 -1
- package/dist/esm/layouts/SafeAreaWrapper/insets.native.js.map +1 -1
- package/dist/esm/layouts/StatusDot.native.js.map +1 -1
- package/dist/esm/layouts/ViewSwitcher.native.js.map +1 -1
- package/dist/esm/layouts/attachments.native.js.map +1 -1
- package/dist/esm/layouts/bottomAccessory.native.js.map +1 -1
- package/dist/esm/layouts/breadcrumbs.native.js.map +1 -1
- package/dist/esm/layouts/index.native.js.map +1 -1
- package/dist/esm/layouts/page.mjs +120 -4
- package/dist/esm/layouts/page.mjs.map +1 -1
- package/dist/esm/layouts/page.native.js +123 -4
- package/dist/esm/layouts/page.native.js.map +1 -1
- package/dist/esm/layouts/pageHeadingScope.native.js.map +1 -1
- package/dist/esm/layouts/screenScroll.mjs +21 -2
- package/dist/esm/layouts/screenScroll.mjs.map +1 -1
- package/dist/esm/layouts/screenScroll.native.js +30 -2
- package/dist/esm/layouts/screenScroll.native.js.map +1 -1
- package/dist/esm/layouts/shellSidebarSlot.native.js.map +1 -1
- package/dist/esm/layouts/sidebar.mjs +26 -4
- package/dist/esm/layouts/sidebar.mjs.map +1 -1
- package/dist/esm/layouts/sidebar.native.js +30 -5
- package/dist/esm/layouts/sidebar.native.js.map +1 -1
- package/dist/esm/layouts/tags.native.js.map +1 -1
- package/dist/esm/layouts/timeline.native.js.map +1 -1
- package/dist/esm/layouts/toolbar.native.js.map +1 -1
- package/dist/esm/shared/actionScan.native.js.map +1 -1
- package/dist/esm/shared/i18n.native.js.map +1 -1
- package/dist/esm/shared/restoreRetries.native.js.map +1 -1
- package/dist/esm/shared/t.native.js.map +1 -1
- package/dist/esm/shared/textRidesText.native.js.map +1 -1
- package/dist/esm/shared/useReturnFocusOnClose.native.js.map +1 -1
- package/dist/esm/surfaces.native.js.map +1 -1
- package/dist/esm/tamagui.native.js.map +1 -1
- package/dist/esm/testSetup.native.js.map +1 -1
- package/dist/esm/utils/setTinted.native.js.map +1 -1
- package/dist/esm/utils/unwrapText.native.js.map +1 -1
- package/dist/esm/views/Calendar.native.js.map +1 -1
- package/dist/esm/views/Dashboard.native.js.map +1 -1
- package/dist/esm/views/Gantt.native.js.map +1 -1
- package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
- package/dist/esm/views/ImageGrid.native.js.map +1 -1
- package/dist/esm/views/List.native.js.map +1 -1
- package/dist/esm/views/ListGroup.native.js.map +1 -1
- package/dist/esm/views/ListRow.mjs +2 -1
- package/dist/esm/views/ListRow.mjs.map +1 -1
- package/dist/esm/views/ListRow.native.js +2 -1
- package/dist/esm/views/ListRow.native.js.map +1 -1
- package/dist/esm/views/Matrix.native.js.map +1 -1
- package/dist/esm/views/ReportBuilder.native.js.map +1 -1
- package/dist/esm/views/ShortcutCard.native.js.map +1 -1
- package/dist/esm/views/TreeView.native.js.map +1 -1
- package/dist/esm/views/calendarMath.native.js.map +1 -1
- package/dist/esm/views/ganttIntervals.native.js.map +1 -1
- package/dist/esm/views/ganttMath.native.js.map +1 -1
- package/dist/esm/views/index.native.js.map +1 -1
- package/dist/esm/views/kanbanDnd.native.js.map +1 -1
- package/dist/esm/views/matrixMath.native.js.map +1 -1
- package/dist/esm/views/treeViewDnd.native.js.map +1 -1
- package/dist/esm/views/treeViewLayout.native.js.map +1 -1
- package/dist/esm/views/treeViewMotion.native.js.map +1 -1
- package/dist/esm/views/treeViewReveal.native.js.map +1 -1
- package/dist/esm/views/widgetChrome.native.js.map +1 -1
- package/dist/jsx/Accordion/index.mjs +23 -37
- package/dist/jsx/Accordion/index.mjs.map +1 -1
- package/dist/jsx/Accordion/index.native.js +33 -47
- package/dist/jsx/Accordion/index.native.js.map +1 -1
- package/dist/jsx/CardHeader.mjs +1 -0
- package/dist/jsx/CardHeader.mjs.map +1 -1
- package/dist/jsx/CardHeader.native.js +1 -0
- package/dist/jsx/CardHeader.native.js.map +1 -1
- package/dist/jsx/layouts/page.mjs +120 -4
- package/dist/jsx/layouts/page.mjs.map +1 -1
- package/dist/jsx/layouts/page.native.js +122 -2
- package/dist/jsx/layouts/page.native.js.map +1 -1
- package/dist/jsx/layouts/screenScroll.mjs +21 -2
- package/dist/jsx/layouts/screenScroll.mjs.map +1 -1
- package/dist/jsx/layouts/screenScroll.native.js +29 -0
- package/dist/jsx/layouts/screenScroll.native.js.map +1 -1
- package/dist/jsx/layouts/sidebar.mjs +26 -4
- package/dist/jsx/layouts/sidebar.mjs.map +1 -1
- package/dist/jsx/layouts/sidebar.native.js +30 -5
- package/dist/jsx/layouts/sidebar.native.js.map +1 -1
- package/dist/jsx/views/ListRow.mjs +2 -1
- package/dist/jsx/views/ListRow.mjs.map +1 -1
- package/dist/jsx/views/ListRow.native.js +2 -1
- package/dist/jsx/views/ListRow.native.js.map +1 -1
- package/package.json +9 -9
- package/src/Accordion/Accordion.spec.tsx +6 -7
- package/src/Accordion/index.tsx +30 -45
- package/src/CardHeader.spec.tsx +11 -8
- package/src/CardHeader.tsx +3 -0
- package/src/ContextMenu/ContextMenu.spec.tsx +4 -5
- package/src/DropdownMenu/DropdownMenu.spec.tsx +3 -4
- package/src/SheetModal/SheetModal.menus.spec.tsx +2 -2
- package/src/checkedRow.native-press.spec.tsx +136 -0
- package/src/checkedRow.spec.tsx +4 -3
- package/src/icons/slots.nativeInk.spec.tsx +1 -1
- package/src/layouts/Sidebar.spec.tsx +34 -0
- package/src/layouts/navBar.spec.tsx +28 -0
- package/src/layouts/page.tsx +127 -4
- package/src/layouts/screenNesting.spec.tsx +201 -0
- package/src/layouts/screenScroll.tsx +23 -0
- package/src/layouts/sidebar.tsx +30 -0
- package/src/views/ListGroup.spec.tsx +14 -0
- package/src/views/ListRow.tsx +12 -2
- package/types/Accordion/index.d.ts.map +1 -1
- package/types/CardHeader.d.ts.map +1 -1
- package/types/layouts/page.d.ts +14 -21
- package/types/layouts/page.d.ts.map +1 -1
- package/types/layouts/screenScroll.d.ts +8 -0
- package/types/layouts/screenScroll.d.ts.map +1 -1
- package/types/layouts/sidebar.d.ts +12 -1
- package/types/layouts/sidebar.d.ts.map +1 -1
- package/types/views/ListRow.d.ts +3 -1
- package/types/views/ListRow.d.ts.map +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-8557, under tamagui's NATIVE build (vitest.native.config.mjs) with the
|
|
3
|
+
* React Native animation driver every MPO app runs on a phone.
|
|
4
|
+
*
|
|
5
|
+
* A checked menu row paints the theme's selection tint on native (LC-262):
|
|
6
|
+
* `$color5` over the dark `$color4` overlay, `$color3` over the light panel.
|
|
7
|
+
* On iOS the appearance menu's checked "Dark" row painted the page colour, a
|
|
8
|
+
* hole through the panel that hid its rounded bottom (FZ-8550 KS sim, main
|
|
9
|
+
* before this lane, when dark rested on `$color2`).
|
|
10
|
+
*/
|
|
11
|
+
import { createDefaultThemeConfig, nativeAnimationConfig } from "@multiplatform.one/theme";
|
|
12
|
+
import { Button } from "@multiplatform.one/forms";
|
|
13
|
+
import { createAnimations } from "@tamagui/animations-react-native";
|
|
14
|
+
import { act, cleanup, render, screen } from "@testing-library/react";
|
|
15
|
+
import type { ReactNode } from "react";
|
|
16
|
+
import { TamaguiProvider, YStack, isWeb } from "tamagui";
|
|
17
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
18
|
+
import { ContextMenu } from "./ContextMenu";
|
|
19
|
+
|
|
20
|
+
vi.mock("@multiplatform.one/theme", async (original) => ({
|
|
21
|
+
...(await original<typeof import("@multiplatform.one/theme")>()),
|
|
22
|
+
transitionProps: (await import("@multiplatform.one/theme/src/theme/transitionProps.native"))
|
|
23
|
+
.transitionProps,
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
// The harness resolves forms web-first, and the web panel portals out of the
|
|
27
|
+
// menu's context under tamagui's native build. The phone's panel is a Modal
|
|
28
|
+
// over the `$color4` overlay surface; this stands in for it inline.
|
|
29
|
+
vi.mock("@multiplatform.one/forms", async (original) => ({
|
|
30
|
+
...(await original<typeof import("@multiplatform.one/forms")>()),
|
|
31
|
+
FloatingPanel: ({
|
|
32
|
+
open,
|
|
33
|
+
trigger,
|
|
34
|
+
children,
|
|
35
|
+
}: {
|
|
36
|
+
open?: boolean;
|
|
37
|
+
trigger?: ReactNode;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
}) => (
|
|
40
|
+
<>
|
|
41
|
+
{trigger}
|
|
42
|
+
{open ? <YStack backgroundColor="$color4">{children}</YStack> : null}
|
|
43
|
+
</>
|
|
44
|
+
),
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
const config = createDefaultThemeConfig({
|
|
48
|
+
animations: createAnimations(nativeAnimationConfig),
|
|
49
|
+
});
|
|
50
|
+
type Scheme = "light" | "dark";
|
|
51
|
+
const themes = config.tamagui.themes as unknown as Record<Scheme, Record<string, { val: string }>>;
|
|
52
|
+
|
|
53
|
+
afterEach(cleanup);
|
|
54
|
+
|
|
55
|
+
const settle = () =>
|
|
56
|
+
act(async () => {
|
|
57
|
+
await new Promise((done) => setTimeout(done, 450));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/** `rgba(r,g,b,a)` with whole channels, from the hex, rgb() and hsl() forms both sides use. */
|
|
61
|
+
function rgb(colour: string): string {
|
|
62
|
+
const probe = document.createElement("div");
|
|
63
|
+
probe.style.color = colour;
|
|
64
|
+
const css = probe.style.color.replace(/\s+/g, "");
|
|
65
|
+
const hsl = css.match(/^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,([\d.]+))?\)$/);
|
|
66
|
+
let channels: number[];
|
|
67
|
+
if (hsl) {
|
|
68
|
+
const [h, s, l] = [Number(hsl[1]) / 360, Number(hsl[2]) / 100, Number(hsl[3]) / 100];
|
|
69
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
70
|
+
const p = 2 * l - q;
|
|
71
|
+
const hue = (t: number) => {
|
|
72
|
+
const u = t < 0 ? t + 1 : t > 1 ? t - 1 : t;
|
|
73
|
+
if (u < 1 / 6) return p + (q - p) * 6 * u;
|
|
74
|
+
if (u < 1 / 2) return q;
|
|
75
|
+
if (u < 2 / 3) return p + (q - p) * (2 / 3 - u) * 6;
|
|
76
|
+
return p;
|
|
77
|
+
};
|
|
78
|
+
channels = [hue(h + 1 / 3), hue(h), hue(h - 1 / 3)].map((v) => v * 255);
|
|
79
|
+
channels.push(hsl[4] === undefined ? 1 : Number(hsl[4]));
|
|
80
|
+
} else {
|
|
81
|
+
const parts = css
|
|
82
|
+
.match(/^rgba?\(([^)]*)\)$/)?.[1]
|
|
83
|
+
?.split(",")
|
|
84
|
+
.map(Number);
|
|
85
|
+
if (!parts) return css;
|
|
86
|
+
channels = [...parts.slice(0, 3), parts[3] ?? 1];
|
|
87
|
+
}
|
|
88
|
+
const [r, g, b, a] = channels;
|
|
89
|
+
return `rgba(${Math.round(r!)},${Math.round(g!)},${Math.round(b!)},${Number(a!.toFixed(2))})`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const token = (scheme: Scheme, key: string) => rgb(themes[scheme][key]!.val);
|
|
93
|
+
|
|
94
|
+
/** The nearest painted box around a row's label: the row's own fill, else the panel's. */
|
|
95
|
+
function fillUnder(label: string): string {
|
|
96
|
+
for (let node = screen.getByText(label).parentElement; node; node = node.parentElement) {
|
|
97
|
+
const fill = node.style.backgroundColor;
|
|
98
|
+
if (fill && fill !== "transparent" && rgb(fill) !== "rgba(0,0,0,0)") return rgb(fill);
|
|
99
|
+
}
|
|
100
|
+
throw new Error(`nothing painted under ${label}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const tint = { light: "color3", dark: "color5" } as const;
|
|
104
|
+
|
|
105
|
+
describe("a checked menu row paints the selection tint on native (LC-262, FZ-8557)", () => {
|
|
106
|
+
it("runs on tamagui's native build", () => {
|
|
107
|
+
expect(isWeb).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
for (const scheme of ["light", "dark"] as const) {
|
|
111
|
+
it(`${scheme}: the checked row is ${tint[scheme]}, not the page, and the others paint nothing`, async () => {
|
|
112
|
+
render(
|
|
113
|
+
<TamaguiProvider config={config.tamagui} defaultTheme={scheme} disableInjectCSS>
|
|
114
|
+
<ContextMenu
|
|
115
|
+
defaultOpen
|
|
116
|
+
items={[
|
|
117
|
+
{ label: "System", checked: false },
|
|
118
|
+
{ label: "Light", checked: false },
|
|
119
|
+
{ label: "Dark", checked: true },
|
|
120
|
+
]}
|
|
121
|
+
>
|
|
122
|
+
<Button>Appearance</Button>
|
|
123
|
+
</ContextMenu>
|
|
124
|
+
</TamaguiProvider>,
|
|
125
|
+
);
|
|
126
|
+
await settle();
|
|
127
|
+
const checked = fillUnder("Dark");
|
|
128
|
+
expect(checked).toBe(token(scheme, tint[scheme]));
|
|
129
|
+
expect(checked).not.toBe(token(scheme, "background"));
|
|
130
|
+
expect(checked).not.toBe(token(scheme, "color2"));
|
|
131
|
+
const panel = fillUnder("System");
|
|
132
|
+
expect(fillUnder("Light")).toBe(panel);
|
|
133
|
+
expect(checked).not.toBe(panel);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
package/src/checkedRow.spec.tsx
CHANGED
|
@@ -22,8 +22,8 @@ function restFills(el: Element) {
|
|
|
22
22
|
.filter((c) => /^_bg-(?!0)/.test(c));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
const checkedFill = { light: "
|
|
25
|
+
/** A tint one step off the panel: light $color3 on white, dark $color5 over the $color4 overlay (FZ-8557). */
|
|
26
|
+
const checkedFill = { light: "color3", dark: "color5" } as const;
|
|
27
27
|
|
|
28
28
|
/** A checked row rests on its scheme's checked fill, and only on it. */
|
|
29
29
|
function expectTint(el: Element | null | undefined, scheme: (typeof schemes)[number]) {
|
|
@@ -69,7 +69,8 @@ describe("a checked menu or picker row is highlighted under its check (LC-262, F
|
|
|
69
69
|
expect(checked.querySelector("[data-mp-check]")?.getAttribute("data-mp-check")).toBe(
|
|
70
70
|
"trailing",
|
|
71
71
|
);
|
|
72
|
-
|
|
72
|
+
// Hover keeps the checked fill; an unchecked row hovers on $color3.
|
|
73
|
+
expect(checked.className).toMatch(new RegExp(`_bg-0hover-${checkedFill[scheme]}`));
|
|
73
74
|
expect(unchecked.className).toMatch(/_bg-0hover-color3/);
|
|
74
75
|
await waitFor(() => {
|
|
75
76
|
expect(document.activeElement?.getAttribute("role")).not.toBe("menuitemcheckbox");
|
|
@@ -61,7 +61,7 @@ describe("shared icon slot ink without CSS inheritance", () => {
|
|
|
61
61
|
);
|
|
62
62
|
const [switcher, accordion, well] = screen.getAllByTestId("icon");
|
|
63
63
|
expect(switcher.dataset.color).toBe(switcher.dataset.selectedInk);
|
|
64
|
-
expect(accordion.dataset.color).toBe(accordion.dataset.
|
|
64
|
+
expect(accordion.dataset.color).toBe(accordion.dataset.ink);
|
|
65
65
|
expect(well.dataset.color).toBe(well.dataset.well);
|
|
66
66
|
},
|
|
67
67
|
);
|
|
@@ -77,3 +77,37 @@ describe("Sidebar as a document rail (FZ-8000)", () => {
|
|
|
77
77
|
expect(nav.className).toContain("mp-hairline-ie");
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
|
+
|
|
81
|
+
describe("Sidebar nesting", () => {
|
|
82
|
+
const items = [
|
|
83
|
+
{ value: "a", label: "Alpha", onPress: () => {} },
|
|
84
|
+
{ value: "b", label: "Beta", onPress: () => {} },
|
|
85
|
+
{ value: "c", label: "Child", depth: 1, onPress: () => {} },
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
it("indents a child row by one icon column per level", () => {
|
|
89
|
+
const result = renderWithProviders(<Sidebar sections={[{ items }]} />);
|
|
90
|
+
const rows = Array.from(result.container.querySelectorAll("[data-sidebar-row]"));
|
|
91
|
+
expect(rows[2].getAttribute("data-depth")).toBe("1");
|
|
92
|
+
expect(rows[2].querySelectorAll("[data-sidebar-indent]")).toHaveLength(1);
|
|
93
|
+
expect(rows[0].querySelectorAll("[data-sidebar-indent]")).toHaveLength(0);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("Sidebar footer", () => {
|
|
98
|
+
const sections = [{ items: [{ value: "a", label: "Alpha" }] }];
|
|
99
|
+
|
|
100
|
+
it("pins the footer under the sections inside the rail", () => {
|
|
101
|
+
const result = renderWithProviders(
|
|
102
|
+
<Sidebar sections={sections} testID="rail" footer={<span>Account</span>} />,
|
|
103
|
+
);
|
|
104
|
+
const footer = result.getByTestId("rail").querySelector("[data-sidebar-footer]")!;
|
|
105
|
+
expect(footer).not.toBeNull();
|
|
106
|
+
expect(footer.textContent).toContain("Account");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("draws no footer slot without a footer", () => {
|
|
110
|
+
const result = renderWithProviders(<Sidebar sections={sections} testID="rail" />);
|
|
111
|
+
expect(result.getByTestId("rail").querySelector("[data-sidebar-footer]")).toBeNull();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -111,6 +111,34 @@ describe("Screen top bar (LC-157)", () => {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
+
describe("back control alignment (FZ-7993)", () => {
|
|
115
|
+
function caretPull(container: HTMLElement): number | null {
|
|
116
|
+
const caret = container.querySelector("[data-back-caret]");
|
|
117
|
+
const cls = String((caret as HTMLElement | null)?.className || "")
|
|
118
|
+
.split(" ")
|
|
119
|
+
.find((c) => c.startsWith("_marginInlineStart-"));
|
|
120
|
+
return cls
|
|
121
|
+
? Number.parseFloat(cls.slice("_marginInlineStart-".length).replace("--", "-"))
|
|
122
|
+
: null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
it("pulls the caret by its glyph's bearing, so its point sits on the large title's edge", () => {
|
|
126
|
+
const { container } = renderWithProviders(
|
|
127
|
+
<Screen topBar={<ScreenToolbar leading={<PageBackButton label="Components" />} />}>
|
|
128
|
+
<PageHeader title="DataTable" />
|
|
129
|
+
</Screen>,
|
|
130
|
+
);
|
|
131
|
+
const back = container.querySelector('[data-top-bar-control="back"]');
|
|
132
|
+
expect(back?.querySelector("[data-back-caret] svg")).toBeTruthy();
|
|
133
|
+
const pull = caretPull(container);
|
|
134
|
+
expect(pull).not.toBeNull();
|
|
135
|
+
expect(pull!).toBeLessThan(0);
|
|
136
|
+
const svg = back!.querySelector("[data-back-caret] svg")!;
|
|
137
|
+
const size = Number(svg.getAttribute("width"));
|
|
138
|
+
expect(Math.abs(pull!)).toBe(Math.round((size * 72) / 256));
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
114
142
|
function AccentProbe() {
|
|
115
143
|
const tint = useGlyphTintOnSurface();
|
|
116
144
|
return <span data-testid="accent-probe" data-label={tint.label} data-glyph={tint.glyph} />;
|
package/src/layouts/page.tsx
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import {
|
|
19
19
|
MIN_PRESS_TARGET,
|
|
20
20
|
PageGutter,
|
|
21
|
+
ScreenNesting,
|
|
21
22
|
containerCapProps,
|
|
22
23
|
hairline,
|
|
23
24
|
layoutBreakpoints,
|
|
@@ -26,8 +27,11 @@ import {
|
|
|
26
27
|
transitionProps,
|
|
27
28
|
useAccentOnSurface,
|
|
28
29
|
useLayoutSizeClass,
|
|
30
|
+
useParentScreen,
|
|
31
|
+
usePageGutter,
|
|
29
32
|
useResolvedKnobs,
|
|
30
33
|
type PageTitleScale,
|
|
34
|
+
type ParentScreen,
|
|
31
35
|
} from "@multiplatform.one/theme";
|
|
32
36
|
import { Button, IconButtonGroup, type ButtonProps } from "@multiplatform.one/forms";
|
|
33
37
|
import { CaretLeftIcon, CaretRightIcon, DotsThreeIcon } from "@phosphor-icons/react";
|
|
@@ -73,6 +77,7 @@ import {
|
|
|
73
77
|
useRegisterPageHeading,
|
|
74
78
|
type PageHeadingLevel,
|
|
75
79
|
} from "./pageHeadingScope";
|
|
80
|
+
import { ParentScrollScope } from "./screenScroll";
|
|
76
81
|
|
|
77
82
|
/** Semantic level → tamagui heading component (runtime `tag` is not honored). */
|
|
78
83
|
const PAGE_HEADING_TAGS = { 1: H1, 2: H2, 3: H3, 4: H4, 5: H5, 6: H6 } as const;
|
|
@@ -118,6 +123,120 @@ export interface ScreenProps extends YStackProps {
|
|
|
118
123
|
topBar?: ReactNode;
|
|
119
124
|
}
|
|
120
125
|
|
|
126
|
+
/**
|
|
127
|
+
* The page shell, or, inside another Screen's content, that page's merged
|
|
128
|
+
* continuation (LC-159, FZ-7993): see `NestedScreen`.
|
|
129
|
+
*/
|
|
130
|
+
export function Screen(props: ScreenProps) {
|
|
131
|
+
const parent = useParentScreen();
|
|
132
|
+
return parent ? <NestedScreen parent={parent} {...props} /> : <PageShell {...props} />;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* A Screen inside another Screen's content. Its parent already owns the page,
|
|
137
|
+
* so it adds only what the parent lacks: the gutter when nothing pads the page
|
|
138
|
+
* yet, the content cap when nothing caps it, and a scroll view when the parent
|
|
139
|
+
* does not scroll. It never pins a second top bar (its `topBar` sits at the
|
|
140
|
+
* head of its content), never avoids the keyboard a second time, and opens no
|
|
141
|
+
* bottom edge of its own. Its large title stays a heading in the content so
|
|
142
|
+
* the parent's bar keeps the parent's title.
|
|
143
|
+
*/
|
|
144
|
+
function NestedScreen({
|
|
145
|
+
parent,
|
|
146
|
+
children,
|
|
147
|
+
scroll = true,
|
|
148
|
+
maxWidth = CONTENT_MAX_WIDTH,
|
|
149
|
+
bleed = false,
|
|
150
|
+
noPadding = false,
|
|
151
|
+
scrollViewProps,
|
|
152
|
+
avoidKeyboard: _avoidKeyboard,
|
|
153
|
+
topBar,
|
|
154
|
+
...rest
|
|
155
|
+
}: ScreenProps & { parent: ParentScreen }) {
|
|
156
|
+
const { knobProps } = useResolvedKnobs({ component: "Screen" });
|
|
157
|
+
const scrollState = useScreenScrollController();
|
|
158
|
+
const ownInset =
|
|
159
|
+
noPadding || parent.inset !== null ? null : (knobProps.panelPadding.padding as string);
|
|
160
|
+
const inset = ownInset ?? parent.inset;
|
|
161
|
+
const cap = !parent.capped && maxWidth && !bleed ? maxWidth : null;
|
|
162
|
+
const ownsScroll = scroll && !parent.scrolls;
|
|
163
|
+
|
|
164
|
+
const content = (
|
|
165
|
+
<PageHeadingScope insetToken={inset}>
|
|
166
|
+
<ScreenNesting
|
|
167
|
+
scrolls={scroll || parent.scrolls}
|
|
168
|
+
inset={inset}
|
|
169
|
+
capped={parent.capped || cap !== null}
|
|
170
|
+
>
|
|
171
|
+
{ownInset ? <PageGutter inset={ownInset}>{children}</PageGutter> : children}
|
|
172
|
+
</ScreenNesting>
|
|
173
|
+
</PageHeadingScope>
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const column = (
|
|
177
|
+
<YStack
|
|
178
|
+
ref={ownsScroll ? (scrollState.contentRoot as never) : undefined}
|
|
179
|
+
data-testid="screen"
|
|
180
|
+
data-screen-nested
|
|
181
|
+
flex={1}
|
|
182
|
+
width="100%"
|
|
183
|
+
{...(cap ? { maxWidth: cap, alignSelf: "center" } : null)}
|
|
184
|
+
{...(ownInset ? knobProps.panelPadding : null)}
|
|
185
|
+
{...knobProps.gapLg}
|
|
186
|
+
{...rest}
|
|
187
|
+
>
|
|
188
|
+
{ownsScroll ? null : topBar}
|
|
189
|
+
{content}
|
|
190
|
+
</YStack>
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
if (!ownsScroll) return <ParentScrollScope>{column}</ParentScrollScope>;
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<ScreenScrollScope controller={scrollState}>
|
|
197
|
+
<YStack flex={1} minHeight={0}>
|
|
198
|
+
{topBar}
|
|
199
|
+
<ScrollView
|
|
200
|
+
flex={1}
|
|
201
|
+
contentContainerStyle={{ flexGrow: 1 }}
|
|
202
|
+
scrollEventThrottle={16}
|
|
203
|
+
{...scrollViewProps}
|
|
204
|
+
onScroll={(event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
205
|
+
scrollState.onScroll(event as never);
|
|
206
|
+
scrollViewProps?.onScroll?.(event as never);
|
|
207
|
+
}}
|
|
208
|
+
>
|
|
209
|
+
{column}
|
|
210
|
+
</ScrollView>
|
|
211
|
+
</YStack>
|
|
212
|
+
</ScreenScrollScope>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Content that stands alone in one host and sits in a page in another (a
|
|
218
|
+
* story, an embedded panel). Alone it pads its sides by the page gutter and
|
|
219
|
+
* declares it; inside a page that already applies a gutter it adds nothing,
|
|
220
|
+
* so its content stays on the page line instead of one gutter in (LC-159,
|
|
221
|
+
* FZ-7993).
|
|
222
|
+
*/
|
|
223
|
+
export function GutterFrame({ children, ...rest }: YStackProps) {
|
|
224
|
+
const { knobProps } = useResolvedKnobs({ component: "Screen" });
|
|
225
|
+
const pageGutter = usePageGutter();
|
|
226
|
+
if (pageGutter) {
|
|
227
|
+
return (
|
|
228
|
+
<YStack data-gutter-frame="page" {...rest}>
|
|
229
|
+
{children}
|
|
230
|
+
</YStack>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
return (
|
|
234
|
+
<YStack data-gutter-frame="own" {...knobProps.panelPadding} {...rest}>
|
|
235
|
+
<PageGutter inset={knobProps.panelPadding.padding as string}>{children}</PageGutter>
|
|
236
|
+
</YStack>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
121
240
|
/**
|
|
122
241
|
* Outer page shell. Pairs with PageHeader/Section/EmptyState for thin
|
|
123
242
|
* compose-only screens.
|
|
@@ -139,7 +258,7 @@ export interface ScreenProps extends YStackProps {
|
|
|
139
258
|
* <FrappeImageView doctype="Pokemon" />
|
|
140
259
|
* </Screen>
|
|
141
260
|
*/
|
|
142
|
-
|
|
261
|
+
function PageShell({
|
|
143
262
|
children,
|
|
144
263
|
scroll = true,
|
|
145
264
|
maxWidth = CONTENT_MAX_WIDTH,
|
|
@@ -172,7 +291,9 @@ export function Screen({
|
|
|
172
291
|
insetToken lets PageHeader bleed its hairline to the column edges. */}
|
|
173
292
|
<PageHeadingScope insetToken={noPadding ? null : (knobProps.panelPadding.padding as string)}>
|
|
174
293
|
<PageGutter inset={noPadding ? null : (knobProps.panelPadding.padding as string)}>
|
|
175
|
-
{
|
|
294
|
+
<ScreenNesting scrolls={scroll} inset={inset} capped={cap !== null}>
|
|
295
|
+
{children}
|
|
296
|
+
</ScreenNesting>
|
|
176
297
|
</PageGutter>
|
|
177
298
|
</PageHeadingScope>
|
|
178
299
|
</YStack>
|
|
@@ -735,7 +856,7 @@ function backCaret(Caret: typeof CaretLeftIcon) {
|
|
|
735
856
|
strokeLinejoin?: "round";
|
|
736
857
|
}) {
|
|
737
858
|
return (
|
|
738
|
-
<XStack marginInlineStart={-Math.round(size * CARET_OPTICAL_INSET)}>
|
|
859
|
+
<XStack data-back-caret="" marginInlineStart={-Math.round(size * CARET_OPTICAL_INSET)}>
|
|
739
860
|
<Caret size={size} color={color} weight={weight} {...stroke} />
|
|
740
861
|
</XStack>
|
|
741
862
|
);
|
|
@@ -752,7 +873,9 @@ export interface PageBackButtonProps extends Omit<ButtonProps, "children"> {
|
|
|
752
873
|
|
|
753
874
|
/**
|
|
754
875
|
* The page's back control. It sits in ScreenToolbar's leading slot, never on
|
|
755
|
-
* a row of its own
|
|
876
|
+
* a row of its own. The button pulls out by its padding (Button `edge`) and
|
|
877
|
+
* the caret by its glyph's bearing, so the caret's point is on the content
|
|
878
|
+
* gutter, the large title's leading edge (FZ-7993).
|
|
756
879
|
*/
|
|
757
880
|
export function PageBackButton({ label, ...props }: PageBackButtonProps) {
|
|
758
881
|
const control = useTopBarControl();
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LC-159, nested Screen amendment (FZ-7993): a Screen inside another
|
|
3
|
+
* Screen's content merges into it. The parent keeps the page's one gutter,
|
|
4
|
+
* one scroll view and one pinned bar; the nested Screen adds only what the
|
|
5
|
+
* parent lacks. Kitchen Sink found it: a story that renders its own page sat
|
|
6
|
+
* a second gutter in, scrolled in a second scroll view, and left an empty
|
|
7
|
+
* band under its content.
|
|
8
|
+
*
|
|
9
|
+
* jsdom cannot cascade Tamagui's atomic CSS; these read the atoms.
|
|
10
|
+
*/
|
|
11
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
12
|
+
import { usePageGutter } from "@multiplatform.one/theme";
|
|
13
|
+
import { act, cleanup, fireEvent, screen } from "@testing-library/react";
|
|
14
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
15
|
+
import { GutterFrame, PageHeader, Screen, ScreenToolbar } from "./page";
|
|
16
|
+
|
|
17
|
+
const TITLE_BOTTOM = 120;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.spyOn(Element.prototype, "getBoundingClientRect").mockImplementation(function (this: Element) {
|
|
21
|
+
const bottom = this.tagName === "H1" ? TITLE_BOTTOM : 0;
|
|
22
|
+
return { top: 0, bottom, left: 0, right: 0, width: 0, height: bottom, x: 0, y: 0 } as DOMRect;
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vi.restoreAllMocks();
|
|
28
|
+
cleanup();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const side = ["_pl-", "_pr-", "_p-", "_px-", "_ps-", "_pe-"];
|
|
32
|
+
|
|
33
|
+
function sideAtoms(el: Element | null): string[] {
|
|
34
|
+
return String((el as HTMLElement | null)?.className || "")
|
|
35
|
+
.split(" ")
|
|
36
|
+
.filter((c) => side.some((p) => c.startsWith(p)))
|
|
37
|
+
.sort();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function frames(container: HTMLElement) {
|
|
41
|
+
const all = [...container.querySelectorAll('[data-testid="screen"]')];
|
|
42
|
+
const nested = all.filter((el) => el.hasAttribute("data-screen-nested"));
|
|
43
|
+
const pages = all.filter((el) => !el.hasAttribute("data-screen-nested"));
|
|
44
|
+
return { pages, nested };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function GutterProbe() {
|
|
48
|
+
return <span data-testid="gutter">{usePageGutter() ?? "none"}</span>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const innerScroll = { testID: "inner-scroll" } as never;
|
|
52
|
+
|
|
53
|
+
describe("a Screen nested in a scrolling, padded Screen", () => {
|
|
54
|
+
function host() {
|
|
55
|
+
return renderWithProviders(
|
|
56
|
+
<Screen
|
|
57
|
+
scrollViewProps={{ testID: "page-scroll" } as never}
|
|
58
|
+
topBar={<ScreenToolbar leading={<span>Back</span>} />}
|
|
59
|
+
>
|
|
60
|
+
<PageHeader title="DataTable" />
|
|
61
|
+
<Screen
|
|
62
|
+
scrollViewProps={innerScroll}
|
|
63
|
+
topBar={<ScreenToolbar leading={<span>Story bar</span>} />}
|
|
64
|
+
>
|
|
65
|
+
<PageHeader title="People" divider={false} />
|
|
66
|
+
<GutterProbe />
|
|
67
|
+
<div style={{ height: 2000 }} />
|
|
68
|
+
</Screen>
|
|
69
|
+
</Screen>,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
it("keeps one gutter: the page pads its sides, the nested page adds none", () => {
|
|
74
|
+
const { container } = host();
|
|
75
|
+
const { pages, nested } = frames(container);
|
|
76
|
+
expect(pages).toHaveLength(1);
|
|
77
|
+
expect(nested).toHaveLength(1);
|
|
78
|
+
expect(sideAtoms(pages[0]!).length).toBeGreaterThan(0);
|
|
79
|
+
expect(sideAtoms(nested[0]!)).toEqual([]);
|
|
80
|
+
expect(screen.getByTestId("gutter").textContent).not.toBe("none");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("keeps one scroll view: the nested page scrolls with its parent", () => {
|
|
84
|
+
host();
|
|
85
|
+
expect(screen.getByTestId("page-scroll").contains(screen.getByText("People"))).toBe(true);
|
|
86
|
+
expect(screen.queryByTestId("inner-scroll")).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("pins one bar; the nested page's bar is an inline toolbar at the head of its content", () => {
|
|
90
|
+
const { container } = host();
|
|
91
|
+
const pinned = container.querySelectorAll("[data-top-bar]");
|
|
92
|
+
expect(pinned).toHaveLength(1);
|
|
93
|
+
expect(pinned[0]!.textContent).toContain("Back");
|
|
94
|
+
const storyBar = screen.getByText("Story bar");
|
|
95
|
+
expect(pinned[0]!.contains(storyBar)).toBe(false);
|
|
96
|
+
expect(frames(container).nested[0]!.contains(storyBar)).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("leaves the parent's large title in its bar when the nested title scrolls away too", async () => {
|
|
100
|
+
const { container } = host();
|
|
101
|
+
const scroller = screen.getByTestId("page-scroll");
|
|
102
|
+
await act(async () => {
|
|
103
|
+
fireEvent.scroll(scroller, { target: { scrollTop: TITLE_BOTTOM + 40 } });
|
|
104
|
+
await new Promise((resolve) => setTimeout(resolve, 120));
|
|
105
|
+
});
|
|
106
|
+
const title = container.querySelector("[data-bar-title]") as HTMLElement;
|
|
107
|
+
expect(title.textContent).toBe("DataTable");
|
|
108
|
+
expect(title.getAttribute("aria-hidden")).toBe("false");
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe("a Screen nested in a Screen that does not scroll", () => {
|
|
113
|
+
it("owns the one scroll view and still adds no gutter of its own", () => {
|
|
114
|
+
const { container } = renderWithProviders(
|
|
115
|
+
<Screen scroll={false}>
|
|
116
|
+
<Screen scrollViewProps={innerScroll}>
|
|
117
|
+
<span>Rows</span>
|
|
118
|
+
</Screen>
|
|
119
|
+
</Screen>,
|
|
120
|
+
);
|
|
121
|
+
expect(screen.getByTestId("inner-scroll").contains(screen.getByText("Rows"))).toBe(true);
|
|
122
|
+
const { nested } = frames(container);
|
|
123
|
+
expect(sideAtoms(nested[0]!)).toEqual([]);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe("a Screen nested in an unpadded Screen", () => {
|
|
128
|
+
it("supplies the gutter the parent left out, once", () => {
|
|
129
|
+
const { container } = renderWithProviders(
|
|
130
|
+
<Screen scroll={false} noPadding>
|
|
131
|
+
<Screen scroll={false}>
|
|
132
|
+
<GutterProbe />
|
|
133
|
+
</Screen>
|
|
134
|
+
</Screen>,
|
|
135
|
+
);
|
|
136
|
+
const { pages, nested } = frames(container);
|
|
137
|
+
expect(sideAtoms(pages[0]!)).toEqual([]);
|
|
138
|
+
expect(sideAtoms(nested[0]!).length).toBeGreaterThan(0);
|
|
139
|
+
expect(screen.getByTestId("gutter").textContent).not.toBe("none");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("a third level adds nothing once a gutter is on the page", () => {
|
|
143
|
+
const { container } = renderWithProviders(
|
|
144
|
+
<Screen scroll={false} noPadding>
|
|
145
|
+
<Screen scroll={false}>
|
|
146
|
+
<Screen scroll={false}>
|
|
147
|
+
<span>Deep</span>
|
|
148
|
+
</Screen>
|
|
149
|
+
</Screen>
|
|
150
|
+
</Screen>,
|
|
151
|
+
);
|
|
152
|
+
const { nested } = frames(container);
|
|
153
|
+
expect(nested).toHaveLength(2);
|
|
154
|
+
expect(sideAtoms(nested[0]!).length).toBeGreaterThan(0);
|
|
155
|
+
expect(sideAtoms(nested[1]!)).toEqual([]);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe("a Screen on its own", () => {
|
|
160
|
+
it("is a page, not a nested one", () => {
|
|
161
|
+
const { container } = renderWithProviders(
|
|
162
|
+
<Screen scrollViewProps={{ testID: "page-scroll" } as never}>
|
|
163
|
+
<span>Alone</span>
|
|
164
|
+
</Screen>,
|
|
165
|
+
);
|
|
166
|
+
const { pages, nested } = frames(container);
|
|
167
|
+
expect(pages).toHaveLength(1);
|
|
168
|
+
expect(nested).toHaveLength(0);
|
|
169
|
+
expect(sideAtoms(pages[0]!).length).toBeGreaterThan(0);
|
|
170
|
+
expect(screen.getByTestId("page-scroll")).toBeTruthy();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe("GutterFrame: content that may or may not sit in a page", () => {
|
|
175
|
+
it("adds no side padding inside a padded Screen, so a story's cards sit on the page line", () => {
|
|
176
|
+
const { container } = renderWithProviders(
|
|
177
|
+
<Screen scroll={false}>
|
|
178
|
+
<PageHeader title="DataTable" />
|
|
179
|
+
<GutterFrame>
|
|
180
|
+
<GutterProbe />
|
|
181
|
+
</GutterFrame>
|
|
182
|
+
</Screen>,
|
|
183
|
+
);
|
|
184
|
+
const frame = container.querySelector("[data-gutter-frame]");
|
|
185
|
+
expect(frame?.getAttribute("data-gutter-frame")).toBe("page");
|
|
186
|
+
expect(sideAtoms(frame)).toEqual([]);
|
|
187
|
+
expect(screen.getByTestId("gutter").textContent).not.toBe("none");
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("pads by the gutter and declares it when no page applies one", () => {
|
|
191
|
+
const { container } = renderWithProviders(
|
|
192
|
+
<GutterFrame>
|
|
193
|
+
<GutterProbe />
|
|
194
|
+
</GutterFrame>,
|
|
195
|
+
);
|
|
196
|
+
const frame = container.querySelector("[data-gutter-frame]");
|
|
197
|
+
expect(frame?.getAttribute("data-gutter-frame")).toBe("own");
|
|
198
|
+
expect(sideAtoms(frame).length).toBeGreaterThan(0);
|
|
199
|
+
expect(screen.getByTestId("gutter").textContent).not.toBe("none");
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -307,3 +307,26 @@ export function TopBarSlot({ children, ...value }: TopBarSlotValue & { children:
|
|
|
307
307
|
export function useTopBarSlot(): TopBarSlotValue | null {
|
|
308
308
|
return useContext(TopBarSlotContext);
|
|
309
309
|
}
|
|
310
|
+
|
|
311
|
+
const inertTitle = () => () => undefined;
|
|
312
|
+
const inertTitleBottom = () => undefined;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* A nested Screen's content scrolls in its parent's scroll view, so it reads
|
|
316
|
+
* the parent's scroll actions, but its own large title stays a heading in the
|
|
317
|
+
* content: the parent's bar keeps showing the parent's title.
|
|
318
|
+
*/
|
|
319
|
+
export function ParentScrollScope({ children }: { children: ReactNode }) {
|
|
320
|
+
const actions = useContext(ScreenScrollActionsContext);
|
|
321
|
+
const scoped = useMemo<ScreenScrollActions | null>(
|
|
322
|
+
() =>
|
|
323
|
+
actions ? { ...actions, registerTitle: inertTitle, setTitleBottom: inertTitleBottom } : null,
|
|
324
|
+
[actions],
|
|
325
|
+
);
|
|
326
|
+
if (!scoped) return <>{children}</>;
|
|
327
|
+
return (
|
|
328
|
+
<ScreenScrollActionsContext.Provider value={scoped}>
|
|
329
|
+
{children}
|
|
330
|
+
</ScreenScrollActionsContext.Provider>
|
|
331
|
+
);
|
|
332
|
+
}
|