@ankhorage/zora 28.8.0 → 28.8.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/selection/adapters/inbound/RuntimeAuthoringOverlay.js +1 -1
- package/dist/features/selection/adapters/inbound/RuntimeAuthoringOverlay.js.map +1 -1
- package/package.json +3 -3
- package/src/features/selection/adapters/inbound/RuntimeAuthoringOverlay.test.tsx +39 -2
- package/src/features/selection/adapters/inbound/RuntimeAuthoringOverlay.tsx +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# ZORA
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Provides opinionated React Native and React Native Web UI components, theme primitives, registries, and reader surfaces built on @ankhorage/surface.
|
|
9
9
|
|
|
@@ -28,7 +28,7 @@ function RuntimeAuthoringOverlayNode({ component, mode, rendered, select, }) {
|
|
|
28
28
|
return;
|
|
29
29
|
selection.select(component.componentId);
|
|
30
30
|
};
|
|
31
|
-
return (<Pressable accessibilityLabel={`Select ${component.node.type}`} accessibilityRole="
|
|
31
|
+
return (<Pressable accessibilityLabel={`Select ${component.node.type}`} accessibilityRole="none" accessibilityState={{ selected }} interactionPolicy={mode === 'edit' ? 'enabled' : 'passive'} onPress={handlePress} style={styles.wrapper} testID={`runtime-authoring-node-${component.componentId}`}>
|
|
32
32
|
{rendered}
|
|
33
33
|
{selected ? (<View borderColor={theme.semantics.highlight} borderWidth={2} pointerEvents="none" style={styles.highlight}/>) : null}
|
|
34
34
|
</Pressable>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeAuthoringOverlay.js","sourceRoot":"","sources":["../../../../../src/features/selection/adapters/inbound/RuntimeAuthoringOverlay.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAA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YAAY,EAAE,CAAC;IACjC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,EAAE;QACrC,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,OAAO;QAC9C,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,SAAS,CACR,kBAAkB,CAAC,CAAC,UAAU,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CACpD,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"RuntimeAuthoringOverlay.js","sourceRoot":"","sources":["../../../../../src/features/selection/adapters/inbound/RuntimeAuthoringOverlay.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEtE,uHAAuH;AACvH,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,EACR,IAAI,EACJ,iBAAiB,EACjB,mBAAmB,GACU;IAC7B,OAAO,CACL,CAAC,iBAAiB,CAChB,QAAQ,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAC7B,IAAI,CAAC,QAAQ,CACb,iBAAiB,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CACxD,WAAW,CAAC,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,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AAC,CAAC,CAAC,SAAS,CAAC,CAC3D,OAAO,CAAC,CAAC,WAAW,CAAC,CACrB,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACtB,MAAM,CAAC,CAAC,0BAA0B,SAAS,CAAC,WAAW,EAAE,CAAC,CAE1D;MAAA,CAAC,QAAQ,CACT;MAAA,CAAC,QAAQ,CAAC,CAAC,CAAC,CACV,CAAC,IAAI,CACH,WAAW,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CACvC,WAAW,CAAC,CAAC,CAAC,CAAC,CACf,aAAa,CAAC,MAAM,CACpB,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,EACxB,CACH,CAAC,CAAC,CAAC,IAAI,CACV;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG;IACb,SAAS,EAAE;QACT,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,UAAmB;QAC7B,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;KACP;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,UAAmB,EAAE;CAC3C,CAAC","sourcesContent":["import type {\n RuntimeAuthoringOverlayAdapter,\n RuntimeAuthoringOverlayNodeArgs,\n} from '@ankhorage/runtime';\nimport { Pressable } from '@ankhorage/surface';\nimport React from 'react';\n\nimport type {\n CreateRuntimeAuthoringOverlayAdapterOptions,\n RuntimeAuthoringOverlayProps,\n} from '../../../../types/selection';\nimport { View } from '../../../layout/public';\nimport { useZoraTheme } from '../../../theme/composition/useZoraTheme';\nimport { SelectionProvider, useSelection } from './SelectionProvider';\n\n/*** Provides controlled, single-node selection to Runtime-rendered content without creating a second renderer tree. */\nexport function RuntimeAuthoringOverlay({\n children,\n mode,\n onSelectionChange,\n selectedComponentId,\n}: RuntimeAuthoringOverlayProps) {\n return (\n <SelectionProvider\n disabled={mode === 'preview'}\n mode=\"single\"\n onSelectionChange={(ids) => onSelectionChange?.(ids[0])}\n selectedIds={selectedComponentId === undefined ? [] : [selectedComponentId]}\n >\n {children}\n </SelectionProvider>\n );\n}\n\n/*** Creates ZORA's visual and input adapter for Runtime's generic authoring-overlay hook. */\nexport function createRuntimeAuthoringOverlayAdapter({\n mode,\n}: CreateRuntimeAuthoringOverlayAdapterOptions): RuntimeAuthoringOverlayAdapter {\n return {\n mode,\n getComponentId: (node) => node.id,\n hitTest: () => mode === 'edit',\n wrapNode: (args) => <RuntimeAuthoringOverlayNode {...args} mode={mode} />,\n };\n}\n\n/*** Wraps one rendered target node with edit-mode selection input while retaining its subtree across modes. */\nfunction RuntimeAuthoringOverlayNode({\n component,\n mode,\n rendered,\n select,\n}: RuntimeAuthoringOverlayNodeArgs & { readonly mode: 'edit' | 'preview' }) {\n const { theme } = useZoraTheme();\n const selection = useSelection();\n const selected = selection.isSelected(component.componentId);\n const handlePress = (event: unknown) => {\n if (mode !== 'edit' || !select(event)) return;\n selection.select(component.componentId);\n };\n\n return (\n <Pressable\n accessibilityLabel={`Select ${component.node.type}`}\n accessibilityRole=\"none\"\n accessibilityState={{ selected }}\n interactionPolicy={mode === 'edit' ? 'enabled' : 'passive'}\n onPress={handlePress}\n style={styles.wrapper}\n testID={`runtime-authoring-node-${component.componentId}`}\n >\n {rendered}\n {selected ? (\n <View\n borderColor={theme.semantics.highlight}\n borderWidth={2}\n pointerEvents=\"none\"\n style={styles.highlight}\n />\n ) : null}\n </Pressable>\n );\n}\n\nconst styles = {\n highlight: {\n bottom: 0,\n left: 0,\n position: 'absolute' as const,\n right: 0,\n top: 0,\n },\n wrapper: { position: 'relative' as const },\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "28.8.
|
|
4
|
+
"version": "28.8.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": {
|
|
@@ -193,8 +193,8 @@
|
|
|
193
193
|
"version-packages": "ankhorage-changeset version"
|
|
194
194
|
},
|
|
195
195
|
"devDependencies": {
|
|
196
|
-
"@ankhorage/devtools": "^2.12.
|
|
197
|
-
"@ankhorage/paradox": "^0.
|
|
196
|
+
"@ankhorage/devtools": "^2.12.22",
|
|
197
|
+
"@ankhorage/paradox": "^0.7.0",
|
|
198
198
|
"@react-native-vector-icons/fontawesome": "^14.0.0",
|
|
199
199
|
"@react-native-vector-icons/fontawesome5": "^14.0.0",
|
|
200
200
|
"@react-native-vector-icons/fontawesome6": "^14.0.0",
|
|
@@ -48,7 +48,7 @@ describe('RuntimeAuthoringOverlay', () => {
|
|
|
48
48
|
expect(selected).toEqual(['replacement']);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
test('uses Runtime identity
|
|
51
|
+
test('uses Runtime identity and a nonsemantic selection wrapper 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,6 +62,25 @@ describe('RuntimeAuthoringOverlay', () => {
|
|
|
62
62
|
expect(isValidElement(editNode) && isValidElement(previewNode) && editNode.type).toBe(
|
|
63
63
|
previewNode.type,
|
|
64
64
|
);
|
|
65
|
+
expect(readWrappedNode(editNode).props.accessibilityRole).toBe('none');
|
|
66
|
+
expect(readWrappedNode(previewNode).props.accessibilityRole).toBe('none');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('selects the hit target only in edit mode', async () => {
|
|
70
|
+
const { createRuntimeAuthoringOverlayAdapter } = await loadOverlay();
|
|
71
|
+
const selected = globalThis as typeof globalThis & {
|
|
72
|
+
runtimeAuthoringOverlaySelections?: string[];
|
|
73
|
+
};
|
|
74
|
+
selected.runtimeAuthoringOverlaySelections = [];
|
|
75
|
+
const args = { isRoot: false, node, rendered: <target /> };
|
|
76
|
+
const editNode = createRuntimeAuthoringOverlayAdapter({ mode: 'edit' }).wrapNode(args);
|
|
77
|
+
const previewNode = createRuntimeAuthoringOverlayAdapter({ mode: 'preview' }).wrapNode(args);
|
|
78
|
+
|
|
79
|
+
readWrappedNode(editNode).props.onPress({});
|
|
80
|
+
readWrappedNode(previewNode).props.onPress({});
|
|
81
|
+
|
|
82
|
+
expect(selected.runtimeAuthoringOverlaySelections).toEqual(['target-button']);
|
|
83
|
+
delete selected.runtimeAuthoringOverlaySelections;
|
|
65
84
|
});
|
|
66
85
|
});
|
|
67
86
|
|
|
@@ -80,6 +99,24 @@ function readProvider(element: ReactElement): ReactElement<{
|
|
|
80
99
|
}>;
|
|
81
100
|
}
|
|
82
101
|
|
|
102
|
+
/*** Renders the stable wrapper with inert controls so its semantic role can be asserted without mounting. */
|
|
103
|
+
function readWrappedNode(element: ReactElement): ReactElement<{
|
|
104
|
+
readonly accessibilityRole: string;
|
|
105
|
+
readonly onPress: (event: unknown) => void;
|
|
106
|
+
}> {
|
|
107
|
+
if (typeof element.type !== 'function') {
|
|
108
|
+
throw new Error('Runtime authoring adapter must wrap each identified node.');
|
|
109
|
+
}
|
|
110
|
+
return element.type({
|
|
111
|
+
...element.props,
|
|
112
|
+
component: { componentId: node.id, node },
|
|
113
|
+
select: () => true,
|
|
114
|
+
}) as ReactElement<{
|
|
115
|
+
readonly accessibilityRole: string;
|
|
116
|
+
readonly onPress: (event: unknown) => void;
|
|
117
|
+
}>;
|
|
118
|
+
}
|
|
119
|
+
|
|
83
120
|
/*** Loads the overlay with inert platform controls so this unit test stays at ZORA's public boundary. */
|
|
84
121
|
async function loadOverlay(): Promise<LoadedOverlay> {
|
|
85
122
|
const build = await Bun.build({
|
|
@@ -100,7 +137,7 @@ async function loadOverlay(): Promise<LoadedOverlay> {
|
|
|
100
137
|
() => ({
|
|
101
138
|
loader: 'js',
|
|
102
139
|
contents: `export const Pressable='Pressable', View='View', SelectionProvider='SelectionProvider',
|
|
103
|
-
useSelection=()=>({isSelected:()=>false,select:()=>
|
|
140
|
+
useSelection=()=>({isSelected:()=>false,select:(id)=>globalThis.runtimeAuthoringOverlaySelections?.push(id)}),
|
|
104
141
|
useZoraTheme=()=>({theme:{semantics:{highlight:'highlight'}}});`,
|
|
105
142
|
}),
|
|
106
143
|
);
|
|
@@ -62,7 +62,7 @@ function RuntimeAuthoringOverlayNode({
|
|
|
62
62
|
return (
|
|
63
63
|
<Pressable
|
|
64
64
|
accessibilityLabel={`Select ${component.node.type}`}
|
|
65
|
-
accessibilityRole="
|
|
65
|
+
accessibilityRole="none"
|
|
66
66
|
accessibilityState={{ selected }}
|
|
67
67
|
interactionPolicy={mode === 'edit' ? 'enabled' : 'passive'}
|
|
68
68
|
onPress={handlePress}
|