@multiplatform.one/components 7.88.4 → 7.88.5
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/Dialog.cjs +5 -4
- package/dist/cjs/Dialog.native.js +7 -4
- package/dist/cjs/Dialog.native.js.map +1 -1
- package/dist/cjs/SheetModal/index.native.js +5 -2
- package/dist/cjs/SheetModal/index.native.js.map +1 -1
- package/dist/cjs/appShell/SystemBar.cjs +21 -5
- package/dist/cjs/appShell/SystemBar.native.js +21 -5
- package/dist/cjs/appShell/SystemBar.native.js.map +1 -1
- package/dist/cjs/appShell/systemBarFit.cjs +67 -0
- package/dist/cjs/appShell/systemBarFit.native.js +74 -0
- package/dist/cjs/appShell/systemBarFit.native.js.map +1 -0
- package/dist/cjs/images/Image/ImageFrame.cjs +23 -12
- package/dist/cjs/images/Image/ImageFrame.native.js +24 -12
- package/dist/cjs/images/Image/ImageFrame.native.js.map +1 -1
- package/dist/cjs/layouts/AsyncBoundary.cjs +11 -16
- package/dist/cjs/layouts/AsyncBoundary.native.js +16 -16
- package/dist/cjs/layouts/AsyncBoundary.native.js.map +1 -1
- package/dist/cjs/layouts/EmptyState.cjs +4 -2
- package/dist/cjs/layouts/EmptyState.native.js +4 -2
- package/dist/cjs/layouts/EmptyState.native.js.map +1 -1
- package/dist/cjs/layouts/PaneScaffold.cjs +2 -1
- package/dist/cjs/layouts/PaneScaffold.native.js +2 -1
- package/dist/cjs/layouts/PaneScaffold.native.js.map +1 -1
- package/dist/cjs/layouts/asyncFailure.cjs +5 -1
- package/dist/cjs/layouts/asyncFailure.native.js +5 -1
- package/dist/cjs/layouts/asyncFailure.native.js.map +1 -1
- package/dist/cjs/surfaces.cjs +1 -1
- package/dist/cjs/surfaces.native.js +1 -1
- package/dist/cjs/surfaces.native.js.map +1 -1
- 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/Carousel/geometry.native.js.map +1 -1
- package/dist/esm/Carousel/index.native.js.map +1 -1
- package/dist/esm/CheckGlyph/MenuCheckColumn.native.js.map +1 -1
- package/dist/esm/CheckGlyph/index.native.js.map +1 -1
- package/dist/esm/Chip/index.native.js.map +1 -1
- package/dist/esm/ChoiceChips/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/CopyMenuButton.native.js.map +1 -1
- package/dist/esm/CopyField/index.native.js.map +1 -1
- package/dist/esm/Dialog.mjs +6 -5
- package/dist/esm/Dialog.mjs.map +1 -1
- package/dist/esm/Dialog.native.js +8 -5
- package/dist/esm/Dialog.native.js.map +1 -1
- package/dist/esm/Diff/diff.native.js.map +1 -1
- package/dist/esm/Diff/index.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/ElapsedProgress/index.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/MachineLiteral/index.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/index.native.js +5 -2
- package/dist/esm/SheetModal/index.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/SortableList/useUserOrder.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/AppShell.native.js.map +1 -1
- package/dist/esm/appShell/BottomChromeClearance.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.mjs +21 -5
- package/dist/esm/appShell/SystemBar.mjs.map +1 -1
- package/dist/esm/appShell/SystemBar.native.js +21 -5
- 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/appShell/systemBarFit.mjs +42 -0
- package/dist/esm/appShell/systemBarFit.mjs.map +1 -0
- package/dist/esm/appShell/systemBarFit.native.js +46 -0
- package/dist/esm/appShell/systemBarFit.native.js.map +1 -0
- 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/LogView.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.mjs +25 -15
- package/dist/esm/images/Image/ImageFrame.mjs.map +1 -1
- package/dist/esm/images/Image/ImageFrame.native.js +26 -15
- 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.mjs +12 -17
- package/dist/esm/layouts/AsyncBoundary.mjs.map +1 -1
- package/dist/esm/layouts/AsyncBoundary.native.js +17 -17
- 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.mjs +5 -3
- package/dist/esm/layouts/EmptyState.mjs.map +1 -1
- package/dist/esm/layouts/EmptyState.native.js +5 -3
- 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.mjs +3 -2
- package/dist/esm/layouts/PaneScaffold.mjs.map +1 -1
- package/dist/esm/layouts/PaneScaffold.native.js +3 -2
- 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/StatusGlyphStrip.native.js.map +1 -1
- package/dist/esm/layouts/ViewSwitcher.native.js.map +1 -1
- package/dist/esm/layouts/asyncFailure.mjs +5 -1
- package/dist/esm/layouts/asyncFailure.mjs.map +1 -1
- package/dist/esm/layouts/asyncFailure.native.js +5 -1
- package/dist/esm/layouts/asyncFailure.native.js.map +1 -1
- package/dist/esm/layouts/attachments.native.js.map +1 -1
- package/dist/esm/layouts/barTitleSpan.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.native.js.map +1 -1
- package/dist/esm/layouts/pageHeadingScope.native.js.map +1 -1
- 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.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.mjs +1 -1
- package/dist/esm/surfaces.mjs.map +1 -1
- package/dist/esm/surfaces.native.js +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/CardGrid.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.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/sameNameScope.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/usePageFlowLoadMore.native.js.map +1 -1
- package/dist/esm/views/widgetChrome.native.js.map +1 -1
- package/dist/jsx/Dialog.mjs +6 -5
- package/dist/jsx/Dialog.mjs.map +1 -1
- package/dist/jsx/Dialog.native.js +7 -4
- package/dist/jsx/Dialog.native.js.map +1 -1
- package/dist/jsx/SheetModal/index.native.js +5 -2
- package/dist/jsx/SheetModal/index.native.js.map +1 -1
- package/dist/jsx/appShell/SystemBar.mjs +21 -5
- package/dist/jsx/appShell/SystemBar.mjs.map +1 -1
- package/dist/jsx/appShell/SystemBar.native.js +21 -5
- package/dist/jsx/appShell/SystemBar.native.js.map +1 -1
- package/dist/jsx/appShell/systemBarFit.mjs +42 -0
- package/dist/jsx/appShell/systemBarFit.mjs.map +1 -0
- package/dist/jsx/appShell/systemBarFit.native.js +74 -0
- package/dist/jsx/appShell/systemBarFit.native.js.map +1 -0
- package/dist/jsx/images/Image/ImageFrame.mjs +25 -15
- package/dist/jsx/images/Image/ImageFrame.mjs.map +1 -1
- package/dist/jsx/images/Image/ImageFrame.native.js +24 -12
- package/dist/jsx/images/Image/ImageFrame.native.js.map +1 -1
- package/dist/jsx/layouts/AsyncBoundary.mjs +12 -17
- package/dist/jsx/layouts/AsyncBoundary.mjs.map +1 -1
- package/dist/jsx/layouts/AsyncBoundary.native.js +16 -16
- package/dist/jsx/layouts/AsyncBoundary.native.js.map +1 -1
- package/dist/jsx/layouts/EmptyState.mjs +5 -3
- package/dist/jsx/layouts/EmptyState.mjs.map +1 -1
- package/dist/jsx/layouts/EmptyState.native.js +4 -2
- package/dist/jsx/layouts/EmptyState.native.js.map +1 -1
- package/dist/jsx/layouts/PaneScaffold.mjs +3 -2
- package/dist/jsx/layouts/PaneScaffold.mjs.map +1 -1
- package/dist/jsx/layouts/PaneScaffold.native.js +2 -1
- package/dist/jsx/layouts/PaneScaffold.native.js.map +1 -1
- package/dist/jsx/layouts/asyncFailure.mjs +5 -1
- package/dist/jsx/layouts/asyncFailure.mjs.map +1 -1
- package/dist/jsx/layouts/asyncFailure.native.js +5 -1
- package/dist/jsx/layouts/asyncFailure.native.js.map +1 -1
- package/dist/jsx/surfaces.mjs +1 -1
- package/dist/jsx/surfaces.mjs.map +1 -1
- package/dist/jsx/surfaces.native.js +1 -1
- package/dist/jsx/surfaces.native.js.map +1 -1
- package/package.json +9 -9
- package/src/Dialog.tsx +6 -3
- package/src/SheetFrame.stories.tsx +32 -1
- package/src/SheetModal/SheetModal.elevation.spec.tsx +79 -0
- package/src/SheetModal/index.native.tsx +7 -2
- package/src/appShell/SystemBar.phoneWidth.spec.tsx +91 -0
- package/src/appShell/SystemBar.tsx +28 -7
- package/src/appShell/systemBarFit.ts +52 -0
- package/src/images/Image/Image.spec.tsx +41 -0
- package/src/images/Image/Image.stories.tsx +24 -0
- package/src/images/Image/ImageFrame.tsx +25 -8
- package/src/layouts/AsyncBoundary.spec.tsx +20 -0
- package/src/layouts/AsyncBoundary.tsx +19 -15
- package/src/layouts/EmptyState.tsx +5 -3
- package/src/layouts/PaneScaffold.tsx +3 -7
- package/src/layouts/asyncFailure.spec.ts +100 -0
- package/src/layouts/asyncFailure.ts +6 -7
- package/src/surfaces.spec.tsx +3 -2
- package/src/surfaces.tsx +6 -4
- package/types/Dialog.d.ts.map +1 -1
- package/types/SheetModal/index.native.d.ts.map +1 -1
- package/types/appShell/SystemBar.d.ts.map +1 -1
- package/types/appShell/systemBarFit.d.ts +25 -0
- package/types/appShell/systemBarFit.d.ts.map +1 -0
- package/types/images/Image/ImageFrame.d.ts +1 -0
- package/types/images/Image/ImageFrame.d.ts.map +1 -1
- package/types/layouts/AsyncBoundary.d.ts.map +1 -1
- package/types/layouts/EmptyState.d.ts.map +1 -1
- package/types/layouts/PaneScaffold.d.ts.map +1 -1
- package/types/layouts/asyncFailure.d.ts.map +1 -1
- package/types/surfaces.d.ts.map +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-9003: at phone width the clock and the scope triggers never share a
|
|
3
|
+
* horizontal span. Widths are the iPhone 17 Pro shots on FZ-9003 (402pt row,
|
|
4
|
+
* "Acme Corp" + "Production" ≈ 230pt, ~165pt left beside a centred clock) and
|
|
5
|
+
* an 820pt iPad row.
|
|
6
|
+
*/
|
|
7
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
8
|
+
import { act, cleanup, renderHook, screen } from "@testing-library/react";
|
|
9
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
10
|
+
import { useSystemBarFit } from "./systemBarFit";
|
|
11
|
+
|
|
12
|
+
const fit = vi.hoisted(() => ({ showClock: true }));
|
|
13
|
+
vi.mock("./systemBarFit", async (importOriginal) => {
|
|
14
|
+
const actual = await importOriginal<typeof import("./systemBarFit")>();
|
|
15
|
+
return {
|
|
16
|
+
...actual,
|
|
17
|
+
useSystemBarFit: () => ({
|
|
18
|
+
...actual.useSystemBarFit(),
|
|
19
|
+
...(fit.showClock ? {} : { showClock: false }),
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
cleanup();
|
|
26
|
+
fit.showClock = true;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const layout = (width: number) => ({ nativeEvent: { layout: { width } } });
|
|
30
|
+
|
|
31
|
+
/** Measure as the bar does: the row, the menus, then the start zone beside a centred clock. */
|
|
32
|
+
function measure(row: number, menus: number, clock: number, gap: number) {
|
|
33
|
+
const hook = renderHook(() => useSystemBarFit());
|
|
34
|
+
act(() => hook.result.current.onRowLayout(layout(row)));
|
|
35
|
+
act(() => hook.result.current.onMenusLayout(layout(menus)));
|
|
36
|
+
const zone = (row - clock) / 2 - gap;
|
|
37
|
+
act(() => hook.result.current.onZoneLayout(layout(zone)));
|
|
38
|
+
return { hook, zone };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe("SystemBar at phone width (FZ-9003)", () => {
|
|
42
|
+
it("the clock gives way when the menus outrun the zone beside a centred clock", () => {
|
|
43
|
+
const { hook } = measure(378, 230, 52, 12);
|
|
44
|
+
expect(hook.result.current.showClock).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("a shown clock never shares a span with the menus", () => {
|
|
48
|
+
for (const [row, menus] of [
|
|
49
|
+
[378, 230],
|
|
50
|
+
[796, 230],
|
|
51
|
+
[796, 380],
|
|
52
|
+
[1000, 230],
|
|
53
|
+
]) {
|
|
54
|
+
const clock = 52;
|
|
55
|
+
const gap = 12;
|
|
56
|
+
const { hook } = measure(row, menus, clock, gap);
|
|
57
|
+
const clockStart = (row - clock) / 2;
|
|
58
|
+
if (hook.result.current.showClock) expect(menus + gap).toBeLessThanOrEqual(clockStart);
|
|
59
|
+
else expect(menus + gap).toBeGreaterThan(clockStart);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("a zone measured before its row still hides the clock", () => {
|
|
64
|
+
const hook = renderHook(() => useSystemBarFit());
|
|
65
|
+
act(() => hook.result.current.onMenusLayout(layout(230)));
|
|
66
|
+
act(() => hook.result.current.onZoneLayout(layout(151)));
|
|
67
|
+
act(() => hook.result.current.onRowLayout(layout(378)));
|
|
68
|
+
expect(hook.result.current.showClock).toBe(false);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("hiding the clock does not flip the verdict back, and a new row width measures again", () => {
|
|
72
|
+
const { hook } = measure(378, 230, 52, 12);
|
|
73
|
+
act(() => hook.result.current.onZoneLayout(layout(290)));
|
|
74
|
+
expect(hook.result.current.showClock).toBe(false);
|
|
75
|
+
act(() => hook.result.current.onRowLayout(layout(796)));
|
|
76
|
+
expect(hook.result.current.showClock).toBe(true);
|
|
77
|
+
act(() => hook.result.current.onZoneLayout(layout(360)));
|
|
78
|
+
expect(hook.result.current.showClock).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("with the clock given way, the bar draws no clock and the menus claim the free width", async () => {
|
|
82
|
+
fit.showClock = false;
|
|
83
|
+
const { SystemBar } = await import("./SystemBar");
|
|
84
|
+
renderWithProviders(
|
|
85
|
+
<SystemBar menus={<span>Acme</span>} now={new Date(2026, 9, 23, 9, 41)} locale="en-US" />,
|
|
86
|
+
);
|
|
87
|
+
expect(screen.queryByTestId("system-bar-clock")).toBeNull();
|
|
88
|
+
expect(screen.queryByTestId("system-bar-centre")).toBeNull();
|
|
89
|
+
expect(screen.getByTestId("system-bar-start").textContent).toBe("Acme");
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -11,7 +11,9 @@ import { IconSlot } from "@multiplatform.one/theme";
|
|
|
11
11
|
* Dynamic Island, while the content sits below the inset;
|
|
12
12
|
* - three zones: the start and end zones share the free width equally
|
|
13
13
|
* (`flex={1}` with a zero basis), so the clock sits on the true centre
|
|
14
|
-
* without a spread justification (LC-102 HUG-CONTENT)
|
|
14
|
+
* without a spread justification (LC-102 HUG-CONTENT). When the menus do
|
|
15
|
+
* not fit beside a centred clock (a phone), the clock gives way and the
|
|
16
|
+
* menus take the width (FZ-9003); on a phone the system shows the time;
|
|
15
17
|
* - status is SHOWN, never narrated (LC-104): each glyph carries its words
|
|
16
18
|
* as its accessible name and no status sentence is drawn beside it.
|
|
17
19
|
*/
|
|
@@ -19,6 +21,7 @@ import { hairline, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
|
19
21
|
import type { ComponentType, ReactNode } from "react";
|
|
20
22
|
import { useEffect, useState } from "react";
|
|
21
23
|
import { XStack, YStack } from "tamagui";
|
|
24
|
+
import { useSystemBarFit } from "./systemBarFit";
|
|
22
25
|
import { useTopInsetStyle } from "./topInset";
|
|
23
26
|
import { SizableText } from "../Text";
|
|
24
27
|
|
|
@@ -88,6 +91,7 @@ export function SystemBar({
|
|
|
88
91
|
const { knobProps } = useResolvedKnobs();
|
|
89
92
|
const insetStyle = useTopInsetStyle();
|
|
90
93
|
const iconSize = Number(knobProps.controlIcon?.width) || undefined;
|
|
94
|
+
const { showClock, onRowLayout, onZoneLayout, onMenusLayout } = useSystemBarFit();
|
|
91
95
|
return (
|
|
92
96
|
<YStack
|
|
93
97
|
role="banner"
|
|
@@ -100,13 +104,30 @@ export function SystemBar({
|
|
|
100
104
|
data-safe-area={extendIntoSafeArea ? "top" : undefined}
|
|
101
105
|
data-testid={testID}
|
|
102
106
|
>
|
|
103
|
-
<XStack
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
<XStack
|
|
108
|
+
minHeight="$3"
|
|
109
|
+
alignItems="center"
|
|
110
|
+
paddingHorizontal="$3"
|
|
111
|
+
gap="$3"
|
|
112
|
+
onLayout={onRowLayout}
|
|
113
|
+
>
|
|
114
|
+
<XStack
|
|
115
|
+
flex={1}
|
|
116
|
+
flexBasis={showClock ? 0 : "auto"}
|
|
117
|
+
minWidth={0}
|
|
118
|
+
alignItems="center"
|
|
119
|
+
onLayout={onZoneLayout}
|
|
120
|
+
data-testid="system-bar-start"
|
|
121
|
+
>
|
|
122
|
+
<XStack flexShrink={0} alignItems="center" gap="$1" onLayout={onMenusLayout}>
|
|
123
|
+
{menus}
|
|
124
|
+
</XStack>
|
|
109
125
|
</XStack>
|
|
126
|
+
{showClock ? (
|
|
127
|
+
<XStack flexShrink={0} alignItems="center" data-testid="system-bar-centre">
|
|
128
|
+
{clock ?? <SystemBarClock now={now} locale={locale} />}
|
|
129
|
+
</XStack>
|
|
130
|
+
) : null}
|
|
110
131
|
<XStack
|
|
111
132
|
flex={1}
|
|
112
133
|
flexBasis={0}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
type LayoutEvent = { nativeEvent: { layout: { width: number } } };
|
|
4
|
+
|
|
5
|
+
interface Widths {
|
|
6
|
+
row?: number;
|
|
7
|
+
zone?: number;
|
|
8
|
+
menus?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* FZ-9003. The clock sits on the bar's true centre only while the start zone,
|
|
13
|
+
* as wide as the centred clock leaves it, holds the menus. Otherwise the clock
|
|
14
|
+
* gives way and the menus claim the centre (at 402pt "Acme Corp" and
|
|
15
|
+
* "Production" need ~230 of the ~165 left beside a centred clock). The zone is
|
|
16
|
+
* measured only while the clock shows, so hiding it cannot flip the verdict
|
|
17
|
+
* back. A new row width measures again only while the clock is hidden: a
|
|
18
|
+
* child's layout lands before its row's, so dropping the zone on every row
|
|
19
|
+
* measure would lose the first zone and leave the clock over the menus.
|
|
20
|
+
*/
|
|
21
|
+
export function useSystemBarFit() {
|
|
22
|
+
const [widths, setWidths] = useState<Widths>({});
|
|
23
|
+
const showClock = !(
|
|
24
|
+
widths.zone !== undefined &&
|
|
25
|
+
widths.menus !== undefined &&
|
|
26
|
+
widths.menus > widths.zone + 0.5
|
|
27
|
+
);
|
|
28
|
+
const onRowLayout = useCallback(
|
|
29
|
+
(event: LayoutEvent) => {
|
|
30
|
+
const row = event.nativeEvent.layout.width;
|
|
31
|
+
setWidths((prev) => {
|
|
32
|
+
if (prev.row === row) return prev;
|
|
33
|
+
if (showClock || prev.row === undefined) return { ...prev, row };
|
|
34
|
+
return { menus: prev.menus, row };
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
[showClock],
|
|
38
|
+
);
|
|
39
|
+
const onZoneLayout = useCallback(
|
|
40
|
+
(event: LayoutEvent) => {
|
|
41
|
+
if (!showClock) return;
|
|
42
|
+
const zone = event.nativeEvent.layout.width;
|
|
43
|
+
setWidths((prev) => (prev.zone === zone ? prev : { ...prev, zone }));
|
|
44
|
+
},
|
|
45
|
+
[showClock],
|
|
46
|
+
);
|
|
47
|
+
const onMenusLayout = useCallback((event: LayoutEvent) => {
|
|
48
|
+
const menus = event.nativeEvent.layout.width;
|
|
49
|
+
setWidths((prev) => (prev.menus === menus ? prev : { ...prev, menus }));
|
|
50
|
+
}, []);
|
|
51
|
+
return { showClock, onRowLayout, onZoneLayout, onMenusLayout };
|
|
52
|
+
}
|
|
@@ -53,6 +53,47 @@ describe("Image", () => {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
describe("blur placeholder (FZ-8080)", () => {
|
|
57
|
+
const BLUR = "https://example.com/blur.jpg";
|
|
58
|
+
|
|
59
|
+
it("draws the loading placeholder blurred 12, the same radius as native", () => {
|
|
60
|
+
const { container } = renderWithProviders(
|
|
61
|
+
<Image src={SRC} placeholder="blur" placeholderSrc={BLUR} width={100} height={100} />,
|
|
62
|
+
);
|
|
63
|
+
const blurred = [...container.querySelectorAll<HTMLElement>("*")].filter((node) =>
|
|
64
|
+
node.style.filter.includes("blur(12px)"),
|
|
65
|
+
);
|
|
66
|
+
expect(blurred.length).toBeGreaterThan(0);
|
|
67
|
+
expect(container.innerHTML).toContain(BLUR);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("shows a percent-encoded utf8 SVG placeholder encoded once on web", () => {
|
|
71
|
+
const svg =
|
|
72
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="8" height="4"><rect width="8" height="4" fill="#3b6ea8"/></svg>';
|
|
73
|
+
const { container } = renderWithProviders(
|
|
74
|
+
<Image
|
|
75
|
+
src={SRC}
|
|
76
|
+
placeholder="blur"
|
|
77
|
+
placeholderSrc={`data:image/svg+xml;utf8,${encodeURIComponent(svg)}`}
|
|
78
|
+
width={100}
|
|
79
|
+
height={100}
|
|
80
|
+
/>,
|
|
81
|
+
);
|
|
82
|
+
const html = container.innerHTML;
|
|
83
|
+
expect(html).toContain(encodeURIComponent(svg));
|
|
84
|
+
expect(html).not.toContain(encodeURIComponent(encodeURIComponent("<svg")));
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("asks for the blur through blurRadius, never a CSS filter in MPO source (LC-206)", () => {
|
|
88
|
+
const frame = readFileSync(
|
|
89
|
+
join(dirname(fileURLToPath(import.meta.url)), "ImageFrame.tsx"),
|
|
90
|
+
"utf8",
|
|
91
|
+
);
|
|
92
|
+
expect(frame).not.toMatch(/filter:\s*["'`]blur\(/);
|
|
93
|
+
expect(frame).toMatch(/blurRadius=\{12\}/);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
56
97
|
describe("web layout props on img", () => {
|
|
57
98
|
it("passes width directly to the img element", () => {
|
|
58
99
|
const { container } = renderWithProviders(<Image src={SRC} alt="test" width={300} />);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
|
|
2
2
|
import { resolveChartPalette } from "@multiplatform.one/theme";
|
|
3
3
|
import { View, XStack, YStack } from "tamagui";
|
|
4
|
+
import { ImageFrame } from "./ImageFrame";
|
|
4
5
|
import { Image } from "./index";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -25,6 +26,7 @@ const palette = resolveChartPalette({ scheme: "light" }).categorical;
|
|
|
25
26
|
const LANDSCAPE_IMG = plateSrc(palette[0] ?? "#3b6ea8", 0, 800, 400);
|
|
26
27
|
const SQUARE_IMG = plateSrc(palette[1] ?? "#6b4ea8", 1, 400, 400);
|
|
27
28
|
const SVG_IMG = plateSrc(palette[2] ?? "#2a9d8f", 2, 200, 200);
|
|
29
|
+
const BLUR_PLATE = `data:image/svg+xml;base64,${btoa(decodeURIComponent(LANDSCAPE_IMG.slice(LANDSCAPE_IMG.indexOf(",") + 1)))}`;
|
|
28
30
|
const GIF_IMG = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
29
31
|
|
|
30
32
|
const meta: Meta<typeof Image> = {
|
|
@@ -268,3 +270,25 @@ export const Gallery: Story = {
|
|
|
268
270
|
</YStack>
|
|
269
271
|
),
|
|
270
272
|
};
|
|
273
|
+
|
|
274
|
+
export const BlurPlaceholder: Story = {
|
|
275
|
+
parameters: {
|
|
276
|
+
docs: {
|
|
277
|
+
description: {
|
|
278
|
+
story:
|
|
279
|
+
"The blur placeholder as it shows while the full image loads: the frame held in its loading state, drawing `placeholderSrc` at blur radius 12 on web and native (FZ-8080).",
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
render: () => (
|
|
284
|
+
<ImageFrame
|
|
285
|
+
alt=""
|
|
286
|
+
width={320}
|
|
287
|
+
aspectRatio={2}
|
|
288
|
+
hasSource
|
|
289
|
+
status="loading"
|
|
290
|
+
placeholder="blur"
|
|
291
|
+
placeholderSrc={BLUR_PLATE}
|
|
292
|
+
/>
|
|
293
|
+
),
|
|
294
|
+
};
|
|
@@ -11,11 +11,29 @@ import {
|
|
|
11
11
|
type GroupOrientation,
|
|
12
12
|
type GroupPosition,
|
|
13
13
|
} from "@multiplatform.one/theme";
|
|
14
|
-
import { Image as
|
|
14
|
+
import { Image as BlurredImage } from "react-native";
|
|
15
|
+
import { View, isWeb } from "tamagui";
|
|
15
16
|
import { Skeleton } from "../../Skeleton";
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
isThumbnailSize,
|
|
19
|
+
objectFitToResizeMode,
|
|
20
|
+
thumbnailPx as resolveThumbnailPx,
|
|
21
|
+
} from "./shared";
|
|
17
22
|
import type { ImagePlaceholder, ImageProps } from "./types";
|
|
18
23
|
|
|
24
|
+
const blurFill = { width: "100%", height: "100%" } as const;
|
|
25
|
+
const svgUtf8Uri = /^(data:image\/svg\+xml;utf8,)([\s\S]*)$/;
|
|
26
|
+
|
|
27
|
+
export function blurPlaceholderUri(src: string): string {
|
|
28
|
+
const match = svgUtf8Uri.exec(src);
|
|
29
|
+
if (!match) return src;
|
|
30
|
+
try {
|
|
31
|
+
return match[1] + decodeURIComponent(match[2]);
|
|
32
|
+
} catch {
|
|
33
|
+
return src;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
export type ImageStatus = "loading" | "loaded" | "error";
|
|
20
38
|
|
|
21
39
|
export type ImageFrameProps = {
|
|
@@ -213,13 +231,12 @@ export function ImageFrame({
|
|
|
213
231
|
{showPlaceholder ? (
|
|
214
232
|
<View position="absolute" top={0} left={0} right={0} bottom={0} pointerEvents="none">
|
|
215
233
|
{placeholder === "blur" && placeholderSrc ? (
|
|
216
|
-
<
|
|
217
|
-
|
|
234
|
+
<BlurredImage
|
|
235
|
+
source={{ uri: blurPlaceholderUri(placeholderSrc) }}
|
|
218
236
|
alt=""
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
{...(isWeb ? { style: { filter: "blur(12px)" } } : { blurRadius: 12 })}
|
|
237
|
+
blurRadius={12}
|
|
238
|
+
resizeMode={objectFitToResizeMode(objectFit) ?? "cover"}
|
|
239
|
+
style={blurFill}
|
|
223
240
|
/>
|
|
224
241
|
) : placeholder === "blur" || placeholder === "skeleton" ? (
|
|
225
242
|
<Skeleton width="100%" height="100%" variant="rounded" />
|
|
@@ -168,6 +168,26 @@ describe("AsyncBoundary", () => {
|
|
|
168
168
|
expect(onRetry).toHaveBeenCalledTimes(1);
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
+
it("renders an error that is not an Error instance as the error state with retry (LC-84, FZ-9278)", () => {
|
|
172
|
+
// GJS hands GLib errors and other realms' Errors through fetch: objects
|
|
173
|
+
// with a message and stack that fail `instanceof Error`.
|
|
174
|
+
const foreign = Object.assign(Object.create(null), {
|
|
175
|
+
message: "Could not connect to localhost: Connection refused",
|
|
176
|
+
stack: "",
|
|
177
|
+
fileName: "soup-fetch.ts",
|
|
178
|
+
lineNumber: 1,
|
|
179
|
+
columnNumber: 1,
|
|
180
|
+
});
|
|
181
|
+
const onRetry = vi.fn();
|
|
182
|
+
renderWithProviders(
|
|
183
|
+
<AsyncBoundary error={foreign} errorTitle="Workspaces unavailable" onRetry={onRetry} />,
|
|
184
|
+
);
|
|
185
|
+
expect(document.querySelector('[data-empty-intent="error"]')).toBeTruthy();
|
|
186
|
+
expect(screen.getByText("Could not connect to localhost: Connection refused")).toBeTruthy();
|
|
187
|
+
fireEvent.click(screen.getByText("Retry"));
|
|
188
|
+
expect(onRetry).toHaveBeenCalledTimes(1);
|
|
189
|
+
});
|
|
190
|
+
|
|
171
191
|
it("hides chrome and Badge counts on error (DG-ST-04)", () => {
|
|
172
192
|
function CountProbe() {
|
|
173
193
|
const count = useAsyncCount(12);
|
|
@@ -14,7 +14,15 @@
|
|
|
14
14
|
import { Button, Spinner } from "@multiplatform.one/forms";
|
|
15
15
|
import { sizeTokenStep, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
16
16
|
import { WarningCircleIcon } from "@phosphor-icons/react";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
createContext,
|
|
19
|
+
isValidElement,
|
|
20
|
+
useContext,
|
|
21
|
+
useEffect,
|
|
22
|
+
useRef,
|
|
23
|
+
useState,
|
|
24
|
+
type ReactNode,
|
|
25
|
+
} from "react";
|
|
18
26
|
import { useTranslation } from "../shared/i18n";
|
|
19
27
|
import { type SizeTokens, XStack, YStack, type YStackProps } from "tamagui";
|
|
20
28
|
import { Alert } from "../Alert";
|
|
@@ -145,10 +153,15 @@ export interface AsyncBoundaryProps extends Omit<YStackProps, "children"> {
|
|
|
145
153
|
// ---------------------------------------------------------------------------
|
|
146
154
|
|
|
147
155
|
function isReactNodeSlot(value: unknown): value is ReactNode {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
return isValidElement(value) || Array.isArray(value);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function errorMessage(error: unknown): string | undefined {
|
|
160
|
+
if (typeof error === "string") return error;
|
|
161
|
+
if (error instanceof Error) return error.message;
|
|
162
|
+
if (typeof error !== "object" || error === null) return undefined;
|
|
163
|
+
const { message } = error as { message?: unknown };
|
|
164
|
+
return typeof message === "string" ? message : undefined;
|
|
152
165
|
}
|
|
153
166
|
|
|
154
167
|
function isActiveError(error: AsyncBoundaryProps["error"]): boolean {
|
|
@@ -189,12 +202,6 @@ interface ReasonCopyOptions {
|
|
|
189
202
|
errorDescription?: string;
|
|
190
203
|
}
|
|
191
204
|
|
|
192
|
-
function errorMessage(error: AsyncBoundaryProps["error"]): string | undefined {
|
|
193
|
-
if (typeof error === "string") return error;
|
|
194
|
-
if (error instanceof Error) return error.message;
|
|
195
|
-
return undefined;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
205
|
function errorCopy(
|
|
199
206
|
error: AsyncBoundaryProps["error"],
|
|
200
207
|
errorTitle: string,
|
|
@@ -233,10 +240,7 @@ function plainErrorCopy(
|
|
|
233
240
|
if (typeof error === "string") {
|
|
234
241
|
return { title: errorTitle, description: errorDescription ?? error };
|
|
235
242
|
}
|
|
236
|
-
|
|
237
|
-
return { title: errorTitle, description: errorDescription ?? error.message };
|
|
238
|
-
}
|
|
239
|
-
return { title: errorTitle, description: errorDescription };
|
|
243
|
+
return { title: errorTitle, description: errorDescription ?? errorMessage(error) };
|
|
240
244
|
}
|
|
241
245
|
|
|
242
246
|
const seenDevWarns = new Set<string>();
|
|
@@ -14,7 +14,7 @@ import { Spinner } from "@multiplatform.one/forms";
|
|
|
14
14
|
import {
|
|
15
15
|
IconSlot,
|
|
16
16
|
Intent,
|
|
17
|
-
|
|
17
|
+
useReadingWidthStyle,
|
|
18
18
|
sizeTokenStep,
|
|
19
19
|
useGlyphColor,
|
|
20
20
|
useResolvedKnobs,
|
|
@@ -103,8 +103,9 @@ function StateSymbol({
|
|
|
103
103
|
* (LC-267).
|
|
104
104
|
*/
|
|
105
105
|
function CommandLine({ command }: { command: string }) {
|
|
106
|
+
const readingWidth = useReadingWidthStyle();
|
|
106
107
|
return (
|
|
107
|
-
<YStack data-empty-command="" alignSelf="center" {...
|
|
108
|
+
<YStack data-empty-command="" alignSelf="center" {...readingWidth}>
|
|
108
109
|
<CodeBlock language="text">{command}</CodeBlock>
|
|
109
110
|
</YStack>
|
|
110
111
|
);
|
|
@@ -130,6 +131,7 @@ export function EmptyState({
|
|
|
130
131
|
...rest
|
|
131
132
|
}: EmptyStateProps) {
|
|
132
133
|
const { knobProps } = useResolvedKnobs({ component: "EmptyState", size });
|
|
134
|
+
const readingWidth = useReadingWidthStyle();
|
|
133
135
|
const small = sizeTokenStep(knobProps.sizeToken) < 0;
|
|
134
136
|
const titleId = useId();
|
|
135
137
|
const isError = intent === "error";
|
|
@@ -203,7 +205,7 @@ export function EmptyState({
|
|
|
203
205
|
{...rest}
|
|
204
206
|
>
|
|
205
207
|
{symbol && isError ? <Intent name="error">{symbol}</Intent> : symbol}
|
|
206
|
-
<YStack alignItems="center" gap="$1" {...
|
|
208
|
+
<YStack alignItems="center" gap="$1" {...readingWidth}>
|
|
207
209
|
{titleNode}
|
|
208
210
|
{descriptionLines.map((line, index) => (
|
|
209
211
|
<Paragraph
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
hairline,
|
|
38
38
|
hairlineWidth,
|
|
39
39
|
pressTargetHitSlop,
|
|
40
|
-
|
|
40
|
+
useReadingWidthStyle,
|
|
41
41
|
useLayoutSizeClass,
|
|
42
42
|
useMultiPane,
|
|
43
43
|
useSemanticGaps,
|
|
@@ -724,13 +724,9 @@ export interface ReadingWidthProps extends YStackProps {
|
|
|
724
724
|
* Full-bleed is the eject (`measure="none"`), not the default.
|
|
725
725
|
*/
|
|
726
726
|
export function ReadingWidth({ measure = READING_WIDTH_CH, children, ...rest }: ReadingWidthProps) {
|
|
727
|
+
const readingWidth = useReadingWidthStyle(measure);
|
|
727
728
|
return (
|
|
728
|
-
<YStack
|
|
729
|
-
alignSelf="flex-start"
|
|
730
|
-
{...readingWidthStyle(measure)}
|
|
731
|
-
data-testid="reading-width"
|
|
732
|
-
{...rest}
|
|
733
|
-
>
|
|
729
|
+
<YStack alignSelf="flex-start" {...readingWidth} data-testid="reading-width" {...rest}>
|
|
734
730
|
{children}
|
|
735
731
|
</YStack>
|
|
736
732
|
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { asyncFailure, isReasonCode } from "./asyncFailure";
|
|
3
|
+
|
|
4
|
+
describe("asyncFailure next step", () => {
|
|
5
|
+
it("says try again later when the caller can't retry", () => {
|
|
6
|
+
expect(asyncFailure({ reason: "timeout" })).toEqual({
|
|
7
|
+
title: "Couldn't load data",
|
|
8
|
+
description: "The server took too long to answer. Try again later.",
|
|
9
|
+
retry: false,
|
|
10
|
+
refusal: false,
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("points at Retry when the caller can retry", () => {
|
|
15
|
+
const failure = asyncFailure({ reason: "busy", retry: true, subject: "Orders" });
|
|
16
|
+
expect(failure.title).toBe("Orders didn't load");
|
|
17
|
+
expect(failure.description).toBe("The server is busy. Tap Retry to try again.");
|
|
18
|
+
expect(failure.retry).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("says it will retry on its own when the view is live", () => {
|
|
22
|
+
expect(asyncFailure({ reason: "unreachable", retry: true, live: true }).description).toBe(
|
|
23
|
+
"Can't reach the server. It will retry; tap Retry to try now.",
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("keeps a reason's own next step and withholds Retry when retrying can't help", () => {
|
|
28
|
+
const failure = asyncFailure({ reason: "payload_large", retry: true, live: true });
|
|
29
|
+
expect(failure.description).toBe(
|
|
30
|
+
"The response is too large to load. Retrying won't help until the view asks for less.",
|
|
31
|
+
);
|
|
32
|
+
expect(failure.retry).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("uses a caller's reason without a next step as retryable", () => {
|
|
36
|
+
const failure = asyncFailure({
|
|
37
|
+
reason: "quota_hit",
|
|
38
|
+
retry: true,
|
|
39
|
+
reasons: { quota_hit: { cause: "The quota ran out." } },
|
|
40
|
+
});
|
|
41
|
+
expect(failure.description).toBe("The quota ran out. Tap Retry to try again.");
|
|
42
|
+
expect(failure.retry).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("asyncFailure codes", () => {
|
|
47
|
+
it("reads a sentence or a missing reason as a plain failure", () => {
|
|
48
|
+
expect(asyncFailure({ reason: "Something broke!" }).description).toBe(
|
|
49
|
+
"The server couldn't finish the request. Try again later.",
|
|
50
|
+
);
|
|
51
|
+
expect(asyncFailure({ reason: null }).description).toBe(
|
|
52
|
+
"The server couldn't finish the request. Try again later.",
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("maps a code to its family, preferring the caller's copy of that family", () => {
|
|
57
|
+
expect(asyncFailure({ reason: "gateway_timed_out" }).description).toMatch(
|
|
58
|
+
/^The server took too long to answer\./,
|
|
59
|
+
);
|
|
60
|
+
expect(
|
|
61
|
+
asyncFailure({
|
|
62
|
+
reason: "service_down",
|
|
63
|
+
reasons: { down: { cause: "Maintenance window." } },
|
|
64
|
+
}).description,
|
|
65
|
+
).toBe("Maintenance window. Try again later.");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("falls back to the caller's failed copy for an unknown code", () => {
|
|
69
|
+
expect(
|
|
70
|
+
asyncFailure({ reason: "odd_code", reasons: { failed: { cause: "Nope." } } }).description,
|
|
71
|
+
).toBe("Nope. Try again later.");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("turns a refusal into the access copy unless the caller words that code", () => {
|
|
75
|
+
expect(asyncFailure({ reason: "permission_denied", retry: true })).toEqual({
|
|
76
|
+
title: "This isn't open to this account",
|
|
77
|
+
description: "Ask an admin for access.",
|
|
78
|
+
retry: false,
|
|
79
|
+
refusal: true,
|
|
80
|
+
});
|
|
81
|
+
expect(asyncFailure({ reason: "forbidden", subject: "Invoices" }).title).toBe(
|
|
82
|
+
"Invoices isn't open to this account",
|
|
83
|
+
);
|
|
84
|
+
expect(
|
|
85
|
+
asyncFailure({ reason: "forbidden", reasons: { forbidden: { cause: "Locked." } } }).refusal,
|
|
86
|
+
).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("isReasonCode", () => {
|
|
91
|
+
it("takes snake codes, known words and family words, not prose", () => {
|
|
92
|
+
expect(isReasonCode("rate_limit")).toBe(true);
|
|
93
|
+
expect(isReasonCode("busy")).toBe(true);
|
|
94
|
+
expect(isReasonCode("forbidden")).toBe(true);
|
|
95
|
+
expect(isReasonCode("overloaded")).toBe(true);
|
|
96
|
+
expect(isReasonCode("hello")).toBe(false);
|
|
97
|
+
expect(isReasonCode("Server error")).toBe(false);
|
|
98
|
+
expect(isReasonCode(404)).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -76,6 +76,11 @@ function lookup(
|
|
|
76
76
|
return reasons?.failed ?? defaultReasons.failed!;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
function nextStep(canRetry: boolean, live: boolean): string {
|
|
80
|
+
if (!canRetry) return "Try again later.";
|
|
81
|
+
return live ? "It will retry; tap Retry to try now." : "Tap Retry to try again.";
|
|
82
|
+
}
|
|
83
|
+
|
|
79
84
|
export function asyncFailure({
|
|
80
85
|
subject,
|
|
81
86
|
reason,
|
|
@@ -94,13 +99,7 @@ export function asyncFailure({
|
|
|
94
99
|
}
|
|
95
100
|
const entry = lookup(code, reasons);
|
|
96
101
|
const retryable = entry.retry !== false;
|
|
97
|
-
const next =
|
|
98
|
-
entry.next ??
|
|
99
|
-
(retryable && retry
|
|
100
|
-
? live
|
|
101
|
-
? "It will retry; tap Retry to try now."
|
|
102
|
-
: "Tap Retry to try again."
|
|
103
|
-
: "Try again later.");
|
|
102
|
+
const next = entry.next ?? nextStep(retryable && retry, live);
|
|
104
103
|
return {
|
|
105
104
|
title: subject ? `${subject} didn't load` : "Couldn't load data",
|
|
106
105
|
description: `${entry.cause} ${next}`,
|
package/src/surfaces.spec.tsx
CHANGED
|
@@ -95,13 +95,14 @@ describe("surfaces package exports", () => {
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
describe("SheetFrame overlay chrome", () => {
|
|
98
|
-
it("binds elevatedSurface
|
|
98
|
+
it("binds elevatedSurface's own fill and transition, not the page or surface-without-elevation (FZ-9211)", () => {
|
|
99
99
|
const src = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "surfaces.tsx"), "utf8");
|
|
100
100
|
const start = src.indexOf("// ── SheetFrame");
|
|
101
101
|
const end = src.indexOf("// ── SheetModal");
|
|
102
102
|
const sheet = src.slice(start, end);
|
|
103
103
|
expect(sheet).toContain("elevatedSurface");
|
|
104
|
-
expect(sheet).toContain('backgroundColor: "$background"');
|
|
104
|
+
expect(sheet).not.toContain('backgroundColor: "$background"');
|
|
105
|
+
expect(sheet).toContain("<Surface painted={false} elevated>");
|
|
105
106
|
expect(sheet).toContain("transitionProps(knobProps.motion.overlay)");
|
|
106
107
|
expect(sheet).toContain("containerRadius");
|
|
107
108
|
expect(sheet).not.toContain("knobProps.surface");
|