@hozo/primitives 0.4.0 → 0.5.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/CHANGELOG.md +23 -0
- package/dist/foundation.d.ts +25 -2
- package/dist/foundation.d.ts.map +1 -1
- package/dist/foundation.js +13 -3
- package/dist/foundation.js.map +1 -1
- package/dist/foundation.native.d.ts +9 -2
- package/dist/foundation.native.d.ts.map +1 -1
- package/dist/foundation.native.js +4 -3
- package/dist/foundation.native.js.map +1 -1
- package/dist/generated/button-dom-props.d.ts.map +1 -1
- package/dist/generated/button-dom-props.js +34 -11
- package/dist/generated/button-dom-props.js.map +1 -1
- package/dist/generated/inherited-leaves.d.ts +2 -0
- package/dist/generated/inherited-leaves.d.ts.map +1 -0
- package/dist/generated/inherited-leaves.js +4 -0
- package/dist/generated/inherited-leaves.js.map +1 -0
- package/dist/generated/text.d.ts +1 -1
- package/dist/generated/text.d.ts.map +1 -1
- package/dist/generated/text.js +4 -1
- package/dist/generated/text.js.map +1 -1
- package/dist/inherited-leaves.native.d.ts +28 -0
- package/dist/inherited-leaves.native.d.ts.map +1 -0
- package/dist/inherited-leaves.native.js +49 -0
- package/dist/inherited-leaves.native.js.map +1 -0
- package/dist/pressable.native.d.ts +13 -1
- package/dist/pressable.native.d.ts.map +1 -1
- package/dist/pressable.native.js +13 -1
- package/dist/pressable.native.js.map +1 -1
- package/package.json +6 -22
- package/src/foundation.native.tsx +14 -2
- package/src/foundation.tsx +45 -1
- package/src/generated/button-dom-props.ts +41 -9
- package/src/generated/inherited-leaves.ts +3 -0
- package/src/generated/text.ts +5 -0
- package/src/inherited-leaves.native.tsx +83 -0
- package/src/pressable.native.tsx +20 -0
- package/dist/generated/inherited-label.d.ts +0 -2
- package/dist/generated/inherited-label.d.ts.map +0 -1
- package/dist/generated/inherited-label.js +0 -3
- package/dist/generated/inherited-label.js.map +0 -1
- package/dist/generated/inherited-pressable.d.ts +0 -2
- package/dist/generated/inherited-pressable.d.ts.map +0 -1
- package/dist/generated/inherited-pressable.js +0 -3
- package/dist/generated/inherited-pressable.js.map +0 -1
- package/dist/generated/inherited-relative-text.d.ts +0 -2
- package/dist/generated/inherited-relative-text.d.ts.map +0 -1
- package/dist/generated/inherited-relative-text.js +0 -3
- package/dist/generated/inherited-relative-text.js.map +0 -1
- package/dist/generated/inherited-text.d.ts +0 -2
- package/dist/generated/inherited-text.d.ts.map +0 -1
- package/dist/generated/inherited-text.js +0 -3
- package/dist/generated/inherited-text.js.map +0 -1
- package/dist/generated/inherited-view.d.ts +0 -2
- package/dist/generated/inherited-view.d.ts.map +0 -1
- package/dist/generated/inherited-view.js +0 -3
- package/dist/generated/inherited-view.js.map +0 -1
- package/dist/inherited-label.native.d.ts +0 -8
- package/dist/inherited-label.native.d.ts.map +0 -1
- package/dist/inherited-label.native.js +0 -12
- package/dist/inherited-label.native.js.map +0 -1
- package/dist/inherited-pressable.native.d.ts +0 -11
- package/dist/inherited-pressable.native.d.ts.map +0 -1
- package/dist/inherited-pressable.native.js +0 -75
- package/dist/inherited-pressable.native.js.map +0 -1
- package/dist/inherited-relative-text.native.d.ts +0 -13
- package/dist/inherited-relative-text.native.d.ts.map +0 -1
- package/dist/inherited-relative-text.native.js +0 -16
- package/dist/inherited-relative-text.native.js.map +0 -1
- package/dist/inherited-text-style.native.d.ts +0 -5
- package/dist/inherited-text-style.native.d.ts.map +0 -1
- package/dist/inherited-text-style.native.js +0 -30
- package/dist/inherited-text-style.native.js.map +0 -1
- package/dist/inherited-text.native.d.ts +0 -5
- package/dist/inherited-text.native.d.ts.map +0 -1
- package/dist/inherited-text.native.js +0 -18
- package/dist/inherited-text.native.js.map +0 -1
- package/dist/inherited-view.native.d.ts +0 -9
- package/dist/inherited-view.native.d.ts.map +0 -1
- package/dist/inherited-view.native.js +0 -17
- package/dist/inherited-view.native.js.map +0 -1
- package/src/generated/inherited-label.ts +0 -2
- package/src/generated/inherited-pressable.ts +0 -2
- package/src/generated/inherited-relative-text.ts +0 -2
- package/src/generated/inherited-text.ts +0 -2
- package/src/generated/inherited-view.ts +0 -2
- package/src/inherited-label.native.tsx +0 -28
- package/src/inherited-pressable.native.tsx +0 -152
- package/src/inherited-relative-text.native.tsx +0 -22
- package/src/inherited-text-style.native.ts +0 -35
- package/src/inherited-text.native.tsx +0 -32
- package/src/inherited-view.native.tsx +0 -37
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { HozoInteractionContext } from '@hozo/behaviors/pressable-interaction';
|
|
3
|
-
import { canBlendColor } from '@hozo/engine';
|
|
4
|
-
import { HOZO_INHERITED_TEXT_FIELDS, useHozoInheritedTextFrame, } from '@hozo/engine/generated/text-inheritance-protocol';
|
|
5
|
-
import { Children, useContext, useMemo, useRef, } from 'react';
|
|
6
|
-
import { HozoInheritedText } from './inherited-text.native.js';
|
|
7
|
-
import { HozoInheritedTextScope } from './inherited-text-scope.js';
|
|
8
|
-
import { flattenInheritedTextStyle } from './inherited-text-style.native.js';
|
|
9
|
-
import { HozoPressable } from './pressable.native.js';
|
|
10
|
-
import { useHozoTextColorTransition } from './text-color-transition.native.js';
|
|
11
|
-
/** Only the label reads/publishes typography; there is no extra native box. */
|
|
12
|
-
function LabelScope({ own, resolve, transition, children, }) {
|
|
13
|
-
const interaction = useContext(HozoInteractionContext);
|
|
14
|
-
if (!interaction)
|
|
15
|
-
throw new Error('Inherited label requires the existing Pressable owner');
|
|
16
|
-
// The existing owner is the only state machine. Resolve the class label
|
|
17
|
-
// once from its committed snapshot, then apply the owner's explicit style.
|
|
18
|
-
const frame = useHozoInheritedTextFrame(flattenInheritedTextStyle([resolve?.({ ...interaction }), own]));
|
|
19
|
-
const labelled = Children.map(children, (child) => typeof child === 'string' || typeof child === 'number' ? (_jsx(HozoInheritedText, { children: child })) : (child));
|
|
20
|
-
return transition ? (_jsx(MotionScope, { frame: frame, transition: transition, children: labelled })) : (_jsx(HozoInheritedTextScope, { frame: frame, children: labelled }));
|
|
21
|
-
}
|
|
22
|
-
function MotionScope({ frame, transition, children, }) {
|
|
23
|
-
if (typeof frame.paint.color !== 'string' ||
|
|
24
|
-
!canBlendColor(frame.paint.color) ||
|
|
25
|
-
frame.paint.motion?.color != null)
|
|
26
|
-
throw new Error('Native text inheritance does not assess unresolved colours or nested inherited motion');
|
|
27
|
-
const color = useHozoTextColorTransition(frame.paint.color, '', transition);
|
|
28
|
-
const paint = useMemo(() => Object.freeze({ color: frame.paint.color, motion: Object.freeze({ color }) }), [color, frame.paint.color]);
|
|
29
|
-
return (_jsx(HozoInheritedTextScope, { frame: { metrics: frame.metrics, paint }, children: children }));
|
|
30
|
-
}
|
|
31
|
-
/** Internal generated ABI. Ordinary Pressable is unchanged. */
|
|
32
|
-
export function HozoInheritedPressable({ style, children, hozoTextStyle, hozoTransition, ...props }) {
|
|
33
|
-
const motion = Boolean(hozoTransition);
|
|
34
|
-
const initialMotion = useRef(motion);
|
|
35
|
-
const callback = typeof style === 'function';
|
|
36
|
-
const initialCallback = useRef(callback);
|
|
37
|
-
if (motion !== initialMotion.current)
|
|
38
|
-
throw new Error('Inherited colour motion does not assess changing transition presence');
|
|
39
|
-
if (motion && callback !== initialCallback.current)
|
|
40
|
-
throw new Error('Inherited colour motion does not assess changing box style ownership');
|
|
41
|
-
if (hozoTransition &&
|
|
42
|
-
(!hozoTransition.colors || hozoTransition.opacity || hozoTransition.transform))
|
|
43
|
-
throw new Error('Native text inheritance does not assess non-colour label transitions');
|
|
44
|
-
const { box, own } = useMemo(() => {
|
|
45
|
-
if (typeof style === 'function') {
|
|
46
|
-
if (!hozoTransition)
|
|
47
|
-
throw new Error('Native text inheritance does not assess style callbacks without motion');
|
|
48
|
-
// Only compiler-owned box callbacks are admitted. Label classes already
|
|
49
|
-
// have their own resolved channel: do not run or merge them twice here.
|
|
50
|
-
return {
|
|
51
|
-
box: (state) => {
|
|
52
|
-
const flat = flattenInheritedTextStyle(style(state));
|
|
53
|
-
if (HOZO_INHERITED_TEXT_FIELDS.some((field) => Object.hasOwn(flat, field)))
|
|
54
|
-
throw new Error('Native text inheritance does not assess text in box callbacks');
|
|
55
|
-
if (flat.backgroundColor != null &&
|
|
56
|
-
(typeof flat.backgroundColor !== 'string' || !canBlendColor(flat.backgroundColor)))
|
|
57
|
-
throw new Error('Native text inheritance does not assess unresolved background colours');
|
|
58
|
-
return flat;
|
|
59
|
-
},
|
|
60
|
-
own: {},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const flat = flattenInheritedTextStyle(style);
|
|
64
|
-
const box = { ...flat };
|
|
65
|
-
const own = {};
|
|
66
|
-
for (const field of HOZO_INHERITED_TEXT_FIELDS) {
|
|
67
|
-
if (Object.hasOwn(flat, field))
|
|
68
|
-
own[field] = flat[field];
|
|
69
|
-
delete box[field];
|
|
70
|
-
}
|
|
71
|
-
return { box: box, own };
|
|
72
|
-
}, [style, hozoTransition]);
|
|
73
|
-
return (_jsx(HozoPressable, { ...props, style: box, hozoTransition: callback ? hozoTransition : undefined, children: (state) => (_jsx(LabelScope, { own: own, resolve: hozoTextStyle, transition: hozoTransition, children: typeof children === 'function' ? children(state) : children })) }));
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=inherited-pressable.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-pressable.native.js","sourceRoot":"","sources":["../src/inherited-pressable.native.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EACL,0BAA0B,EAE1B,yBAAyB,GAC1B,MAAM,kDAAkD,CAAA;AACzD,OAAO,EACL,QAAQ,EAGR,UAAU,EACV,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA6B,CAAA;AAC/D,OAAO,EAAE,sBAAsB,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,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;YACxD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAA;QACnB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,GAAgB,EAAE,GAAG,EAAE,CAAA;IACvC,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAA;IAC3B,OAAO,CACL,KAAC,aAAa,OAAK,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,YACxF,CAAC,KAAK,EAAE,EAAE,CAAC,CACV,KAAC,UAAU,IAAC,GAAG,EAAE,GAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,YAClF,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GACjD,CACd,GACa,CACjB,CAAA;AACH,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithRef } from 'react';
|
|
2
|
-
import type { Text } from 'react-native';
|
|
3
|
-
/**
|
|
4
|
-
* A semantic size ratio, not a second style resolver. The scope's legacy
|
|
5
|
-
* size bridge comes from the same effective metrics as the seven-field frame.
|
|
6
|
-
* Resolve the default once; the element's own class/explicit size wins after
|
|
7
|
-
* it and the shared Text publishes the result for opaque descendants too.
|
|
8
|
-
* Kept separate so passive Text pays no new hook or import for relative text.
|
|
9
|
-
*/
|
|
10
|
-
export declare function HozoInheritedRelativeText({ hozoRelative, style, ...props }: ComponentPropsWithRef<typeof Text> & {
|
|
11
|
-
hozoRelative: number;
|
|
12
|
-
}): import("react").JSX.Element;
|
|
13
|
-
//# sourceMappingURL=inherited-relative-text.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-relative-text.native.d.ts","sourceRoot":"","sources":["../src/inherited-relative-text.native.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,qBAAqB,EAAc,MAAM,OAAO,CAAA;AAC9D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGxC;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,YAAY,EACZ,KAAK,EACL,GAAG,KAAK,EACT,EAAE,qBAAqB,CAAC,OAAO,IAAI,CAAC,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,+BAK/D"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { HozoTextSizeContext } from '@hozo/engine/generated/text-size-context';
|
|
3
|
-
import { useContext } from 'react';
|
|
4
|
-
import { HozoInheritedText } from './inherited-text.native.js';
|
|
5
|
-
/**
|
|
6
|
-
* A semantic size ratio, not a second style resolver. The scope's legacy
|
|
7
|
-
* size bridge comes from the same effective metrics as the seven-field frame.
|
|
8
|
-
* Resolve the default once; the element's own class/explicit size wins after
|
|
9
|
-
* it and the shared Text publishes the result for opaque descendants too.
|
|
10
|
-
* Kept separate so passive Text pays no new hook or import for relative text.
|
|
11
|
-
*/
|
|
12
|
-
export function HozoInheritedRelativeText({ hozoRelative, style, ...props }) {
|
|
13
|
-
const base = useContext(HozoTextSizeContext);
|
|
14
|
-
return (_jsx(HozoInheritedText, { ...props, style: [{ fontSize: Math.round(base * hozoRelative) }, style] }));
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=inherited-relative-text.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-relative-text.native.js","sourceRoot":"","sources":["../src/inherited-relative-text.native.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAA;AAC9E,OAAO,EAA8B,UAAU,EAAE,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA6B,CAAA;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,EACxC,YAAY,EACZ,KAAK,EACL,GAAG,KAAK,EACsD;IAC9D,MAAM,IAAI,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAC5C,OAAO,CACL,KAAC,iBAAiB,OAAK,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,GAAI,CAChG,CAAA;AACH,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type HozoInheritedTextOwn } from '@hozo/engine/generated/text-inheritance-protocol';
|
|
2
|
-
import { type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
3
|
-
export type InheritedNativeStyle = StyleProp<TextStyle & ViewStyle>;
|
|
4
|
-
export declare function flattenInheritedTextStyle(style: InheritedNativeStyle): Record<string, unknown> & HozoInheritedTextOwn;
|
|
5
|
-
//# sourceMappingURL=inherited-text-style.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-text-style.native.d.ts","sourceRoot":"","sources":["../src/inherited-text-style.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,KAAK,SAAS,EAAc,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAEzF,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;AAGnE,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,GAwBpD,0BAAc,oBAAoB,CAClD"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { HOZO_INHERITED_TEXT_FIELDS, } from '@hozo/engine/generated/text-inheritance-protocol';
|
|
2
|
-
import { StyleSheet } from 'react-native';
|
|
3
|
-
const EMPTY = Object.freeze({});
|
|
4
|
-
export function flattenInheritedTextStyle(style) {
|
|
5
|
-
if (typeof style === 'function')
|
|
6
|
-
throw new Error('Native text inheritance does not assess style callbacks');
|
|
7
|
-
// Read static records without cloning them. Only the View host needs its
|
|
8
|
-
// own normalized copy; the compiler's/source owner's style is never edited.
|
|
9
|
-
const flat = (StyleSheet.flatten(style) ?? EMPTY);
|
|
10
|
-
for (const name of ['fontFamily', 'fontVariant', 'fontStyle']) {
|
|
11
|
-
if (flat[name] != null)
|
|
12
|
-
throw new Error(`Native text inheritance does not assess ${name}`);
|
|
13
|
-
}
|
|
14
|
-
// This internal first slice accepts resolved seven-field frames, not
|
|
15
|
-
// Animated nodes or opaque platform colors. Do not silently certify them.
|
|
16
|
-
for (const name of HOZO_INHERITED_TEXT_FIELDS) {
|
|
17
|
-
const value = flat[name];
|
|
18
|
-
if (value == null)
|
|
19
|
-
continue;
|
|
20
|
-
const numeric = name === 'fontSize' || name === 'lineHeight' || name === 'letterSpacing';
|
|
21
|
-
const textual = name === 'textAlign' || name === 'textTransform';
|
|
22
|
-
if ((numeric && typeof value !== 'number') ||
|
|
23
|
-
(textual && typeof value !== 'string') ||
|
|
24
|
-
(!numeric && !textual && typeof value !== 'string' && typeof value !== 'number') ||
|
|
25
|
-
(typeof value === 'number' && !Number.isFinite(value)))
|
|
26
|
-
throw new Error(`Native text inheritance does not assess ${name}`);
|
|
27
|
-
}
|
|
28
|
-
return flat;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=inherited-text-style.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-text-style.native.js","sourceRoot":"","sources":["../src/inherited-text-style.native.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,GAE3B,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAkB,UAAU,EAAkC,MAAM,cAAc,CAAA;AAGzF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAE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AAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ComponentPropsWithRef } from 'react';
|
|
2
|
-
import { Text } from 'react-native';
|
|
3
|
-
/** @internal Generated ABI; ordinary output does not import it. */
|
|
4
|
-
export declare function HozoInheritedText({ style, children, ...props }: ComponentPropsWithRef<typeof Text>): import("react").JSX.Element;
|
|
5
|
-
//# sourceMappingURL=inherited-text.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-text.native.d.ts","sourceRoot":"","sources":["../src/inherited-text.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAe,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAY,IAAI,EAAkB,MAAM,cAAc,CAAA;AAM7D,mEAAmE;AACnE,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,CAAC,OAAO,IAAI,CAAC,+BAkBpC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useHozoInheritedTextFrame } from '@hozo/engine/generated/text-inheritance-protocol';
|
|
3
|
-
import { Animated, Text } from 'react-native';
|
|
4
|
-
import { HozoInheritedTextScope } from './inherited-text-scope.js';
|
|
5
|
-
import { flattenInheritedTextStyle } from './inherited-text-style.native.js';
|
|
6
|
-
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
7
|
-
/** @internal Generated ABI; ordinary output does not import it. */
|
|
8
|
-
export function HozoInheritedText({ style, children, ...props }) {
|
|
9
|
-
const frame = useHozoInheritedTextFrame(flattenInheritedTextStyle(style));
|
|
10
|
-
// Local overrides mask the shared value but retain this host kind. Toggling
|
|
11
|
-
// an own colour must not remount nested state or allocate another timeline.
|
|
12
|
-
const Component = frame.paint.motion ? AnimatedText : Text;
|
|
13
|
-
const paint = frame.paint.motion
|
|
14
|
-
? { color: frame.paint.motion.color ?? frame.paint.color }
|
|
15
|
-
: frame.paint;
|
|
16
|
-
return (_jsx(HozoInheritedTextScope, { frame: frame, children: _jsx(Component, { ...props, style: [style, frame.metrics, paint], children: children }) }));
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=inherited-text.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-text.native.js","sourceRoot":"","sources":["../src/inherited-text.native.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAA;AAE5F,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA4B,CAAA;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAE5E,MAAM,YAAY,GAAgB,QAAQ,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;AAExE,mEAAmE;AACnE,MAAM,UAAU,iBAAiB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EAC2B;IACnC,MAAM,KAAK,GAAG,yBAAyB,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAA;IACzE,4EAA4E;IAC5E,4EAA4E;IAC5E,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAA;IAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM;QAC9B,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;QAC1D,CAAC,CAAC,KAAK,CAAC,KAAK,CAAA;IACf,OAAO,CACL,KAAC,sBAAsB,IAAC,KAAK,EAAE,KAAK,YAClC,KAAC,SAAS,OACJ,KAAK,EACT,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAA6B,EAAE,KAA2B,CAAC,YAE/E,QAAQ,GACC,GACW,CAC1B,CAAA;AACH,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithRef } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { type InheritedNativeStyle } from './inherited-text-style.native.ts';
|
|
4
|
-
export interface HozoInheritedViewProps extends Omit<ComponentPropsWithRef<typeof View>, 'style'> {
|
|
5
|
-
style?: InheritedNativeStyle;
|
|
6
|
-
}
|
|
7
|
-
/** @internal Publish owner data before removing invalid host View fields. */
|
|
8
|
-
export declare function HozoInheritedView({ style, children, ...props }: HozoInheritedViewProps): import("react").JSX.Element;
|
|
9
|
-
//# sourceMappingURL=inherited-view.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-view.native.d.ts","sourceRoot":"","sources":["../src/inherited-view.native.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAA;AAGnD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAA;AAEzC,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC;IAC/F,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,sBAAsB,+BAkBtF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { HOZO_INHERITED_TEXT_FIELDS, useHozoInheritedTextFrame, } from '@hozo/engine/generated/text-inheritance-protocol';
|
|
3
|
-
import { Children } from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
import { HozoInheritedText } from './inherited-text.native.js';
|
|
6
|
-
import { HozoInheritedTextScope } from './inherited-text-scope.js';
|
|
7
|
-
import { flattenInheritedTextStyle, } from './inherited-text-style.native.js';
|
|
8
|
-
/** @internal Publish owner data before removing invalid host View fields. */
|
|
9
|
-
export function HozoInheritedView({ style, children, ...props }) {
|
|
10
|
-
const own = flattenInheritedTextStyle(style);
|
|
11
|
-
const frame = useHozoInheritedTextFrame(own);
|
|
12
|
-
const rendered = { ...own };
|
|
13
|
-
for (const name of HOZO_INHERITED_TEXT_FIELDS)
|
|
14
|
-
delete rendered[name];
|
|
15
|
-
return (_jsx(HozoInheritedTextScope, { frame: frame, children: _jsx(View, { ...props, style: rendered, children: Children.map(children, (child) => typeof child === 'string' || typeof child === 'number' ? (_jsx(HozoInheritedText, { children: child })) : (child)) }) }));
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=inherited-view.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inherited-view.native.js","sourceRoot":"","sources":["../src/inherited-view.native.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,QAAQ,EAA8B,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA6B,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA4B,CAAA;AACnE,OAAO,EACL,yBAAyB,GAE1B,MAAM,kCAAkC,CAAA;AAMzC,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAA0B;IACrF,MAAM,GAAG,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAA;IAC5C,MAAM,KAAK,GAAG,yBAAyB,CAAC,GAAG,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,EAAE,GAAG,GAAG,EAAE,CAAA;IAC3B,KAAK,MAAM,IAAI,IAAI,0BAA0B;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpE,OAAO,CACL,KAAC,sBAAsB,IAAC,KAAK,EAAE,KAAK,YAClC,KAAC,IAAI,OAAK,KAAK,EAAE,KAAK,EAAE,QAA8B,YACnD,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAChC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CACvD,KAAC,iBAAiB,cAAE,KAAK,GAAqB,CAC/C,CAAC,CAAC,CAAC,CACF,KAAK,CACN,CACF,GACI,GACgB,CAC1B,CAAA;AACH,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useHozoInheritedTextFrame } from '@hozo/engine/generated/text-inheritance-protocol'
|
|
2
|
-
import { Children, type ReactNode } from 'react'
|
|
3
|
-
import type { StyleProp, TextStyle } from 'react-native'
|
|
4
|
-
import { HozoInheritedText } from './inherited-text.native.tsx'
|
|
5
|
-
import { HozoInheritedTextScope } from './inherited-text-scope.tsx'
|
|
6
|
-
import { flattenInheritedTextStyle } from './inherited-text-style.native.ts'
|
|
7
|
-
|
|
8
|
-
/** A pattern supplies already-resolved label styles, not classes or state. */
|
|
9
|
-
export function HozoInheritedLabel({
|
|
10
|
-
style,
|
|
11
|
-
children,
|
|
12
|
-
}: {
|
|
13
|
-
style?: StyleProp<TextStyle>
|
|
14
|
-
children?: ReactNode
|
|
15
|
-
}) {
|
|
16
|
-
const frame = useHozoInheritedTextFrame(flattenInheritedTextStyle(style))
|
|
17
|
-
return (
|
|
18
|
-
<HozoInheritedTextScope frame={frame}>
|
|
19
|
-
{Children.map(children, (child) =>
|
|
20
|
-
typeof child === 'string' || typeof child === 'number' ? (
|
|
21
|
-
<HozoInheritedText style={style}>{child}</HozoInheritedText>
|
|
22
|
-
) : (
|
|
23
|
-
child
|
|
24
|
-
),
|
|
25
|
-
)}
|
|
26
|
-
</HozoInheritedTextScope>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { HozoInteractionContext } from '@hozo/behaviors/pressable-interaction'
|
|
2
|
-
import { canBlendColor } from '@hozo/engine'
|
|
3
|
-
import {
|
|
4
|
-
HOZO_INHERITED_TEXT_FIELDS,
|
|
5
|
-
type HozoInheritedTextFrame,
|
|
6
|
-
useHozoInheritedTextFrame,
|
|
7
|
-
} from '@hozo/engine/generated/text-inheritance-protocol'
|
|
8
|
-
import {
|
|
9
|
-
Children,
|
|
10
|
-
type ComponentPropsWithRef,
|
|
11
|
-
type ReactNode,
|
|
12
|
-
useContext,
|
|
13
|
-
useMemo,
|
|
14
|
-
useRef,
|
|
15
|
-
} from 'react'
|
|
16
|
-
import type { Pressable, StyleProp, TextStyle, ViewStyle } from 'react-native'
|
|
17
|
-
import { HozoInheritedText } from './inherited-text.native.tsx'
|
|
18
|
-
import { HozoInheritedTextScope } from './inherited-text-scope.tsx'
|
|
19
|
-
import { flattenInheritedTextStyle } from './inherited-text-style.native.ts'
|
|
20
|
-
import { HozoPressable, type HozoPressableProps } from './pressable.native.tsx'
|
|
21
|
-
import { useHozoTextColorTransition } from './text-color-transition.native.ts'
|
|
22
|
-
|
|
23
|
-
type Props = Omit<HozoPressableProps, 'style'> & {
|
|
24
|
-
style?: StyleProp<ViewStyle & TextStyle> | Exclude<HozoPressableProps['style'], undefined>
|
|
25
|
-
ref?: ComponentPropsWithRef<typeof Pressable>['ref']
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Only the label reads/publishes typography; there is no extra native box. */
|
|
29
|
-
function LabelScope({
|
|
30
|
-
own,
|
|
31
|
-
resolve,
|
|
32
|
-
transition,
|
|
33
|
-
children,
|
|
34
|
-
}: {
|
|
35
|
-
own: TextStyle
|
|
36
|
-
resolve: HozoPressableProps['hozoTextStyle']
|
|
37
|
-
transition?: HozoPressableProps['hozoTransition']
|
|
38
|
-
children?: ReactNode
|
|
39
|
-
}) {
|
|
40
|
-
const interaction = useContext(HozoInteractionContext)
|
|
41
|
-
if (!interaction) throw new Error('Inherited label requires the existing Pressable owner')
|
|
42
|
-
// The existing owner is the only state machine. Resolve the class label
|
|
43
|
-
// once from its committed snapshot, then apply the owner's explicit style.
|
|
44
|
-
const frame = useHozoInheritedTextFrame(
|
|
45
|
-
flattenInheritedTextStyle([resolve?.({ ...interaction }), own]),
|
|
46
|
-
)
|
|
47
|
-
const labelled = Children.map(children, (child) =>
|
|
48
|
-
typeof child === 'string' || typeof child === 'number' ? (
|
|
49
|
-
<HozoInheritedText>{child}</HozoInheritedText>
|
|
50
|
-
) : (
|
|
51
|
-
child
|
|
52
|
-
),
|
|
53
|
-
)
|
|
54
|
-
return transition ? (
|
|
55
|
-
<MotionScope frame={frame} transition={transition}>
|
|
56
|
-
{labelled}
|
|
57
|
-
</MotionScope>
|
|
58
|
-
) : (
|
|
59
|
-
<HozoInheritedTextScope frame={frame}>{labelled}</HozoInheritedTextScope>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function MotionScope({
|
|
64
|
-
frame,
|
|
65
|
-
transition,
|
|
66
|
-
children,
|
|
67
|
-
}: {
|
|
68
|
-
frame: HozoInheritedTextFrame
|
|
69
|
-
transition: NonNullable<HozoPressableProps['hozoTransition']>
|
|
70
|
-
children?: ReactNode
|
|
71
|
-
}) {
|
|
72
|
-
if (
|
|
73
|
-
typeof frame.paint.color !== 'string' ||
|
|
74
|
-
!canBlendColor(frame.paint.color) ||
|
|
75
|
-
frame.paint.motion?.color != null
|
|
76
|
-
)
|
|
77
|
-
throw new Error(
|
|
78
|
-
'Native text inheritance does not assess unresolved colours or nested inherited motion',
|
|
79
|
-
)
|
|
80
|
-
const color = useHozoTextColorTransition(frame.paint.color, '', transition)
|
|
81
|
-
const paint = useMemo(
|
|
82
|
-
() => Object.freeze({ color: frame.paint.color, motion: Object.freeze({ color }) }),
|
|
83
|
-
[color, frame.paint.color],
|
|
84
|
-
)
|
|
85
|
-
return (
|
|
86
|
-
<HozoInheritedTextScope frame={{ metrics: frame.metrics, paint }}>
|
|
87
|
-
{children}
|
|
88
|
-
</HozoInheritedTextScope>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** Internal generated ABI. Ordinary Pressable is unchanged. */
|
|
93
|
-
export function HozoInheritedPressable({
|
|
94
|
-
style,
|
|
95
|
-
children,
|
|
96
|
-
hozoTextStyle,
|
|
97
|
-
hozoTransition,
|
|
98
|
-
...props
|
|
99
|
-
}: Props) {
|
|
100
|
-
const motion = Boolean(hozoTransition)
|
|
101
|
-
const initialMotion = useRef(motion)
|
|
102
|
-
const callback = typeof style === 'function'
|
|
103
|
-
const initialCallback = useRef(callback)
|
|
104
|
-
if (motion !== initialMotion.current)
|
|
105
|
-
throw new Error('Inherited colour motion does not assess changing transition presence')
|
|
106
|
-
if (motion && callback !== initialCallback.current)
|
|
107
|
-
throw new Error('Inherited colour motion does not assess changing box style ownership')
|
|
108
|
-
if (
|
|
109
|
-
hozoTransition &&
|
|
110
|
-
(!hozoTransition.colors || hozoTransition.opacity || hozoTransition.transform)
|
|
111
|
-
)
|
|
112
|
-
throw new Error('Native text inheritance does not assess non-colour label transitions')
|
|
113
|
-
const { box, own } = useMemo(() => {
|
|
114
|
-
if (typeof style === 'function') {
|
|
115
|
-
if (!hozoTransition)
|
|
116
|
-
throw new Error('Native text inheritance does not assess style callbacks without motion')
|
|
117
|
-
// Only compiler-owned box callbacks are admitted. Label classes already
|
|
118
|
-
// have their own resolved channel: do not run or merge them twice here.
|
|
119
|
-
return {
|
|
120
|
-
box: (state: Parameters<typeof style>[0]) => {
|
|
121
|
-
const flat = flattenInheritedTextStyle(style(state))
|
|
122
|
-
if (HOZO_INHERITED_TEXT_FIELDS.some((field) => Object.hasOwn(flat, field)))
|
|
123
|
-
throw new Error('Native text inheritance does not assess text in box callbacks')
|
|
124
|
-
if (
|
|
125
|
-
flat.backgroundColor != null &&
|
|
126
|
-
(typeof flat.backgroundColor !== 'string' || !canBlendColor(flat.backgroundColor))
|
|
127
|
-
)
|
|
128
|
-
throw new Error('Native text inheritance does not assess unresolved background colours')
|
|
129
|
-
return flat as ViewStyle
|
|
130
|
-
},
|
|
131
|
-
own: {},
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const flat = flattenInheritedTextStyle(style)
|
|
135
|
-
const box = { ...flat }
|
|
136
|
-
const own: Record<string, unknown> = {}
|
|
137
|
-
for (const field of HOZO_INHERITED_TEXT_FIELDS) {
|
|
138
|
-
if (Object.hasOwn(flat, field)) own[field] = flat[field]
|
|
139
|
-
delete box[field]
|
|
140
|
-
}
|
|
141
|
-
return { box: box as ViewStyle, own }
|
|
142
|
-
}, [style, hozoTransition])
|
|
143
|
-
return (
|
|
144
|
-
<HozoPressable {...props} style={box} hozoTransition={callback ? hozoTransition : undefined}>
|
|
145
|
-
{(state) => (
|
|
146
|
-
<LabelScope own={own as TextStyle} resolve={hozoTextStyle} transition={hozoTransition}>
|
|
147
|
-
{typeof children === 'function' ? children(state) : children}
|
|
148
|
-
</LabelScope>
|
|
149
|
-
)}
|
|
150
|
-
</HozoPressable>
|
|
151
|
-
)
|
|
152
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HozoTextSizeContext } from '@hozo/engine/generated/text-size-context'
|
|
2
|
-
import { type ComponentPropsWithRef, useContext } from 'react'
|
|
3
|
-
import type { Text } from 'react-native'
|
|
4
|
-
import { HozoInheritedText } from './inherited-text.native.tsx'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A semantic size ratio, not a second style resolver. The scope's legacy
|
|
8
|
-
* size bridge comes from the same effective metrics as the seven-field frame.
|
|
9
|
-
* Resolve the default once; the element's own class/explicit size wins after
|
|
10
|
-
* it and the shared Text publishes the result for opaque descendants too.
|
|
11
|
-
* Kept separate so passive Text pays no new hook or import for relative text.
|
|
12
|
-
*/
|
|
13
|
-
export function HozoInheritedRelativeText({
|
|
14
|
-
hozoRelative,
|
|
15
|
-
style,
|
|
16
|
-
...props
|
|
17
|
-
}: ComponentPropsWithRef<typeof Text> & { hozoRelative: number }) {
|
|
18
|
-
const base = useContext(HozoTextSizeContext)
|
|
19
|
-
return (
|
|
20
|
-
<HozoInheritedText {...props} style={[{ fontSize: Math.round(base * hozoRelative) }, style]} />
|
|
21
|
-
)
|
|
22
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HOZO_INHERITED_TEXT_FIELDS,
|
|
3
|
-
type HozoInheritedTextOwn,
|
|
4
|
-
} from '@hozo/engine/generated/text-inheritance-protocol'
|
|
5
|
-
import { type StyleProp, StyleSheet, type TextStyle, type ViewStyle } from 'react-native'
|
|
6
|
-
|
|
7
|
-
export type InheritedNativeStyle = StyleProp<TextStyle & ViewStyle>
|
|
8
|
-
const EMPTY = Object.freeze({})
|
|
9
|
-
|
|
10
|
-
export function flattenInheritedTextStyle(style: InheritedNativeStyle) {
|
|
11
|
-
if (typeof style === 'function')
|
|
12
|
-
throw new Error('Native text inheritance does not assess style callbacks')
|
|
13
|
-
// Read static records without cloning them. Only the View host needs its
|
|
14
|
-
// own normalized copy; the compiler's/source owner's style is never edited.
|
|
15
|
-
const flat = (StyleSheet.flatten(style) ?? EMPTY) as Record<string, unknown>
|
|
16
|
-
for (const name of ['fontFamily', 'fontVariant', 'fontStyle']) {
|
|
17
|
-
if (flat[name] != null) throw new Error(`Native text inheritance does not assess ${name}`)
|
|
18
|
-
}
|
|
19
|
-
// This internal first slice accepts resolved seven-field frames, not
|
|
20
|
-
// Animated nodes or opaque platform colors. Do not silently certify them.
|
|
21
|
-
for (const name of HOZO_INHERITED_TEXT_FIELDS) {
|
|
22
|
-
const value = flat[name]
|
|
23
|
-
if (value == null) continue
|
|
24
|
-
const numeric = name === 'fontSize' || name === 'lineHeight' || name === 'letterSpacing'
|
|
25
|
-
const textual = name === 'textAlign' || name === 'textTransform'
|
|
26
|
-
if (
|
|
27
|
-
(numeric && typeof value !== 'number') ||
|
|
28
|
-
(textual && typeof value !== 'string') ||
|
|
29
|
-
(!numeric && !textual && typeof value !== 'string' && typeof value !== 'number') ||
|
|
30
|
-
(typeof value === 'number' && !Number.isFinite(value))
|
|
31
|
-
)
|
|
32
|
-
throw new Error(`Native text inheritance does not assess ${name}`)
|
|
33
|
-
}
|
|
34
|
-
return flat as typeof flat & HozoInheritedTextOwn
|
|
35
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { useHozoInheritedTextFrame } from '@hozo/engine/generated/text-inheritance-protocol'
|
|
2
|
-
import type { ComponentPropsWithRef, ElementType } from 'react'
|
|
3
|
-
import { Animated, Text, type TextProps } from 'react-native'
|
|
4
|
-
import { HozoInheritedTextScope } from './inherited-text-scope.tsx'
|
|
5
|
-
import { flattenInheritedTextStyle } from './inherited-text-style.native.ts'
|
|
6
|
-
|
|
7
|
-
const AnimatedText: ElementType = Animated.createAnimatedComponent(Text)
|
|
8
|
-
|
|
9
|
-
/** @internal Generated ABI; ordinary output does not import it. */
|
|
10
|
-
export function HozoInheritedText({
|
|
11
|
-
style,
|
|
12
|
-
children,
|
|
13
|
-
...props
|
|
14
|
-
}: ComponentPropsWithRef<typeof Text>) {
|
|
15
|
-
const frame = useHozoInheritedTextFrame(flattenInheritedTextStyle(style))
|
|
16
|
-
// Local overrides mask the shared value but retain this host kind. Toggling
|
|
17
|
-
// an own colour must not remount nested state or allocate another timeline.
|
|
18
|
-
const Component = frame.paint.motion ? AnimatedText : Text
|
|
19
|
-
const paint = frame.paint.motion
|
|
20
|
-
? { color: frame.paint.motion.color ?? frame.paint.color }
|
|
21
|
-
: frame.paint
|
|
22
|
-
return (
|
|
23
|
-
<HozoInheritedTextScope frame={frame}>
|
|
24
|
-
<Component
|
|
25
|
-
{...props}
|
|
26
|
-
style={[style, frame.metrics as TextProps['style'], paint as TextProps['style']]}
|
|
27
|
-
>
|
|
28
|
-
{children}
|
|
29
|
-
</Component>
|
|
30
|
-
</HozoInheritedTextScope>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HOZO_INHERITED_TEXT_FIELDS,
|
|
3
|
-
useHozoInheritedTextFrame,
|
|
4
|
-
} from '@hozo/engine/generated/text-inheritance-protocol'
|
|
5
|
-
import { Children, type ComponentPropsWithRef } from 'react'
|
|
6
|
-
import { View, type ViewProps } from 'react-native'
|
|
7
|
-
import { HozoInheritedText } from './inherited-text.native.tsx'
|
|
8
|
-
import { HozoInheritedTextScope } from './inherited-text-scope.tsx'
|
|
9
|
-
import {
|
|
10
|
-
flattenInheritedTextStyle,
|
|
11
|
-
type InheritedNativeStyle,
|
|
12
|
-
} from './inherited-text-style.native.ts'
|
|
13
|
-
|
|
14
|
-
export interface HozoInheritedViewProps extends Omit<ComponentPropsWithRef<typeof View>, 'style'> {
|
|
15
|
-
style?: InheritedNativeStyle
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** @internal Publish owner data before removing invalid host View fields. */
|
|
19
|
-
export function HozoInheritedView({ style, children, ...props }: HozoInheritedViewProps) {
|
|
20
|
-
const own = flattenInheritedTextStyle(style)
|
|
21
|
-
const frame = useHozoInheritedTextFrame(own)
|
|
22
|
-
const rendered = { ...own }
|
|
23
|
-
for (const name of HOZO_INHERITED_TEXT_FIELDS) delete rendered[name]
|
|
24
|
-
return (
|
|
25
|
-
<HozoInheritedTextScope frame={frame}>
|
|
26
|
-
<View {...props} style={rendered as ViewProps['style']}>
|
|
27
|
-
{Children.map(children, (child) =>
|
|
28
|
-
typeof child === 'string' || typeof child === 'number' ? (
|
|
29
|
-
<HozoInheritedText>{child}</HozoInheritedText>
|
|
30
|
-
) : (
|
|
31
|
-
child
|
|
32
|
-
),
|
|
33
|
-
)}
|
|
34
|
-
</View>
|
|
35
|
-
</HozoInheritedTextScope>
|
|
36
|
-
)
|
|
37
|
-
}
|