@multiplatform.one/components 8.2.1 → 8.3.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/DrillStack/DrillBar.cjs +124 -0
- package/dist/cjs/DrillStack/DrillBar.native.js +133 -0
- package/dist/cjs/DrillStack/DrillBar.native.js.map +1 -0
- package/dist/cjs/DrillStack/context.cjs +66 -0
- package/dist/cjs/DrillStack/context.native.js +73 -0
- package/dist/cjs/DrillStack/context.native.js.map +1 -0
- package/dist/cjs/DrillStack/drillMotion.cjs +68 -0
- package/dist/cjs/DrillStack/drillMotion.native.js +72 -0
- package/dist/cjs/DrillStack/drillMotion.native.js.map +1 -0
- package/dist/cjs/DrillStack/drillSlide.cjs +171 -0
- package/dist/cjs/DrillStack/drillSlide.native.js +36 -0
- package/dist/cjs/DrillStack/drillSlide.native.js.map +1 -0
- package/dist/cjs/DrillStack/index.cjs +158 -0
- package/dist/cjs/DrillStack/index.native.js +294 -0
- package/dist/cjs/DrillStack/index.native.js.map +1 -0
- package/dist/cjs/DropdownMenu/index.cjs +288 -41
- package/dist/cjs/DropdownMenu/index.native.js +334 -44
- package/dist/cjs/DropdownMenu/index.native.js.map +1 -1
- package/dist/cjs/MiddleEllipsisText/index.cjs +79 -0
- package/dist/cjs/MiddleEllipsisText/index.native.js +46 -0
- package/dist/cjs/MiddleEllipsisText/index.native.js.map +1 -0
- package/dist/cjs/MiddleEllipsisText/middleSplit.cjs +43 -0
- package/dist/cjs/MiddleEllipsisText/middleSplit.native.js +48 -0
- package/dist/cjs/MiddleEllipsisText/middleSplit.native.js.map +1 -0
- package/dist/cjs/MiddleEllipsisText/types.cjs +18 -0
- package/dist/cjs/MiddleEllipsisText/types.native.js +21 -0
- package/dist/cjs/MiddleEllipsisText/types.native.js.map +1 -0
- package/dist/cjs/SheetScrollView/index.cjs +306 -0
- package/dist/cjs/SheetScrollView/index.native.js +361 -0
- package/dist/cjs/SheetScrollView/index.native.js.map +1 -0
- package/dist/cjs/SheetScrollView/sheetDrag.cjs +30 -0
- package/dist/cjs/SheetScrollView/sheetDrag.native.js +40 -0
- package/dist/cjs/SheetScrollView/sheetDrag.native.js.map +1 -0
- package/dist/cjs/SheetScrollView/sheetHandoff.cjs +225 -0
- package/dist/cjs/SheetScrollView/sheetHandoff.native.js +242 -0
- package/dist/cjs/SheetScrollView/sheetHandoff.native.js.map +1 -0
- package/dist/cjs/Tabs/index.cjs +12 -9
- package/dist/cjs/Tabs/index.native.js +12 -9
- package/dist/cjs/Tabs/index.native.js.map +1 -1
- package/dist/cjs/code/PayloadView/index.cjs +404 -0
- package/dist/cjs/code/PayloadView/index.native.js +443 -0
- package/dist/cjs/code/PayloadView/index.native.js.map +1 -0
- package/dist/cjs/code/PayloadView/payloadModel.cjs +281 -0
- package/dist/cjs/code/PayloadView/payloadModel.native.js +348 -0
- package/dist/cjs/code/PayloadView/payloadModel.native.js.map +1 -0
- package/dist/cjs/code/index.cjs +2 -1
- package/dist/cjs/code/index.native.js +1 -0
- package/dist/cjs/code/index.native.js.map +1 -1
- package/dist/cjs/images/RemoteArt/index.cjs +50 -0
- package/dist/cjs/images/RemoteArt/index.native.js +73 -0
- package/dist/cjs/images/RemoteArt/index.native.js.map +1 -0
- package/dist/cjs/images/RemoteArt/remoteArtCache.cjs +179 -0
- package/dist/cjs/images/RemoteArt/remoteArtCache.native.js +222 -0
- package/dist/cjs/images/RemoteArt/remoteArtCache.native.js.map +1 -0
- package/dist/cjs/images/RemoteArt/svgMarkup.cjs +119 -0
- package/dist/cjs/images/RemoteArt/svgMarkup.native.js +225 -0
- package/dist/cjs/images/RemoteArt/svgMarkup.native.js.map +1 -0
- package/dist/cjs/images/RemoteArt/types.cjs +18 -0
- package/dist/cjs/images/RemoteArt/types.native.js +21 -0
- package/dist/cjs/images/RemoteArt/types.native.js.map +1 -0
- package/dist/cjs/images/index.cjs +13 -1
- package/dist/cjs/images/index.native.js +12 -0
- package/dist/cjs/images/index.native.js.map +1 -1
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/index.native.js +8 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/layouts/attachments.cjs +2 -2
- package/dist/cjs/layouts/attachments.native.js +2 -2
- package/dist/cjs/layouts/attachments.native.js.map +1 -1
- package/dist/cjs/views/List.cjs +1 -0
- package/dist/cjs/views/List.native.js +1 -0
- package/dist/cjs/views/List.native.js.map +1 -1
- package/dist/cjs/views/ListGroup.cjs +277 -20
- package/dist/cjs/views/ListGroup.native.js +290 -23
- package/dist/cjs/views/ListGroup.native.js.map +1 -1
- package/dist/cjs/views/ListRow.cjs +70 -12
- package/dist/cjs/views/ListRow.native.js +72 -12
- package/dist/cjs/views/ListRow.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/ChatTurn/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.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/DrillStack/DrillBar.mjs +99 -0
- package/dist/esm/DrillStack/DrillBar.mjs.map +1 -0
- package/dist/esm/DrillStack/DrillBar.native.js +105 -0
- package/dist/esm/DrillStack/DrillBar.native.js.map +1 -0
- package/dist/esm/DrillStack/context.mjs +39 -0
- package/dist/esm/DrillStack/context.mjs.map +1 -0
- package/dist/esm/DrillStack/context.native.js +43 -0
- package/dist/esm/DrillStack/context.native.js.map +1 -0
- package/dist/esm/DrillStack/drillMotion.mjs +41 -0
- package/dist/esm/DrillStack/drillMotion.mjs.map +1 -0
- package/dist/esm/DrillStack/drillMotion.native.js +42 -0
- package/dist/esm/DrillStack/drillMotion.native.js.map +1 -0
- package/dist/esm/DrillStack/drillSlide.mjs +144 -0
- package/dist/esm/DrillStack/drillSlide.mjs.map +1 -0
- package/dist/esm/DrillStack/drillSlide.native.js +7 -0
- package/dist/esm/DrillStack/drillSlide.native.js.map +1 -0
- package/dist/esm/DrillStack/index.mjs +131 -0
- package/dist/esm/DrillStack/index.mjs.map +1 -0
- package/dist/esm/DrillStack/index.native.js +260 -0
- package/dist/esm/DrillStack/index.native.js.map +1 -0
- package/dist/esm/DropDownPanel/index.native.js.map +1 -1
- package/dist/esm/DropdownMenu/index.mjs +264 -17
- package/dist/esm/DropdownMenu/index.mjs.map +1 -1
- package/dist/esm/DropdownMenu/index.native.js +306 -16
- 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/MiddleEllipsisText/index.mjs +53 -0
- package/dist/esm/MiddleEllipsisText/index.mjs.map +1 -0
- package/dist/esm/MiddleEllipsisText/index.native.js +18 -0
- package/dist/esm/MiddleEllipsisText/index.native.js.map +1 -0
- package/dist/esm/MiddleEllipsisText/middleSplit.mjs +18 -0
- package/dist/esm/MiddleEllipsisText/middleSplit.mjs.map +1 -0
- package/dist/esm/MiddleEllipsisText/middleSplit.native.js +20 -0
- package/dist/esm/MiddleEllipsisText/middleSplit.native.js.map +1 -0
- package/dist/esm/MiddleEllipsisText/types.mjs +2 -0
- package/dist/esm/MiddleEllipsisText/types.mjs.map +1 -0
- package/dist/esm/MiddleEllipsisText/types.native.js +2 -0
- package/dist/esm/MiddleEllipsisText/types.native.js.map +1 -0
- 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/SheetScrollView/index.mjs +277 -0
- package/dist/esm/SheetScrollView/index.mjs.map +1 -0
- package/dist/esm/SheetScrollView/index.native.js +329 -0
- package/dist/esm/SheetScrollView/index.native.js.map +1 -0
- package/dist/esm/SheetScrollView/sheetDrag.mjs +5 -0
- package/dist/esm/SheetScrollView/sheetDrag.mjs.map +1 -0
- package/dist/esm/SheetScrollView/sheetDrag.native.js +12 -0
- package/dist/esm/SheetScrollView/sheetDrag.native.js.map +1 -0
- package/dist/esm/SheetScrollView/sheetHandoff.mjs +190 -0
- package/dist/esm/SheetScrollView/sheetHandoff.mjs.map +1 -0
- package/dist/esm/SheetScrollView/sheetHandoff.native.js +204 -0
- package/dist/esm/SheetScrollView/sheetHandoff.native.js.map +1 -0
- 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/SwipeDismissRow/index.native.js.map +1 -1
- package/dist/esm/Tabs/index.mjs +12 -10
- package/dist/esm/Tabs/index.mjs.map +1 -1
- package/dist/esm/Tabs/index.native.js +12 -10
- 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.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.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/LogView.native.js.map +1 -1
- package/dist/esm/code/PayloadView/index.mjs +377 -0
- package/dist/esm/code/PayloadView/index.mjs.map +1 -0
- package/dist/esm/code/PayloadView/index.native.js +413 -0
- package/dist/esm/code/PayloadView/index.native.js.map +1 -0
- package/dist/esm/code/PayloadView/payloadModel.mjs +245 -0
- package/dist/esm/code/PayloadView/payloadModel.mjs.map +1 -0
- package/dist/esm/code/PayloadView/payloadModel.native.js +309 -0
- package/dist/esm/code/PayloadView/payloadModel.native.js.map +1 -0
- package/dist/esm/code/Pre/index.native.js.map +1 -1
- package/dist/esm/code/index.mjs +1 -0
- package/dist/esm/code/index.mjs.map +1 -1
- package/dist/esm/code/index.native.js +1 -0
- 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/RemoteArt/index.mjs +25 -0
- package/dist/esm/images/RemoteArt/index.mjs.map +1 -0
- package/dist/esm/images/RemoteArt/index.native.js +45 -0
- package/dist/esm/images/RemoteArt/index.native.js.map +1 -0
- package/dist/esm/images/RemoteArt/remoteArtCache.mjs +150 -0
- package/dist/esm/images/RemoteArt/remoteArtCache.mjs.map +1 -0
- package/dist/esm/images/RemoteArt/remoteArtCache.native.js +190 -0
- package/dist/esm/images/RemoteArt/remoteArtCache.native.js.map +1 -0
- package/dist/esm/images/RemoteArt/svgMarkup.mjs +93 -0
- package/dist/esm/images/RemoteArt/svgMarkup.mjs.map +1 -0
- package/dist/esm/images/RemoteArt/svgMarkup.native.js +196 -0
- package/dist/esm/images/RemoteArt/svgMarkup.native.js.map +1 -0
- package/dist/esm/images/RemoteArt/types.mjs +2 -0
- package/dist/esm/images/RemoteArt/types.mjs.map +1 -0
- package/dist/esm/images/RemoteArt/types.native.js +2 -0
- package/dist/esm/images/RemoteArt/types.native.js.map +1 -0
- package/dist/esm/images/index.mjs +3 -0
- package/dist/esm/images/index.mjs.map +1 -1
- package/dist/esm/images/index.native.js +3 -0
- package/dist/esm/images/index.native.js.map +1 -1
- package/dist/esm/index.gnome.native.js.map +1 -1
- package/dist/esm/index.mjs +4 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +4 -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/StatusGlyphStrip.native.js.map +1 -1
- package/dist/esm/layouts/ViewSwitcher.native.js.map +1 -1
- package/dist/esm/layouts/asyncFailure.native.js.map +1 -1
- package/dist/esm/layouts/attachments.mjs +3 -3
- package/dist/esm/layouts/attachments.mjs.map +1 -1
- package/dist/esm/layouts/attachments.native.js +3 -3
- 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.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/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.mjs +2 -2
- package/dist/esm/views/List.mjs.map +1 -1
- package/dist/esm/views/List.native.js +2 -2
- package/dist/esm/views/List.native.js.map +1 -1
- package/dist/esm/views/ListGroup.mjs +278 -21
- package/dist/esm/views/ListGroup.mjs.map +1 -1
- package/dist/esm/views/ListGroup.native.js +291 -24
- package/dist/esm/views/ListGroup.native.js.map +1 -1
- package/dist/esm/views/ListRow.mjs +65 -8
- package/dist/esm/views/ListRow.mjs.map +1 -1
- package/dist/esm/views/ListRow.native.js +67 -8
- 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/DrillStack/DrillBar.mjs +99 -0
- package/dist/jsx/DrillStack/DrillBar.mjs.map +1 -0
- package/dist/jsx/DrillStack/DrillBar.native.js +133 -0
- package/dist/jsx/DrillStack/DrillBar.native.js.map +1 -0
- package/dist/jsx/DrillStack/context.mjs +39 -0
- package/dist/jsx/DrillStack/context.mjs.map +1 -0
- package/dist/jsx/DrillStack/context.native.js +73 -0
- package/dist/jsx/DrillStack/context.native.js.map +1 -0
- package/dist/jsx/DrillStack/drillMotion.mjs +41 -0
- package/dist/jsx/DrillStack/drillMotion.mjs.map +1 -0
- package/dist/jsx/DrillStack/drillMotion.native.js +72 -0
- package/dist/jsx/DrillStack/drillMotion.native.js.map +1 -0
- package/dist/jsx/DrillStack/drillSlide.mjs +144 -0
- package/dist/jsx/DrillStack/drillSlide.mjs.map +1 -0
- package/dist/jsx/DrillStack/drillSlide.native.js +36 -0
- package/dist/jsx/DrillStack/drillSlide.native.js.map +1 -0
- package/dist/jsx/DrillStack/index.mjs +131 -0
- package/dist/jsx/DrillStack/index.mjs.map +1 -0
- package/dist/jsx/DrillStack/index.native.js +294 -0
- package/dist/jsx/DrillStack/index.native.js.map +1 -0
- package/dist/jsx/DropdownMenu/index.mjs +264 -17
- package/dist/jsx/DropdownMenu/index.mjs.map +1 -1
- package/dist/jsx/DropdownMenu/index.native.js +334 -44
- package/dist/jsx/DropdownMenu/index.native.js.map +1 -1
- package/dist/jsx/MiddleEllipsisText/index.mjs +53 -0
- package/dist/jsx/MiddleEllipsisText/index.mjs.map +1 -0
- package/dist/jsx/MiddleEllipsisText/index.native.js +46 -0
- package/dist/jsx/MiddleEllipsisText/index.native.js.map +1 -0
- package/dist/jsx/MiddleEllipsisText/middleSplit.mjs +18 -0
- package/dist/jsx/MiddleEllipsisText/middleSplit.mjs.map +1 -0
- package/dist/jsx/MiddleEllipsisText/middleSplit.native.js +48 -0
- package/dist/jsx/MiddleEllipsisText/middleSplit.native.js.map +1 -0
- package/dist/jsx/MiddleEllipsisText/types.mjs +2 -0
- package/dist/jsx/MiddleEllipsisText/types.mjs.map +1 -0
- package/dist/jsx/MiddleEllipsisText/types.native.js +21 -0
- package/dist/jsx/MiddleEllipsisText/types.native.js.map +1 -0
- package/dist/jsx/SheetScrollView/index.mjs +277 -0
- package/dist/jsx/SheetScrollView/index.mjs.map +1 -0
- package/dist/jsx/SheetScrollView/index.native.js +361 -0
- package/dist/jsx/SheetScrollView/index.native.js.map +1 -0
- package/dist/jsx/SheetScrollView/sheetDrag.mjs +5 -0
- package/dist/jsx/SheetScrollView/sheetDrag.mjs.map +1 -0
- package/dist/jsx/SheetScrollView/sheetDrag.native.js +40 -0
- package/dist/jsx/SheetScrollView/sheetDrag.native.js.map +1 -0
- package/dist/jsx/SheetScrollView/sheetHandoff.mjs +190 -0
- package/dist/jsx/SheetScrollView/sheetHandoff.mjs.map +1 -0
- package/dist/jsx/SheetScrollView/sheetHandoff.native.js +242 -0
- package/dist/jsx/SheetScrollView/sheetHandoff.native.js.map +1 -0
- package/dist/jsx/Tabs/index.mjs +12 -10
- package/dist/jsx/Tabs/index.mjs.map +1 -1
- package/dist/jsx/Tabs/index.native.js +12 -9
- package/dist/jsx/Tabs/index.native.js.map +1 -1
- package/dist/jsx/code/PayloadView/index.mjs +377 -0
- package/dist/jsx/code/PayloadView/index.mjs.map +1 -0
- package/dist/jsx/code/PayloadView/index.native.js +443 -0
- package/dist/jsx/code/PayloadView/index.native.js.map +1 -0
- package/dist/jsx/code/PayloadView/payloadModel.mjs +245 -0
- package/dist/jsx/code/PayloadView/payloadModel.mjs.map +1 -0
- package/dist/jsx/code/PayloadView/payloadModel.native.js +348 -0
- package/dist/jsx/code/PayloadView/payloadModel.native.js.map +1 -0
- package/dist/jsx/code/index.mjs +1 -0
- package/dist/jsx/code/index.mjs.map +1 -1
- package/dist/jsx/code/index.native.js +1 -0
- package/dist/jsx/code/index.native.js.map +1 -1
- package/dist/jsx/images/RemoteArt/index.mjs +25 -0
- package/dist/jsx/images/RemoteArt/index.mjs.map +1 -0
- package/dist/jsx/images/RemoteArt/index.native.js +73 -0
- package/dist/jsx/images/RemoteArt/index.native.js.map +1 -0
- package/dist/jsx/images/RemoteArt/remoteArtCache.mjs +150 -0
- package/dist/jsx/images/RemoteArt/remoteArtCache.mjs.map +1 -0
- package/dist/jsx/images/RemoteArt/remoteArtCache.native.js +222 -0
- package/dist/jsx/images/RemoteArt/remoteArtCache.native.js.map +1 -0
- package/dist/jsx/images/RemoteArt/svgMarkup.mjs +93 -0
- package/dist/jsx/images/RemoteArt/svgMarkup.mjs.map +1 -0
- package/dist/jsx/images/RemoteArt/svgMarkup.native.js +225 -0
- package/dist/jsx/images/RemoteArt/svgMarkup.native.js.map +1 -0
- package/dist/jsx/images/RemoteArt/types.mjs +2 -0
- package/dist/jsx/images/RemoteArt/types.mjs.map +1 -0
- package/dist/jsx/images/RemoteArt/types.native.js +21 -0
- package/dist/jsx/images/RemoteArt/types.native.js.map +1 -0
- package/dist/jsx/images/index.mjs +3 -0
- package/dist/jsx/images/index.mjs.map +1 -1
- package/dist/jsx/images/index.native.js +12 -0
- package/dist/jsx/images/index.native.js.map +1 -1
- package/dist/jsx/index.js +4 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +4 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +8 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/layouts/attachments.mjs +3 -3
- package/dist/jsx/layouts/attachments.mjs.map +1 -1
- package/dist/jsx/layouts/attachments.native.js +2 -2
- package/dist/jsx/layouts/attachments.native.js.map +1 -1
- package/dist/jsx/views/List.mjs +2 -2
- package/dist/jsx/views/List.mjs.map +1 -1
- package/dist/jsx/views/List.native.js +1 -0
- package/dist/jsx/views/List.native.js.map +1 -1
- package/dist/jsx/views/ListGroup.mjs +278 -21
- package/dist/jsx/views/ListGroup.mjs.map +1 -1
- package/dist/jsx/views/ListGroup.native.js +290 -23
- package/dist/jsx/views/ListGroup.native.js.map +1 -1
- package/dist/jsx/views/ListRow.mjs +65 -8
- package/dist/jsx/views/ListRow.mjs.map +1 -1
- package/dist/jsx/views/ListRow.native.js +72 -12
- package/dist/jsx/views/ListRow.native.js.map +1 -1
- package/package.json +7 -7
- package/src/DrillStack/DrillBar.tsx +87 -0
- package/src/DrillStack/DrillStack.native.spec.tsx +194 -0
- package/src/DrillStack/DrillStack.spec.tsx +200 -0
- package/src/DrillStack/DrillStack.stories.tsx +108 -0
- package/src/DrillStack/context.ts +71 -0
- package/src/DrillStack/drillMotion.ts +59 -0
- package/src/DrillStack/drillSlide.native.ts +11 -0
- package/src/DrillStack/drillSlide.ts +157 -0
- package/src/DrillStack/index.native.tsx +293 -0
- package/src/DrillStack/index.tsx +146 -0
- package/src/DropdownMenu/DropdownMenu.stories.tsx +144 -0
- package/src/DropdownMenu/DropdownMenu.sub.native.spec.tsx +91 -0
- package/src/DropdownMenu/DropdownMenu.sub.spec.tsx +335 -0
- package/src/DropdownMenu/DropdownMenu.triggerSizing.spec.tsx +44 -0
- package/src/DropdownMenu/index.tsx +360 -14
- package/src/MiddleEllipsisText/MiddleEllipsisText.native.spec.tsx +36 -0
- package/src/MiddleEllipsisText/MiddleEllipsisText.spec.tsx +40 -0
- package/src/MiddleEllipsisText/MiddleEllipsisText.stories.tsx +55 -0
- package/src/MiddleEllipsisText/index.native.tsx +12 -0
- package/src/MiddleEllipsisText/index.tsx +53 -0
- package/src/MiddleEllipsisText/middleSplit.spec.ts +40 -0
- package/src/MiddleEllipsisText/middleSplit.ts +22 -0
- package/src/MiddleEllipsisText/types.ts +11 -0
- package/src/SheetFrame.stories.tsx +1 -1
- package/src/SheetScrollView/SheetScrollView.native-press.spec.tsx +58 -0
- package/src/SheetScrollView/SheetScrollView.spec.tsx +292 -0
- package/src/SheetScrollView/SheetScrollView.stories.tsx +99 -0
- package/src/SheetScrollView/index.tsx +399 -0
- package/src/SheetScrollView/sheetDrag.native.ts +15 -0
- package/src/SheetScrollView/sheetDrag.ts +9 -0
- package/src/SheetScrollView/sheetHandoff.spec.ts +357 -0
- package/src/SheetScrollView/sheetHandoff.ts +315 -0
- package/src/Tabs/index.tsx +14 -11
- package/src/code/PayloadView/PayloadView.spec.tsx +239 -0
- package/src/code/PayloadView/PayloadView.stories.tsx +67 -0
- package/src/code/PayloadView/index.tsx +424 -0
- package/src/code/PayloadView/payloadModel.ts +234 -0
- package/src/code/index.ts +1 -0
- package/src/images/RemoteArt/RemoteArt.native.spec.tsx +118 -0
- package/src/images/RemoteArt/RemoteArt.spec.tsx +32 -0
- package/src/images/RemoteArt/RemoteArt.stories.tsx +61 -0
- package/src/images/RemoteArt/index.native.tsx +50 -0
- package/src/images/RemoteArt/index.tsx +26 -0
- package/src/images/RemoteArt/remoteArtCache.ts +180 -0
- package/src/images/RemoteArt/svgMarkup.spec.ts +54 -0
- package/src/images/RemoteArt/svgMarkup.ts +153 -0
- package/src/images/RemoteArt/types.ts +12 -0
- package/src/images/index.ts +6 -0
- package/src/index.ts +6 -0
- package/src/layouts/Attachments.stories.tsx +38 -0
- package/src/layouts/attachments.tsx +3 -3
- package/src/views/List.tsx +1 -0
- package/src/views/ListGroup.states.spec.tsx +274 -0
- package/src/views/ListGroup.stories.tsx +76 -1
- package/src/views/ListGroup.tsx +368 -31
- package/src/views/ListRow.spec.tsx +146 -0
- package/src/views/ListRow.stories.tsx +111 -0
- package/src/views/ListRow.tsx +91 -7
- package/types/DrillStack/DrillBar.d.ts +13 -0
- package/types/DrillStack/DrillBar.d.ts.map +1 -0
- package/types/DrillStack/context.d.ts +34 -0
- package/types/DrillStack/context.d.ts.map +1 -0
- package/types/DrillStack/drillMotion.d.ts +26 -0
- package/types/DrillStack/drillMotion.d.ts.map +1 -0
- package/types/DrillStack/drillSlide.d.ts +23 -0
- package/types/DrillStack/drillSlide.d.ts.map +1 -0
- package/types/DrillStack/drillSlide.native.d.ts +6 -0
- package/types/DrillStack/drillSlide.native.d.ts.map +1 -0
- package/types/DrillStack/index.d.ts +21 -0
- package/types/DrillStack/index.d.ts.map +1 -0
- package/types/DrillStack/index.native.d.ts +25 -0
- package/types/DrillStack/index.native.d.ts.map +1 -0
- package/types/DropdownMenu/index.d.ts +37 -2
- package/types/DropdownMenu/index.d.ts.map +1 -1
- package/types/MiddleEllipsisText/index.d.ts +5 -0
- package/types/MiddleEllipsisText/index.d.ts.map +1 -0
- package/types/MiddleEllipsisText/index.native.d.ts +4 -0
- package/types/MiddleEllipsisText/index.native.d.ts.map +1 -0
- package/types/MiddleEllipsisText/middleSplit.d.ts +14 -0
- package/types/MiddleEllipsisText/middleSplit.d.ts.map +1 -0
- package/types/MiddleEllipsisText/types.d.ts +8 -0
- package/types/MiddleEllipsisText/types.d.ts.map +1 -0
- package/types/SheetScrollView/index.d.ts +100 -0
- package/types/SheetScrollView/index.d.ts.map +1 -0
- package/types/SheetScrollView/sheetDrag.d.ts +7 -0
- package/types/SheetScrollView/sheetDrag.d.ts.map +1 -0
- package/types/SheetScrollView/sheetDrag.native.d.ts +3 -0
- package/types/SheetScrollView/sheetDrag.native.d.ts.map +1 -0
- package/types/SheetScrollView/sheetHandoff.d.ts +168 -0
- package/types/SheetScrollView/sheetHandoff.d.ts.map +1 -0
- package/types/Tabs/index.d.ts +7 -0
- package/types/Tabs/index.d.ts.map +1 -1
- package/types/code/PayloadView/index.d.ts +16 -0
- package/types/code/PayloadView/index.d.ts.map +1 -0
- package/types/code/PayloadView/payloadModel.d.ts +80 -0
- package/types/code/PayloadView/payloadModel.d.ts.map +1 -0
- package/types/code/index.d.ts +1 -0
- package/types/code/index.d.ts.map +1 -1
- package/types/images/RemoteArt/index.d.ts +4 -0
- package/types/images/RemoteArt/index.d.ts.map +1 -0
- package/types/images/RemoteArt/index.native.d.ts +4 -0
- package/types/images/RemoteArt/index.native.d.ts.map +1 -0
- package/types/images/RemoteArt/remoteArtCache.d.ts +38 -0
- package/types/images/RemoteArt/remoteArtCache.d.ts.map +1 -0
- package/types/images/RemoteArt/svgMarkup.d.ts +22 -0
- package/types/images/RemoteArt/svgMarkup.d.ts.map +1 -0
- package/types/images/RemoteArt/types.d.ts +12 -0
- package/types/images/RemoteArt/types.d.ts.map +1 -0
- package/types/images/index.d.ts +2 -0
- package/types/images/index.d.ts.map +1 -1
- package/types/index.d.ts +5 -0
- package/types/index.d.ts.map +1 -1
- package/types/layouts/attachments.d.ts.map +1 -1
- package/types/views/List.d.ts +1 -1
- package/types/views/List.d.ts.map +1 -1
- package/types/views/ListGroup.d.ts +61 -4
- package/types/views/ListGroup.d.ts.map +1 -1
- package/types/views/ListRow.d.ts +37 -2
- package/types/views/ListRow.d.ts.map +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-7606: remote art on native, from one URL fetched once for every
|
|
3
|
+
* RemoteArt naming it. The SHC console drew a monogram for every app because
|
|
4
|
+
* native had no `<img>` (FZ-7530), and an Illustrator SVG styled by a
|
|
5
|
+
* `<style>` block drew all black through react-native-svg.
|
|
6
|
+
*/
|
|
7
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
8
|
+
import { cleanup, waitFor } from "@testing-library/react";
|
|
9
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
10
|
+
|
|
11
|
+
const hosts = vi.hoisted(() => ({ image: [] as Record<string, unknown>[] }));
|
|
12
|
+
|
|
13
|
+
vi.mock("react-native-svg", async () => {
|
|
14
|
+
const { createElement } = await import("react");
|
|
15
|
+
return {
|
|
16
|
+
SvgXml: ({ xml, width }: { xml: string; width: number }) =>
|
|
17
|
+
createElement("div", {
|
|
18
|
+
"data-testid": "svg-xml",
|
|
19
|
+
"data-xml": xml,
|
|
20
|
+
"data-width": String(width),
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
vi.mock("../Image", () => ({
|
|
26
|
+
Image: (props: Record<string, unknown>) => {
|
|
27
|
+
hosts.image.push(props);
|
|
28
|
+
return null;
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const { RemoteArt } = await import("./index.native");
|
|
33
|
+
const { resetRemoteArtCache, setRemoteArtStore } = await import("./remoteArtCache");
|
|
34
|
+
|
|
35
|
+
const URL = "https://catalog.example.test/apps/nextcloud/icon";
|
|
36
|
+
const styled =
|
|
37
|
+
'<svg viewBox="0 0 24 24"><style>.a{fill:#0082c9}</style><path class="a" d="M0 0h24v24H0z"/></svg>';
|
|
38
|
+
|
|
39
|
+
function answer(status: number, type: string, body: string) {
|
|
40
|
+
return Promise.resolve(new Response(body, { status, headers: { "content-type": type } }));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
cleanup();
|
|
45
|
+
hosts.image.length = 0;
|
|
46
|
+
setRemoteArtStore(undefined);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("RemoteArt on native", () => {
|
|
50
|
+
it("draws a styled SVG from one fetch for every RemoteArt naming the URL", async () => {
|
|
51
|
+
const get = vi.fn((_url: string) => answer(200, "image/svg+xml", styled));
|
|
52
|
+
resetRemoteArtCache(get);
|
|
53
|
+
renderWithProviders(
|
|
54
|
+
<>
|
|
55
|
+
<RemoteArt uri={URL} size={48} />
|
|
56
|
+
<RemoteArt uri={URL} size={48} />
|
|
57
|
+
</>,
|
|
58
|
+
);
|
|
59
|
+
await waitFor(() =>
|
|
60
|
+
expect(document.querySelectorAll('[data-testid="svg-xml"]')).toHaveLength(2),
|
|
61
|
+
);
|
|
62
|
+
const drawn = document.querySelector('[data-testid="svg-xml"]')!;
|
|
63
|
+
expect(drawn.getAttribute("data-xml")).toContain('fill="#0082c9"');
|
|
64
|
+
expect(drawn.getAttribute("data-xml")).not.toContain("<style");
|
|
65
|
+
expect(drawn.getAttribute("data-width")).toBe("48");
|
|
66
|
+
expect(get).toHaveBeenCalledTimes(1);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("draws a raster answer through the house Image at the same URL", async () => {
|
|
70
|
+
resetRemoteArtCache(() => answer(200, "image/png", "png"));
|
|
71
|
+
renderWithProviders(<RemoteArt uri={URL} size={40} alt="Nextcloud" />);
|
|
72
|
+
await waitFor(() => expect(hosts.image.at(-1)?.src).toBe(URL));
|
|
73
|
+
expect(hosts.image.at(-1)).toMatchObject({
|
|
74
|
+
width: 40,
|
|
75
|
+
height: 40,
|
|
76
|
+
alt: "Nextcloud",
|
|
77
|
+
objectFit: "contain",
|
|
78
|
+
});
|
|
79
|
+
expect(document.querySelector('[data-testid="svg-xml"]')).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("draws the fallback when the URL answers no art", async () => {
|
|
83
|
+
resetRemoteArtCache(() => answer(404, "text/plain", "404 page not found"));
|
|
84
|
+
renderWithProviders(<RemoteArt uri={URL} size={40} fallback={<span>NC</span>} />);
|
|
85
|
+
await waitFor(() => expect(document.body.textContent).toContain("NC"));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("draws nothing while the one fetch is in flight, so art never flashes its fallback", () => {
|
|
89
|
+
resetRemoteArtCache(() => new Promise<Response>(() => {}));
|
|
90
|
+
renderWithProviders(<RemoteArt uri={URL} size={40} fallback={<span>NC</span>} />);
|
|
91
|
+
expect(document.body.textContent).not.toContain("NC");
|
|
92
|
+
expect(document.querySelector('[data-testid="svg-xml"]')).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("reads an SVG data URI without a fetch", async () => {
|
|
96
|
+
const get = vi.fn((_url: string) => answer(500, "text/plain", ""));
|
|
97
|
+
resetRemoteArtCache(get);
|
|
98
|
+
const uri = `data:image/svg+xml;utf8,${encodeURIComponent(styled)}`;
|
|
99
|
+
renderWithProviders(<RemoteArt uri={uri} size={24} />);
|
|
100
|
+
await waitFor(() => expect(document.querySelector('[data-testid="svg-xml"]')).toBeTruthy());
|
|
101
|
+
expect(get).not.toHaveBeenCalled();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("draws what a phone remembered on the first frame, then keeps the fresh answer", async () => {
|
|
105
|
+
const kept = new Map<string, string>([
|
|
106
|
+
[`mpo.remote-art.1.${URL}`, JSON.stringify({ kind: "svg", xml: styled })],
|
|
107
|
+
]);
|
|
108
|
+
setRemoteArtStore({
|
|
109
|
+
getItem: (key) => kept.get(key),
|
|
110
|
+
setItem: (key, value) => void kept.set(key, value),
|
|
111
|
+
removeItem: (key) => void kept.delete(key),
|
|
112
|
+
});
|
|
113
|
+
resetRemoteArtCache(() => answer(200, "image/png", "png"));
|
|
114
|
+
renderWithProviders(<RemoteArt uri={URL} size={24} />);
|
|
115
|
+
expect(document.querySelector('[data-testid="svg-xml"]')).toBeTruthy();
|
|
116
|
+
await waitFor(() => expect(kept.get(`mpo.remote-art.1.${URL}`)).toBe('{"kind":"raster"}'));
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** FZ-7606: on the web, remote art is the house Image, whose `<img>` reads SVG and rasters alike. */
|
|
2
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
3
|
+
import { cleanup, fireEvent } from "@testing-library/react";
|
|
4
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
5
|
+
import { RemoteArt } from "./index";
|
|
6
|
+
|
|
7
|
+
afterEach(cleanup);
|
|
8
|
+
|
|
9
|
+
const URL = "https://catalog.example.test/apps/nextcloud/icon";
|
|
10
|
+
|
|
11
|
+
describe("RemoteArt on the web", () => {
|
|
12
|
+
it("draws the URL as an image contained in its box", () => {
|
|
13
|
+
const { container } = renderWithProviders(<RemoteArt uri={URL} size={48} alt="Nextcloud" />);
|
|
14
|
+
const img = container.querySelector("img");
|
|
15
|
+
expect(img?.getAttribute("src")).toBe(URL);
|
|
16
|
+
expect(img?.getAttribute("alt")).toBe("Nextcloud");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("draws the fallback without a URL and after the art fails", () => {
|
|
20
|
+
const missing = renderWithProviders(
|
|
21
|
+
<RemoteArt uri={undefined} size={48} fallback={<span>NC</span>} />,
|
|
22
|
+
);
|
|
23
|
+
expect(missing.container.textContent).toBe("NC");
|
|
24
|
+
missing.unmount();
|
|
25
|
+
const { container } = renderWithProviders(
|
|
26
|
+
<RemoteArt uri={URL} size={48} fallback={<span>NC</span>} />,
|
|
27
|
+
);
|
|
28
|
+
fireEvent.error(container.querySelector("img")!);
|
|
29
|
+
expect(container.textContent).toBe("NC");
|
|
30
|
+
expect(container.querySelector("img")).toBeNull();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
|
|
2
|
+
import { XStack, YStack } from "tamagui";
|
|
3
|
+
import { SizableText } from "../../Text";
|
|
4
|
+
import { RemoteArt } from "./index";
|
|
5
|
+
|
|
6
|
+
// An Illustrator-style export: its paint lives in a <style> block, with a dark variant.
|
|
7
|
+
const styledSvg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><style>.plate{fill:#0082c9}.mark{fill:#ffffff}@media (prefers-color-scheme: dark){.plate{fill:#4fb3ff}}</style><rect class="plate" width="64" height="64" rx="14"/><circle class="mark" cx="32" cy="32" r="12"/></svg>`;
|
|
8
|
+
const styledSvgUri = `data:image/svg+xml;utf8,${encodeURIComponent(styledSvg)}`;
|
|
9
|
+
const rasterUri =
|
|
10
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAHElEQVR4nGOQ7yogCTGMaqCJhk8rSUOjGmiiAQB7sFoQjx6YdAAAAABJRU5ErkJggg==";
|
|
11
|
+
|
|
12
|
+
function Monogram() {
|
|
13
|
+
return (
|
|
14
|
+
<YStack
|
|
15
|
+
width={64}
|
|
16
|
+
height={64}
|
|
17
|
+
alignItems="center"
|
|
18
|
+
justifyContent="center"
|
|
19
|
+
backgroundColor="$color4"
|
|
20
|
+
borderRadius="$4"
|
|
21
|
+
>
|
|
22
|
+
<SizableText fontWeight="600">NC</SizableText>
|
|
23
|
+
</YStack>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const meta: Meta<typeof RemoteArt> = {
|
|
28
|
+
title: "Components/RemoteArt",
|
|
29
|
+
component: RemoteArt,
|
|
30
|
+
parameters: {
|
|
31
|
+
status: { type: "beta" },
|
|
32
|
+
docs: {
|
|
33
|
+
description: {
|
|
34
|
+
component:
|
|
35
|
+
"Art from one URL that answers SVG or a raster, decided by the response, not the extension. Web draws it through the house Image; native fetches it once per URL for every RemoteArt naming it, folds an SVG's <style> onto its elements (react-native-svg ignores <style>) following the theme's scheme, and draws a raster through Image. The fallback shows when the URL answers no art; nothing draws while the one fetch is in flight.",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
argTypes: {
|
|
40
|
+
uri: { control: "text", description: "URL answering SVG or a raster" },
|
|
41
|
+
size: { control: "number", description: "Square box in px" },
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export default meta;
|
|
45
|
+
|
|
46
|
+
type Story = StoryObj<typeof RemoteArt>;
|
|
47
|
+
|
|
48
|
+
export const Default: Story = {
|
|
49
|
+
name: "Main",
|
|
50
|
+
args: { uri: styledSvgUri, size: 64, alt: "Styled SVG art" },
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const SvgAndRaster: Story = {
|
|
54
|
+
render: () => (
|
|
55
|
+
<XStack gap="$4" alignItems="center">
|
|
56
|
+
<RemoteArt uri={styledSvgUri} size={64} alt="Styled SVG art" />
|
|
57
|
+
<RemoteArt uri={rasterUri} size={64} alt="Raster art" />
|
|
58
|
+
<RemoteArt uri={undefined} size={64} fallback={<Monogram />} />
|
|
59
|
+
</XStack>
|
|
60
|
+
),
|
|
61
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote art on native (FZ-7606). Native has no `<img>`, so the URL is fetched
|
|
3
|
+
* once through ./remoteArtCache for every RemoteArt naming it. An SVG draws
|
|
4
|
+
* through react-native-svg with its `<style>` folded onto its elements (it
|
|
5
|
+
* ignores `<style>`, so an Illustrator export draws all black), following the
|
|
6
|
+
* theme's scheme for `prefers-color-scheme` blocks. A raster falls to the
|
|
7
|
+
* house Image. Nothing draws while the one fetch is in flight, so art never
|
|
8
|
+
* flashes its fallback first.
|
|
9
|
+
*/
|
|
10
|
+
import { SvgXml } from "react-native-svg";
|
|
11
|
+
import { useThemeName } from "tamagui";
|
|
12
|
+
import { Image } from "../Image";
|
|
13
|
+
import { remoteArtXml, useRemoteArt } from "./remoteArtCache";
|
|
14
|
+
import type { RemoteArtProps } from "./types";
|
|
15
|
+
|
|
16
|
+
export type { RemoteArtProps } from "./types";
|
|
17
|
+
|
|
18
|
+
function ignore(): void {}
|
|
19
|
+
|
|
20
|
+
export function RemoteArt({ uri, size, alt = "", fallback = null }: RemoteArtProps) {
|
|
21
|
+
const art = useRemoteArt(uri);
|
|
22
|
+
const dark = String(useThemeName()).startsWith("dark");
|
|
23
|
+
if (art.kind === "svg") {
|
|
24
|
+
return (
|
|
25
|
+
<SvgXml
|
|
26
|
+
xml={remoteArtXml(art, dark)}
|
|
27
|
+
width={size}
|
|
28
|
+
height={size}
|
|
29
|
+
accessibilityLabel={alt || undefined}
|
|
30
|
+
accessibilityElementsHidden={!alt}
|
|
31
|
+
importantForAccessibility={alt ? "auto" : "no-hide-descendants"}
|
|
32
|
+
fallback={<>{fallback}</>}
|
|
33
|
+
onError={ignore}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (art.kind === "raster") {
|
|
38
|
+
return (
|
|
39
|
+
<Image
|
|
40
|
+
src={art.uri}
|
|
41
|
+
alt={alt}
|
|
42
|
+
width={size}
|
|
43
|
+
height={size}
|
|
44
|
+
objectFit="contain"
|
|
45
|
+
fallback={fallback}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return art.kind === "none" ? <>{fallback}</> : null;
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote art on the web (FZ-7606): the URL draws through the house Image, an
|
|
3
|
+
* `<img>` that reads SVG (its `<style>` included) and rasters alike, cached by
|
|
4
|
+
* the browser. ./index.native.tsx fetches it once per URL instead.
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { Image } from "../Image";
|
|
8
|
+
import type { RemoteArtProps } from "./types";
|
|
9
|
+
|
|
10
|
+
export type { RemoteArtProps } from "./types";
|
|
11
|
+
|
|
12
|
+
export function RemoteArt({ uri, size, alt = "", fallback = null }: RemoteArtProps) {
|
|
13
|
+
const [failed, setFailed] = useState<string>();
|
|
14
|
+
if (!uri || failed === uri) return <>{fallback}</>;
|
|
15
|
+
return (
|
|
16
|
+
<Image
|
|
17
|
+
src={uri}
|
|
18
|
+
alt={alt}
|
|
19
|
+
aria-hidden={alt ? undefined : true}
|
|
20
|
+
width={size}
|
|
21
|
+
height={size}
|
|
22
|
+
objectFit="contain"
|
|
23
|
+
onError={() => setFailed(uri)}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote art for native (FZ-7606, from the SHC console's catalog art,
|
|
3
|
+
* FZ-7530). The web draws an art URL with `<img>` and the browser caches it.
|
|
4
|
+
* Native has no `<img>`, and an art endpoint (`shc.app.icon`) answers SVG or a
|
|
5
|
+
* raster under one URL with no extension, so the response is fetched once per
|
|
6
|
+
* URL into this module, its content type decides how it draws, and every
|
|
7
|
+
* RemoteArt naming that URL reads the same entry.
|
|
8
|
+
*/
|
|
9
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
10
|
+
import { inlineSvgStyles, prepareSvg } from "./svgMarkup";
|
|
11
|
+
|
|
12
|
+
export type RemoteArtState =
|
|
13
|
+
| { kind: "pending" }
|
|
14
|
+
| { kind: "svg"; xml: string }
|
|
15
|
+
| { kind: "raster"; uri: string }
|
|
16
|
+
| { kind: "none" };
|
|
17
|
+
|
|
18
|
+
type Fetcher = (url: string) => Promise<Response>;
|
|
19
|
+
|
|
20
|
+
/** Where a phone remembers what each URL answered: AsyncStorage-shaped, synchronous. */
|
|
21
|
+
export interface RemoteArtStore {
|
|
22
|
+
getItem(key: string): string | null | undefined;
|
|
23
|
+
setItem(key: string, value: string): void;
|
|
24
|
+
removeItem(key: string): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const pending: RemoteArtState = { kind: "pending" };
|
|
28
|
+
const none: RemoteArtState = { kind: "none" };
|
|
29
|
+
/** A network failure is not a 404: a RemoteArt mounting after this asks again. */
|
|
30
|
+
const retryAfterMs = 60_000;
|
|
31
|
+
const memoryPrefix = "mpo.remote-art.1.";
|
|
32
|
+
const memoryMaxChars = 64 * 1024;
|
|
33
|
+
|
|
34
|
+
const entries = new Map<string, RemoteArtState>();
|
|
35
|
+
/** URLs this runtime has asked, so a remembered entry is still checked once. */
|
|
36
|
+
const asked = new Set<string>();
|
|
37
|
+
const inflight = new Set<string>();
|
|
38
|
+
const listeners = new Map<string, Set<() => void>>();
|
|
39
|
+
const inlined = new WeakMap<RemoteArtState, { dark?: string; light?: string }>();
|
|
40
|
+
let fetcher: Fetcher = (url) => fetch(url);
|
|
41
|
+
let store: RemoteArtStore | undefined;
|
|
42
|
+
|
|
43
|
+
function decodeDataUri(uri: string): { type: string; body: string } | undefined {
|
|
44
|
+
const comma = uri.indexOf(",");
|
|
45
|
+
if (comma === -1) return undefined;
|
|
46
|
+
const meta = uri.slice(5, comma);
|
|
47
|
+
const data = uri.slice(comma + 1);
|
|
48
|
+
const type = meta.split(";")[0]?.toLowerCase() ?? "";
|
|
49
|
+
if (!type.includes("svg")) return { type, body: "" };
|
|
50
|
+
return { type, body: meta.includes("base64") ? atob(data) : decodeURIComponent(data) };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readSvg(xml: string): RemoteArtState {
|
|
54
|
+
return /<svg[\s>/]/i.test(xml) ? { kind: "svg", xml: prepareSvg(xml) } : none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** One fetch, read into what native can draw. Rejects only on a network failure. */
|
|
58
|
+
export async function fetchRemoteArt(url: string, get: Fetcher = fetcher): Promise<RemoteArtState> {
|
|
59
|
+
if (url.startsWith("data:")) {
|
|
60
|
+
const data = decodeDataUri(url);
|
|
61
|
+
if (!data) return none;
|
|
62
|
+
if (data.type.includes("svg")) return readSvg(data.body);
|
|
63
|
+
return data.type.startsWith("image/") ? { kind: "raster", uri: url } : none;
|
|
64
|
+
}
|
|
65
|
+
const res = await get(url);
|
|
66
|
+
if (!res.ok) return none;
|
|
67
|
+
const type = (res.headers.get("content-type") ?? "").toLowerCase();
|
|
68
|
+
if (type.includes("svg")) return readSvg(await res.text());
|
|
69
|
+
return type.startsWith("image/") ? { kind: "raster", uri: url } : none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Lets a phone keep what each URL answered across launches, so art is on the
|
|
74
|
+
* first frame after a reload instead of an empty box. The fetch still runs
|
|
75
|
+
* once per runtime and its answer replaces the remembered one. A network
|
|
76
|
+
* failure is not an answer and is not kept. Pass undefined to stop.
|
|
77
|
+
*/
|
|
78
|
+
export function setRemoteArtStore(next: RemoteArtStore | undefined): void {
|
|
79
|
+
store = next;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function remembered(url: string): RemoteArtState | undefined {
|
|
83
|
+
try {
|
|
84
|
+
const raw = store?.getItem(memoryPrefix + url);
|
|
85
|
+
if (!raw) return undefined;
|
|
86
|
+
const kept = JSON.parse(raw) as { kind?: unknown; xml?: unknown };
|
|
87
|
+
if (kept.kind === "svg" && typeof kept.xml === "string") return { kind: "svg", xml: kept.xml };
|
|
88
|
+
if (kept.kind === "raster") return { kind: "raster", uri: url };
|
|
89
|
+
if (kept.kind === "none") return none;
|
|
90
|
+
} catch {
|
|
91
|
+
// Unreadable: the fetch answers instead.
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function remember(url: string, art: RemoteArtState): void {
|
|
97
|
+
if (!store) return;
|
|
98
|
+
try {
|
|
99
|
+
if (art.kind === "svg" && art.xml.length <= memoryMaxChars) {
|
|
100
|
+
store.setItem(memoryPrefix + url, JSON.stringify({ kind: "svg", xml: art.xml }));
|
|
101
|
+
} else if (art.kind === "raster" || art.kind === "none") {
|
|
102
|
+
store.setItem(memoryPrefix + url, JSON.stringify({ kind: art.kind }));
|
|
103
|
+
} else {
|
|
104
|
+
store.removeItem(memoryPrefix + url);
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
// The store refused: the next runtime fetches, as before.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function settle(url: string, art: RemoteArtState): void {
|
|
112
|
+
entries.set(url, art);
|
|
113
|
+
for (const listener of listeners.get(url) ?? []) listener();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function ensure(url: string): void {
|
|
117
|
+
if (asked.has(url) || inflight.has(url)) return;
|
|
118
|
+
asked.add(url);
|
|
119
|
+
inflight.add(url);
|
|
120
|
+
fetchRemoteArt(url)
|
|
121
|
+
.then(
|
|
122
|
+
(art) => {
|
|
123
|
+
settle(url, art);
|
|
124
|
+
remember(url, art);
|
|
125
|
+
},
|
|
126
|
+
() => {
|
|
127
|
+
settle(url, entries.get(url) ?? none);
|
|
128
|
+
setTimeout(() => asked.delete(url), retryAfterMs);
|
|
129
|
+
},
|
|
130
|
+
)
|
|
131
|
+
.finally(() => inflight.delete(url));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The entry for a URL: this runtime's, else what the phone remembered. */
|
|
135
|
+
function current(url: string): RemoteArtState {
|
|
136
|
+
const known = entries.get(url);
|
|
137
|
+
if (known) return known;
|
|
138
|
+
const kept = remembered(url);
|
|
139
|
+
if (!kept) return pending;
|
|
140
|
+
entries.set(url, kept);
|
|
141
|
+
return kept;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** The art for one URL: `pending` until the one fetch lands, `none` without a URL. */
|
|
145
|
+
export function useRemoteArt(url: string | undefined): RemoteArtState {
|
|
146
|
+
const subscribe = useCallback(
|
|
147
|
+
(listener: () => void) => {
|
|
148
|
+
if (!url) return () => {};
|
|
149
|
+
const set = listeners.get(url) ?? new Set<() => void>();
|
|
150
|
+
listeners.set(url, set);
|
|
151
|
+
set.add(listener);
|
|
152
|
+
ensure(url);
|
|
153
|
+
return () => {
|
|
154
|
+
set.delete(listener);
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
[url],
|
|
158
|
+
);
|
|
159
|
+
const snapshot = () => (url ? current(url) : none);
|
|
160
|
+
return useSyncExternalStore(subscribe, snapshot, snapshot);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The SVG with its `<style>` folded onto its elements, once per art and scheme. */
|
|
164
|
+
export function remoteArtXml(art: { kind: "svg"; xml: string }, dark: boolean): string {
|
|
165
|
+
const pair = inlined.get(art) ?? {};
|
|
166
|
+
inlined.set(art, pair);
|
|
167
|
+
const key = dark ? "dark" : "light";
|
|
168
|
+
const xml = pair[key] ?? inlineSvgStyles(art.xml, dark);
|
|
169
|
+
pair[key] = xml;
|
|
170
|
+
return xml;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Specs only: forget every entry and fetch through `get`. */
|
|
174
|
+
export function resetRemoteArtCache(get: Fetcher = (url) => fetch(url)): void {
|
|
175
|
+
entries.clear();
|
|
176
|
+
asked.clear();
|
|
177
|
+
inflight.clear();
|
|
178
|
+
listeners.clear();
|
|
179
|
+
fetcher = get;
|
|
180
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-7606: react-native-svg ignores `<style>`, drops a `<switch>` with its
|
|
3
|
+
* children, and draws a root with no viewBox at its own size.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { inlineSvgStyles, prepareSvg } from "./svgMarkup";
|
|
7
|
+
|
|
8
|
+
describe("inlineSvgStyles", () => {
|
|
9
|
+
it("folds class, id and type rules onto the elements they select, by specificity", () => {
|
|
10
|
+
const xml =
|
|
11
|
+
'<svg><style>path{fill:red}.a{fill:#0082c9}#b{stroke:#111}</style><path class="a"/><path id="b"/></svg>';
|
|
12
|
+
const out = inlineSvgStyles(xml, false);
|
|
13
|
+
expect(out).not.toContain("<style");
|
|
14
|
+
expect(out).toContain('<path class="a" fill="#0082c9"/>');
|
|
15
|
+
expect(out).toContain('<path id="b" fill="red" stroke="#111"/>');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("follows the scheme for prefers-color-scheme blocks", () => {
|
|
19
|
+
const xml =
|
|
20
|
+
'<svg><style>.a{fill:#000}@media (prefers-color-scheme: dark){.a{fill:#fff}}</style><path class="a"/></svg>';
|
|
21
|
+
expect(inlineSvgStyles(xml, false)).toContain('fill="#000"');
|
|
22
|
+
expect(inlineSvgStyles(xml, true)).toContain('fill="#fff"');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("keeps an element's own inline style over a stylesheet rule", () => {
|
|
26
|
+
const out = inlineSvgStyles(
|
|
27
|
+
'<svg><style>.a{fill:red}</style><path class="a" style="fill:blue"/></svg>',
|
|
28
|
+
false,
|
|
29
|
+
);
|
|
30
|
+
expect(out).not.toContain('fill="red"');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("drops a rule it cannot read rather than guessing", () => {
|
|
34
|
+
const out = inlineSvgStyles(
|
|
35
|
+
'<svg><style>g > .a{fill:red}</style><g><path class="a"/></g></svg>',
|
|
36
|
+
false,
|
|
37
|
+
);
|
|
38
|
+
expect(out).not.toContain('fill="red"');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("prepareSvg", () => {
|
|
43
|
+
it("turns a switch into a group so its children draw", () => {
|
|
44
|
+
expect(prepareSvg('<svg viewBox="0 0 1 1"><switch><path/></switch></svg>')).toBe(
|
|
45
|
+
'<svg viewBox="0 0 1 1"><g><path/></g></svg>',
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("gives a sized root with no viewBox one, so it scales to its box", () => {
|
|
50
|
+
expect(prepareSvg('<svg width="32px" height="16"><path/></svg>')).toContain(
|
|
51
|
+
'viewBox="0 0 32 16"',
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What react-native-svg cannot draw as a remote SVG ships (FZ-7606, from the
|
|
3
|
+
* SHC console's catalog art, FZ-7530). Pure string work, specced without a
|
|
4
|
+
* renderer.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** The first capture of `pattern` in `text`, or undefined. */
|
|
8
|
+
function capture(text: string, pattern: RegExp): string | undefined {
|
|
9
|
+
return text.match(pattern)?.[1];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* What react-native-svg's parser cannot take as shipped: a `<switch>`, which
|
|
14
|
+
* it drops with every child (mariadb), and a root with a size but no
|
|
15
|
+
* viewBox, which draws at its own size instead of the plate's.
|
|
16
|
+
*/
|
|
17
|
+
export function prepareSvg(xml: string): string {
|
|
18
|
+
const out = xml.replace(/<switch\b([^>]*)>/gi, "<g$1>").replace(/<\/switch\s*>/gi, "</g>");
|
|
19
|
+
return out.replace(/<svg\b([^>]*)>/i, (tag, attrs: string) => {
|
|
20
|
+
if (/\sviewBox\s*=/i.test(attrs)) return tag;
|
|
21
|
+
const w = capture(attrs, /\swidth\s*=\s*["']([\d.]+)(?:px)?["']/i);
|
|
22
|
+
const h = capture(attrs, /\sheight\s*=\s*["']([\d.]+)(?:px)?["']/i);
|
|
23
|
+
return w && h ? `<svg viewBox="0 0 ${w} ${h}"${attrs}>` : tag;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface SimpleSelector {
|
|
28
|
+
tag?: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
classes: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface CssRule {
|
|
34
|
+
selector: SimpleSelector;
|
|
35
|
+
specificity: number;
|
|
36
|
+
order: number;
|
|
37
|
+
decls: ReadonlyArray<readonly [string, string]>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Folds an SVG's `<style>` onto the elements it selects, as presentation
|
|
42
|
+
* attributes. react-native-svg ignores `<style>`, so an Illustrator export
|
|
43
|
+
* (wordpress, paperless, nginx, mongodb) otherwise draws all black.
|
|
44
|
+
*
|
|
45
|
+
* Covers what the catalog ships: type, class and id selectors and their
|
|
46
|
+
* compounds, comma lists, and `prefers-color-scheme` media blocks, which
|
|
47
|
+
* follow `dark`. A rule it cannot read is dropped, never guessed at.
|
|
48
|
+
*/
|
|
49
|
+
export function inlineSvgStyles(xml: string, dark: boolean): string {
|
|
50
|
+
const rules: CssRule[] = [];
|
|
51
|
+
const body = xml.replace(/<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi, (_, css: string) => {
|
|
52
|
+
collectRules(css.replace(/<!\[CDATA\[|\]\]>/g, ""), dark, rules);
|
|
53
|
+
return "";
|
|
54
|
+
});
|
|
55
|
+
if (rules.length === 0) return body;
|
|
56
|
+
rules.sort((a, b) => a.specificity - b.specificity || a.order - b.order);
|
|
57
|
+
return body.replace(
|
|
58
|
+
/<([A-Za-z][\w:.-]*)(\s[^<>]*?)?(\/?)>/g,
|
|
59
|
+
(tag, name: string, rawAttrs: string | undefined, close: string) => {
|
|
60
|
+
let attrs = rawAttrs ?? "";
|
|
61
|
+
const classes = (capture(attrs, /\sclass\s*=\s*["']([^"']*)["']/) ?? "")
|
|
62
|
+
.split(/\s+/)
|
|
63
|
+
.filter(Boolean);
|
|
64
|
+
const id = capture(attrs, /\sid\s*=\s*["']([^"']*)["']/);
|
|
65
|
+
const applied = new Map<string, string>();
|
|
66
|
+
for (const rule of rules) {
|
|
67
|
+
if (!matches(rule.selector, name, id, classes)) continue;
|
|
68
|
+
for (const [prop, value] of rule.decls) applied.set(prop, value);
|
|
69
|
+
}
|
|
70
|
+
if (applied.size === 0) return tag;
|
|
71
|
+
const inlineStyle = capture(attrs, /\sstyle\s*=\s*["']([^"']*)["']/) ?? "";
|
|
72
|
+
for (const [prop, value] of applied) {
|
|
73
|
+
if (new RegExp(`(^|;)\\s*${prop}\\s*:`, "i").test(inlineStyle)) continue;
|
|
74
|
+
attrs = attrs.replace(new RegExp(`\\s${prop}\\s*=\\s*("[^"]*"|'[^']*')`, "gi"), "");
|
|
75
|
+
attrs += ` ${prop}="${value.replace(/"/g, "'")}"`;
|
|
76
|
+
}
|
|
77
|
+
return `<${name}${attrs}${close}>`;
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function matches(
|
|
83
|
+
selector: SimpleSelector,
|
|
84
|
+
tag: string,
|
|
85
|
+
id: string | undefined,
|
|
86
|
+
classes: readonly string[],
|
|
87
|
+
): boolean {
|
|
88
|
+
if (selector.tag && selector.tag !== "*" && selector.tag !== tag) return false;
|
|
89
|
+
if (selector.id && selector.id !== id) return false;
|
|
90
|
+
return selector.classes.every((c) => classes.includes(c));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function collectRules(css: string, dark: boolean, into: CssRule[]): void {
|
|
94
|
+
const src = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
95
|
+
let i = 0;
|
|
96
|
+
while (i < src.length) {
|
|
97
|
+
const open = src.indexOf("{", i);
|
|
98
|
+
if (open === -1) return;
|
|
99
|
+
const prelude = src.slice(i, open).trim();
|
|
100
|
+
let depth = 1;
|
|
101
|
+
let j = open + 1;
|
|
102
|
+
while (j < src.length && depth > 0) {
|
|
103
|
+
if (src[j] === "{") depth++;
|
|
104
|
+
else if (src[j] === "}") depth--;
|
|
105
|
+
j++;
|
|
106
|
+
}
|
|
107
|
+
const block = src.slice(open + 1, j - 1);
|
|
108
|
+
i = j;
|
|
109
|
+
if (prelude.startsWith("@")) {
|
|
110
|
+
const scheme = capture(prelude, /prefers-color-scheme\s*:\s*(dark|light)/i)?.toLowerCase();
|
|
111
|
+
if (/^@media\b/i.test(prelude) && scheme === (dark ? "dark" : "light")) {
|
|
112
|
+
collectRules(block, dark, into);
|
|
113
|
+
}
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const decls = block
|
|
117
|
+
.split(";")
|
|
118
|
+
.map((d) => d.split(":"))
|
|
119
|
+
.filter((parts) => parts.length >= 2)
|
|
120
|
+
.map(
|
|
121
|
+
([prop, ...rest]) =>
|
|
122
|
+
[
|
|
123
|
+
prop!.trim().toLowerCase(),
|
|
124
|
+
rest
|
|
125
|
+
.join(":")
|
|
126
|
+
.replace(/!important/i, "")
|
|
127
|
+
.trim(),
|
|
128
|
+
] as const,
|
|
129
|
+
)
|
|
130
|
+
.filter(([prop, value]) => /^[a-z-]+$/.test(prop) && value !== "");
|
|
131
|
+
if (decls.length === 0) continue;
|
|
132
|
+
for (const part of prelude.split(",")) {
|
|
133
|
+
const selector = parseSelector(part.trim());
|
|
134
|
+
if (!selector) continue;
|
|
135
|
+
const specificity =
|
|
136
|
+
(selector.id ? 100 : 0) +
|
|
137
|
+
selector.classes.length * 10 +
|
|
138
|
+
(selector.tag && selector.tag !== "*" ? 1 : 0);
|
|
139
|
+
into.push({ selector, specificity, order: into.length, decls });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function parseSelector(text: string): SimpleSelector | undefined {
|
|
145
|
+
const m = text.match(/^([A-Za-z][\w-]*|\*)?((?:[.#][\w-]+)*)$/);
|
|
146
|
+
if (!m || text === "") return undefined;
|
|
147
|
+
const parts = m[2]!.match(/[.#][\w-]+/g) ?? [];
|
|
148
|
+
return {
|
|
149
|
+
tag: m[1],
|
|
150
|
+
id: parts.find((p) => p.startsWith("#"))?.slice(1),
|
|
151
|
+
classes: parts.filter((p) => p.startsWith(".")).map((p) => p.slice(1)),
|
|
152
|
+
};
|
|
153
|
+
}
|