@symbiote-native/solid 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -14
- package/babel-lower-host-primitives.cjs +323 -0
- package/babel-preset.cjs +5 -0
- package/build/bootstrap.d.ts +7 -0
- package/build/bootstrap.js +18 -0
- package/build/components/activity-indicator/index.android.d.ts +2 -0
- package/build/components/activity-indicator/index.android.js +11 -0
- package/build/components/activity-indicator/index.d.ts +1 -0
- package/build/components/activity-indicator/index.ios.d.ts +2 -0
- package/build/components/activity-indicator/index.ios.js +10 -0
- package/build/components/activity-indicator/index.js +4 -0
- package/build/components/activity-indicator/shared.d.ts +8 -0
- package/build/components/activity-indicator/shared.js +51 -0
- package/build/components/button.d.ts +7 -0
- package/build/components/button.jsx +45 -0
- package/build/components/flat-list/index.d.ts +10 -0
- package/build/components/flat-list/index.jsx +118 -0
- package/build/components/image-background.d.ts +10 -0
- package/build/components/image-background.jsx +74 -0
- package/build/components/image.d.ts +9 -0
- package/build/components/image.js +75 -0
- package/build/components/input-accessory-view.d.ts +11 -0
- package/build/components/input-accessory-view.jsx +39 -0
- package/build/components/keyboard-avoiding-view.d.ts +15 -0
- package/build/components/keyboard-avoiding-view.jsx +152 -0
- package/build/components/modal.d.ts +24 -0
- package/build/components/modal.jsx +125 -0
- package/build/components/pressable.d.ts +31 -0
- package/build/components/pressable.jsx +211 -0
- package/build/components/refresh-control.d.ts +18 -0
- package/build/components/refresh-control.jsx +36 -0
- package/build/components/safe-area-view.d.ts +11 -0
- package/build/components/safe-area-view.jsx +24 -0
- package/build/components/scroll-view/index.android.d.ts +2 -0
- package/build/components/scroll-view/index.android.js +11 -0
- package/build/components/scroll-view/index.d.ts +2 -0
- package/build/components/scroll-view/index.ios.d.ts +2 -0
- package/build/components/scroll-view/index.ios.js +8 -0
- package/build/components/scroll-view/index.js +9 -0
- package/build/components/scroll-view/shared.d.ts +85 -0
- package/build/components/scroll-view/shared.jsx +334 -0
- package/build/components/scroll-view/sticky-header.d.ts +18 -0
- package/build/components/scroll-view/sticky-header.jsx +182 -0
- package/build/components/section-list/index.d.ts +6 -0
- package/build/components/section-list/index.jsx +8 -0
- package/build/components/switch/index.android.d.ts +2 -0
- package/build/components/switch/index.android.js +12 -0
- package/build/components/switch/index.d.ts +1 -0
- package/build/components/switch/index.ios.d.ts +2 -0
- package/build/components/switch/index.ios.js +11 -0
- package/build/components/switch/index.js +4 -0
- package/build/components/switch/shared.d.ts +11 -0
- package/build/components/switch/shared.js +87 -0
- package/build/components/text-input.d.ts +10 -0
- package/build/components/text-input.js +290 -0
- package/build/components/text.d.ts +26 -0
- package/build/components/text.jsx +27 -0
- package/build/components/touchable/index.d.ts +22 -0
- package/build/components/touchable/index.jsx +247 -0
- package/build/components/touchable-native-feedback/index.d.ts +16 -0
- package/build/components/touchable-native-feedback/index.jsx +68 -0
- package/build/components/view.d.ts +32 -0
- package/build/components/view.jsx +49 -0
- package/build/components/virtualized-list/index.android.d.ts +2 -0
- package/build/components/virtualized-list/index.android.js +9 -0
- package/build/components/virtualized-list/index.d.ts +1 -0
- package/build/components/virtualized-list/index.ios.d.ts +2 -0
- package/build/components/virtualized-list/index.ios.js +9 -0
- package/build/components/virtualized-list/index.js +4 -0
- package/build/components/virtualized-list/shared.d.ts +75 -0
- package/build/components/virtualized-list/shared.jsx +782 -0
- package/build/components/virtualized-section-list/index.d.ts +62 -0
- package/build/components/virtualized-section-list/index.jsx +145 -0
- package/build/components.d.ts +43 -0
- package/build/components.js +54 -0
- package/build/create-portal/index.d.ts +11 -0
- package/build/create-portal/index.jsx +88 -0
- package/build/create-tunnel/index.d.ts +13 -0
- package/build/create-tunnel/index.jsx +53 -0
- package/build/descriptor-to-solid.d.ts +3 -0
- package/build/descriptor-to-solid.js +91 -0
- package/build/host-instance.d.ts +2 -0
- package/build/host-instance.js +36 -0
- package/build/index.d.ts +31 -0
- package/build/index.js +98 -0
- package/build/jsx-runtime.d.ts +26 -0
- package/build/jsx-runtime.js +46 -0
- package/build/modules/animated/create-animated-component.d.ts +10 -0
- package/build/modules/animated/create-animated-component.jsx +127 -0
- package/build/modules/animated/index.d.ts +54 -0
- package/build/modules/animated/index.js +78 -0
- package/build/modules/app-registry/index.d.ts +7 -0
- package/build/modules/app-registry/index.js +37 -0
- package/build/modules/status-bar.d.ts +7 -0
- package/build/modules/status-bar.js +45 -0
- package/build/primitives/create-color-scheme.d.ts +3 -0
- package/build/primitives/create-color-scheme.js +33 -0
- package/build/primitives/create-window-dimensions.d.ts +3 -0
- package/build/primitives/create-window-dimensions.js +34 -0
- package/build/register.d.ts +1 -0
- package/build/register.js +31 -0
- package/build/render.d.ts +7 -0
- package/build/render.js +91 -0
- package/build/renderer.d.ts +8 -0
- package/build/renderer.js +259 -0
- package/build/state-style.d.ts +1 -0
- package/build/state-style.js +13 -0
- package/build/utils/host-ref.d.ts +3 -0
- package/build/utils/host-ref.js +22 -0
- package/build/utils/stable-keys.d.ts +1 -0
- package/build/utils/stable-keys.js +31 -0
- package/package.json +24 -8
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Modal — the Solid lifecycle half. RCTModalHostView is an ordinary Fabric host node committing
|
|
2
|
+
// through the SAME childSet as the rest of the tree (no second JS surface, no portal). The style
|
|
3
|
+
// math (the backdrop override, the container/host styles, the presentationStyle default), the
|
|
4
|
+
// visible gate, and the keep-alive reducer all live framework-agnostic in
|
|
5
|
+
// @symbiote-native/components (state/modal.ts + view/render-modal.ts) and are shared verbatim with
|
|
6
|
+
// React, Vue and Svelte. Solid supplies only the reactivity: a signal over the keep-alive state, a
|
|
7
|
+
// post-render effect driving the visible→hidden transition, and the two host tags renderModal's
|
|
8
|
+
// fixed shape resolves to.
|
|
9
|
+
//
|
|
10
|
+
// A FLAT FILE, not a folder: Modal has no platform variant to select by filename. Every platform
|
|
11
|
+
// difference it carries is a PROP (supportedOrientations/allowSwipeDismissal are iOS-read,
|
|
12
|
+
// hardwareAccelerated/statusBarTranslucent/navigationBarTranslucent Android-read) forwarded by name
|
|
13
|
+
// to the one host, exactly as React's, Vue's and Svelte's single-file Modals do — unlike Switch,
|
|
14
|
+
// whose native prop NAMES and snap-back command genuinely differ per host (symbiote-file-layout:
|
|
15
|
+
// only a real platform/shared group gets a folder).
|
|
16
|
+
//
|
|
17
|
+
// WHY HAND-AUTHORED JSX AND NOT descriptorToSolid. Modal takes `children` — a live subtree of the
|
|
18
|
+
// user's components, which is the case the render-fn boundary rules OUT of core
|
|
19
|
+
// (.claude/rules/component-render-fn-boundary.md), so the bridge would have nothing to do with the
|
|
20
|
+
// half that matters and would hand back a root whose container child we would then have to reach
|
|
21
|
+
// into to `insert` into. renderModal always paints the SAME two-tag shape (one symbiote-modal host
|
|
22
|
+
// wrapping one collapsable symbiote-view container; only prop VALUES vary), so the tags are written
|
|
23
|
+
// out and the computed props read off the fixed positions — the same call React's createElement
|
|
24
|
+
// chain, Vue's h() chain and Svelte's markup all make. `children` then reaches the container
|
|
25
|
+
// through the compiler's own `insert`, which is the point of view.tsx's header.
|
|
26
|
+
//
|
|
27
|
+
// `Show` IS IMPORTED FROM solid-js ON PURPOSE. babel-preset-solid resolves an un-imported control-
|
|
28
|
+
// flow name against the renderer module instead, and renderer.ts exports no `Show` — the bundle
|
|
29
|
+
// still builds and `createComponent(undefined, …)` throws at RUNTIME, far from the JSX that caused
|
|
30
|
+
// it (.claude/rules/solid-descriptor-bridge.md §3).
|
|
31
|
+
//
|
|
32
|
+
// NOTHING here destructures `props`. Solid props are getters and a component body runs ONCE; every
|
|
33
|
+
// read below sits inside an accessor or an effect. The single deliberate exception is the reducer
|
|
34
|
+
// SEED, which is a mount-time value by definition (React's useReducer lazy init and Svelte's
|
|
35
|
+
// $state(...) initializer read it exactly once too).
|
|
36
|
+
import { createEffect, createSignal, Show, splitProps } from 'solid-js';
|
|
37
|
+
import { createDescriptorShapeGuard, createInitialModalState, modalReducer, renderModal, resolveAccessibilityProps, shouldRenderModal, } from '@symbiote-native/components';
|
|
38
|
+
import { dlog, } from '@symbiote-native/engine';
|
|
39
|
+
import { withStableKeys } from '../utils/stable-keys.js';
|
|
40
|
+
// Read by Modal itself; everything else (the four DirectEvents, testID/nativeID, every
|
|
41
|
+
// accessibility* and aria-* field) forwards onto the host node through `passthrough`, exactly as
|
|
42
|
+
// React's `...passthrough` rest does.
|
|
43
|
+
const HANDLED_PROPS = [
|
|
44
|
+
'visible',
|
|
45
|
+
'transparent',
|
|
46
|
+
'backdropColor',
|
|
47
|
+
'animationType',
|
|
48
|
+
'presentationStyle',
|
|
49
|
+
'supportedOrientations',
|
|
50
|
+
'hardwareAccelerated',
|
|
51
|
+
'statusBarTranslucent',
|
|
52
|
+
'navigationBarTranslucent',
|
|
53
|
+
'allowSwipeDismissal',
|
|
54
|
+
'style',
|
|
55
|
+
'class',
|
|
56
|
+
'children',
|
|
57
|
+
];
|
|
58
|
+
const shape = createDescriptorShapeGuard('Modal');
|
|
59
|
+
export function Modal(props) {
|
|
60
|
+
const [local, rest] = splitProps(props, HANDLED_PROPS);
|
|
61
|
+
const isVisible = () => local.visible === true;
|
|
62
|
+
// The keep-alive seed is a mount-time value by contract (createInitialModalState: a modal that
|
|
63
|
+
// starts visible is rendered, one that starts hidden contributes no node), so this one read
|
|
64
|
+
// outside an accessor is correct rather than the frozen-props bug.
|
|
65
|
+
const [state, setState] = createSignal(createInitialModalState(isVisible()));
|
|
66
|
+
// createEffect, not createRenderEffect: it runs AFTER the render that used the OLD state, which
|
|
67
|
+
// is the position React's useEffect, Vue's flush:'post' watch and Svelte's $effect all occupy —
|
|
68
|
+
// so a visible→hidden transition renders once more with isRendered still true (the keep-alive
|
|
69
|
+
// frame) before this drops it. A render effect would unmount immediately and kill the keep-alive.
|
|
70
|
+
// The reducer is identity-stable, so the mount run and any no-op transition write the same object
|
|
71
|
+
// back and nothing downstream recomputes.
|
|
72
|
+
//
|
|
73
|
+
// As on Svelte, and for the same reason: under this adapter's microtask-coalesced requestCommit()
|
|
74
|
+
// the whole cascade settles inside one flush, so the keep-alive frame is real but never lands as
|
|
75
|
+
// its own Fabric commit the way React's synchronous per-render commit makes it.
|
|
76
|
+
createEffect(() => {
|
|
77
|
+
setState(current => modalReducer(current, isVisible() ? { type: 'show' } : { type: 'hide' }));
|
|
78
|
+
});
|
|
79
|
+
const shouldRender = () => shouldRenderModal(isVisible(), state());
|
|
80
|
+
createEffect(() => {
|
|
81
|
+
if (!shouldRender())
|
|
82
|
+
dlog('Modal hidden -> no node committed');
|
|
83
|
+
});
|
|
84
|
+
// A plain accessor rather than a createMemo, unlike descriptor-to-solid.ts. A memo runs EAGERLY
|
|
85
|
+
// at creation, which would paint a descriptor (and emit renderModal's "committing" dlog) for a
|
|
86
|
+
// modal that is hidden and commits nothing. Read from inside the two `spread` render effects
|
|
87
|
+
// instead, it never runs at all while `Show` is closed; the cost is that a change recomputes this
|
|
88
|
+
// pure object literal twice, once per bag.
|
|
89
|
+
const descriptor = () => renderModal({
|
|
90
|
+
visible: local.visible,
|
|
91
|
+
transparent: local.transparent,
|
|
92
|
+
backdropColor: local.backdropColor,
|
|
93
|
+
animationType: local.animationType,
|
|
94
|
+
presentationStyle: local.presentationStyle,
|
|
95
|
+
supportedOrientations: local.supportedOrientations,
|
|
96
|
+
hardwareAccelerated: local.hardwareAccelerated,
|
|
97
|
+
statusBarTranslucent: local.statusBarTranslucent,
|
|
98
|
+
navigationBarTranslucent: local.navigationBarTranslucent,
|
|
99
|
+
allowSwipeDismissal: local.allowSwipeDismissal,
|
|
100
|
+
style: local.style,
|
|
101
|
+
passthrough: resolveAccessibilityProps(rest),
|
|
102
|
+
});
|
|
103
|
+
// root = symbiote-modal > [container]; the user children nest UNDER the container View, never as
|
|
104
|
+
// a direct sibling of the host (RN's modal content layout, render-modal.ts).
|
|
105
|
+
const container = () => {
|
|
106
|
+
const [first] = descriptor().children;
|
|
107
|
+
if (first === undefined)
|
|
108
|
+
throw shape.error('the container child disappeared');
|
|
109
|
+
return shape.asElement(first);
|
|
110
|
+
};
|
|
111
|
+
// withStableKeys on both bags because `passthrough` goes through resolveAccessibilityProps, whose
|
|
112
|
+
// two branches emit DIFFERENT key sets — and Solid's `spread` walks only the CURRENT keys with no
|
|
113
|
+
// removal pass, so a vanished key would keep its last value on the native view forever
|
|
114
|
+
// (.claude/rules/solid-descriptor-bridge.md §1).
|
|
115
|
+
const hostBag = withStableKeys(() => descriptor().props);
|
|
116
|
+
const containerBag = withStableKeys(() => ({
|
|
117
|
+
...container().props,
|
|
118
|
+
class: local.class,
|
|
119
|
+
}));
|
|
120
|
+
return (<Show when={shouldRender()}>
|
|
121
|
+
<symbiote-modal {...hostBag()}>
|
|
122
|
+
<symbiote-view {...containerBag()}>{local.children}</symbiote-view>
|
|
123
|
+
</symbiote-modal>
|
|
124
|
+
</Show>);
|
|
125
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
import type { JSX } from '../jsx-runtime';
|
|
3
|
+
import { type IAccessibilityProps, type IAriaProps, type IPressHandler, type IPressState, type IPressableAndroidRippleConfig, type IRectOffset } from '@symbiote-native/components';
|
|
4
|
+
import { type IClassNameValue, type IStyleProp, type IViewStyle } from '@symbiote-native/engine';
|
|
5
|
+
export type { IPressState, IPressableAndroidRippleConfig, } from '@symbiote-native/components';
|
|
6
|
+
type IPressableStyle = IStyleProp<IViewStyle> | ((state: IPressState) => IStyleProp<IViewStyle>);
|
|
7
|
+
type IPressableChildren = JSX.Element | ((state: Accessor<IPressState>) => JSX.Element);
|
|
8
|
+
export interface IPressableProps extends IAccessibilityProps, IAriaProps {
|
|
9
|
+
onPress?: IPressHandler;
|
|
10
|
+
onPressIn?: IPressHandler;
|
|
11
|
+
onPressOut?: IPressHandler;
|
|
12
|
+
onPressMove?: IPressHandler;
|
|
13
|
+
onLongPress?: IPressHandler;
|
|
14
|
+
delayLongPress?: number;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
cancelable?: boolean;
|
|
17
|
+
hitSlop?: IRectOffset;
|
|
18
|
+
pressRetentionOffset?: IRectOffset;
|
|
19
|
+
unstable_pressDelay?: number;
|
|
20
|
+
android_ripple?: IPressableAndroidRippleConfig;
|
|
21
|
+
android_disableSound?: boolean;
|
|
22
|
+
onHoverIn?: IPressHandler;
|
|
23
|
+
onHoverOut?: IPressHandler;
|
|
24
|
+
delayHoverIn?: number;
|
|
25
|
+
delayHoverOut?: number;
|
|
26
|
+
style?: IPressableStyle;
|
|
27
|
+
class?: IClassNameValue;
|
|
28
|
+
children?: IPressableChildren;
|
|
29
|
+
}
|
|
30
|
+
export declare function Pressable(props: IPressableProps): JSX.Element;
|
|
31
|
+
export declare function TouchablePressable(props: IPressableProps): JSX.Element;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// Pressable — the Solid lifecycle half. The press lifecycle (the long-press timer, the
|
|
2
|
+
// unstable_pressDelay deferral, the pressRetentionOffset drift test, the suppression flags) lives
|
|
3
|
+
// in @symbiote-native/components/state as a pure machine over a runtime + host; the render
|
|
4
|
+
// decisions (which responder listeners the View carries, the disabled→accessibilityState fold, the
|
|
5
|
+
// ripple prop) in @symbiote-native/components/view. Both are shared verbatim with React, Vue and
|
|
6
|
+
// Svelte. Solid supplies only the reactivity: a signal for `pressed`, a setup-scope object for the
|
|
7
|
+
// press runtime, a plain variable for the responder node, and one memo that rebuilds the handler
|
|
8
|
+
// bag when the caller's config changes.
|
|
9
|
+
//
|
|
10
|
+
// THE RESPONDER EVENTS ARE NEVER NAMED AS EVENTS HERE. buildPressableListeners returns a flat bag
|
|
11
|
+
// (`onPress`, `onStartShouldSetResponder`, `onResponderMove`, …) which rides into View's prop bag
|
|
12
|
+
// and reaches the engine through routeProp, which decides prop-vs-event from the node's ViewConfig
|
|
13
|
+
// and attaches the responder protocol itself (symbiote-engine-core §2). An adapter-side `onX` check
|
|
14
|
+
// would both duplicate that and get the edge cases wrong.
|
|
15
|
+
//
|
|
16
|
+
// Pressable composes View rather than painting its own host tag, exactly as React's and Vue's do —
|
|
17
|
+
// so the aria/role fold, the class+style merge and the vanished-key widening (utils/stable-keys)
|
|
18
|
+
// all happen once, in View. That also means there is no renderPressable() Descriptor to bridge:
|
|
19
|
+
// `children` is a live Solid subtree, which is the case the render-fn boundary rules OUT of core
|
|
20
|
+
// (.claude/rules/component-render-fn-boundary.md).
|
|
21
|
+
//
|
|
22
|
+
// NOTHING here destructures `props`. Solid props are getters and a component body runs ONCE, so a
|
|
23
|
+
// destructure would freeze the Pressable at its mount-time config; every read below sits inside an
|
|
24
|
+
// accessor, a memo or an event handler.
|
|
25
|
+
import { createEffect, createMemo, onCleanup, createSignal, splitProps, untrack, } from 'solid-js';
|
|
26
|
+
import { buildPressableListeners, createPressHandlers, createPressRuntime, disposePressRuntime, noteHoverNoop, resolveDisabledAccessibilityState, rippleProps, DEFAULT_DELAY_LONG_PRESS_MS, DEFAULT_MIN_PRESS_DURATION_MS, } from '@symbiote-native/components';
|
|
27
|
+
import { dlog, } from '@symbiote-native/engine';
|
|
28
|
+
import { setHostPressed } from '../renderer.js';
|
|
29
|
+
import { View } from './view.jsx';
|
|
30
|
+
// Read by Pressable itself; everything else forwards onto View. The user's press callbacks MUST be
|
|
31
|
+
// split off — they are pure JS, and it is the machine's SYNTHESIZED handlers that go on the host.
|
|
32
|
+
const HANDLED_PROPS = [
|
|
33
|
+
'onPress',
|
|
34
|
+
'onPressIn',
|
|
35
|
+
'onPressOut',
|
|
36
|
+
'onPressMove',
|
|
37
|
+
'onLongPress',
|
|
38
|
+
'delayLongPress',
|
|
39
|
+
'disabled',
|
|
40
|
+
'cancelable',
|
|
41
|
+
'pressRetentionOffset',
|
|
42
|
+
'unstable_pressDelay',
|
|
43
|
+
'android_ripple',
|
|
44
|
+
'android_disableSound',
|
|
45
|
+
'onHoverIn',
|
|
46
|
+
'onHoverOut',
|
|
47
|
+
'delayHoverIn',
|
|
48
|
+
'delayHoverOut',
|
|
49
|
+
'accessibilityState',
|
|
50
|
+
'style',
|
|
51
|
+
'children',
|
|
52
|
+
];
|
|
53
|
+
// `hitSlop` is deliberately NOT in that list: the machine reads it for the retention test AND the
|
|
54
|
+
// host needs it to enlarge the touch target, so it forwards through `rest` untouched.
|
|
55
|
+
function PressableImpl(props, minPressDuration) {
|
|
56
|
+
const [local, rest] = splitProps(props, HANDLED_PROPS);
|
|
57
|
+
const [pressed, setPressed] = createSignal(false);
|
|
58
|
+
// The mutable press runtime (in-flight timers, suppression flags, measured region). A plain
|
|
59
|
+
// setup-scope object, never a signal: the machine mutates it on every event and nothing reads it
|
|
60
|
+
// reactively — same shape as Vue's setup-scope runtime and Svelte's plain `const`.
|
|
61
|
+
const runtime = createPressRuntime();
|
|
62
|
+
// The responder node, held by IDENTITY in a plain variable. A store or a deep proxy would become
|
|
63
|
+
// a different key than the one the engine's commit mirror holds, and measure() would silently
|
|
64
|
+
// no-op (symbiote-engine-core §3).
|
|
65
|
+
let responder = null;
|
|
66
|
+
const attachRef = (node) => {
|
|
67
|
+
responder = node;
|
|
68
|
+
};
|
|
69
|
+
// The lifecycle seam the machine fills: flip the reactive `pressed` cell, and expose the
|
|
70
|
+
// responder's raw frame-measure. Before the first commit the node has no Fabric tag, so measure()
|
|
71
|
+
// no-ops and the machine falls back to its radius test — the same degradation every adapter has,
|
|
72
|
+
// and not a whenCommitted case: the measure is triggered by a touch, which cannot arrive before
|
|
73
|
+
// the view exists.
|
|
74
|
+
const host = {
|
|
75
|
+
// Two sinks for one fact, and both are needed. The signal drives the FRAMEWORK-visible half —
|
|
76
|
+
// a functional `style`, a render-prop child — which is what forces this element to stay a
|
|
77
|
+
// component at all. `setHostPressed` drives the ENGINE-visible half, so `.btn:active` applies
|
|
78
|
+
// to a refused Pressable exactly as it would to a lowered `symbiote-pressable`. That is what
|
|
79
|
+
// makes a refusal cost the component instance and NOT the pressed styling
|
|
80
|
+
// (`.claude/rules/host-primitive-tier.md`).
|
|
81
|
+
//
|
|
82
|
+
// Before the first commit `responder` is null and the engine call is skipped: nothing is
|
|
83
|
+
// painted yet, and a press cannot arrive before the view exists.
|
|
84
|
+
setPressed: next => {
|
|
85
|
+
setPressed(next);
|
|
86
|
+
if (responder !== null)
|
|
87
|
+
setHostPressed(responder, next);
|
|
88
|
+
},
|
|
89
|
+
getMeasureFn: () => {
|
|
90
|
+
const node = responder;
|
|
91
|
+
if (node === null)
|
|
92
|
+
return undefined;
|
|
93
|
+
return callback => {
|
|
94
|
+
node.measure(callback);
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
schedule: (callback, ms) => {
|
|
98
|
+
const id = setTimeout(callback, ms);
|
|
99
|
+
return () => {
|
|
100
|
+
clearTimeout(id);
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
now: Date.now,
|
|
104
|
+
};
|
|
105
|
+
onCleanup(() => {
|
|
106
|
+
disposePressRuntime(runtime);
|
|
107
|
+
});
|
|
108
|
+
// Rebuilt when the caller's config changes (the closures capture live values); the runtime
|
|
109
|
+
// persists across rebuilds, so an in-flight timer or drift flag survives one. Deliberately does
|
|
110
|
+
// NOT read `pressed` — a press must not churn the handler identities the host node holds.
|
|
111
|
+
const handlers = createMemo(() => createPressHandlers({
|
|
112
|
+
onPress: local.onPress,
|
|
113
|
+
onPressIn: local.onPressIn,
|
|
114
|
+
onPressOut: local.onPressOut,
|
|
115
|
+
onPressMove: local.onPressMove,
|
|
116
|
+
onLongPress: local.onLongPress,
|
|
117
|
+
delayLongPress: local.delayLongPress ?? DEFAULT_DELAY_LONG_PRESS_MS,
|
|
118
|
+
unstable_pressDelay: local.unstable_pressDelay ?? 0,
|
|
119
|
+
minPressDuration,
|
|
120
|
+
hitSlop: rest.hitSlop,
|
|
121
|
+
pressRetentionOffset: local.pressRetentionOffset,
|
|
122
|
+
}, runtime, host));
|
|
123
|
+
createEffect(() => {
|
|
124
|
+
noteHoverNoop(local.onHoverIn, local.onHoverOut);
|
|
125
|
+
});
|
|
126
|
+
// Reading `pressed` sits INSIDE the function branch on purpose: a static style must not make the
|
|
127
|
+
// prop bag depend on the press signal, or every touch would re-diff and re-commit the whole bag
|
|
128
|
+
// for nothing. Unlike the children case below, reading it here is SAFE even in the function form
|
|
129
|
+
// — the value feeds viewProps, a prop bag, and a prop bag reaches the host through `spread`,
|
|
130
|
+
// which is a per-key diff on the SAME element. Nothing is rebuilt, so nothing can be rebuilt
|
|
131
|
+
// mid-gesture.
|
|
132
|
+
const pressStyle = () => {
|
|
133
|
+
const style = local.style;
|
|
134
|
+
if (typeof style !== 'function')
|
|
135
|
+
return style;
|
|
136
|
+
return style({ pressed: pressed() });
|
|
137
|
+
};
|
|
138
|
+
const viewProps = createMemo(() => {
|
|
139
|
+
const disabled = local.disabled;
|
|
140
|
+
const bag = {
|
|
141
|
+
...rest,
|
|
142
|
+
style: pressStyle(),
|
|
143
|
+
accessibilityState: resolveDisabledAccessibilityState(local.accessibilityState, disabled),
|
|
144
|
+
};
|
|
145
|
+
// Forwarded under RN's own key; inert on iOS.
|
|
146
|
+
if (local.android_disableSound !== undefined) {
|
|
147
|
+
bag.android_disableSound = local.android_disableSound;
|
|
148
|
+
}
|
|
149
|
+
// Last, so the synthesized responder listeners win over anything of the same name in `rest`.
|
|
150
|
+
// When disabled the bag is EMPTY — every listener key vanishes, and View's withStableKeys
|
|
151
|
+
// widens it back to `undefined`, which routeProp treats as a delete. Without that widening a
|
|
152
|
+
// Pressable that became disabled would keep its old listeners on the native view forever
|
|
153
|
+
// (.claude/rules/solid-descriptor-bridge.md §1).
|
|
154
|
+
Object.assign(bag, buildPressableListeners(handlers(), {
|
|
155
|
+
disabled,
|
|
156
|
+
cancelable: local.cancelable,
|
|
157
|
+
}));
|
|
158
|
+
return bag;
|
|
159
|
+
});
|
|
160
|
+
// A memo, not a bare `() => ({ pressed: pressed() })`: two leaves reading `state()` in the same
|
|
161
|
+
// press must see the same object, and an unchanged press must not hand out a fresh one.
|
|
162
|
+
const pressState = createMemo(() => ({ pressed: pressed() }));
|
|
163
|
+
// WHY AN ACCESSOR AND NOT `{ pressed: pressed() }`. Solid has no reconciler between what this
|
|
164
|
+
// file returns and the host nodes — `insert` REPLACES a subtree, it never diffs one (the same
|
|
165
|
+
// fact descriptor-to-solid.ts opens with). resolveChildren runs inside View's `insert` render
|
|
166
|
+
// effect, so reading `pressed()` there put the press signal in that effect's dependency set:
|
|
167
|
+
// every touch tore the child subtree down and built a fresh one. On device that rebuild landed
|
|
168
|
+
// between `pressIn` and the native responder grant, the grant was lost, the gesture died, and
|
|
169
|
+
// `pressed` stayed true — the "fires on every other tap, label stuck on its pressed text"
|
|
170
|
+
// report. Vue diffs the slot's vnodes, Svelte patches a Snippet in place, Angular updates a
|
|
171
|
+
// template context; all three reuse the nodes underneath. Solid has no such layer, so the
|
|
172
|
+
// reactivity must cross the boundary as an accessor and only the leaf that reads it re-runs.
|
|
173
|
+
//
|
|
174
|
+
// The call is UNTRACKED and happens once, which is exactly how Solid core treats its own render
|
|
175
|
+
// props: `<For>` runs the map fn under createRoot, and createRoot nulls the Listener. A signal
|
|
176
|
+
// read at the top level of the child function therefore does not re-run it — nest it in the JSX
|
|
177
|
+
// (or a <Show>) like anywhere else in Solid.
|
|
178
|
+
const resolveChildren = () => {
|
|
179
|
+
const children = local.children;
|
|
180
|
+
if (typeof children !== 'function')
|
|
181
|
+
return children;
|
|
182
|
+
// A zero-argument accessor is an ordinary Solid JSX child (JSX.Element covers `() => Element`),
|
|
183
|
+
// not a render prop, and `typeof` cannot tell the two apart — arity can. Handing it back
|
|
184
|
+
// unread lets `insert` wrap it in its own render effect, which keeps it reactive; calling it
|
|
185
|
+
// here, under untrack, would freeze it at its first value.
|
|
186
|
+
if (children.length === 0)
|
|
187
|
+
return () => children(pressState);
|
|
188
|
+
return untrack(() => children(pressState));
|
|
189
|
+
};
|
|
190
|
+
// android_ripple rides a dedicated inner View — Android's ReactViewManager reads the ripple
|
|
191
|
+
// background off a child, not off the responder itself. rippleProps() returns undefined off
|
|
192
|
+
// Android, so the child renders unwrapped, no extra node (RN Pressable.js: "inert on iOS").
|
|
193
|
+
const renderContent = () => {
|
|
194
|
+
const config = local.android_ripple;
|
|
195
|
+
const ripple = config !== undefined ? rippleProps(config) : undefined;
|
|
196
|
+
if (ripple === undefined)
|
|
197
|
+
return resolveChildren();
|
|
198
|
+
dlog('Pressable wrapping children in an android_ripple View');
|
|
199
|
+
return <symbiote-view {...ripple}>{resolveChildren()}</symbiote-view>;
|
|
200
|
+
};
|
|
201
|
+
return (<View ref={attachRef} {...viewProps()}>
|
|
202
|
+
{renderContent()}
|
|
203
|
+
</View>);
|
|
204
|
+
}
|
|
205
|
+
export function Pressable(props) {
|
|
206
|
+
return PressableImpl(props, DEFAULT_MIN_PRESS_DURATION_MS);
|
|
207
|
+
}
|
|
208
|
+
// Relative-only composition seam; the public component barrel exports Pressable, never this.
|
|
209
|
+
export function TouchablePressable(props) {
|
|
210
|
+
return PressableImpl(props, 0);
|
|
211
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JSX } from '../jsx-runtime';
|
|
2
|
+
import { type IAccessibilityProps, type IAriaProps } from '@symbiote-native/components';
|
|
3
|
+
import { type IClassNameValue } from '@symbiote-native/engine';
|
|
4
|
+
export interface IRefreshControlProps extends IAccessibilityProps, IAriaProps {
|
|
5
|
+
refreshing: boolean;
|
|
6
|
+
onRefresh?: () => void | Promise<void>;
|
|
7
|
+
tintColor?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
titleColor?: string;
|
|
10
|
+
progressViewOffset?: number;
|
|
11
|
+
colors?: readonly string[];
|
|
12
|
+
progressBackgroundColor?: string;
|
|
13
|
+
size?: 'default' | 'large';
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
class?: IClassNameValue;
|
|
16
|
+
children?: JSX.Element;
|
|
17
|
+
}
|
|
18
|
+
export declare function RefreshControl(props: IRefreshControlProps): JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// RefreshControl — the Solid lifecycle half, and there is barely any: the component owns one host
|
|
2
|
+
// tag and forwards its props onto it. On iOS `symbiote-refresh-control` resolves to Fabric's
|
|
3
|
+
// PullToRefreshView, which lives INSIDE a ScrollView as a childless sibling before the content
|
|
4
|
+
// container; on Android it is AndroidSwipeRefreshLayout and WRAPS the scroll view instead (an
|
|
5
|
+
// Android ScrollView hosts exactly one child). Which of the two shapes is built is ScrollView's
|
|
6
|
+
// job, not this file's — see scroll-view/shared.tsx's `refreshControlMode`.
|
|
7
|
+
//
|
|
8
|
+
// `refreshing` is a CONTROLLED prop: the parent owns it and pushes it down, and native reports the
|
|
9
|
+
// gesture back through the direct `topRefresh` event. `onRefresh` therefore rides in the forwarded
|
|
10
|
+
// bag untouched — routeProp asks the node's ViewConfig whether `onRefresh` is an event and attaches
|
|
11
|
+
// it as a listener, which is why nothing here inspects the `on` prefix itself
|
|
12
|
+
// (symbiote-engine-core §2).
|
|
13
|
+
//
|
|
14
|
+
// FLAT, not a folder: the file-layout rule gives a module its own folder only when it has real
|
|
15
|
+
// platform (`.ios`/`.android`) or `-shared` variants. There is no JS-side platform branch here —
|
|
16
|
+
// every prop forwards to the native node, which reads what it understands and ignores the rest, so
|
|
17
|
+
// the Android-only spinner props below are harmless on iOS and vice versa.
|
|
18
|
+
import { splitProps } from 'solid-js';
|
|
19
|
+
import { resolveAccessibilityProps, } from '@symbiote-native/components';
|
|
20
|
+
import { dlog } from '@symbiote-native/engine';
|
|
21
|
+
import { withStableKeys } from '../utils/stable-keys.js';
|
|
22
|
+
export function RefreshControl(props) {
|
|
23
|
+
// `children` is pulled out rather than left in the bag: spread skips it anyway, but leaving it in
|
|
24
|
+
// would make the bag accessor re-run whenever the child subtree changed. Same split View makes.
|
|
25
|
+
const [local, rest] = splitProps(props, ['children']);
|
|
26
|
+
// withStableKeys because resolveAccessibilityProps has two branches with DIFFERENT key sets — it
|
|
27
|
+
// returns its input untouched while no aria-* alias holds a value, and a fully-blanked bag once
|
|
28
|
+
// one does. Solid's `spread` walks only the current keys and has no removal pass, so a key that
|
|
29
|
+
// vanishes would keep its last value on the native view forever
|
|
30
|
+
// (.claude/rules/solid-descriptor-bridge.md §1).
|
|
31
|
+
const bag = withStableKeys(() => ({ ...resolveAccessibilityProps(rest) }));
|
|
32
|
+
dlog('RefreshControl -> PullToRefreshView');
|
|
33
|
+
return (<symbiote-refresh-control {...bag()}>
|
|
34
|
+
{local.children}
|
|
35
|
+
</symbiote-refresh-control>);
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from '../jsx-runtime';
|
|
2
|
+
import { type IAccessibilityProps, type IAriaProps } from '@symbiote-native/components';
|
|
3
|
+
import { type IClassNameValue, type IStyleProp, type ISymbioteEvent, type IViewStyle } from '@symbiote-native/engine';
|
|
4
|
+
export interface ISafeAreaViewProps extends IAccessibilityProps, IAriaProps {
|
|
5
|
+
style?: IStyleProp<IViewStyle>;
|
|
6
|
+
id?: string;
|
|
7
|
+
class?: IClassNameValue;
|
|
8
|
+
onLayout?: (event: ISymbioteEvent) => void;
|
|
9
|
+
children?: JSX.Element;
|
|
10
|
+
}
|
|
11
|
+
export declare function SafeAreaView(props: ISafeAreaViewProps): JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SafeAreaView — the native view that insets its children past the notch, the rounded corners and
|
|
2
|
+
// the system bars. There is no JS-side inset math anywhere in this project: the host does it, and
|
|
3
|
+
// every adapter's job is only to put style + children on the `symbiote-safe-area-view` intrinsic.
|
|
4
|
+
//
|
|
5
|
+
// So this is a View twin, and ./view.tsx carries the reasoning they share (why the file is real
|
|
6
|
+
// JSX, why nothing is destructured at setup, why children and ref are pulled out of the bag).
|
|
7
|
+
// The one thing worth repeating: there is no renderSafeAreaView() in @symbiote-native/components
|
|
8
|
+
// and there must not be (.claude/rules/component-render-fn-boundary.md) — `children` is a live
|
|
9
|
+
// Solid subtree that flows through the reconciler and is never reduced back to a Descriptor.
|
|
10
|
+
//
|
|
11
|
+
// The bag goes through withStableKeys because resolveAccessibilityProps has two branches with
|
|
12
|
+
// DIFFERENT key sets, and Solid's `spread` has no removal pass — see utils/stable-keys.ts.
|
|
13
|
+
import { splitProps } from 'solid-js';
|
|
14
|
+
import { resolveAccessibilityProps, } from '@symbiote-native/components';
|
|
15
|
+
import { dlog, } from '@symbiote-native/engine';
|
|
16
|
+
import { withStableKeys } from '../utils/stable-keys.js';
|
|
17
|
+
export function SafeAreaView(props) {
|
|
18
|
+
const [local, rest] = splitProps(props, ['children']);
|
|
19
|
+
dlog('SafeAreaView -> SafeAreaView');
|
|
20
|
+
const bag = withStableKeys(() => ({ ...resolveAccessibilityProps(rest) }));
|
|
21
|
+
return (<symbiote-safe-area-view {...bag()}>
|
|
22
|
+
{local.children}
|
|
23
|
+
</symbiote-safe-area-view>);
|
|
24
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { IScrollViewProps, IScrollViewHandle, IScrollViewHostPlatform, IStickyHeaderComponentType, IStickyHeaderComponentProps, } from './shared';
|
|
2
|
+
export declare const ScrollView: (props: import("./shared").IScrollViewProps) => import("@symbiote-native/solid/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ScrollView on Android. An Android ScrollView accepts only ONE child, so a RefreshControl cannot
|
|
2
|
+
// sit beside the content the way iOS allows ("addViewAt: failed to insert view … at index 1").
|
|
3
|
+
// Instead the RefreshControl (AndroidSwipeRefreshLayout) WRAPS the scroll view, which nests inside
|
|
4
|
+
// it with nestedScrollEnabled so the inner scroll takes the gesture before the refresh parent —
|
|
5
|
+
// RN's own ScrollView.js android branch, and the same fact adapters/react's, adapters/vue's and
|
|
6
|
+
// adapters/svelte's Android bindings encode. Metro picks this file on an Android host; no
|
|
7
|
+
// Platform.OS read.
|
|
8
|
+
import { createScrollView } from './shared.jsx';
|
|
9
|
+
export const ScrollView = createScrollView({
|
|
10
|
+
refreshControlMode: 'wrap',
|
|
11
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { IScrollViewProps, IScrollViewHandle, IScrollViewHostPlatform, IStickyHeaderComponentType, IStickyHeaderComponentProps, } from './shared';
|
|
2
|
+
export declare const ScrollView: (props: import("./shared").IScrollViewProps) => import("@symbiote-native/solid/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// ScrollView on iOS. The RefreshControl (PullToRefreshView) is a CHILD of the scroll view, rendered
|
|
2
|
+
// as a childless SIBLING BEFORE the content container — RN ScrollView.js's
|
|
3
|
+
// `{refreshControl}{contentContainer}`, the same fact adapters/react's, adapters/vue's and
|
|
4
|
+
// adapters/svelte's iOS bindings encode. Metro picks this file on an iOS host; no Platform.OS read.
|
|
5
|
+
import { createScrollView } from './shared.jsx';
|
|
6
|
+
export const ScrollView = createScrollView({
|
|
7
|
+
refreshControlMode: 'sibling',
|
|
8
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Base / default ScrollView: re-exports the iOS build. Metro overrides this with index.ios.ts /
|
|
2
|
+
// index.android.ts on a real host; under vitest / tsc the resolution lands here. Filename is the
|
|
3
|
+
// selector, no Platform.OS read.
|
|
4
|
+
//
|
|
5
|
+
// ScrollViewStickyHeader is exported from here rather than from the platform files: it has no
|
|
6
|
+
// platform branch of its own, and an app may compose it directly around a section instead of going
|
|
7
|
+
// through `stickyHeaderIndices`.
|
|
8
|
+
export * from './index.ios.js';
|
|
9
|
+
export { ScrollViewStickyHeader } from './sticky-header.jsx';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type Ref } from 'solid-js';
|
|
2
|
+
import type { JSX } from '../../jsx-runtime';
|
|
3
|
+
import { type IAccessibilityProps, type IAriaProps, type IScrollViewHandle } from '@symbiote-native/components';
|
|
4
|
+
import { type IClassNameValue, type IStyleProp, type ISymbioteEvent, type IViewStyle } from '@symbiote-native/engine';
|
|
5
|
+
import { type IStickyHeaderComponentType } from './sticky-header';
|
|
6
|
+
export type { IScrollViewHandle } from '@symbiote-native/components';
|
|
7
|
+
export type { IStickyHeaderComponentType, IStickyHeaderComponentProps, } from './sticky-header';
|
|
8
|
+
type IScrollHandler = (event: ISymbioteEvent) => void;
|
|
9
|
+
export type IScrollViewHostPlatform = {
|
|
10
|
+
refreshControlMode: 'sibling' | 'wrap';
|
|
11
|
+
};
|
|
12
|
+
export interface IScrollViewProps extends IAccessibilityProps, IAriaProps {
|
|
13
|
+
style?: IStyleProp<IViewStyle>;
|
|
14
|
+
class?: IClassNameValue;
|
|
15
|
+
contentContainerStyle?: IStyleProp<IViewStyle> | string;
|
|
16
|
+
horizontal?: boolean;
|
|
17
|
+
scrollEnabled?: boolean;
|
|
18
|
+
showsVerticalScrollIndicator?: boolean;
|
|
19
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
20
|
+
pagingEnabled?: boolean;
|
|
21
|
+
bounces?: boolean;
|
|
22
|
+
decelerationRate?: 'normal' | 'fast' | number;
|
|
23
|
+
scrollEventThrottle?: number;
|
|
24
|
+
contentInset?: {
|
|
25
|
+
top?: number;
|
|
26
|
+
left?: number;
|
|
27
|
+
bottom?: number;
|
|
28
|
+
right?: number;
|
|
29
|
+
};
|
|
30
|
+
contentOffset?: {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
34
|
+
refreshControl?: JSX.Element;
|
|
35
|
+
removeClippedSubviews?: boolean;
|
|
36
|
+
onContentSizeChange?: (width: number, height: number) => void;
|
|
37
|
+
snapToInterval?: number;
|
|
38
|
+
snapToOffsets?: number[];
|
|
39
|
+
snapToAlignment?: 'start' | 'center' | 'end';
|
|
40
|
+
snapToStart?: boolean;
|
|
41
|
+
snapToEnd?: boolean;
|
|
42
|
+
disableIntervalMomentum?: boolean;
|
|
43
|
+
stickyHeaderIndices?: number[];
|
|
44
|
+
invertStickyHeaders?: boolean;
|
|
45
|
+
StickyHeaderComponent?: IStickyHeaderComponentType;
|
|
46
|
+
keyboardDismissMode?: 'none' | 'on-drag' | 'interactive';
|
|
47
|
+
keyboardShouldPersistTaps?: boolean | 'always' | 'never' | 'handled';
|
|
48
|
+
maintainVisibleContentPosition?: {
|
|
49
|
+
minIndexForVisible: number;
|
|
50
|
+
autoscrollToTopThreshold?: number;
|
|
51
|
+
};
|
|
52
|
+
alwaysBounceHorizontal?: boolean;
|
|
53
|
+
alwaysBounceVertical?: boolean;
|
|
54
|
+
centerContent?: boolean;
|
|
55
|
+
scrollIndicatorInsets?: {
|
|
56
|
+
top?: number;
|
|
57
|
+
left?: number;
|
|
58
|
+
bottom?: number;
|
|
59
|
+
right?: number;
|
|
60
|
+
};
|
|
61
|
+
indicatorStyle?: 'default' | 'black' | 'white';
|
|
62
|
+
directionalLockEnabled?: boolean;
|
|
63
|
+
automaticallyAdjustKeyboardInsets?: boolean;
|
|
64
|
+
contentInsetAdjustmentBehavior?: 'automatic' | 'scrollableAxes' | 'never' | 'always';
|
|
65
|
+
minimumZoomScale?: number;
|
|
66
|
+
maximumZoomScale?: number;
|
|
67
|
+
zoomScale?: number;
|
|
68
|
+
bouncesZoom?: boolean;
|
|
69
|
+
pinchGestureEnabled?: boolean;
|
|
70
|
+
nestedScrollEnabled?: boolean;
|
|
71
|
+
overScrollMode?: 'auto' | 'always' | 'never';
|
|
72
|
+
fadingEdgeLength?: number;
|
|
73
|
+
persistentScrollbar?: boolean;
|
|
74
|
+
endFillColor?: string;
|
|
75
|
+
onLayout?: IScrollHandler;
|
|
76
|
+
onScroll?: IScrollHandler;
|
|
77
|
+
onScrollBeginDrag?: IScrollHandler;
|
|
78
|
+
onScrollEndDrag?: IScrollHandler;
|
|
79
|
+
onMomentumScrollBegin?: IScrollHandler;
|
|
80
|
+
onMomentumScrollEnd?: IScrollHandler;
|
|
81
|
+
onScrollToTop?: IScrollHandler;
|
|
82
|
+
ref?: Ref<IScrollViewHandle>;
|
|
83
|
+
children?: JSX.Element;
|
|
84
|
+
}
|
|
85
|
+
export declare function createScrollView(platform: IScrollViewHostPlatform): (props: IScrollViewProps) => JSX.Element;
|