@symbiote-native/angular 0.0.0-canary-20260724081123
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/LICENSE +21 -0
- package/README.md +157 -0
- package/babel-linker.cjs +7 -0
- package/babel-register-composed.cjs +127 -0
- package/bin/symbiote-angular-dev.cjs +93 -0
- package/build/angular/anchor-host-registry.d.ts +2 -0
- package/build/angular/anchor-host-registry.js +84 -0
- package/build/angular/anchor-host-registry.js.map +1 -0
- package/build/angular/bootstrap.d.ts +7 -0
- package/build/angular/bootstrap.js +15 -0
- package/build/angular/bootstrap.js.map +1 -0
- package/build/angular/components/activity-indicator/index.android.d.ts +12 -0
- package/build/angular/components/activity-indicator/index.android.js +21 -0
- package/build/angular/components/activity-indicator/index.android.js.map +1 -0
- package/build/angular/components/activity-indicator/index.d.ts +1 -0
- package/build/angular/components/activity-indicator/index.ios.d.ts +8 -0
- package/build/angular/components/activity-indicator/index.ios.js +21 -0
- package/build/angular/components/activity-indicator/index.ios.js.map +1 -0
- package/build/angular/components/activity-indicator/index.js +4 -0
- package/build/angular/components/activity-indicator/index.js.map +1 -0
- package/build/angular/components/activity-indicator/shared.d.ts +67 -0
- package/build/angular/components/activity-indicator/shared.js +260 -0
- package/build/angular/components/activity-indicator/shared.js.map +1 -0
- package/build/angular/components/button.d.ts +63 -0
- package/build/angular/components/button.js +332 -0
- package/build/angular/components/button.js.map +1 -0
- package/build/angular/components/flat-list/index.d.ts +122 -0
- package/build/angular/components/flat-list/index.js +688 -0
- package/build/angular/components/flat-list/index.js.map +1 -0
- package/build/angular/components/image/index.android.d.ts +10 -0
- package/build/angular/components/image/index.android.js +59 -0
- package/build/angular/components/image/index.android.js.map +1 -0
- package/build/angular/components/image/index.d.ts +1 -0
- package/build/angular/components/image/index.ios.d.ts +10 -0
- package/build/angular/components/image/index.ios.js +59 -0
- package/build/angular/components/image/index.ios.js.map +1 -0
- package/build/angular/components/image/index.js +3 -0
- package/build/angular/components/image/index.js.map +1 -0
- package/build/angular/components/image/shared.d.ts +101 -0
- package/build/angular/components/image/shared.js +406 -0
- package/build/angular/components/image/shared.js.map +1 -0
- package/build/angular/components/image-background.d.ts +81 -0
- package/build/angular/components/image-background.js +418 -0
- package/build/angular/components/image-background.js.map +1 -0
- package/build/angular/components/input-accessory-view/index.d.ts +60 -0
- package/build/angular/components/input-accessory-view/index.js +251 -0
- package/build/angular/components/input-accessory-view/index.js.map +1 -0
- package/build/angular/components/keyboard-avoiding-view/index.d.ts +82 -0
- package/build/angular/components/keyboard-avoiding-view/index.js +358 -0
- package/build/angular/components/keyboard-avoiding-view/index.js.map +1 -0
- package/build/angular/components/modal/index.d.ts +92 -0
- package/build/angular/components/modal/index.js +360 -0
- package/build/angular/components/modal/index.js.map +1 -0
- package/build/angular/components/pressable/index.d.ts +123 -0
- package/build/angular/components/pressable/index.js +420 -0
- package/build/angular/components/pressable/index.js.map +1 -0
- package/build/angular/components/refresh-control/index.d.ts +86 -0
- package/build/angular/components/refresh-control/index.js +342 -0
- package/build/angular/components/refresh-control/index.js.map +1 -0
- package/build/angular/components/safe-area-view/index.d.ts +57 -0
- package/build/angular/components/safe-area-view/index.js +248 -0
- package/build/angular/components/safe-area-view/index.js.map +1 -0
- package/build/angular/components/scroll-view/index.android.d.ts +21 -0
- package/build/angular/components/scroll-view/index.android.js +235 -0
- package/build/angular/components/scroll-view/index.android.js.map +1 -0
- package/build/angular/components/scroll-view/index.d.ts +3 -0
- package/build/angular/components/scroll-view/index.ios.d.ts +9 -0
- package/build/angular/components/scroll-view/index.ios.js +86 -0
- package/build/angular/components/scroll-view/index.ios.js.map +1 -0
- package/build/angular/components/scroll-view/index.js +6 -0
- package/build/angular/components/scroll-view/index.js.map +1 -0
- package/build/angular/components/scroll-view/projection.d.ts +32 -0
- package/build/angular/components/scroll-view/projection.js +334 -0
- package/build/angular/components/scroll-view/projection.js.map +1 -0
- package/build/angular/components/scroll-view/shared.d.ts +230 -0
- package/build/angular/components/scroll-view/shared.js +682 -0
- package/build/angular/components/scroll-view/shared.js.map +1 -0
- package/build/angular/components/scroll-view/sticky-header.d.ts +40 -0
- package/build/angular/components/scroll-view/sticky-header.js +225 -0
- package/build/angular/components/scroll-view/sticky-header.js.map +1 -0
- package/build/angular/components/section-list/index.d.ts +116 -0
- package/build/angular/components/section-list/index.js +641 -0
- package/build/angular/components/section-list/index.js.map +1 -0
- package/build/angular/components/switch/index.android.d.ts +20 -0
- package/build/angular/components/switch/index.android.js +70 -0
- package/build/angular/components/switch/index.android.js.map +1 -0
- package/build/angular/components/switch/index.d.ts +1 -0
- package/build/angular/components/switch/index.ios.d.ts +19 -0
- package/build/angular/components/switch/index.ios.js +69 -0
- package/build/angular/components/switch/index.ios.js.map +1 -0
- package/build/angular/components/switch/index.js +4 -0
- package/build/angular/components/switch/index.js.map +1 -0
- package/build/angular/components/switch/shared.d.ts +40 -0
- package/build/angular/components/switch/shared.js +127 -0
- package/build/angular/components/switch/shared.js.map +1 -0
- package/build/angular/components/text-input.d.ts +153 -0
- package/build/angular/components/text-input.js +599 -0
- package/build/angular/components/text-input.js.map +1 -0
- package/build/angular/components/touchable/index.d.ts +245 -0
- package/build/angular/components/touchable/index.js +1186 -0
- package/build/angular/components/touchable/index.js.map +1 -0
- package/build/angular/components/touchable-native-feedback/index.d.ts +83 -0
- package/build/angular/components/touchable-native-feedback/index.js +371 -0
- package/build/angular/components/touchable-native-feedback/index.js.map +1 -0
- package/build/angular/components/virtualized-list/directives.d.ts +54 -0
- package/build/angular/components/virtualized-list/directives.js +153 -0
- package/build/angular/components/virtualized-list/directives.js.map +1 -0
- package/build/angular/components/virtualized-list/index.d.ts +253 -0
- package/build/angular/components/virtualized-list/index.js +1031 -0
- package/build/angular/components/virtualized-list/index.js.map +1 -0
- package/build/angular/components/virtualized-section-list/directives.d.ts +37 -0
- package/build/angular/components/virtualized-section-list/directives.js +76 -0
- package/build/angular/components/virtualized-section-list/directives.js.map +1 -0
- package/build/angular/components/virtualized-section-list/index.d.ts +178 -0
- package/build/angular/components/virtualized-section-list/index.js +720 -0
- package/build/angular/components/virtualized-section-list/index.js.map +1 -0
- package/build/angular/components.d.ts +39 -0
- package/build/angular/components.js +38 -0
- package/build/angular/components.js.map +1 -0
- package/build/angular/create-portal/index.d.ts +22 -0
- package/build/angular/create-portal/index.js +74 -0
- package/build/angular/create-portal/index.js.map +1 -0
- package/build/angular/create-tunnel/index.d.ts +34 -0
- package/build/angular/create-tunnel/index.js +126 -0
- package/build/angular/create-tunnel/index.js.map +1 -0
- package/build/angular/descriptor-to-angular/index.d.ts +22 -0
- package/build/angular/descriptor-to-angular/index.js +142 -0
- package/build/angular/descriptor-to-angular/index.js.map +1 -0
- package/build/angular/host-instance/index.d.ts +2 -0
- package/build/angular/host-instance/index.js +37 -0
- package/build/angular/host-instance/index.js.map +1 -0
- package/build/angular/index.d.ts +22 -0
- package/build/angular/index.js +46 -0
- package/build/angular/index.js.map +1 -0
- package/build/angular/modules/animated/animated-leaf-binder/index.d.ts +14 -0
- package/build/angular/modules/animated/animated-leaf-binder/index.js +91 -0
- package/build/angular/modules/animated/animated-leaf-binder/index.js.map +1 -0
- package/build/angular/modules/animated/animated-leaf-binder.d.ts +14 -0
- package/build/angular/modules/animated/animated-leaf-binder.js +91 -0
- package/build/angular/modules/animated/animated-leaf-binder.js.map +1 -0
- package/build/angular/modules/animated/create-animated-component.d.ts +59 -0
- package/build/angular/modules/animated/create-animated-component.js +364 -0
- package/build/angular/modules/animated/create-animated-component.js.map +1 -0
- package/build/angular/modules/animated/index.d.ts +51 -0
- package/build/angular/modules/animated/index.js +59 -0
- package/build/angular/modules/animated/index.js.map +1 -0
- package/build/angular/modules/app-registry/index.d.ts +7 -0
- package/build/angular/modules/app-registry/index.js +23 -0
- package/build/angular/modules/app-registry/index.js.map +1 -0
- package/build/angular/modules/status-bar/index.d.ts +20 -0
- package/build/angular/modules/status-bar/index.js +59 -0
- package/build/angular/modules/status-bar/index.js.map +1 -0
- package/build/angular/primitives/index.d.ts +63 -0
- package/build/angular/primitives/index.js +189 -0
- package/build/angular/primitives/index.js.map +1 -0
- package/build/angular/primitives/shared.d.ts +88 -0
- package/build/angular/primitives/shared.js +171 -0
- package/build/angular/primitives/shared.js.map +1 -0
- package/build/angular/render/index.d.ts +11 -0
- package/build/angular/render/index.js +171 -0
- package/build/angular/render/index.js.map +1 -0
- package/build/angular/renderer/index.d.ts +37 -0
- package/build/angular/renderer/index.js +301 -0
- package/build/angular/renderer/index.js.map +1 -0
- package/build/angular/services/color-scheme.service.d.ts +16 -0
- package/build/angular/services/color-scheme.service.js +31 -0
- package/build/angular/services/color-scheme.service.js.map +1 -0
- package/build/angular/services/index.d.ts +2 -0
- package/build/angular/services/index.js +3 -0
- package/build/angular/services/index.js.map +1 -0
- package/build/angular/services/window-dimensions.service.d.ts +16 -0
- package/build/angular/services/window-dimensions.service.js +42 -0
- package/build/angular/services/window-dimensions.service.js.map +1 -0
- package/metro-config.cjs +48 -0
- package/metro-css-parser.cjs +13 -0
- package/package.json +80 -0
- package/src/__tests__/responder-change-detection.test.ts +102 -0
- package/src/__tests__/responder-nested-cd.test.ts +113 -0
- package/src/anchor-host-registry.ts +88 -0
- package/src/angular-gaps.test.ts +142 -0
- package/src/angular-imports.test.ts +100 -0
- package/src/bootstrap.ts +26 -0
- package/src/components/activity-indicator/activity-indicator-class-style.test.ts +44 -0
- package/src/components/activity-indicator/activity-indicator.test.ts +131 -0
- package/src/components/activity-indicator/index.android.ts +16 -0
- package/src/components/activity-indicator/index.ios.ts +17 -0
- package/src/components/activity-indicator/index.ts +4 -0
- package/src/components/activity-indicator/shared.ts +206 -0
- package/src/components/button.ts +193 -0
- package/src/components/flat-list/column-wrapper-style-class.test.ts +116 -0
- package/src/components/flat-list/flat-list-array-style.test.ts +131 -0
- package/src/components/flat-list/flat-list-class-style.test.ts +74 -0
- package/src/components/flat-list/flat-list-scroll-containment.test.ts +107 -0
- package/src/components/flat-list/flat-list.test.ts +99 -0
- package/src/components/flat-list/index.ts +574 -0
- package/src/components/image/image-class-style.test.ts +46 -0
- package/src/components/image/index.android.ts +48 -0
- package/src/components/image/index.ios.ts +48 -0
- package/src/components/image/index.ts +3 -0
- package/src/components/image/shared.ts +479 -0
- package/src/components/image-background-class-style.test.ts +48 -0
- package/src/components/image-background-style-class.test.ts +79 -0
- package/src/components/image-background.ts +270 -0
- package/src/components/input-accessory-view/index.ts +185 -0
- package/src/components/input-accessory-view/input-accessory-view.test.ts +43 -0
- package/src/components/keyboard-avoiding-view/index.ts +303 -0
- package/src/components/keyboard-avoiding-view/keyboard-avoiding-view.test.ts +54 -0
- package/src/components/modal/index.ts +299 -0
- package/src/components/modal/modal.test.ts +43 -0
- package/src/components/pressable/index.ts +373 -0
- package/src/components/pressable/pressable.test.ts +85 -0
- package/src/components/refresh-control/index.ts +284 -0
- package/src/components/refresh-control/refresh-control.test.ts +41 -0
- package/src/components/safe-area-view/index.ts +177 -0
- package/src/components/safe-area-view/safe-area-view.test.ts +43 -0
- package/src/components/scroll-view/android-scroll-view-axis-projection.test.ts +123 -0
- package/src/components/scroll-view/content-container-style-class.test.ts +75 -0
- package/src/components/scroll-view/index.android.ts +190 -0
- package/src/components/scroll-view/index.ios.ts +79 -0
- package/src/components/scroll-view/index.ts +7 -0
- package/src/components/scroll-view/projection.ts +414 -0
- package/src/components/scroll-view/scroll-view-class-style.test.ts +134 -0
- package/src/components/scroll-view/scroll-view-projection.test.ts +194 -0
- package/src/components/scroll-view/shared.ts +844 -0
- package/src/components/scroll-view/sticky-header.ts +255 -0
- package/src/components/section-list/index.ts +445 -0
- package/src/components/switch/android-switch-class.test.ts +42 -0
- package/src/components/switch/index.android.ts +61 -0
- package/src/components/switch/index.ios.ts +60 -0
- package/src/components/switch/index.ts +4 -0
- package/src/components/switch/shared.ts +197 -0
- package/src/components/switch/switch.test.ts +92 -0
- package/src/components/text-input-class-style.test.ts +54 -0
- package/src/components/text-input.ts +531 -0
- package/src/components/touchable/index.ts +629 -0
- package/src/components/touchable/touchable.test.ts +102 -0
- package/src/components/touchable-native-feedback/index.ts +254 -0
- package/src/components/touchable-native-feedback/touchable-native-feedback.test.ts +49 -0
- package/src/components/virtualized-list/directives.ts +168 -0
- package/src/components/virtualized-list/index.ts +992 -0
- package/src/components/virtualized-list/virtualized-list-class-style.test.ts +76 -0
- package/src/components/virtualized-section-list/directives.ts +90 -0
- package/src/components/virtualized-section-list/index.ts +601 -0
- package/src/components/virtualized-section-list/virtualized-section-list-class-style.test.ts +60 -0
- package/src/components.ts +149 -0
- package/src/create-portal/create-portal.test.ts +90 -0
- package/src/create-portal/index.ts +74 -0
- package/src/create-tunnel/create-tunnel.test.ts +120 -0
- package/src/create-tunnel/index.ts +136 -0
- package/src/descriptor-to-angular/descriptor-outlet.test.ts +94 -0
- package/src/descriptor-to-angular/index.ts +190 -0
- package/src/host-instance/host-instance.test.ts +49 -0
- package/src/host-instance/index.ts +36 -0
- package/src/index.ts +261 -0
- package/src/modules/animated/animated-leaf-binder/animated-leaf-binder.test.ts +116 -0
- package/src/modules/animated/animated-leaf-binder/index.ts +101 -0
- package/src/modules/animated/animated-leaf-binder.test.ts +116 -0
- package/src/modules/animated/animated-leaf-binder.ts +101 -0
- package/src/modules/animated/animated-scroll-view.test.ts +102 -0
- package/src/modules/animated/create-animated-component.ts +365 -0
- package/src/modules/animated/index.ts +105 -0
- package/src/modules/app-registry/app-registry.test.ts +106 -0
- package/src/modules/app-registry/index.ts +60 -0
- package/src/modules/status-bar/index.ts +57 -0
- package/src/modules/status-bar/status-bar.test.ts +50 -0
- package/src/primitives/index.ts +119 -0
- package/src/primitives/shared.ts +190 -0
- package/src/render/index.ts +235 -0
- package/src/render/render.test.ts +147 -0
- package/src/renderer/index.ts +347 -0
- package/src/renderer/renderer.test.ts +203 -0
- package/src/services/color-scheme.service.ts +27 -0
- package/src/services/index.ts +2 -0
- package/src/services/services.test.ts +163 -0
- package/src/services/window-dimensions.service.ts +41 -0
- package/tsconfig.angular.base.json +30 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Regression test for the anchor/class bug: Image is its own
|
|
2
|
+
// ANCHOR_HOST_COMPONENTS entry — a class= on <Image> resolves onto Image's OWN anchor and needs
|
|
3
|
+
// its OWN anchorHostStyle merge (see index.ios.ts/index.android.ts's imageProps override), not
|
|
4
|
+
// transitively fixed by anything else. Mirrors pressable.test.ts's "resolves a class=" case.
|
|
5
|
+
import '@angular/compiler';
|
|
6
|
+
import { Component } from '@angular/core';
|
|
7
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
8
|
+
import { clearGlobalStyles, registerStyles } from '@symbiote-native/engine';
|
|
9
|
+
import { installFabric } from '@symbiote-native/test-utils';
|
|
10
|
+
|
|
11
|
+
import { mount, unmount } from '../../render';
|
|
12
|
+
import { Image } from './index';
|
|
13
|
+
|
|
14
|
+
const ROOT_TAG = 915;
|
|
15
|
+
const fabric = installFabric();
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'symbiote-image-class-host',
|
|
19
|
+
standalone: true,
|
|
20
|
+
imports: [Image],
|
|
21
|
+
template: `<Image
|
|
22
|
+
[testID]="'photo'"
|
|
23
|
+
class="card"
|
|
24
|
+
[source]="{ uri: 'https://example.com/a.png' }"
|
|
25
|
+
/>`,
|
|
26
|
+
})
|
|
27
|
+
class ImageClassHost {}
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
fabric.reset();
|
|
31
|
+
registerStyles({ card: { backgroundColor: 'red' } });
|
|
32
|
+
});
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
unmount(ROOT_TAG);
|
|
35
|
+
clearGlobalStyles();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('Image anchor class= resolution', () => {
|
|
39
|
+
it('resolves a class= on the Image use site onto the real committed view, not the anchor', async () => {
|
|
40
|
+
mount(ROOT_TAG, ImageClassHost);
|
|
41
|
+
await new Promise<void>(resolve => setTimeout(resolve, 0));
|
|
42
|
+
|
|
43
|
+
const node = fabric.find(n => n.props.testID === 'photo');
|
|
44
|
+
expect(node?.props.backgroundColor).toBe('red');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CUSTOM_ELEMENTS_SCHEMA, Component, ElementRef, inject } from '@angular/core';
|
|
2
|
+
import { anchorHostStyle, ImageHost, SymbioteHostPropsDirective } from '../../primitives';
|
|
3
|
+
import { IMAGE_INPUTS, IMAGE_OUTPUTS, ImageBase, resolveImageProps } from './shared';
|
|
4
|
+
export { setImageSourceResolver } from './shared';
|
|
5
|
+
export type {
|
|
6
|
+
IImageProps,
|
|
7
|
+
IImageSource,
|
|
8
|
+
IImageSourceProp,
|
|
9
|
+
IResizeMode,
|
|
10
|
+
IImageSize,
|
|
11
|
+
IImageCacheStatus,
|
|
12
|
+
} from './shared';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'Image',
|
|
16
|
+
standalone: true,
|
|
17
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
18
|
+
imports: [ImageHost, SymbioteHostPropsDirective],
|
|
19
|
+
inputs: IMAGE_INPUTS,
|
|
20
|
+
outputs: IMAGE_OUTPUTS,
|
|
21
|
+
template: `
|
|
22
|
+
<symbiote-image
|
|
23
|
+
[symbioteHostProps]="imageProps"
|
|
24
|
+
(accessibilityAction)="handleAccessibilityAction($event)"
|
|
25
|
+
(accessibilityTap)="handleAccessibilityTap($event)"
|
|
26
|
+
(magicTap)="handleMagicTap($event)"
|
|
27
|
+
(accessibilityEscape)="handleAccessibilityEscape($event)"
|
|
28
|
+
(loadStart)="handleLoadStart($event)"
|
|
29
|
+
(load)="handleLoad($event)"
|
|
30
|
+
(loadEnd)="handleLoadEnd($event)"
|
|
31
|
+
(error)="handleError($event)"
|
|
32
|
+
(progress)="handleProgress($event)"
|
|
33
|
+
(partialLoad)="handlePartialLoad($event)"
|
|
34
|
+
/>
|
|
35
|
+
`,
|
|
36
|
+
})
|
|
37
|
+
export class Image extends ImageBase {
|
|
38
|
+
// This component's OWN host — the non-painting anchor `class="..."` at the use site resolves
|
|
39
|
+
// onto (see anchorHostStyle's doc comment) — NOT the inner `symbiote-image` one level down.
|
|
40
|
+
private readonly elementRef = inject(ElementRef);
|
|
41
|
+
|
|
42
|
+
override get imageProps(): Record<string, unknown> {
|
|
43
|
+
return resolveImageProps({
|
|
44
|
+
...this.imageInputProps,
|
|
45
|
+
style: [anchorHostStyle(this.elementRef), this.style],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CUSTOM_ELEMENTS_SCHEMA, Component, ElementRef, inject } from '@angular/core';
|
|
2
|
+
import { anchorHostStyle, ImageHost, SymbioteHostPropsDirective } from '../../primitives';
|
|
3
|
+
import { IMAGE_INPUTS, IMAGE_OUTPUTS, ImageBase, resolveImageProps } from './shared';
|
|
4
|
+
export { setImageSourceResolver } from './shared';
|
|
5
|
+
export type {
|
|
6
|
+
IImageProps,
|
|
7
|
+
IImageSource,
|
|
8
|
+
IImageSourceProp,
|
|
9
|
+
IResizeMode,
|
|
10
|
+
IImageSize,
|
|
11
|
+
IImageCacheStatus,
|
|
12
|
+
} from './shared';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'Image',
|
|
16
|
+
standalone: true,
|
|
17
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
18
|
+
imports: [ImageHost, SymbioteHostPropsDirective],
|
|
19
|
+
inputs: IMAGE_INPUTS,
|
|
20
|
+
outputs: IMAGE_OUTPUTS,
|
|
21
|
+
template: `
|
|
22
|
+
<symbiote-image
|
|
23
|
+
[symbioteHostProps]="imageProps"
|
|
24
|
+
(accessibilityAction)="handleAccessibilityAction($event)"
|
|
25
|
+
(accessibilityTap)="handleAccessibilityTap($event)"
|
|
26
|
+
(magicTap)="handleMagicTap($event)"
|
|
27
|
+
(accessibilityEscape)="handleAccessibilityEscape($event)"
|
|
28
|
+
(loadStart)="handleLoadStart($event)"
|
|
29
|
+
(load)="handleLoad($event)"
|
|
30
|
+
(loadEnd)="handleLoadEnd($event)"
|
|
31
|
+
(error)="handleError($event)"
|
|
32
|
+
(progress)="handleProgress($event)"
|
|
33
|
+
(partialLoad)="handlePartialLoad($event)"
|
|
34
|
+
/>
|
|
35
|
+
`,
|
|
36
|
+
})
|
|
37
|
+
export class Image extends ImageBase {
|
|
38
|
+
// This component's OWN host — the non-painting anchor `class="..."` at the use site resolves
|
|
39
|
+
// onto (see anchorHostStyle's doc comment) — NOT the inner `symbiote-image` one level down.
|
|
40
|
+
private readonly elementRef = inject(ElementRef);
|
|
41
|
+
|
|
42
|
+
override get imageProps(): Record<string, unknown> {
|
|
43
|
+
return resolveImageProps({
|
|
44
|
+
...this.imageInputProps,
|
|
45
|
+
style: [anchorHostStyle(this.elementRef), this.style],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
imageStatics,
|
|
4
|
+
renderImage,
|
|
5
|
+
resolveAccessibilityProps,
|
|
6
|
+
type IAccessibilityProps,
|
|
7
|
+
type IAriaProps,
|
|
8
|
+
type IImageProps,
|
|
9
|
+
type IImageSourceProp,
|
|
10
|
+
type IResizeMode,
|
|
11
|
+
} from '@symbiote-native/components';
|
|
12
|
+
import {
|
|
13
|
+
isSymbioteEvent,
|
|
14
|
+
type IStyleProp,
|
|
15
|
+
type ISymbioteEvent,
|
|
16
|
+
type IViewStyle,
|
|
17
|
+
} from '@symbiote-native/engine';
|
|
18
|
+
|
|
19
|
+
export { setImageSourceResolver } from '@symbiote-native/components';
|
|
20
|
+
export type {
|
|
21
|
+
IImageProps,
|
|
22
|
+
IImageSource,
|
|
23
|
+
IImageSourceProp,
|
|
24
|
+
IResizeMode,
|
|
25
|
+
IImageSize,
|
|
26
|
+
IImageCacheStatus,
|
|
27
|
+
} from '@symbiote-native/components';
|
|
28
|
+
|
|
29
|
+
export const IMAGE_INPUTS = [
|
|
30
|
+
'source',
|
|
31
|
+
'defaultSource',
|
|
32
|
+
'loadingIndicatorSource',
|
|
33
|
+
'style',
|
|
34
|
+
'resizeMode',
|
|
35
|
+
'resizeMethod',
|
|
36
|
+
'tintColor',
|
|
37
|
+
'blurRadius',
|
|
38
|
+
'capInsets',
|
|
39
|
+
'fadeDuration',
|
|
40
|
+
'progressiveRenderingEnabled',
|
|
41
|
+
'src',
|
|
42
|
+
'srcSet',
|
|
43
|
+
'alt',
|
|
44
|
+
'width',
|
|
45
|
+
'height',
|
|
46
|
+
'crossOrigin',
|
|
47
|
+
'referrerPolicy',
|
|
48
|
+
'testID',
|
|
49
|
+
'nativeID',
|
|
50
|
+
'accessible',
|
|
51
|
+
'accessibilityLabel',
|
|
52
|
+
'accessibilityHint',
|
|
53
|
+
'accessibilityRole',
|
|
54
|
+
'accessibilityState',
|
|
55
|
+
'accessibilityValue',
|
|
56
|
+
'accessibilityActions',
|
|
57
|
+
'accessibilityLabelledBy',
|
|
58
|
+
'importantForAccessibility',
|
|
59
|
+
'accessibilityLiveRegion',
|
|
60
|
+
'screenReaderFocusable',
|
|
61
|
+
'accessibilityViewIsModal',
|
|
62
|
+
'accessibilityElementsHidden',
|
|
63
|
+
'accessibilityIgnoresInvertColors',
|
|
64
|
+
'accessibilityLanguage',
|
|
65
|
+
'accessibilityRespondsToUserInteraction',
|
|
66
|
+
'accessibilityShowsLargeContentViewer',
|
|
67
|
+
'accessibilityLargeContentTitle',
|
|
68
|
+
'role',
|
|
69
|
+
'ariaLabel: aria-label',
|
|
70
|
+
'ariaLabelledBy: aria-labelledby',
|
|
71
|
+
'ariaLive: aria-live',
|
|
72
|
+
'ariaHidden: aria-hidden',
|
|
73
|
+
'ariaBusy: aria-busy',
|
|
74
|
+
'ariaChecked: aria-checked',
|
|
75
|
+
'ariaDisabled: aria-disabled',
|
|
76
|
+
'ariaExpanded: aria-expanded',
|
|
77
|
+
'ariaSelected: aria-selected',
|
|
78
|
+
'ariaModal: aria-modal',
|
|
79
|
+
'ariaValueMax: aria-valuemax',
|
|
80
|
+
'ariaValueMin: aria-valuemin',
|
|
81
|
+
'ariaValueNow: aria-valuenow',
|
|
82
|
+
'ariaValueText: aria-valuetext',
|
|
83
|
+
'onAccessibilityAction',
|
|
84
|
+
'onAccessibilityTap',
|
|
85
|
+
'onMagicTap',
|
|
86
|
+
'onAccessibilityEscape',
|
|
87
|
+
'onLoadStart',
|
|
88
|
+
'onLoad',
|
|
89
|
+
'onLoadEnd',
|
|
90
|
+
'onError',
|
|
91
|
+
'onProgress',
|
|
92
|
+
'onPartialLoad',
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
export const IMAGE_OUTPUTS = [
|
|
96
|
+
'accessibilityAction',
|
|
97
|
+
'accessibilityTap',
|
|
98
|
+
'magicTap',
|
|
99
|
+
'accessibilityEscape',
|
|
100
|
+
'loadStart',
|
|
101
|
+
'load',
|
|
102
|
+
'loadEnd',
|
|
103
|
+
'error',
|
|
104
|
+
'progress',
|
|
105
|
+
'partialLoad',
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
type IImagePassthroughProps = Record<string, unknown> &
|
|
109
|
+
IAccessibilityProps &
|
|
110
|
+
IAriaProps &
|
|
111
|
+
Pick<
|
|
112
|
+
IImageProps,
|
|
113
|
+
| 'resizeMethod'
|
|
114
|
+
| 'blurRadius'
|
|
115
|
+
| 'capInsets'
|
|
116
|
+
| 'fadeDuration'
|
|
117
|
+
| 'progressiveRenderingEnabled'
|
|
118
|
+
| 'onLoadStart'
|
|
119
|
+
| 'onLoad'
|
|
120
|
+
| 'onLoadEnd'
|
|
121
|
+
| 'onError'
|
|
122
|
+
| 'onProgress'
|
|
123
|
+
| 'onPartialLoad'
|
|
124
|
+
>;
|
|
125
|
+
|
|
126
|
+
function asSource(value: unknown): IImageSourceProp | undefined {
|
|
127
|
+
if (typeof value === 'number') return value;
|
|
128
|
+
if (typeof value === 'object' && value !== null) return value;
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function asResizeMode(value: unknown): IResizeMode | undefined {
|
|
133
|
+
if (
|
|
134
|
+
value === 'cover' ||
|
|
135
|
+
value === 'contain' ||
|
|
136
|
+
value === 'stretch' ||
|
|
137
|
+
value === 'repeat' ||
|
|
138
|
+
value === 'center'
|
|
139
|
+
) {
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function asString(value: unknown): string | undefined {
|
|
146
|
+
return typeof value === 'string' ? value : undefined;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function asNumber(value: unknown): number | undefined {
|
|
150
|
+
return typeof value === 'number' ? value : undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function asCrossOrigin(value: unknown): 'anonymous' | 'use-credentials' | undefined {
|
|
154
|
+
return value === 'anonymous' || value === 'use-credentials' ? value : undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function asStyle(value: unknown): IStyleProp<IViewStyle> | undefined {
|
|
158
|
+
return typeof value === 'object' && value !== null ? value : undefined;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function resolveImageProps(input: Record<string, unknown>): Record<string, unknown> {
|
|
162
|
+
const passthrough: IImagePassthroughProps = {
|
|
163
|
+
resizeMethod: input['resizeMethod'] as IImageProps['resizeMethod'],
|
|
164
|
+
blurRadius: asNumber(input['blurRadius']),
|
|
165
|
+
capInsets: input['capInsets'] as IImageProps['capInsets'],
|
|
166
|
+
fadeDuration: asNumber(input['fadeDuration']),
|
|
167
|
+
progressiveRenderingEnabled:
|
|
168
|
+
typeof input['progressiveRenderingEnabled'] === 'boolean'
|
|
169
|
+
? input['progressiveRenderingEnabled']
|
|
170
|
+
: undefined,
|
|
171
|
+
testID: asString(input['testID']),
|
|
172
|
+
nativeID: asString(input['nativeID']),
|
|
173
|
+
accessible: typeof input['accessible'] === 'boolean' ? input['accessible'] : undefined,
|
|
174
|
+
accessibilityLabel: asString(input['accessibilityLabel']),
|
|
175
|
+
accessibilityHint: asString(input['accessibilityHint']),
|
|
176
|
+
accessibilityRole: input['accessibilityRole'] as IAccessibilityProps['accessibilityRole'],
|
|
177
|
+
accessibilityState: input['accessibilityState'] as IAccessibilityProps['accessibilityState'],
|
|
178
|
+
accessibilityValue: input['accessibilityValue'] as IAccessibilityProps['accessibilityValue'],
|
|
179
|
+
accessibilityActions: input[
|
|
180
|
+
'accessibilityActions'
|
|
181
|
+
] as IAccessibilityProps['accessibilityActions'],
|
|
182
|
+
accessibilityLabelledBy: input[
|
|
183
|
+
'accessibilityLabelledBy'
|
|
184
|
+
] as IAccessibilityProps['accessibilityLabelledBy'],
|
|
185
|
+
importantForAccessibility: input[
|
|
186
|
+
'importantForAccessibility'
|
|
187
|
+
] as IAccessibilityProps['importantForAccessibility'],
|
|
188
|
+
accessibilityLiveRegion: input[
|
|
189
|
+
'accessibilityLiveRegion'
|
|
190
|
+
] as IAccessibilityProps['accessibilityLiveRegion'],
|
|
191
|
+
screenReaderFocusable:
|
|
192
|
+
typeof input['screenReaderFocusable'] === 'boolean'
|
|
193
|
+
? input['screenReaderFocusable']
|
|
194
|
+
: undefined,
|
|
195
|
+
accessibilityViewIsModal:
|
|
196
|
+
typeof input['accessibilityViewIsModal'] === 'boolean'
|
|
197
|
+
? input['accessibilityViewIsModal']
|
|
198
|
+
: undefined,
|
|
199
|
+
accessibilityElementsHidden:
|
|
200
|
+
typeof input['accessibilityElementsHidden'] === 'boolean'
|
|
201
|
+
? input['accessibilityElementsHidden']
|
|
202
|
+
: undefined,
|
|
203
|
+
accessibilityIgnoresInvertColors:
|
|
204
|
+
typeof input['accessibilityIgnoresInvertColors'] === 'boolean'
|
|
205
|
+
? input['accessibilityIgnoresInvertColors']
|
|
206
|
+
: undefined,
|
|
207
|
+
accessibilityLanguage: asString(input['accessibilityLanguage']),
|
|
208
|
+
accessibilityRespondsToUserInteraction:
|
|
209
|
+
typeof input['accessibilityRespondsToUserInteraction'] === 'boolean'
|
|
210
|
+
? input['accessibilityRespondsToUserInteraction']
|
|
211
|
+
: undefined,
|
|
212
|
+
accessibilityShowsLargeContentViewer:
|
|
213
|
+
typeof input['accessibilityShowsLargeContentViewer'] === 'boolean'
|
|
214
|
+
? input['accessibilityShowsLargeContentViewer']
|
|
215
|
+
: undefined,
|
|
216
|
+
accessibilityLargeContentTitle: asString(input['accessibilityLargeContentTitle']),
|
|
217
|
+
role: input['role'] as IAriaProps['role'],
|
|
218
|
+
'aria-label': asString(input['ariaLabel'] ?? input['aria-label']),
|
|
219
|
+
'aria-labelledby': asString(input['ariaLabelledBy'] ?? input['aria-labelledby']),
|
|
220
|
+
'aria-live': input['ariaLive'] as IAriaProps['aria-live'],
|
|
221
|
+
'aria-hidden': typeof input['ariaHidden'] === 'boolean' ? input['ariaHidden'] : undefined,
|
|
222
|
+
'aria-busy': typeof input['ariaBusy'] === 'boolean' ? input['ariaBusy'] : undefined,
|
|
223
|
+
'aria-checked': input['ariaChecked'] as IAriaProps['aria-checked'],
|
|
224
|
+
'aria-disabled': typeof input['ariaDisabled'] === 'boolean' ? input['ariaDisabled'] : undefined,
|
|
225
|
+
'aria-expanded': typeof input['ariaExpanded'] === 'boolean' ? input['ariaExpanded'] : undefined,
|
|
226
|
+
'aria-selected': typeof input['ariaSelected'] === 'boolean' ? input['ariaSelected'] : undefined,
|
|
227
|
+
'aria-modal': typeof input['ariaModal'] === 'boolean' ? input['ariaModal'] : undefined,
|
|
228
|
+
'aria-valuemax': asNumber(input['ariaValueMax']),
|
|
229
|
+
'aria-valuemin': asNumber(input['ariaValueMin']),
|
|
230
|
+
'aria-valuenow': asNumber(input['ariaValueNow']),
|
|
231
|
+
'aria-valuetext': asString(input['ariaValueText']),
|
|
232
|
+
onAccessibilityAction: input['onAccessibilityAction'] as IImageProps['onLoad'],
|
|
233
|
+
onAccessibilityTap: input['onAccessibilityTap'] as IImageProps['onLoad'],
|
|
234
|
+
onMagicTap: input['onMagicTap'] as IImageProps['onLoad'],
|
|
235
|
+
onAccessibilityEscape: input['onAccessibilityEscape'] as IImageProps['onLoad'],
|
|
236
|
+
onLoadStart: input['onLoadStart'] as IImageProps['onLoadStart'],
|
|
237
|
+
onLoad: input['onLoad'] as IImageProps['onLoad'],
|
|
238
|
+
onLoadEnd: input['onLoadEnd'] as IImageProps['onLoadEnd'],
|
|
239
|
+
onError: input['onError'] as IImageProps['onError'],
|
|
240
|
+
onProgress: input['onProgress'] as IImageProps['onProgress'],
|
|
241
|
+
onPartialLoad: input['onPartialLoad'] as IImageProps['onPartialLoad'],
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return renderImage({
|
|
245
|
+
source: asSource(input['source']),
|
|
246
|
+
defaultSource: asSource(input['defaultSource']),
|
|
247
|
+
loadingIndicatorSource: asSource(input['loadingIndicatorSource']),
|
|
248
|
+
style: asStyle(input['style']),
|
|
249
|
+
resizeMode: asResizeMode(input['resizeMode']),
|
|
250
|
+
tintColor: asString(input['tintColor']),
|
|
251
|
+
src: asString(input['src']),
|
|
252
|
+
srcSet: asString(input['srcSet']),
|
|
253
|
+
alt: asString(input['alt']),
|
|
254
|
+
width: asNumber(input['width']),
|
|
255
|
+
height: asNumber(input['height']),
|
|
256
|
+
crossOrigin: asCrossOrigin(input['crossOrigin']),
|
|
257
|
+
referrerPolicy: asString(input['referrerPolicy']),
|
|
258
|
+
passthrough: resolveAccessibilityProps(passthrough),
|
|
259
|
+
}).props;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export abstract class ImageBase {
|
|
263
|
+
static readonly getSize = imageStatics.getSize;
|
|
264
|
+
static readonly getSizeWithHeaders = imageStatics.getSizeWithHeaders;
|
|
265
|
+
static readonly prefetch = imageStatics.prefetch;
|
|
266
|
+
static readonly abortPrefetch = imageStatics.abortPrefetch;
|
|
267
|
+
static readonly queryCache = imageStatics.queryCache;
|
|
268
|
+
static readonly resolveAssetSource = imageStatics.resolveAssetSource;
|
|
269
|
+
|
|
270
|
+
source: unknown;
|
|
271
|
+
defaultSource: unknown;
|
|
272
|
+
loadingIndicatorSource: unknown;
|
|
273
|
+
style: unknown;
|
|
274
|
+
resizeMode: unknown;
|
|
275
|
+
resizeMethod: IImageProps['resizeMethod'];
|
|
276
|
+
tintColor: unknown;
|
|
277
|
+
blurRadius: number | undefined;
|
|
278
|
+
capInsets: IImageProps['capInsets'];
|
|
279
|
+
fadeDuration: number | undefined;
|
|
280
|
+
progressiveRenderingEnabled: boolean | undefined;
|
|
281
|
+
src: unknown;
|
|
282
|
+
srcSet: unknown;
|
|
283
|
+
alt: unknown;
|
|
284
|
+
width: unknown;
|
|
285
|
+
height: unknown;
|
|
286
|
+
crossOrigin: unknown;
|
|
287
|
+
referrerPolicy: unknown;
|
|
288
|
+
|
|
289
|
+
testID: string | undefined;
|
|
290
|
+
nativeID: string | undefined;
|
|
291
|
+
accessible: boolean | undefined;
|
|
292
|
+
accessibilityLabel: string | undefined;
|
|
293
|
+
accessibilityHint: string | undefined;
|
|
294
|
+
accessibilityRole: IAccessibilityProps['accessibilityRole'];
|
|
295
|
+
accessibilityState: IAccessibilityProps['accessibilityState'];
|
|
296
|
+
accessibilityValue: IAccessibilityProps['accessibilityValue'];
|
|
297
|
+
accessibilityActions: IAccessibilityProps['accessibilityActions'];
|
|
298
|
+
accessibilityLabelledBy: IAccessibilityProps['accessibilityLabelledBy'];
|
|
299
|
+
importantForAccessibility: IAccessibilityProps['importantForAccessibility'];
|
|
300
|
+
accessibilityLiveRegion: IAccessibilityProps['accessibilityLiveRegion'];
|
|
301
|
+
screenReaderFocusable: boolean | undefined;
|
|
302
|
+
accessibilityViewIsModal: boolean | undefined;
|
|
303
|
+
accessibilityElementsHidden: boolean | undefined;
|
|
304
|
+
accessibilityIgnoresInvertColors: boolean | undefined;
|
|
305
|
+
accessibilityLanguage: string | undefined;
|
|
306
|
+
accessibilityRespondsToUserInteraction: boolean | undefined;
|
|
307
|
+
accessibilityShowsLargeContentViewer: boolean | undefined;
|
|
308
|
+
accessibilityLargeContentTitle: string | undefined;
|
|
309
|
+
|
|
310
|
+
role: IAriaProps['role'];
|
|
311
|
+
ariaLabel: string | undefined;
|
|
312
|
+
ariaLabelledBy: string | undefined;
|
|
313
|
+
ariaLive: IAriaProps['aria-live'];
|
|
314
|
+
ariaHidden: boolean | undefined;
|
|
315
|
+
ariaBusy: boolean | undefined;
|
|
316
|
+
ariaChecked: IAriaProps['aria-checked'];
|
|
317
|
+
ariaDisabled: boolean | undefined;
|
|
318
|
+
ariaExpanded: boolean | undefined;
|
|
319
|
+
ariaSelected: boolean | undefined;
|
|
320
|
+
ariaModal: boolean | undefined;
|
|
321
|
+
ariaValueMax: number | undefined;
|
|
322
|
+
ariaValueMin: number | undefined;
|
|
323
|
+
ariaValueNow: number | undefined;
|
|
324
|
+
ariaValueText: string | undefined;
|
|
325
|
+
|
|
326
|
+
onAccessibilityAction: ((event: ISymbioteEvent) => void) | undefined;
|
|
327
|
+
onAccessibilityTap: ((event: ISymbioteEvent) => void) | undefined;
|
|
328
|
+
onMagicTap: ((event: ISymbioteEvent) => void) | undefined;
|
|
329
|
+
onAccessibilityEscape: ((event: ISymbioteEvent) => void) | undefined;
|
|
330
|
+
onLoadStart: ((event: ISymbioteEvent) => void) | undefined;
|
|
331
|
+
onLoad: ((event: ISymbioteEvent) => void) | undefined;
|
|
332
|
+
onLoadEnd: ((event: ISymbioteEvent) => void) | undefined;
|
|
333
|
+
onError: ((event: ISymbioteEvent) => void) | undefined;
|
|
334
|
+
onProgress: ((event: ISymbioteEvent) => void) | undefined;
|
|
335
|
+
onPartialLoad: ((event: ISymbioteEvent) => void) | undefined;
|
|
336
|
+
|
|
337
|
+
readonly accessibilityAction = new EventEmitter<ISymbioteEvent>();
|
|
338
|
+
readonly accessibilityTap = new EventEmitter<ISymbioteEvent>();
|
|
339
|
+
readonly magicTap = new EventEmitter<ISymbioteEvent>();
|
|
340
|
+
readonly accessibilityEscape = new EventEmitter<ISymbioteEvent>();
|
|
341
|
+
readonly loadStart = new EventEmitter<ISymbioteEvent>();
|
|
342
|
+
readonly load = new EventEmitter<ISymbioteEvent>();
|
|
343
|
+
readonly loadEnd = new EventEmitter<ISymbioteEvent>();
|
|
344
|
+
readonly error = new EventEmitter<ISymbioteEvent>();
|
|
345
|
+
readonly progress = new EventEmitter<ISymbioteEvent>();
|
|
346
|
+
readonly partialLoad = new EventEmitter<ISymbioteEvent>();
|
|
347
|
+
|
|
348
|
+
handleAccessibilityAction(event: Event): void {
|
|
349
|
+
if (!isSymbioteEvent(event)) return;
|
|
350
|
+
this.onAccessibilityAction?.(event);
|
|
351
|
+
this.accessibilityAction.emit(event);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
handleAccessibilityTap(event: Event): void {
|
|
355
|
+
if (!isSymbioteEvent(event)) return;
|
|
356
|
+
this.onAccessibilityTap?.(event);
|
|
357
|
+
this.accessibilityTap.emit(event);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
handleMagicTap(event: Event): void {
|
|
361
|
+
if (!isSymbioteEvent(event)) return;
|
|
362
|
+
this.onMagicTap?.(event);
|
|
363
|
+
this.magicTap.emit(event);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
handleAccessibilityEscape(event: Event): void {
|
|
367
|
+
if (!isSymbioteEvent(event)) return;
|
|
368
|
+
this.onAccessibilityEscape?.(event);
|
|
369
|
+
this.accessibilityEscape.emit(event);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
handleLoadStart(event: Event): void {
|
|
373
|
+
if (!isSymbioteEvent(event)) return;
|
|
374
|
+
this.onLoadStart?.(event);
|
|
375
|
+
this.loadStart.emit(event);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
handleLoad(event: Event): void {
|
|
379
|
+
if (!isSymbioteEvent(event)) return;
|
|
380
|
+
this.onLoad?.(event);
|
|
381
|
+
this.load.emit(event);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
handleLoadEnd(event: Event): void {
|
|
385
|
+
if (!isSymbioteEvent(event)) return;
|
|
386
|
+
this.onLoadEnd?.(event);
|
|
387
|
+
this.loadEnd.emit(event);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
handleError(event: Event): void {
|
|
391
|
+
if (!isSymbioteEvent(event)) return;
|
|
392
|
+
this.onError?.(event);
|
|
393
|
+
this.error.emit(event);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
handleProgress(event: Event): void {
|
|
397
|
+
if (!isSymbioteEvent(event)) return;
|
|
398
|
+
this.onProgress?.(event);
|
|
399
|
+
this.progress.emit(event);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
handlePartialLoad(event: Event): void {
|
|
403
|
+
if (!isSymbioteEvent(event)) return;
|
|
404
|
+
this.onPartialLoad?.(event);
|
|
405
|
+
this.partialLoad.emit(event);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
protected get imageInputProps(): Record<string, unknown> {
|
|
409
|
+
return {
|
|
410
|
+
source: this.source,
|
|
411
|
+
defaultSource: this.defaultSource,
|
|
412
|
+
loadingIndicatorSource: this.loadingIndicatorSource,
|
|
413
|
+
style: this.style,
|
|
414
|
+
resizeMode: this.resizeMode,
|
|
415
|
+
resizeMethod: this.resizeMethod,
|
|
416
|
+
tintColor: this.tintColor,
|
|
417
|
+
blurRadius: this.blurRadius,
|
|
418
|
+
capInsets: this.capInsets,
|
|
419
|
+
fadeDuration: this.fadeDuration,
|
|
420
|
+
progressiveRenderingEnabled: this.progressiveRenderingEnabled,
|
|
421
|
+
src: this.src,
|
|
422
|
+
srcSet: this.srcSet,
|
|
423
|
+
alt: this.alt,
|
|
424
|
+
width: this.width,
|
|
425
|
+
height: this.height,
|
|
426
|
+
crossOrigin: this.crossOrigin,
|
|
427
|
+
referrerPolicy: this.referrerPolicy,
|
|
428
|
+
testID: this.testID,
|
|
429
|
+
nativeID: this.nativeID,
|
|
430
|
+
accessible: this.accessible,
|
|
431
|
+
accessibilityLabel: this.accessibilityLabel,
|
|
432
|
+
accessibilityHint: this.accessibilityHint,
|
|
433
|
+
accessibilityRole: this.accessibilityRole,
|
|
434
|
+
accessibilityState: this.accessibilityState,
|
|
435
|
+
accessibilityValue: this.accessibilityValue,
|
|
436
|
+
accessibilityActions: this.accessibilityActions,
|
|
437
|
+
accessibilityLabelledBy: this.accessibilityLabelledBy,
|
|
438
|
+
importantForAccessibility: this.importantForAccessibility,
|
|
439
|
+
accessibilityLiveRegion: this.accessibilityLiveRegion,
|
|
440
|
+
screenReaderFocusable: this.screenReaderFocusable,
|
|
441
|
+
accessibilityViewIsModal: this.accessibilityViewIsModal,
|
|
442
|
+
accessibilityElementsHidden: this.accessibilityElementsHidden,
|
|
443
|
+
accessibilityIgnoresInvertColors: this.accessibilityIgnoresInvertColors,
|
|
444
|
+
accessibilityLanguage: this.accessibilityLanguage,
|
|
445
|
+
accessibilityRespondsToUserInteraction: this.accessibilityRespondsToUserInteraction,
|
|
446
|
+
accessibilityShowsLargeContentViewer: this.accessibilityShowsLargeContentViewer,
|
|
447
|
+
accessibilityLargeContentTitle: this.accessibilityLargeContentTitle,
|
|
448
|
+
role: this.role,
|
|
449
|
+
ariaLabel: this.ariaLabel,
|
|
450
|
+
ariaLabelledBy: this.ariaLabelledBy,
|
|
451
|
+
ariaLive: this.ariaLive,
|
|
452
|
+
ariaHidden: this.ariaHidden,
|
|
453
|
+
ariaBusy: this.ariaBusy,
|
|
454
|
+
ariaChecked: this.ariaChecked,
|
|
455
|
+
ariaDisabled: this.ariaDisabled,
|
|
456
|
+
ariaExpanded: this.ariaExpanded,
|
|
457
|
+
ariaSelected: this.ariaSelected,
|
|
458
|
+
ariaModal: this.ariaModal,
|
|
459
|
+
ariaValueMax: this.ariaValueMax,
|
|
460
|
+
ariaValueMin: this.ariaValueMin,
|
|
461
|
+
ariaValueNow: this.ariaValueNow,
|
|
462
|
+
ariaValueText: this.ariaValueText,
|
|
463
|
+
onAccessibilityAction: this.onAccessibilityAction,
|
|
464
|
+
onAccessibilityTap: this.onAccessibilityTap,
|
|
465
|
+
onMagicTap: this.onMagicTap,
|
|
466
|
+
onAccessibilityEscape: this.onAccessibilityEscape,
|
|
467
|
+
onLoadStart: this.onLoadStart,
|
|
468
|
+
onLoad: this.onLoad,
|
|
469
|
+
onLoadEnd: this.onLoadEnd,
|
|
470
|
+
onError: this.onError,
|
|
471
|
+
onProgress: this.onProgress,
|
|
472
|
+
onPartialLoad: this.onPartialLoad,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
get imageProps(): Record<string, unknown> {
|
|
477
|
+
return resolveImageProps(this.imageInputProps);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Regression test for the anchor/class bug: ImageBackground is its own
|
|
2
|
+
// ANCHOR_HOST_COMPONENTS entry, separate from the Image it composes internally — a class= on
|
|
3
|
+
// <ImageBackground> resolves onto ImageBackground's OWN anchor and needs its OWN anchorHostStyle
|
|
4
|
+
// merge onto its wrapper View (see image-background.ts's wrapperStyle getter), NOT onto its
|
|
5
|
+
// `imageStyle` (a separate, deliberately untouched prop — see the file's header comment).
|
|
6
|
+
// Mirrors pressable.test.ts's "resolves a class=" case.
|
|
7
|
+
import '@angular/compiler';
|
|
8
|
+
import { Component } from '@angular/core';
|
|
9
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
10
|
+
import { clearGlobalStyles, registerStyles } from '@symbiote-native/engine';
|
|
11
|
+
import { installFabric } from '@symbiote-native/test-utils';
|
|
12
|
+
|
|
13
|
+
import { mount, unmount } from '../render';
|
|
14
|
+
import { ImageBackground } from './image-background';
|
|
15
|
+
|
|
16
|
+
const ROOT_TAG = 916;
|
|
17
|
+
const fabric = installFabric();
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
selector: 'symbiote-image-background-class-host',
|
|
21
|
+
standalone: true,
|
|
22
|
+
imports: [ImageBackground],
|
|
23
|
+
template: `
|
|
24
|
+
<ImageBackground class="card" [source]="{ uri: 'https://example.com/a.png' }">
|
|
25
|
+
<symbiote-text>on top</symbiote-text>
|
|
26
|
+
</ImageBackground>
|
|
27
|
+
`,
|
|
28
|
+
})
|
|
29
|
+
class ImageBackgroundClassHost {}
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
fabric.reset();
|
|
33
|
+
registerStyles({ card: { backgroundColor: 'red' } });
|
|
34
|
+
});
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
unmount(ROOT_TAG);
|
|
37
|
+
clearGlobalStyles();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('ImageBackground anchor class= resolution', () => {
|
|
41
|
+
it('resolves a class= on the ImageBackground use site onto the real committed wrapper View', async () => {
|
|
42
|
+
mount(ROOT_TAG, ImageBackgroundClassHost);
|
|
43
|
+
await new Promise<void>(resolve => setTimeout(resolve, 0));
|
|
44
|
+
|
|
45
|
+
const node = fabric.find(n => n.props.backgroundColor === 'red');
|
|
46
|
+
expect(node, 'a real Fabric node carries the class-derived style').toBeDefined();
|
|
47
|
+
});
|
|
48
|
+
});
|