@ankhorage/zora 28.12.0 → 28.12.1
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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/features/button/adapters/inbound/Button.d.ts.map +1 -1
- package/dist/features/button/adapters/inbound/Button.js +4 -2
- package/dist/features/button/adapters/inbound/Button.js.map +1 -1
- package/dist/features/layout/adapters/inbound/Screen.d.ts.map +1 -1
- package/dist/features/layout/adapters/inbound/Screen.js +2 -2
- package/dist/features/layout/adapters/inbound/Screen.js.map +1 -1
- package/dist/features/master-detail/adapters/inbound/MasterDetail.js +14 -11
- package/dist/features/master-detail/adapters/inbound/MasterDetail.js.map +1 -1
- package/dist/features/selection/adapters/inbound/RuntimeAuthoringOverlay.d.ts.map +1 -1
- package/dist/features/selection/adapters/inbound/RuntimeAuthoringOverlay.js +8 -19
- package/dist/features/selection/adapters/inbound/RuntimeAuthoringOverlay.js.map +1 -1
- package/dist/features/typography/adapters/inbound/Heading.d.ts.map +1 -1
- package/dist/features/typography/adapters/inbound/Heading.js +4 -2
- package/dist/features/typography/adapters/inbound/Heading.js.map +1 -1
- package/dist/features/typography/adapters/inbound/Text.d.ts.map +1 -1
- package/dist/features/typography/adapters/inbound/Text.js +4 -2
- package/dist/features/typography/adapters/inbound/Text.js.map +1 -1
- package/dist/types/heading.d.ts +3 -0
- package/dist/types/heading.d.ts.map +1 -1
- package/dist/types/heading.js.map +1 -1
- package/dist/types/layout.d.ts +2 -0
- package/dist/types/layout.d.ts.map +1 -1
- package/dist/types/layout.js.map +1 -1
- package/dist/types/master-detail.d.ts +3 -0
- package/dist/types/master-detail.d.ts.map +1 -1
- package/dist/types/master-detail.js.map +1 -1
- package/dist/types/text.d.ts +3 -0
- package/dist/types/text.d.ts.map +1 -1
- package/dist/types/text.js.map +1 -1
- package/package.json +2 -2
- package/src/features/button/adapters/inbound/Button.tsx +9 -1
- package/src/features/calendar/adapters/inbound/Calendar.interaction.test.tsx +54 -15
- package/src/features/layout/adapters/inbound/Screen.tsx +2 -0
- package/src/features/list/adapters/inbound/virtualizedLists.test.tsx +1 -0
- package/src/features/master-detail/adapters/inbound/MasterDetail.runtime.test.tsx +29 -1
- package/src/features/master-detail/adapters/inbound/MasterDetail.tsx +62 -10
- package/src/features/matrix-grid/adapters/inbound/MatrixGrid.protected-focus.test.tsx +47 -12
- package/src/features/matrix-grid/adapters/inbound/MatrixGrid.test.tsx +58 -1
- package/src/features/selection/adapters/inbound/RuntimeAuthoringOverlay.test.tsx +24 -10
- package/src/features/selection/adapters/inbound/RuntimeAuthoringOverlay.tsx +10 -32
- package/src/features/typography/adapters/inbound/Heading.tsx +9 -1
- package/src/features/typography/adapters/inbound/Text.tsx +9 -1
- package/src/types/heading.ts +3 -0
- package/src/types/layout.ts +2 -0
- package/src/types/master-detail.ts +3 -0
- package/src/types/text.ts +3 -0
- package/src/webPackageExports.test.ts +35 -5
- package/web-dist/authoring/index.d.ts +2 -2
- package/web-dist/authoring/index.js +5 -5
- package/web-dist/chunks/{Accordion-cah5j61y.js → Accordion-0khxr0bc.js} +1 -1
- package/web-dist/chunks/{Accordion-zagrbkq1.js → Accordion-0zg7bp65.js} +1 -1
- package/web-dist/chunks/{Accordion-h2rnzgyv.js → Accordion-13qdzpsw.js} +2 -2
- package/web-dist/chunks/{Accordion-gy3bx3xa.js → Accordion-1dv9qy83.js} +1 -1
- package/web-dist/chunks/{Accordion-7eysykr1.js → Accordion-215f8pzb.js} +6 -4
- package/web-dist/chunks/{Accordion-b1tqkxx6.js → Accordion-2khy77a4.js} +2 -2
- package/web-dist/chunks/{Accordion-5x4cv0kv.js → Accordion-31xdsdbt.js} +15 -2
- package/web-dist/chunks/{Accordion-qz6ddnmv.js → Accordion-451n4t9y.js} +2 -2
- package/web-dist/chunks/{Accordion-a8b6g53f.js → Accordion-4e5wzq5h.js} +5 -3
- package/web-dist/chunks/{Accordion-w4zh2nws.js → Accordion-5hs2x3mg.js} +8 -6
- package/web-dist/chunks/{Accordion-ajqj6ymg.js → Accordion-5ry809w9.js} +2 -2
- package/web-dist/chunks/Accordion-63x9gd07.js +21 -0
- package/web-dist/chunks/{Accordion-a0hbjxg9.js → Accordion-87rb2j42.js} +2 -2
- package/web-dist/chunks/{Accordion-nhf8zjt4.js → Accordion-8y0zdc9b.js} +1 -1
- package/web-dist/chunks/{Accordion-eysfka31.js → Accordion-9brxrdt0.js} +9 -7
- package/web-dist/chunks/{Accordion-et7xzm6k.js → Accordion-a3p5s8r5.js} +9 -7
- package/web-dist/chunks/{Accordion-vbh3xqv6.js → Accordion-b32cj447.js} +9 -4
- package/web-dist/chunks/{Accordion-afxbyvwp.js → Accordion-cx1wpv5h.js} +2 -2
- package/web-dist/chunks/{Accordion-p84h11ek.js → Accordion-e8e1qanc.js} +2 -2
- package/web-dist/chunks/{Accordion-ak6dvant.js → Accordion-fkdxf4za.js} +2 -2
- package/web-dist/chunks/{Accordion-mkd3k28h.js → Accordion-fx6h9j9b.js} +2 -2
- package/web-dist/chunks/{Accordion-dy1j2a7p.js → Accordion-hj2c784w.js} +4 -4
- package/web-dist/chunks/{Accordion-wkqemqjw.js → Accordion-j41dzcsm.js} +11 -10
- package/web-dist/chunks/{Accordion-e9jwetg7.js → Accordion-jf05jg7c.js} +2 -2
- package/web-dist/chunks/{Accordion-yannd7r3.js → Accordion-mb7bvv02.js} +2 -2
- package/web-dist/chunks/{Accordion-2b3sd76b.js → Accordion-n4pb4fxf.js} +1 -1
- package/web-dist/chunks/{Accordion-2kv6p7by.js → Accordion-ngp3wrcj.js} +22 -32
- package/web-dist/chunks/{Accordion-rv90tjqr.js → Accordion-r3s4hat8.js} +1 -1
- package/web-dist/chunks/{Accordion-x9sb23p3.js → Accordion-s6gkg1x4.js} +1 -1
- package/web-dist/chunks/{Accordion-95003ycq.js → Accordion-t3307xtr.js} +5 -5
- package/web-dist/chunks/{Accordion-th7yhwhf.js → Accordion-tchser6z.js} +6 -6
- package/web-dist/chunks/{Accordion-a49s4ywn.js → Accordion-tjdjcft9.js} +3 -3
- package/web-dist/chunks/{Accordion-ek0hh2nx.js → Accordion-v8296kpx.js} +5 -5
- package/web-dist/chunks/{Accordion-kxjjp03t.js → Accordion-xmstkrsz.js} +3 -3
- package/web-dist/chunks/{Accordion-zays65re.js → Accordion-y2vzyy2q.js} +4 -4
- package/web-dist/chunks/{Accordion-064hgrct.js → Accordion-znrwa5dy.js} +2 -2
- package/web-dist/chunks/{Accordion-dnfgtbq3.js → Accordion-zyjtbb0x.js} +8 -6
- package/web-dist/chunks/{RichTextClient-qd6gmm0x.js → RichTextClient-vvh5mm40.js} +12 -11
- package/web-dist/chunks/{Video.native-7zsbp5vg.js → Video.native-tth5fevy.js} +8 -7
- package/web-dist/components/accordion/Accordion.js +4 -3
- package/web-dist/components/accordion-item/AccordionItem.js +4 -3
- package/web-dist/components/app-bar/AppBar.js +7 -6
- package/web-dist/components/app-header/AppHeader.js +7 -6
- package/web-dist/components/app-shell/AppShell.js +2 -1
- package/web-dist/components/audio/Audio.js +8 -7
- package/web-dist/components/auth-screen/AuthScreen.js +8 -7
- package/web-dist/components/avatar/Avatar.js +4 -3
- package/web-dist/components/avatar-group/AvatarGroup.js +4 -3
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +8 -7
- package/web-dist/components/bottom-sheet/BottomSheet.js +3 -2
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +3 -2
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +3 -2
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +3 -2
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +3 -2
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +3 -2
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +7 -6
- package/web-dist/components/button/Button.js +4 -3
- package/web-dist/components/button-group/ButtonGroup.js +4 -3
- package/web-dist/components/calendar/Calendar.js +6 -5
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +8 -7
- package/web-dist/components/card/Card.js +7 -6
- package/web-dist/components/chat-list-item/ChatListItem.js +5 -4
- package/web-dist/components/checkbox/Checkbox.js +4 -3
- package/web-dist/components/checkbox-group/CheckboxGroup.js +4 -3
- package/web-dist/components/chip/Chip.js +4 -3
- package/web-dist/components/chip-group/ChipGroup.js +4 -3
- package/web-dist/components/collection-editor/CollectionEditor.js +10 -9
- package/web-dist/components/color-hue-scale/ColorHueScale.js +12 -11
- package/web-dist/components/color-picker/ColorPicker.js +12 -11
- package/web-dist/components/color-tone/ColorTone.js +12 -11
- package/web-dist/components/color-wheel/ColorWheel.js +12 -11
- package/web-dist/components/content-rail/ContentRail.js +7 -6
- package/web-dist/components/data-table/DataTable.js +16 -15
- package/web-dist/components/date-picker/DatePicker.js +9 -8
- package/web-dist/components/dialog/Dialog.js +4 -3
- package/web-dist/components/divider/Divider.js +2 -1
- package/web-dist/components/empty-state/EmptyState.js +9 -8
- package/web-dist/components/explorer/Explorer.js +5 -4
- package/web-dist/components/field/Field.js +4 -3
- package/web-dist/components/file-explorer/FileExplorer.js +5 -4
- package/web-dist/components/flat-list/FlatList.js +5 -4
- package/web-dist/components/flow-canvas/FlowCanvas.js +8 -7
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +8 -7
- package/web-dist/components/form/Form.js +6 -5
- package/web-dist/components/form-actions/FormActions.js +6 -5
- package/web-dist/components/form-error/FormError.js +6 -5
- package/web-dist/components/game/Game.js +3 -2
- package/web-dist/components/game-entity/GameEntity.js +3 -2
- package/web-dist/components/game-field/GameField.js +3 -2
- package/web-dist/components/game-input-zone/GameInputZone.js +3 -2
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +3 -2
- package/web-dist/components/game-overlay/GameOverlay.js +3 -2
- package/web-dist/components/gradient/Gradient.js +3 -2
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +3 -2
- package/web-dist/components/graph-node/GraphNode.js +8 -7
- package/web-dist/components/grid/Grid.js +2 -1
- package/web-dist/components/heading/Heading.js +2 -1
- package/web-dist/components/heading/Heading.types-0.d.ts +4 -0
- package/web-dist/components/hero/Hero.js +12 -10
- package/web-dist/components/icon-button/IconButton.js +4 -3
- package/web-dist/components/image/Image.js +3 -2
- package/web-dist/components/link/Link.js +2 -1
- package/web-dist/components/list/List.js +5 -4
- package/web-dist/components/list-item/ListItem.js +5 -4
- package/web-dist/components/list-section/ListSection.js +5 -4
- package/web-dist/components/master-detail/MasterDetail.js +21 -3
- package/web-dist/components/master-detail/MasterDetail.types-0.d.ts +4 -0
- package/web-dist/components/matrix-grid/MatrixGrid.js +1 -2
- package/web-dist/components/media-card/MediaCard.js +7 -6
- package/web-dist/components/media-explorer/MediaExplorer.js +5 -4
- package/web-dist/components/message-bubble/MessageBubble.js +5 -4
- package/web-dist/components/metric-card/MetricCard.js +7 -6
- package/web-dist/components/missing-element/MissingElement.js +3 -2
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +8 -7
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +8 -7
- package/web-dist/components/otp-form/OtpForm.js +8 -7
- package/web-dist/components/pagination/Pagination.js +7 -6
- package/web-dist/components/palette-item/PaletteItem.js +7 -6
- package/web-dist/components/popover-menu/PopoverMenu.js +3 -2
- package/web-dist/components/post-card/PostCard.js +7 -6
- package/web-dist/components/product-card/ProductCard.js +7 -6
- package/web-dist/components/progress/Progress.js +4 -3
- package/web-dist/components/progress-ring/ProgressRing.js +4 -3
- package/web-dist/components/radio/Radio.js +4 -3
- package/web-dist/components/radio-group/RadioGroup.js +4 -3
- package/web-dist/components/rating/Rating.js +2 -1
- package/web-dist/components/reader/Reader.js +11 -10
- package/web-dist/components/rich-text/RichText.js +2 -2
- package/web-dist/components/runtime-authoring-overlay/RuntimeAuthoringOverlay.js +3 -6
- package/web-dist/components/scan-overlay/ScanOverlay.js +8 -7
- package/web-dist/components/screen/Screen.js +2 -1
- package/web-dist/components/screen/Screen.types-0.d.ts +4 -0
- package/web-dist/components/screen-section/ScreenSection.js +4 -3
- package/web-dist/components/scroll-view/ScrollView.js +2 -1
- package/web-dist/components/search-input/SearchInput.js +6 -5
- package/web-dist/components/section-header/SectionHeader.js +4 -3
- package/web-dist/components/section-list/SectionList.js +5 -4
- package/web-dist/components/select/Select.js +8 -7
- package/web-dist/components/selectable-item/SelectableItem.js +3 -6
- package/web-dist/components/selection-provider/SelectionProvider.js +3 -6
- package/web-dist/components/sign-in-form/SignInForm.js +8 -7
- package/web-dist/components/sign-up-form/SignUpForm.js +8 -7
- package/web-dist/components/skeleton/Skeleton.js +10 -9
- package/web-dist/components/skeleton-card/SkeletonCard.js +10 -9
- package/web-dist/components/skeleton-list/SkeletonList.js +10 -9
- package/web-dist/components/skeleton-text/SkeletonText.js +10 -9
- package/web-dist/components/text/Text.js +2 -1
- package/web-dist/components/text/Text.types-0.d.ts +4 -0
- package/web-dist/components/text-input/TextInput.js +5 -4
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +4 -3
- package/web-dist/components/time-picker/TimePicker.js +8 -7
- package/web-dist/components/timeline/Timeline.js +4 -3
- package/web-dist/components/toolbar/Toolbar.js +8 -7
- package/web-dist/components/tree-item/TreeItem.js +10 -9
- package/web-dist/components/uploader/Uploader.js +13 -12
- package/web-dist/components/video/Video.js +5 -4
- package/web-dist/components/view/View.js +2 -1
- package/web-dist/components/zora-web-style-sheet/ZoraWebStyleSheet.js +2 -1
- package/web-dist/manifest.json +626 -525
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "28.12.
|
|
4
|
+
"version": "28.12.1",
|
|
5
5
|
"description": "Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/zora#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@ankhorage/grid-view": "^0.5.0",
|
|
51
51
|
"@ankhorage/reader": "^0.1.4",
|
|
52
52
|
"@ankhorage/runtime": "^5.8.4",
|
|
53
|
-
"@ankhorage/surface": "^9.
|
|
53
|
+
"@ankhorage/surface": "^9.9.0",
|
|
54
54
|
"@ankhorage/utility": "^1.11.0",
|
|
55
55
|
"expo-asset": "~57.0.21",
|
|
56
56
|
"expo-audio": "~57.0.5",
|
|
@@ -2,6 +2,7 @@ import { Button as SurfaceButton } from '@ankhorage/surface';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ButtonProps } from '../../../../types/button';
|
|
5
|
+
import { View } from '../../../layout/public';
|
|
5
6
|
import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope';
|
|
6
7
|
import { useZoraThemeRecipe } from '../../../theme/composition/useZoraThemeRecipe';
|
|
7
8
|
import { resolveButtonThemeRecipe } from '../../utils/resolveButtonThemeRecipe';
|
|
@@ -22,12 +23,13 @@ function ButtonInner({
|
|
|
22
23
|
variant,
|
|
23
24
|
size,
|
|
24
25
|
interactionPolicy,
|
|
26
|
+
selectionDecoration,
|
|
25
27
|
...props
|
|
26
28
|
}: ButtonProps) {
|
|
27
29
|
const themeFields = useZoraThemeRecipe(buttonThemeRecipeMeta);
|
|
28
30
|
const recipe = resolveButtonThemeRecipe({ color, variant, size, themeFields });
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
const rendered = (
|
|
31
33
|
<SurfaceButton
|
|
32
34
|
{...props}
|
|
33
35
|
color={recipe.color}
|
|
@@ -36,4 +38,10 @@ function ButtonInner({
|
|
|
36
38
|
interactionPolicy={interactionPolicy}
|
|
37
39
|
/>
|
|
38
40
|
);
|
|
41
|
+
|
|
42
|
+
return selectionDecoration === undefined ? (
|
|
43
|
+
rendered
|
|
44
|
+
) : (
|
|
45
|
+
<View selectionDecoration={selectionDecoration}>{rendered}</View>
|
|
46
|
+
);
|
|
39
47
|
}
|
|
@@ -16,12 +16,56 @@ import type { ZoraProvider as ZoraProviderComponent } from '../../../theme/runti
|
|
|
16
16
|
import type { Calendar as CalendarComponent } from './Calendar';
|
|
17
17
|
|
|
18
18
|
const webDistRoot = join(import.meta.dir, '../../../../../web-dist');
|
|
19
|
+
let browserArtifact: Promise<BrowserArtifact> | undefined;
|
|
20
|
+
|
|
21
|
+
interface BrowserArtifact {
|
|
22
|
+
readonly Calendar: typeof CalendarComponent;
|
|
23
|
+
readonly ZoraProvider: typeof ZoraProviderComponent;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*** Load the generated Calendar and provider through one browser-conditioned module graph. */
|
|
27
|
+
async function loadCalendar() {
|
|
28
|
+
browserArtifact ??= buildBrowserArtifact();
|
|
29
|
+
return browserArtifact;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*** Bundle existing generated artifacts with browser dependency resolution for Bun's DOM assertions. */
|
|
33
|
+
async function buildBrowserArtifact(): Promise<BrowserArtifact> {
|
|
34
|
+
const entryPath = join(webDistRoot, '.calendar-browser-entry.mjs');
|
|
35
|
+
const outputPath = join(webDistRoot, '.calendar-browser-test.mjs');
|
|
36
|
+
await Bun.write(
|
|
37
|
+
entryPath,
|
|
38
|
+
"export { Calendar } from './components/calendar/index.js';\nexport { ZoraProvider } from './runtime/ZoraProvider.js';\n",
|
|
39
|
+
);
|
|
40
|
+
const build = await Bun.build({
|
|
41
|
+
entrypoints: [entryPath],
|
|
42
|
+
conditions: ['browser', 'import', 'default'],
|
|
43
|
+
external: ['react', 'react/*', 'react-dom', 'react-dom/*', 'react-native-web'],
|
|
44
|
+
format: 'esm',
|
|
45
|
+
minifyWhitespace: true,
|
|
46
|
+
outfile: outputPath,
|
|
47
|
+
plugins: [
|
|
48
|
+
{
|
|
49
|
+
name: 'calendar-browser-react-native-alias',
|
|
50
|
+
setup(builder) {
|
|
51
|
+
builder.onResolve({ filter: /^react-native$/u }, () => ({
|
|
52
|
+
external: true,
|
|
53
|
+
path: 'react-native-web',
|
|
54
|
+
}));
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
target: 'browser',
|
|
59
|
+
write: true,
|
|
60
|
+
});
|
|
61
|
+
if (!build.success || !build.outputs[0])
|
|
62
|
+
throw new Error(build.logs.map((log) => log.message).join('\n'));
|
|
63
|
+
await Bun.write(outputPath, build.outputs[0]);
|
|
64
|
+
return (await import(pathToFileURL(outputPath).href)) as BrowserArtifact;
|
|
65
|
+
}
|
|
19
66
|
|
|
20
67
|
test('selects adjacent days through the locked GridView in regular and compact calendars', async () => {
|
|
21
|
-
const
|
|
22
|
-
import(pathToFileURL(join(webDistRoot, 'components', 'calendar', 'index.js')).href),
|
|
23
|
-
import(pathToFileURL(join(webDistRoot, 'runtime/ZoraProvider.js')).href),
|
|
24
|
-
])) as [{ Calendar: typeof CalendarComponent }, { ZoraProvider: typeof ZoraProviderComponent }];
|
|
68
|
+
const { Calendar, ZoraProvider } = await loadCalendar();
|
|
25
69
|
|
|
26
70
|
await withBrowserAsync(async (host) => {
|
|
27
71
|
const selections: string[] = [];
|
|
@@ -82,10 +126,7 @@ test('selects adjacent days through the locked GridView in regular and compact c
|
|
|
82
126
|
});
|
|
83
127
|
|
|
84
128
|
test('renders responsive day columns, a time axis, and activatable event cards in a direct week Calendar', async () => {
|
|
85
|
-
const
|
|
86
|
-
import(pathToFileURL(join(webDistRoot, 'components', 'calendar', 'index.js')).href),
|
|
87
|
-
import(pathToFileURL(join(webDistRoot, 'runtime/ZoraProvider.js')).href),
|
|
88
|
-
])) as [{ Calendar: typeof CalendarComponent }, { ZoraProvider: typeof ZoraProviderComponent }];
|
|
129
|
+
const { Calendar, ZoraProvider } = await loadCalendar();
|
|
89
130
|
|
|
90
131
|
await withBrowserAsync(async (host) => {
|
|
91
132
|
const activations: string[] = [];
|
|
@@ -109,6 +150,7 @@ test('renders responsive day columns, a time axis, and activatable event cards i
|
|
|
109
150
|
title: 'Planning',
|
|
110
151
|
},
|
|
111
152
|
]}
|
|
153
|
+
locale="en-US"
|
|
112
154
|
onEventActivate={({ eventId }) => activations.push(eventId)}
|
|
113
155
|
testID="direct-week-calendar"
|
|
114
156
|
timeZone="Europe/Zurich"
|
|
@@ -126,7 +168,7 @@ test('renders responsive day columns, a time axis, and activatable event cards i
|
|
|
126
168
|
);
|
|
127
169
|
if (!grid || !event) throw new Error('Missing responsive week Calendar grid or event card');
|
|
128
170
|
|
|
129
|
-
expect(host.textContent).
|
|
171
|
+
expect(host.textContent).toMatch(/Mon 30|30 Mon/);
|
|
130
172
|
expect(host.textContent).toContain('Planning');
|
|
131
173
|
expect(grid.getAttribute('style')).not.toContain('width: 320px');
|
|
132
174
|
await interactAsync(() => event.click());
|
|
@@ -138,14 +180,11 @@ test('renders responsive day columns, a time axis, and activatable event cards i
|
|
|
138
180
|
});
|
|
139
181
|
|
|
140
182
|
test('renders a Calendar manifest and reactively updates its controlled date and events', async () => {
|
|
141
|
-
const
|
|
142
|
-
import(pathToFileURL(join(webDistRoot, 'components', 'calendar', 'index.js')).href),
|
|
143
|
-
import(pathToFileURL(join(webDistRoot, 'runtime/ZoraProvider.js')).href),
|
|
144
|
-
])) as [{ Calendar: typeof CalendarComponent }, { ZoraProvider: typeof ZoraProviderComponent }];
|
|
183
|
+
const { Calendar, ZoraProvider } = await loadCalendar();
|
|
145
184
|
const node = {
|
|
146
185
|
id: 'calendar',
|
|
147
186
|
type: 'Calendar',
|
|
148
|
-
props: { testID: 'manifest-calendar', view: 'week' },
|
|
187
|
+
props: { locale: 'en-US', testID: 'manifest-calendar', view: 'week' },
|
|
149
188
|
} as const satisfies UiNode;
|
|
150
189
|
const bindings = {
|
|
151
190
|
calendar: {
|
|
@@ -212,7 +251,7 @@ test('renders a Calendar manifest and reactively updates its controlled date and
|
|
|
212
251
|
try {
|
|
213
252
|
await interactAsync(render);
|
|
214
253
|
expect(host.textContent).toContain('Zurich');
|
|
215
|
-
expect(host.textContent).
|
|
254
|
+
expect(host.textContent).toMatch(/Fri 4|4 Fri/);
|
|
216
255
|
expect(
|
|
217
256
|
host.querySelector('[data-testid="manifest-calendar-week-grid-viewport"]'),
|
|
218
257
|
).not.toBeNull();
|
|
@@ -13,6 +13,7 @@ function ScreenInner({
|
|
|
13
13
|
children,
|
|
14
14
|
footer,
|
|
15
15
|
scroll = true,
|
|
16
|
+
selectionDecoration,
|
|
16
17
|
width = 'default',
|
|
17
18
|
testID,
|
|
18
19
|
}: ScreenProps) {
|
|
@@ -26,6 +27,7 @@ function ScreenInner({
|
|
|
26
27
|
minWidth={scroll ? undefined : 0}
|
|
27
28
|
px={{ base: 16, md: 24, lg: 32 }}
|
|
28
29
|
py="xl"
|
|
30
|
+
selectionDecoration={selectionDecoration}
|
|
29
31
|
testID={testID}
|
|
30
32
|
width="100%"
|
|
31
33
|
>
|
|
@@ -38,6 +38,7 @@ await mock.module('@ankhorage/surface', () => ({
|
|
|
38
38
|
resolveResponsive: <T,>(value: T) => value,
|
|
39
39
|
useResponsiveRuntime: () => ({ breakpoint: undefined }),
|
|
40
40
|
useTheme: () => ({ theme: {} }),
|
|
41
|
+
View: ({ children }: React.PropsWithChildren) => <>{children}</>,
|
|
41
42
|
}));
|
|
42
43
|
await mock.module('../../../layout/public', () => ({ Divider: () => null }));
|
|
43
44
|
|
|
@@ -28,14 +28,22 @@ await mock.module('@ankhorage/surface', () => ({
|
|
|
28
28
|
flex,
|
|
29
29
|
minHeight,
|
|
30
30
|
minWidth,
|
|
31
|
+
selectionDecoration,
|
|
31
32
|
testID,
|
|
32
33
|
}: React.PropsWithChildren<{
|
|
33
34
|
readonly flex?: number;
|
|
34
35
|
readonly minHeight?: number;
|
|
35
36
|
readonly minWidth?: number;
|
|
37
|
+
readonly selectionDecoration?: { readonly selected: boolean };
|
|
36
38
|
readonly testID?: string;
|
|
37
39
|
}>) => (
|
|
38
|
-
<div
|
|
40
|
+
<div
|
|
41
|
+
data-flex={flex}
|
|
42
|
+
data-min-height={minHeight}
|
|
43
|
+
data-min-width={minWidth}
|
|
44
|
+
data-selection={selectionDecoration?.selected ? 'selected' : undefined}
|
|
45
|
+
data-view={testID}
|
|
46
|
+
>
|
|
39
47
|
{children}
|
|
40
48
|
</div>
|
|
41
49
|
),
|
|
@@ -158,3 +166,23 @@ test('keeps the compact detail pane bounded without scrolling', () => {
|
|
|
158
166
|
expect(markup).toContain('data-view="workspace-detail"');
|
|
159
167
|
expect(markup).not.toContain('data-scroll="workspace-detail"');
|
|
160
168
|
});
|
|
169
|
+
|
|
170
|
+
test('attaches selection to Screen content and the bounded MasterDetail host without changing panes', () => {
|
|
171
|
+
runtimeEnvironment.breakpoint = 'md';
|
|
172
|
+
const selectionDecoration = { onPress: () => undefined, selected: true };
|
|
173
|
+
const markup = renderToStaticMarkup(
|
|
174
|
+
<Screen scroll={false} selectionDecoration={selectionDecoration} testID="screen">
|
|
175
|
+
<MasterDetail selectionDecoration={selectionDecoration} testID="workspace">
|
|
176
|
+
<span>Master content</span>
|
|
177
|
+
<span>Detail content</span>
|
|
178
|
+
</MasterDetail>
|
|
179
|
+
</Screen>,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
expect(markup).toContain('data-selection="selected" data-view="screen"');
|
|
183
|
+
expect(markup).toContain('data-selection="selected" data-view="workspace"');
|
|
184
|
+
expect(markup.match(/data-selection="selected"/gu)).toHaveLength(2);
|
|
185
|
+
expect(markup).toContain('data-min-height="0"');
|
|
186
|
+
expect(markup).toContain('data-scroll="workspace-master"');
|
|
187
|
+
expect(markup).toContain('data-scroll="workspace-detail"');
|
|
188
|
+
});
|
|
@@ -19,19 +19,42 @@ function MasterDetailInner({
|
|
|
19
19
|
children,
|
|
20
20
|
masterWidth = 30,
|
|
21
21
|
masterScroll = true,
|
|
22
|
+
selectionDecoration,
|
|
22
23
|
detailScroll = true,
|
|
23
24
|
testID,
|
|
24
25
|
}: MasterDetailProps) {
|
|
25
26
|
const presentation = resolveMasterDetailPresentation(useBreakpoint(), activePane, desktopMode);
|
|
26
27
|
const [master, detail] = React.Children.toArray(children);
|
|
27
|
-
const
|
|
28
|
-
const
|
|
28
|
+
const paneSelectionDecoration = presentation === 'split' ? undefined : selectionDecoration;
|
|
29
|
+
const masterPane = (
|
|
30
|
+
<MasterPane
|
|
31
|
+
master={master}
|
|
32
|
+
scroll={masterScroll}
|
|
33
|
+
selectionDecoration={paneSelectionDecoration}
|
|
34
|
+
testID={testID}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
const detailPane = (
|
|
38
|
+
<DetailPane
|
|
39
|
+
detail={detail}
|
|
40
|
+
scroll={detailScroll}
|
|
41
|
+
selectionDecoration={paneSelectionDecoration}
|
|
42
|
+
testID={testID}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
29
45
|
|
|
30
46
|
if (presentation === 'master') return masterPane;
|
|
31
47
|
if (presentation === 'detail') return detailPane;
|
|
32
48
|
|
|
33
49
|
return (
|
|
34
|
-
<View
|
|
50
|
+
<View
|
|
51
|
+
direction="row"
|
|
52
|
+
flex={1}
|
|
53
|
+
minHeight={0}
|
|
54
|
+
minWidth={0}
|
|
55
|
+
selectionDecoration={selectionDecoration}
|
|
56
|
+
testID={testID}
|
|
57
|
+
>
|
|
35
58
|
<View flex={masterWidth} minHeight={0} minWidth={0}>
|
|
36
59
|
{masterPane}
|
|
37
60
|
</View>
|
|
@@ -46,10 +69,18 @@ function MasterDetailInner({
|
|
|
46
69
|
function MasterPane({
|
|
47
70
|
master,
|
|
48
71
|
scroll,
|
|
72
|
+
selectionDecoration,
|
|
49
73
|
testID,
|
|
50
|
-
}: Pick<MasterDetailProps, 'testID'> & {
|
|
74
|
+
}: Pick<MasterDetailProps, 'selectionDecoration' | 'testID'> & {
|
|
75
|
+
master?: React.ReactNode;
|
|
76
|
+
scroll: boolean;
|
|
77
|
+
}) {
|
|
51
78
|
return (
|
|
52
|
-
<PaneRegion
|
|
79
|
+
<PaneRegion
|
|
80
|
+
scroll={scroll}
|
|
81
|
+
selectionDecoration={selectionDecoration}
|
|
82
|
+
testID={testID ? `${testID}-master` : undefined}
|
|
83
|
+
>
|
|
53
84
|
{master}
|
|
54
85
|
</PaneRegion>
|
|
55
86
|
);
|
|
@@ -59,10 +90,18 @@ function MasterPane({
|
|
|
59
90
|
function DetailPane({
|
|
60
91
|
detail,
|
|
61
92
|
scroll,
|
|
93
|
+
selectionDecoration,
|
|
62
94
|
testID,
|
|
63
|
-
}: Pick<MasterDetailProps, 'testID'> & {
|
|
95
|
+
}: Pick<MasterDetailProps, 'selectionDecoration' | 'testID'> & {
|
|
96
|
+
detail?: React.ReactNode;
|
|
97
|
+
scroll: boolean;
|
|
98
|
+
}) {
|
|
64
99
|
return (
|
|
65
|
-
<PaneRegion
|
|
100
|
+
<PaneRegion
|
|
101
|
+
scroll={scroll}
|
|
102
|
+
selectionDecoration={selectionDecoration}
|
|
103
|
+
testID={testID ? `${testID}-detail` : undefined}
|
|
104
|
+
>
|
|
66
105
|
{detail}
|
|
67
106
|
</PaneRegion>
|
|
68
107
|
);
|
|
@@ -72,11 +111,22 @@ function DetailPane({
|
|
|
72
111
|
function PaneRegion({
|
|
73
112
|
children,
|
|
74
113
|
scroll,
|
|
114
|
+
selectionDecoration,
|
|
75
115
|
testID,
|
|
76
|
-
}: React.PropsWithChildren<{
|
|
116
|
+
}: React.PropsWithChildren<{
|
|
117
|
+
scroll: boolean;
|
|
118
|
+
selectionDecoration?: MasterDetailProps['selectionDecoration'];
|
|
119
|
+
testID?: string;
|
|
120
|
+
}>) {
|
|
77
121
|
if (!scroll) {
|
|
78
122
|
return (
|
|
79
|
-
<View
|
|
123
|
+
<View
|
|
124
|
+
flex={1}
|
|
125
|
+
minHeight={0}
|
|
126
|
+
minWidth={0}
|
|
127
|
+
selectionDecoration={selectionDecoration}
|
|
128
|
+
testID={testID}
|
|
129
|
+
>
|
|
80
130
|
{children}
|
|
81
131
|
</View>
|
|
82
132
|
);
|
|
@@ -84,7 +134,9 @@ function PaneRegion({
|
|
|
84
134
|
|
|
85
135
|
return (
|
|
86
136
|
<ScrollView flex={1} minHeight={0} minWidth={0} testID={testID}>
|
|
87
|
-
{
|
|
137
|
+
<View minHeight={0} minWidth={0} selectionDecoration={selectionDecoration}>
|
|
138
|
+
{children}
|
|
139
|
+
</View>
|
|
88
140
|
</ScrollView>
|
|
89
141
|
);
|
|
90
142
|
}
|
|
@@ -15,7 +15,12 @@ const browserKeys = [
|
|
|
15
15
|
'IS_REACT_ACT_ENVIRONMENT',
|
|
16
16
|
] as const;
|
|
17
17
|
const webDistRoot = join(import.meta.dir, '../../../../../web-dist');
|
|
18
|
-
|
|
18
|
+
let browserArtifact: Promise<BrowserArtifact> | undefined;
|
|
19
|
+
|
|
20
|
+
interface BrowserArtifact {
|
|
21
|
+
readonly MatrixGrid: MatrixGridComponent;
|
|
22
|
+
readonly ZoraProvider: ZoraProviderComponent;
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
interface MatrixCell {
|
|
21
26
|
readonly columnId: string;
|
|
@@ -38,6 +43,47 @@ type MatrixGridComponent = React.ComponentType<{
|
|
|
38
43
|
}>;
|
|
39
44
|
type ZoraProviderComponent = React.ComponentType<{ readonly children: React.ReactNode }>;
|
|
40
45
|
|
|
46
|
+
/*** Load the generated MatrixGrid and provider through one browser-conditioned module graph. */
|
|
47
|
+
async function loadMatrixGrid() {
|
|
48
|
+
browserArtifact ??= buildBrowserArtifact();
|
|
49
|
+
return browserArtifact;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/*** Bundle existing generated artifacts with browser dependency resolution for Bun's DOM assertions. */
|
|
53
|
+
async function buildBrowserArtifact(): Promise<BrowserArtifact> {
|
|
54
|
+
const entryPath = join(webDistRoot, '.matrix-grid-protected-focus-entry.mjs');
|
|
55
|
+
const outputPath = join(webDistRoot, '.matrix-grid-protected-focus-test.mjs');
|
|
56
|
+
await Bun.write(
|
|
57
|
+
entryPath,
|
|
58
|
+
"export { MatrixGrid } from './components/matrix-grid/MatrixGrid.js';\nexport { ZoraProvider } from './runtime/ZoraProvider.js';\n",
|
|
59
|
+
);
|
|
60
|
+
const build = await Bun.build({
|
|
61
|
+
entrypoints: [entryPath],
|
|
62
|
+
conditions: ['browser', 'import', 'default'],
|
|
63
|
+
external: ['react', 'react/*', 'react-dom', 'react-dom/*', 'react-native-web'],
|
|
64
|
+
format: 'esm',
|
|
65
|
+
minifyWhitespace: true,
|
|
66
|
+
outfile: outputPath,
|
|
67
|
+
plugins: [
|
|
68
|
+
{
|
|
69
|
+
name: 'matrix-grid-protected-focus-browser-react-native-alias',
|
|
70
|
+
setup(builder) {
|
|
71
|
+
builder.onResolve({ filter: /^react-native$/u }, () => ({
|
|
72
|
+
external: true,
|
|
73
|
+
path: 'react-native-web',
|
|
74
|
+
}));
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
target: 'browser',
|
|
79
|
+
write: true,
|
|
80
|
+
});
|
|
81
|
+
if (!build.success || !build.outputs[0])
|
|
82
|
+
throw new Error(build.logs.map((log) => log.message).join('\n'));
|
|
83
|
+
await Bun.write(outputPath, build.outputs[0]);
|
|
84
|
+
return (await import(pathToFileURL(outputPath).href)) as BrowserArtifact;
|
|
85
|
+
}
|
|
86
|
+
|
|
41
87
|
/*** Mount MatrixGrid through React Native Web and restore the ambient DOM after each assertion. */
|
|
42
88
|
async function withMatrixDom(assertion: (host: HTMLElement, browser: Window) => Promise<void>) {
|
|
43
89
|
const browser = new Window();
|
|
@@ -65,17 +111,6 @@ async function withMatrixDom(assertion: (host: HTMLElement, browser: Window) =>
|
|
|
65
111
|
}
|
|
66
112
|
}
|
|
67
113
|
|
|
68
|
-
/*** Load the compiled MatrixGrid and provider used by React Native Web interaction tests. */
|
|
69
|
-
async function loadMatrixGrid() {
|
|
70
|
-
const { MatrixGrid } = (await load('components/matrix-grid/MatrixGrid.js')) as {
|
|
71
|
-
MatrixGrid: MatrixGridComponent;
|
|
72
|
-
};
|
|
73
|
-
const { ZoraProvider } = (await load('runtime/ZoraProvider.js')) as {
|
|
74
|
-
ZoraProvider: ZoraProviderComponent;
|
|
75
|
-
};
|
|
76
|
-
return { MatrixGrid, ZoraProvider };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
114
|
test('retains focus when protected terminal cells block all four arrow directions', async () => {
|
|
80
115
|
await withMatrixDom(async (host, browser) => {
|
|
81
116
|
const root = createRoot(host);
|
|
@@ -15,7 +15,64 @@ const browserKeys = [
|
|
|
15
15
|
'IS_REACT_ACT_ENVIRONMENT',
|
|
16
16
|
] as const;
|
|
17
17
|
const webDistRoot = join(import.meta.dir, '../../../../../web-dist');
|
|
18
|
-
const load = (path: string) =>
|
|
18
|
+
const load = async (path: string) => {
|
|
19
|
+
const artifact = await loadBrowserArtifact();
|
|
20
|
+
return path === 'components/matrix-grid/MatrixGrid.js'
|
|
21
|
+
? {
|
|
22
|
+
MatrixGrid: artifact.MatrixGrid,
|
|
23
|
+
}
|
|
24
|
+
: {
|
|
25
|
+
ZoraProvider: artifact.ZoraProvider,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
interface BrowserArtifact {
|
|
30
|
+
readonly MatrixGrid: React.ComponentType<unknown>;
|
|
31
|
+
readonly ZoraProvider: React.ComponentType<{ readonly children: React.ReactNode }>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*** Load the generated MatrixGrid and provider through the same browser-conditioned module graph. */
|
|
35
|
+
let browserArtifact: Promise<BrowserArtifact> | undefined;
|
|
36
|
+
|
|
37
|
+
function loadBrowserArtifact() {
|
|
38
|
+
browserArtifact ??= buildBrowserArtifact();
|
|
39
|
+
return browserArtifact;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*** Bundle existing generated artifacts with browser dependency resolution for Bun's DOM assertions. */
|
|
43
|
+
async function buildBrowserArtifact() {
|
|
44
|
+
const entryPath = join(webDistRoot, '.matrix-grid-browser-entry.mjs');
|
|
45
|
+
const outputPath = join(webDistRoot, '.matrix-grid-browser-test.mjs');
|
|
46
|
+
await Bun.write(
|
|
47
|
+
entryPath,
|
|
48
|
+
"export { MatrixGrid } from './components/matrix-grid/MatrixGrid.js';\nexport { ZoraProvider } from './runtime/ZoraProvider.js';\n",
|
|
49
|
+
);
|
|
50
|
+
const build = await Bun.build({
|
|
51
|
+
entrypoints: [entryPath],
|
|
52
|
+
conditions: ['browser', 'import', 'default'],
|
|
53
|
+
external: ['react', 'react/*', 'react-dom', 'react-dom/*', 'react-native-web'],
|
|
54
|
+
format: 'esm',
|
|
55
|
+
minifyWhitespace: true,
|
|
56
|
+
outfile: outputPath,
|
|
57
|
+
plugins: [
|
|
58
|
+
{
|
|
59
|
+
name: 'matrix-grid-browser-react-native-alias',
|
|
60
|
+
setup(builder) {
|
|
61
|
+
builder.onResolve({ filter: /^react-native$/u }, () => ({
|
|
62
|
+
external: true,
|
|
63
|
+
path: 'react-native-web',
|
|
64
|
+
}));
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
target: 'browser',
|
|
69
|
+
write: true,
|
|
70
|
+
});
|
|
71
|
+
if (!build.success || !build.outputs[0])
|
|
72
|
+
throw new Error(build.logs.map((log) => log.message).join('\n'));
|
|
73
|
+
await Bun.write(outputPath, build.outputs[0]);
|
|
74
|
+
return (await import(pathToFileURL(outputPath).href)) as BrowserArtifact;
|
|
75
|
+
}
|
|
19
76
|
|
|
20
77
|
/*** Mount MatrixGrid through React Native Web and restore the ambient DOM after each assertion. */
|
|
21
78
|
async function withMatrixDom(assertion: (host: HTMLElement, browser: Window) => Promise<void>) {
|
|
@@ -48,7 +48,7 @@ describe('RuntimeAuthoringOverlay', () => {
|
|
|
48
48
|
expect(selected).toEqual(['replacement']);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
test('uses Runtime identity and
|
|
51
|
+
test('uses Runtime identity and decorates the rendered target in both modes', async () => {
|
|
52
52
|
const { createRuntimeAuthoringOverlayAdapter } = await loadOverlay();
|
|
53
53
|
const edit = createRuntimeAuthoringOverlayAdapter({ mode: 'edit' });
|
|
54
54
|
const preview = createRuntimeAuthoringOverlayAdapter({ mode: 'preview' });
|
|
@@ -62,8 +62,20 @@ describe('RuntimeAuthoringOverlay', () => {
|
|
|
62
62
|
expect(isValidElement(editNode) && isValidElement(previewNode) && editNode.type).toBe(
|
|
63
63
|
previewNode.type,
|
|
64
64
|
);
|
|
65
|
-
expect(
|
|
66
|
-
expect(
|
|
65
|
+
expect(readDecoration(editNode).type).toBe('SelectionDecoration');
|
|
66
|
+
expect(readDecoration(previewNode).type).toBe('SelectionDecoration');
|
|
67
|
+
expect(readDecoration(editNode).props.interactionPolicy).toBe('enabled');
|
|
68
|
+
expect(readDecoration(previewNode).props.interactionPolicy).toBe('passive');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('keeps the rendered target as the direct decoration child', async () => {
|
|
72
|
+
const { createRuntimeAuthoringOverlayAdapter } = await loadOverlay();
|
|
73
|
+
const args = { isRoot: false, node, rendered: <target /> };
|
|
74
|
+
const editNode = createRuntimeAuthoringOverlayAdapter({ mode: 'edit' }).wrapNode(args);
|
|
75
|
+
const previewNode = createRuntimeAuthoringOverlayAdapter({ mode: 'preview' }).wrapNode(args);
|
|
76
|
+
|
|
77
|
+
expect(readDecoration(editNode).props.children).toBe(args.rendered);
|
|
78
|
+
expect(readDecoration(previewNode).props.children).toBe(args.rendered);
|
|
67
79
|
});
|
|
68
80
|
|
|
69
81
|
test('selects the hit target only in edit mode', async () => {
|
|
@@ -76,8 +88,8 @@ describe('RuntimeAuthoringOverlay', () => {
|
|
|
76
88
|
const editNode = createRuntimeAuthoringOverlayAdapter({ mode: 'edit' }).wrapNode(args);
|
|
77
89
|
const previewNode = createRuntimeAuthoringOverlayAdapter({ mode: 'preview' }).wrapNode(args);
|
|
78
90
|
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
readDecoration(editNode).props.onPress({});
|
|
92
|
+
readDecoration(previewNode).props.onPress({});
|
|
81
93
|
|
|
82
94
|
expect(selected.runtimeAuthoringOverlaySelections).toEqual(['target-button']);
|
|
83
95
|
delete selected.runtimeAuthoringOverlaySelections;
|
|
@@ -99,9 +111,10 @@ function readProvider(element: ReactElement): ReactElement<{
|
|
|
99
111
|
}>;
|
|
100
112
|
}
|
|
101
113
|
|
|
102
|
-
/*** Renders the
|
|
103
|
-
function
|
|
104
|
-
readonly
|
|
114
|
+
/*** Renders the direct decoration with inert controls so selection behavior can be asserted without mounting. */
|
|
115
|
+
function readDecoration(element: ReactElement): ReactElement<{
|
|
116
|
+
readonly children: ReactElement;
|
|
117
|
+
readonly interactionPolicy: 'enabled' | 'passive';
|
|
105
118
|
readonly onPress: (event: unknown) => void;
|
|
106
119
|
}> {
|
|
107
120
|
if (typeof element.type !== 'function') {
|
|
@@ -112,7 +125,8 @@ function readWrappedNode(element: ReactElement): ReactElement<{
|
|
|
112
125
|
component: { componentId: node.id, node },
|
|
113
126
|
select: () => true,
|
|
114
127
|
}) as ReactElement<{
|
|
115
|
-
readonly
|
|
128
|
+
readonly children: ReactElement;
|
|
129
|
+
readonly interactionPolicy: 'enabled' | 'passive';
|
|
116
130
|
readonly onPress: (event: unknown) => void;
|
|
117
131
|
}>;
|
|
118
132
|
}
|
|
@@ -136,7 +150,7 @@ async function loadOverlay(): Promise<LoadedOverlay> {
|
|
|
136
150
|
{ filter: /.*/u, namespace: 'inert-runtime-authoring-overlay-controls' },
|
|
137
151
|
() => ({
|
|
138
152
|
loader: 'js',
|
|
139
|
-
contents: `export const
|
|
153
|
+
contents: `export const SelectionDecoration='SelectionDecoration', SelectionProvider='SelectionProvider',
|
|
140
154
|
useSelection=()=>({isSelected:()=>false,select:(id)=>globalThis.runtimeAuthoringOverlaySelections?.push(id)}),
|
|
141
155
|
useZoraTheme=()=>({theme:{semantics:{highlight:'highlight'}}});`,
|
|
142
156
|
}),
|
|
@@ -2,15 +2,14 @@ import type {
|
|
|
2
2
|
RuntimeAuthoringOverlayAdapter,
|
|
3
3
|
RuntimeAuthoringOverlayNodeArgs,
|
|
4
4
|
} from '@ankhorage/runtime';
|
|
5
|
-
import {
|
|
5
|
+
import type { ViewProps as SurfaceViewProps } from '@ankhorage/surface';
|
|
6
|
+
import { SelectionDecoration } from '@ankhorage/surface/authoring-controls';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
|
|
8
9
|
import type {
|
|
9
10
|
CreateRuntimeAuthoringOverlayAdapterOptions,
|
|
10
11
|
RuntimeAuthoringOverlayProps,
|
|
11
12
|
} from '../../../../types/selection';
|
|
12
|
-
import { View } from '../../../layout/public';
|
|
13
|
-
import { useZoraTheme } from '../../../theme/composition/useZoraTheme';
|
|
14
13
|
import { SelectionProvider, useSelection } from './SelectionProvider';
|
|
15
14
|
|
|
16
15
|
/*** Provides controlled, single-node selection to Runtime-rendered content without creating a second renderer tree. */
|
|
@@ -44,14 +43,13 @@ export function createRuntimeAuthoringOverlayAdapter({
|
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
/***
|
|
46
|
+
/*** Attaches selection directly to the rendered node's ZORA-owned host boundary without a layout wrapper. */
|
|
48
47
|
function RuntimeAuthoringOverlayNode({
|
|
49
48
|
component,
|
|
50
49
|
mode,
|
|
51
50
|
rendered,
|
|
52
51
|
select,
|
|
53
52
|
}: RuntimeAuthoringOverlayNodeArgs & { readonly mode: 'edit' | 'preview' }) {
|
|
54
|
-
const { theme } = useZoraTheme();
|
|
55
53
|
const selection = useSelection();
|
|
56
54
|
const selected = selection.isSelected(component.componentId);
|
|
57
55
|
const handlePress = (event: unknown) => {
|
|
@@ -59,36 +57,16 @@ function RuntimeAuthoringOverlayNode({
|
|
|
59
57
|
selection.select(component.componentId);
|
|
60
58
|
};
|
|
61
59
|
|
|
60
|
+
if (!React.isValidElement(rendered)) return rendered;
|
|
61
|
+
const target = rendered as React.ReactElement<Pick<SurfaceViewProps, 'selectionDecoration'>>;
|
|
62
|
+
|
|
62
63
|
return (
|
|
63
|
-
<
|
|
64
|
-
accessibilityLabel={`Select ${component.node.type}`}
|
|
65
|
-
accessibilityRole="none"
|
|
66
|
-
accessibilityState={{ selected }}
|
|
64
|
+
<SelectionDecoration
|
|
67
65
|
interactionPolicy={mode === 'edit' ? 'enabled' : 'passive'}
|
|
68
66
|
onPress={handlePress}
|
|
69
|
-
|
|
70
|
-
testID={`runtime-authoring-node-${component.componentId}`}
|
|
67
|
+
selected={selected}
|
|
71
68
|
>
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
<View
|
|
75
|
-
borderColor={theme.semantics.highlight}
|
|
76
|
-
borderWidth={2}
|
|
77
|
-
pointerEvents="none"
|
|
78
|
-
style={styles.highlight}
|
|
79
|
-
/>
|
|
80
|
-
) : null}
|
|
81
|
-
</Pressable>
|
|
69
|
+
{target}
|
|
70
|
+
</SelectionDecoration>
|
|
82
71
|
);
|
|
83
72
|
}
|
|
84
|
-
|
|
85
|
-
const styles = {
|
|
86
|
-
highlight: {
|
|
87
|
-
bottom: 0,
|
|
88
|
-
left: 0,
|
|
89
|
-
position: 'absolute' as const,
|
|
90
|
-
right: 0,
|
|
91
|
-
top: 0,
|
|
92
|
-
},
|
|
93
|
-
wrapper: { position: 'relative' as const },
|
|
94
|
-
};
|