@hozo/primitives 0.3.0 → 0.4.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.
Files changed (176) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +1 -1
  3. package/dist/button-host-attributes.d.ts +20 -0
  4. package/dist/button-host-attributes.d.ts.map +1 -0
  5. package/dist/button-host-attributes.js +47 -0
  6. package/dist/button-host-attributes.js.map +1 -0
  7. package/dist/button-host-props.native.d.ts +8 -0
  8. package/dist/button-host-props.native.d.ts.map +1 -0
  9. package/dist/button-host-props.native.js +20 -0
  10. package/dist/button-host-props.native.js.map +1 -0
  11. package/dist/foundation.d.ts +21 -3
  12. package/dist/foundation.d.ts.map +1 -1
  13. package/dist/foundation.js +41 -5
  14. package/dist/foundation.js.map +1 -1
  15. package/dist/foundation.native.d.ts +27 -7
  16. package/dist/foundation.native.d.ts.map +1 -1
  17. package/dist/foundation.native.js +18 -3
  18. package/dist/foundation.native.js.map +1 -1
  19. package/dist/generated/button-dom-props.d.ts +11 -0
  20. package/dist/generated/button-dom-props.d.ts.map +1 -0
  21. package/dist/generated/button-dom-props.js +132 -0
  22. package/dist/generated/button-dom-props.js.map +1 -0
  23. package/dist/generated/button-props.d.ts +3 -0
  24. package/dist/generated/button-props.d.ts.map +1 -0
  25. package/dist/generated/button-props.js +5 -0
  26. package/dist/generated/button-props.js.map +1 -0
  27. package/dist/generated/button-props.native.d.ts +2 -0
  28. package/dist/generated/button-props.native.d.ts.map +1 -0
  29. package/dist/generated/button-props.native.js +2 -0
  30. package/dist/generated/button-props.native.js.map +1 -0
  31. package/dist/generated/inherited-label.d.ts +2 -0
  32. package/dist/generated/inherited-label.d.ts.map +1 -0
  33. package/dist/generated/inherited-label.js +3 -0
  34. package/dist/generated/inherited-label.js.map +1 -0
  35. package/dist/generated/inherited-pressable.d.ts +2 -0
  36. package/dist/generated/inherited-pressable.d.ts.map +1 -0
  37. package/dist/generated/inherited-pressable.js +3 -0
  38. package/dist/generated/inherited-pressable.js.map +1 -0
  39. package/dist/generated/inherited-relative-text.d.ts +2 -0
  40. package/dist/generated/inherited-relative-text.d.ts.map +1 -0
  41. package/dist/generated/inherited-relative-text.js +3 -0
  42. package/dist/generated/inherited-relative-text.js.map +1 -0
  43. package/dist/generated/inherited-text.d.ts +2 -0
  44. package/dist/generated/inherited-text.d.ts.map +1 -0
  45. package/dist/generated/inherited-text.js +3 -0
  46. package/dist/generated/inherited-text.js.map +1 -0
  47. package/dist/generated/inherited-view.d.ts +2 -0
  48. package/dist/generated/inherited-view.d.ts.map +1 -0
  49. package/dist/generated/inherited-view.js +3 -0
  50. package/dist/generated/inherited-view.js.map +1 -0
  51. package/dist/generated/native-disabled.d.ts +2 -0
  52. package/dist/generated/native-disabled.d.ts.map +1 -0
  53. package/dist/generated/native-disabled.js +2 -0
  54. package/dist/generated/native-disabled.js.map +1 -0
  55. package/dist/generated/text-input-dom-props.d.ts +7 -0
  56. package/dist/generated/text-input-dom-props.d.ts.map +1 -0
  57. package/dist/generated/text-input-dom-props.js +130 -0
  58. package/dist/generated/text-input-dom-props.js.map +1 -0
  59. package/dist/generated/text-input.native.d.ts +1 -1
  60. package/dist/generated/text-input.native.d.ts.map +1 -1
  61. package/dist/generated/text-input.native.js +1 -1
  62. package/dist/generated/text-input.native.js.map +1 -1
  63. package/dist/generated/view-dom-props.d.ts +8 -0
  64. package/dist/generated/view-dom-props.d.ts.map +1 -0
  65. package/dist/generated/view-dom-props.js +241 -0
  66. package/dist/generated/view-dom-props.js.map +1 -0
  67. package/dist/inherited-label.native.d.ts +8 -0
  68. package/dist/inherited-label.native.d.ts.map +1 -0
  69. package/dist/inherited-label.native.js +12 -0
  70. package/dist/inherited-label.native.js.map +1 -0
  71. package/dist/inherited-pressable.native.d.ts +11 -0
  72. package/dist/inherited-pressable.native.d.ts.map +1 -0
  73. package/dist/inherited-pressable.native.js +75 -0
  74. package/dist/inherited-pressable.native.js.map +1 -0
  75. package/dist/inherited-relative-text.native.d.ts +13 -0
  76. package/dist/inherited-relative-text.native.d.ts.map +1 -0
  77. package/dist/inherited-relative-text.native.js +16 -0
  78. package/dist/inherited-relative-text.native.js.map +1 -0
  79. package/dist/inherited-text-scope.d.ts +8 -0
  80. package/dist/inherited-text-scope.d.ts.map +1 -0
  81. package/dist/inherited-text-scope.js +10 -0
  82. package/dist/inherited-text-scope.js.map +1 -0
  83. package/dist/inherited-text-style.native.d.ts +5 -0
  84. package/dist/inherited-text-style.native.d.ts.map +1 -0
  85. package/dist/inherited-text-style.native.js +30 -0
  86. package/dist/inherited-text-style.native.js.map +1 -0
  87. package/dist/inherited-text.native.d.ts +5 -0
  88. package/dist/inherited-text.native.d.ts.map +1 -0
  89. package/dist/inherited-text.native.js +18 -0
  90. package/dist/inherited-text.native.js.map +1 -0
  91. package/dist/inherited-view.native.d.ts +9 -0
  92. package/dist/inherited-view.native.d.ts.map +1 -0
  93. package/dist/inherited-view.native.js +17 -0
  94. package/dist/inherited-view.native.js.map +1 -0
  95. package/dist/link.d.ts +4 -3
  96. package/dist/link.d.ts.map +1 -1
  97. package/dist/link.js +9 -1
  98. package/dist/link.js.map +1 -1
  99. package/dist/link.native.d.ts +1 -1
  100. package/dist/link.native.d.ts.map +1 -1
  101. package/dist/link.native.js +7 -1
  102. package/dist/link.native.js.map +1 -1
  103. package/dist/native-disabled.d.ts +13 -0
  104. package/dist/native-disabled.d.ts.map +1 -0
  105. package/dist/native-disabled.js +13 -0
  106. package/dist/native-disabled.js.map +1 -0
  107. package/dist/presence.native.d.ts.map +1 -1
  108. package/dist/presence.native.js +1 -1
  109. package/dist/presence.native.js.map +1 -1
  110. package/dist/pressable.d.ts.map +1 -1
  111. package/dist/pressable.js +8 -1
  112. package/dist/pressable.js.map +1 -1
  113. package/dist/pressable.native.d.ts +10 -1
  114. package/dist/pressable.native.d.ts.map +1 -1
  115. package/dist/pressable.native.js +44 -45
  116. package/dist/pressable.native.js.map +1 -1
  117. package/dist/text-color-transition.native.d.ts +12 -0
  118. package/dist/text-color-transition.native.d.ts.map +1 -0
  119. package/dist/text-color-transition.native.js +87 -0
  120. package/dist/text-color-transition.native.js.map +1 -0
  121. package/dist/text-input-props.native.d.ts +10 -0
  122. package/dist/text-input-props.native.d.ts.map +1 -0
  123. package/dist/text-input-props.native.js +15 -0
  124. package/dist/text-input-props.native.js.map +1 -0
  125. package/dist/text-input.native.d.ts +19 -0
  126. package/dist/text-input.native.d.ts.map +1 -0
  127. package/dist/text-input.native.js +32 -0
  128. package/dist/text-input.native.js.map +1 -0
  129. package/package.json +51 -7
  130. package/src/button-host-attributes.ts +56 -0
  131. package/src/button-host-props.native.ts +22 -0
  132. package/src/foundation.native.tsx +45 -6
  133. package/src/foundation.tsx +74 -4
  134. package/src/generated/button-dom-props.ts +127 -0
  135. package/src/generated/button-props.native.ts +1 -0
  136. package/src/generated/button-props.ts +4 -0
  137. package/src/generated/inherited-label.ts +2 -0
  138. package/src/generated/inherited-pressable.ts +2 -0
  139. package/src/generated/inherited-relative-text.ts +2 -0
  140. package/src/generated/inherited-text.ts +2 -0
  141. package/src/generated/inherited-view.ts +2 -0
  142. package/src/generated/native-disabled.ts +1 -0
  143. package/src/generated/text-input-dom-props.ts +128 -0
  144. package/src/generated/text-input.native.ts +1 -4
  145. package/src/generated/view-dom-props.ts +267 -0
  146. package/src/inherited-label.native.tsx +28 -0
  147. package/src/inherited-pressable.native.tsx +152 -0
  148. package/src/inherited-relative-text.native.tsx +22 -0
  149. package/src/inherited-text-scope.tsx +27 -0
  150. package/src/inherited-text-style.native.ts +35 -0
  151. package/src/inherited-text.native.tsx +32 -0
  152. package/src/inherited-view.native.tsx +37 -0
  153. package/src/link.native.tsx +17 -13
  154. package/src/link.ts +12 -0
  155. package/src/native-disabled.ts +23 -0
  156. package/src/presence.native.tsx +1 -1
  157. package/src/pressable.native.tsx +70 -42
  158. package/src/pressable.ts +8 -1
  159. package/src/text-color-transition.native.ts +96 -0
  160. package/src/text-input-props.native.ts +26 -0
  161. package/src/text-input.native.tsx +57 -0
  162. package/dist/generated/animated.d.ts +0 -2
  163. package/dist/generated/animated.d.ts.map +0 -1
  164. package/dist/generated/animated.js +0 -3
  165. package/dist/generated/animated.js.map +0 -1
  166. package/dist/presence-context.d.ts +0 -15
  167. package/dist/presence-context.d.ts.map +0 -1
  168. package/dist/presence-context.js +0 -11
  169. package/dist/presence-context.js.map +0 -1
  170. package/dist/runtime-transition.native.d.ts +0 -30
  171. package/dist/runtime-transition.native.d.ts.map +0 -1
  172. package/dist/runtime-transition.native.js +0 -183
  173. package/dist/runtime-transition.native.js.map +0 -1
  174. package/src/generated/animated.ts +0 -6
  175. package/src/presence-context.ts +0 -27
  176. package/src/runtime-transition.native.tsx +0 -244
@@ -0,0 +1,87 @@
1
+ import { blendColor } from '@hozo/engine';
2
+ import { useLayoutEffect, useMemo, useRef, useState } from 'react';
3
+ import { Animated, Easing } from 'react-native';
4
+ function easingFor(name) {
5
+ switch (name) {
6
+ case 'linear':
7
+ return Easing.linear;
8
+ case 'ease-in':
9
+ return Easing.in(Easing.ease);
10
+ case 'ease-out':
11
+ return Easing.out(Easing.ease);
12
+ case 'ease-in-out':
13
+ return Easing.inOut(Easing.ease);
14
+ }
15
+ }
16
+ /**
17
+ * One colour timeline, reusable by a leaf or an inherited label owner.
18
+ * Progress is not reset when retargeting: the new interpolation starts at the
19
+ * observed position. Resetting a live value to zero would briefly send the
20
+ * previous interpolation back to its old starting colour.
21
+ */
22
+ export function useHozoTextColorTransition(target, revision, spec) {
23
+ const [progress] = useState(() => new Animated.Value(0));
24
+ const position = useRef(0);
25
+ const animation = useRef(null);
26
+ const [range, setRange] = useState(() => ({
27
+ from: target ?? '',
28
+ to: target ?? '',
29
+ target,
30
+ revision,
31
+ start: 0,
32
+ animate: false,
33
+ }));
34
+ useLayoutEffect(() => {
35
+ const listener = progress.addListener(({ value }) => {
36
+ position.current = value;
37
+ });
38
+ return () => {
39
+ progress.removeListener(listener);
40
+ animation.current?.stop();
41
+ };
42
+ }, [progress]);
43
+ useLayoutEffect(() => {
44
+ if (range.target === target && range.revision === revision)
45
+ return;
46
+ animation.current?.stop();
47
+ const start = position.current;
48
+ const fraction = Math.max(0, Math.min(1, start - range.start));
49
+ const current = range.from ? blendColor(range.from, range.to, fraction) : (target ?? '');
50
+ // Only committed inputs may replace the range. An abandoned Suspense
51
+ // render must not consume the target or mutate the visible timeline.
52
+ setRange({
53
+ from: target ? current : '',
54
+ to: target ?? '',
55
+ target,
56
+ revision,
57
+ start,
58
+ animate: Boolean(target),
59
+ });
60
+ }, [range, target, revision]);
61
+ const { duration, delay = 0, easing } = spec;
62
+ useLayoutEffect(() => {
63
+ if (!range.animate)
64
+ return;
65
+ const next = Animated.timing(progress, {
66
+ toValue: range.start + 1,
67
+ duration,
68
+ delay,
69
+ easing: easingFor(easing),
70
+ useNativeDriver: false,
71
+ });
72
+ animation.current = next;
73
+ next.start();
74
+ return () => {
75
+ next.stop();
76
+ if (animation.current === next)
77
+ animation.current = null;
78
+ };
79
+ }, [progress, range, duration, delay, easing]);
80
+ return useMemo(() => range.from
81
+ ? progress.interpolate({
82
+ inputRange: [range.start, range.start + 1],
83
+ outputRange: [range.from, range.to],
84
+ })
85
+ : undefined, [progress, range]);
86
+ }
87
+ //# sourceMappingURL=text-color-transition.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-color-transition.native.js","sourceRoot":"","sources":["../src/text-color-transition.native.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ import type { TextInputProps as RNTextInputProps } from 'react-native';
2
+ /** Canonical disabled is distinct from an editable/read-only field. */
3
+ export interface NativeTextInputProps extends RNTextInputProps {
4
+ disabled?: boolean;
5
+ className?: string;
6
+ 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling';
7
+ }
8
+ /** Shared by value-level and generated hosts; RN has no disabled input prop. */
9
+ export declare function nativeTextInputProps({ disabled, 'aria-invalid': _invalid, ...props }: NativeTextInputProps): RNTextInputProps;
10
+ //# sourceMappingURL=text-input-props.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-input-props.native.d.ts","sourceRoot":"","sources":["../src/text-input-props.native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEtE,uEAAuE;AACvE,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;CACrE;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,cAAc,EAAE,QAAQ,EACxB,GAAG,KAAK,EACT,EAAE,oBAAoB,GAAG,gBAAgB,CAWzC"}
@@ -0,0 +1,15 @@
1
+ /** Shared by value-level and generated hosts; RN has no disabled input prop. */
2
+ export function nativeTextInputProps({ disabled, 'aria-invalid': _invalid, ...props }) {
3
+ if (!disabled)
4
+ return props;
5
+ // Both RN spellings must prevent editing even if the caller authored
6
+ // readOnly=false. Do not turn ordinary read-only fields into disabled ones.
7
+ return {
8
+ ...props,
9
+ editable: false,
10
+ readOnly: true,
11
+ accessibilityState: { ...props.accessibilityState, disabled: true },
12
+ 'aria-disabled': true,
13
+ };
14
+ }
15
+ //# sourceMappingURL=text-input-props.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-input-props.native.js","sourceRoot":"","sources":["../src/text-input-props.native.ts"],"names":[],"mappings":"AASA,gFAAgF;AAChF,MAAM,UAAU,oBAAoB,CAAC,EACnC,QAAQ,EACR,cAAc,EAAE,QAAQ,EACxB,GAAG,KAAK,EACa;IACrB,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3B,qEAAqE;IACrE,4EAA4E;IAC5E,OAAO;QACL,GAAG,KAAK;QACR,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,IAAI;QACd,kBAAkB,EAAE,EAAE,GAAG,KAAK,CAAC,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnE,eAAe,EAAE,IAAI;KACtB,CAAA;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type HozoPressableInteractionState } from '@hozo/behaviors/pressable-interaction';
2
+ import type { ComponentRef, Ref } from 'react';
3
+ import { TextInput, type TextInputProps } from 'react-native';
4
+ import { type NativeTextInputProps } from './text-input-props.native.ts';
5
+ export interface HozoTextInputProps extends NativeTextInputProps {
6
+ ref?: Ref<ComponentRef<typeof TextInput>>;
7
+ /** Compiler-only style evaluation on this input, not an ancestor Pressable. */
8
+ hozoStyle?: (state: HozoPressableInteractionState) => TextInputProps['style'];
9
+ }
10
+ /**
11
+ * Generated-code host when static or dynamic classes need input focus. Ordinary
12
+ * compiled inputs stay RN TextInput. No extra box, context, animation or
13
+ * subscriptions; the same native field keeps its ref, events and semantics.
14
+ *
15
+ * A keyboard-input field indicates focus even after a pointer/touch focuses
16
+ * it (Selectors 4 §9.4). A button's pointer modality is not its policy.
17
+ */
18
+ export declare function HozoTextInput(props: HozoTextInputProps): import("react").JSX.Element;
19
+ //# sourceMappingURL=text-input.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-input.native.d.ts","sourceRoot":"","sources":["../src/text-input.native.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uCAAuC,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,KAAK,oBAAoB,EAAwB,MAAM,8BAA8B,CAAA;AAE9F,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,SAAS,CAAC,CAAC,CAAA;IACzC,+EAA+E;IAC/E,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,6BAA6B,KAAK,cAAc,CAAC,OAAO,CAAC,CAAA;CAC9E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAQtD"}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { usePressableInteraction, } from '@hozo/behaviors/pressable-interaction';
3
+ import { TextInput } from 'react-native';
4
+ import { nativeTextInputProps } from './text-input-props.native.js';
5
+ /**
6
+ * Generated-code host when static or dynamic classes need input focus. Ordinary
7
+ * compiled inputs stay RN TextInput. No extra box, context, animation or
8
+ * subscriptions; the same native field keeps its ref, events and semantics.
9
+ *
10
+ * A keyboard-input field indicates focus even after a pointer/touch focuses
11
+ * it (Selectors 4 §9.4). A button's pointer modality is not its policy.
12
+ */
13
+ export function HozoTextInput(props) {
14
+ // A prop-only adapter needs no state subscription. The focus child exists
15
+ // only for a compiler callback and still renders exactly one RN field.
16
+ if (!props.hozoStyle) {
17
+ const { hozoStyle: _hozoStyle, ref, ...hostProps } = props;
18
+ return _jsx(TextInput, { ...nativeTextInputProps(hostProps), ref: ref });
19
+ }
20
+ return _jsx(FocusedTextInput, { ...props });
21
+ }
22
+ function FocusedTextInput({ ref, hozoStyle, style, onFocus, onBlur, ...props }) {
23
+ const { state, handlers } = usePressableInteraction({ focusVisible: 'keyboard-input' });
24
+ return (_jsx(TextInput, { ...nativeTextInputProps(props), ref: ref, style: [hozoStyle?.(state), style], onFocus: (event) => {
25
+ handlers.focus();
26
+ onFocus?.(event);
27
+ }, onBlur: (event) => {
28
+ handlers.blur();
29
+ onBlur?.(event);
30
+ } }));
31
+ }
32
+ //# sourceMappingURL=text-input.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-input.native.js","sourceRoot":"","sources":["../src/text-input.native.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,uBAAuB,GACxB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAA;AAC7D,OAAO,EAA6B,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAQ9F;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,0EAA0E;IAC1E,uEAAuE;IACvE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACrB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;QAC1D,OAAO,KAAC,SAAS,OAAK,oBAAoB,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,GAAI,CAAA;IACrE,CAAC;IACD,OAAO,KAAC,gBAAgB,OAAK,KAAK,GAAI,CAAA;AACxC,CAAC;AAED,SAAS,gBAAgB,CAAC,EACxB,GAAG,EACH,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACW;IACnB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,uBAAuB,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,CAAA;IACvF,OAAO,CACL,KAAC,SAAS,OACJ,oBAAoB,CAAC,KAAK,CAAC,EAC/B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAClC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,QAAQ,CAAC,KAAK,EAAE,CAAA;YAChB,OAAO,EAAE,CAAC,KAAK,CAAC,CAAA;QAClB,CAAC,EACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,QAAQ,CAAC,IAAI,EAAE,CAAA;YACf,MAAM,EAAE,CAAC,KAAK,CAAC,CAAA;QACjB,CAAC,GACD,CACH,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hozo/primitives",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Canonical universal UI primitives for Hozo applications.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -32,14 +32,26 @@
32
32
  "types": "./dist/index.d.ts",
33
33
  "default": "./dist/index.js"
34
34
  },
35
- "./generated/animated": {
36
- "types": "./dist/generated/animated.d.ts",
37
- "default": "./dist/generated/animated.js"
35
+ "./windowing": {
36
+ "types": "./dist/windowing.d.ts",
37
+ "default": "./dist/windowing.js"
38
38
  },
39
39
  "./generated/backdrop-filter": {
40
40
  "types": "./dist/generated/backdrop-filter.d.ts",
41
41
  "default": "./dist/generated/backdrop-filter.js"
42
42
  },
43
+ "./generated/button-dom-props": {
44
+ "types": "./dist/generated/button-dom-props.d.ts",
45
+ "default": "./dist/generated/button-dom-props.js"
46
+ },
47
+ "./generated/button-props": {
48
+ "react-native": {
49
+ "types": "./dist/generated/button-props.native.d.ts",
50
+ "default": "./dist/generated/button-props.native.js"
51
+ },
52
+ "types": "./dist/generated/button-props.d.ts",
53
+ "default": "./dist/generated/button-props.js"
54
+ },
43
55
  "./generated/container": {
44
56
  "types": "./dist/generated/container.d.ts",
45
57
  "default": "./dist/generated/container.js"
@@ -56,6 +68,26 @@
56
68
  "types": "./dist/generated/grid.d.ts",
57
69
  "default": "./dist/generated/grid.js"
58
70
  },
71
+ "./generated/inherited-label": {
72
+ "types": "./dist/generated/inherited-label.d.ts",
73
+ "default": "./dist/generated/inherited-label.js"
74
+ },
75
+ "./generated/inherited-pressable": {
76
+ "types": "./dist/generated/inherited-pressable.d.ts",
77
+ "default": "./dist/generated/inherited-pressable.js"
78
+ },
79
+ "./generated/inherited-relative-text": {
80
+ "types": "./dist/generated/inherited-relative-text.d.ts",
81
+ "default": "./dist/generated/inherited-relative-text.js"
82
+ },
83
+ "./generated/inherited-text": {
84
+ "types": "./dist/generated/inherited-text.d.ts",
85
+ "default": "./dist/generated/inherited-text.js"
86
+ },
87
+ "./generated/inherited-view": {
88
+ "types": "./dist/generated/inherited-view.d.ts",
89
+ "default": "./dist/generated/inherited-view.js"
90
+ },
59
91
  "./generated/link": {
60
92
  "react-native": {
61
93
  "types": "./dist/generated/link.native.d.ts",
@@ -64,6 +96,10 @@
64
96
  "types": "./dist/generated/link.d.ts",
65
97
  "default": "./dist/generated/link.js"
66
98
  },
99
+ "./generated/native-disabled": {
100
+ "types": "./dist/generated/native-disabled.d.ts",
101
+ "default": "./dist/generated/native-disabled.js"
102
+ },
67
103
  "./generated/pressable": {
68
104
  "react-native": {
69
105
  "types": "./dist/generated/pressable.native.d.ts",
@@ -104,6 +140,10 @@
104
140
  "types": "./dist/generated/text-input.d.ts",
105
141
  "default": "./dist/generated/text-input.js"
106
142
  },
143
+ "./generated/text-input-dom-props": {
144
+ "types": "./dist/generated/text-input-dom-props.d.ts",
145
+ "default": "./dist/generated/text-input-dom-props.js"
146
+ },
107
147
  "./generated/text-size": {
108
148
  "types": "./dist/generated/text-size.d.ts",
109
149
  "default": "./dist/generated/text-size.js"
@@ -116,6 +156,10 @@
116
156
  "types": "./dist/generated/view.d.ts",
117
157
  "default": "./dist/generated/view.js"
118
158
  },
159
+ "./generated/view-dom-props": {
160
+ "types": "./dist/generated/view-dom-props.d.ts",
161
+ "default": "./dist/generated/view-dom-props.js"
162
+ },
119
163
  "./package.json": "./package.json"
120
164
  },
121
165
  "files": [
@@ -131,12 +175,12 @@
131
175
  "provenance": true
132
176
  },
133
177
  "dependencies": {
134
- "@hozo/behaviors": "^0.3.0",
135
- "@hozo/engine": "^0.3.0"
178
+ "@hozo/behaviors": "^0.4.0",
179
+ "@hozo/engine": "^0.4.0"
136
180
  },
137
181
  "peerDependencies": {
138
182
  "react": "^19.0.0",
139
- "react-native": ">=0.86"
183
+ "react-native": ">=0.87"
140
184
  },
141
185
  "peerDependenciesMeta": {
142
186
  "react-native": {
@@ -0,0 +1,56 @@
1
+ /** The documented DOM metadata channel; never forward arbitrary leftover props. */
2
+ export interface ButtonDataProps {
3
+ [name: `data-${string}`]: string | number | boolean | undefined
4
+ }
5
+
6
+ export function buttonDataProps(props: ButtonDataProps): ButtonDataProps {
7
+ const data: ButtonDataProps = {}
8
+ for (const name in props) {
9
+ if (Object.hasOwn(props, name) && name.startsWith('data-')) {
10
+ data[name as `data-${string}`] = props[name as `data-${string}`]
11
+ }
12
+ }
13
+ return data
14
+ }
15
+
16
+ /**
17
+ * What a wrapper hands a Button to make it a trigger, by platform.
18
+ *
19
+ * `Tooltip` clones its child with a ref to position against, the handlers
20
+ * that open it, and -- on the Web -- `aria-describedby` naming the bubble.
21
+ * A Button that dropped them was a trigger nothing could hear (#1137).
22
+ * `Toolbar` hands its items a roving `tabIndex` on the Web, and a Button
23
+ * that dropped it left every item a tab stop of its own.
24
+ * Still a list rather than "every leftover prop": the rule above stands,
25
+ * and these are the ones a known wrapper writes.
26
+ */
27
+ export const BUTTON_TRIGGER_PROPS_WEB = [
28
+ 'ref',
29
+ 'onFocus',
30
+ 'onBlur',
31
+ 'onKeyDown',
32
+ 'onPointerEnter',
33
+ 'onPointerLeave',
34
+ 'aria-describedby',
35
+ 'tabIndex',
36
+ ] as const
37
+
38
+ export const BUTTON_TRIGGER_PROPS_NATIVE = [
39
+ 'ref',
40
+ 'onFocus',
41
+ 'onBlur',
42
+ 'onHoverIn',
43
+ 'onHoverOut',
44
+ 'onLongPress',
45
+ ] as const
46
+
47
+ export function buttonTriggerProps(
48
+ props: Record<string, unknown>,
49
+ names: readonly string[],
50
+ ): Record<string, unknown> {
51
+ const out: Record<string, unknown> = {}
52
+ for (const name of names) {
53
+ if (Object.hasOwn(props, name)) out[name] = props[name]
54
+ }
55
+ return out
56
+ }
@@ -0,0 +1,22 @@
1
+ let warned = false
2
+
3
+ /**
4
+ * Preserve evaluation/identity of authored props, but name the platform
5
+ * boundary: RN has no DOM dataset. Metadata is not an accessibility label
6
+ * or nativeID. Do not fabricate either from an application's data channel.
7
+ * The compiler uses this for opaque spreads; the fallback uses it too.
8
+ */
9
+ export function hozoButtonProps<T>(props: T): T {
10
+ if (!warned && props !== null && typeof props === 'object') {
11
+ for (const name in props) {
12
+ if (Object.hasOwn(props, name) && name.startsWith('data-')) {
13
+ warned = true
14
+ console.warn(
15
+ '[hozo] Button data-* metadata requires a Web DOM dataset; React Native does not consume it. nativeID remains available on both platforms. No data values are mapped to accessibility props.',
16
+ )
17
+ break
18
+ }
19
+ }
20
+ }
21
+ return props
22
+ }
@@ -1,19 +1,28 @@
1
1
  import { hozoTextChildren } from '@hozo/behaviors'
2
2
  import { HozoTextSizeContext } from '@hozo/engine'
3
- import React, { type ComponentType, type ReactNode, type Ref } from 'react'
3
+ import React, { type ComponentRef, type ComponentType, type ReactNode, type Ref } from 'react'
4
4
  import {
5
5
  type AccessibilityRole,
6
- type HostInstance,
7
6
  Pressable as RNPressable,
8
7
  type PressableProps as RNPressableProps,
9
8
  Text as RNText,
9
+ TextInput as RNTextInput,
10
10
  type TextProps as RNTextProps,
11
11
  type StyleProp,
12
12
  StyleSheet,
13
13
  type TextStyle,
14
14
  type ViewStyle,
15
15
  } from 'react-native'
16
+ import {
17
+ BUTTON_TRIGGER_PROPS_NATIVE,
18
+ type ButtonDataProps,
19
+ buttonDataProps,
20
+ buttonTriggerProps,
21
+ } from './button-host-attributes.ts'
22
+ import { hozoButtonProps } from './button-host-props.native.ts'
16
23
  import { HozoLink } from './link.native.tsx'
24
+ import { nativeDisabledProps } from './native-disabled.ts'
25
+ import { type NativeTextInputProps, nativeTextInputProps } from './text-input-props.native.ts'
17
26
 
18
27
  export type {
19
28
  HozoResponderEvent,
@@ -24,10 +33,15 @@ export type {
24
33
  } from '@hozo/engine'
25
34
  export type {
26
35
  ImageProps,
27
- TextInputProps,
28
36
  ViewProps,
29
37
  } from 'react-native'
30
- export { Image, TextInput, View } from 'react-native'
38
+ export { Image, View } from 'react-native'
39
+ export type TextInputProps = NativeTextInputProps & { ref?: Ref<ComponentRef<typeof RNTextInput>> }
40
+
41
+ /** The canonical disabled contract also applies outside compiler-owned JSX. */
42
+ export function TextInput({ ref, ...props }: TextInputProps) {
43
+ return <RNTextInput {...nativeTextInputProps(props)} ref={ref} />
44
+ }
31
45
  export type {
32
46
  HozoImageSource,
33
47
  HozoImageSourceObject,
@@ -60,7 +74,11 @@ export interface PressableProps extends RNPressableProps {
60
74
  * A caller needs it to hand the control to something else: `Dialog`'s
61
75
  * `restoreFocusTo` is where this came up (#462).
62
76
  */
63
- ref?: Ref<HostInstance>
77
+ // Derived from the installed peer's Pressable rather than spelled out:
78
+ // its ref type has changed between minors (0.86 a View instance, later a
79
+ // HostInstance), and this stays exactly what that Pressable accepts (and
80
+ // Dialog can restore).
81
+ ref?: Ref<ComponentRef<typeof RNPressable>>
64
82
  href?: string
65
83
  external?: boolean
66
84
  replace?: boolean
@@ -80,6 +98,7 @@ export function Pressable({
80
98
  download: _download,
81
99
  ...props
82
100
  }: PressableProps) {
101
+ props = nativeDisabledProps(props)
83
102
  if (href === undefined) return <RNPressable {...props} />
84
103
 
85
104
  const Link = HozoLink as unknown as ComponentType<
@@ -99,6 +118,7 @@ export interface LinkProps {
99
118
  rel?: string
100
119
  download?: boolean | string
101
120
  onPress?: (event: { defaultPrevented?: boolean }) => void
121
+ disabled?: boolean
102
122
  style?: StyleProp<TextStyle>
103
123
  testID?: string
104
124
  nativeID?: string
@@ -128,7 +148,7 @@ export function Link({
128
148
  )
129
149
  }
130
150
 
131
- export interface ButtonProps {
151
+ export interface ButtonProps extends ButtonDataProps {
132
152
  className?: string
133
153
  children?: ReactNode
134
154
  onPress?: RNPressableProps['onPress']
@@ -144,6 +164,18 @@ export interface ButtonProps {
144
164
  download?: boolean | string
145
165
  style?: StyleProp<ViewStyle>
146
166
  testID?: string
167
+ nativeID?: string
168
+ /**
169
+ * What a wrapper writes to make this a trigger -- `Tooltip` measures the
170
+ * ref and opens on hover or a long press (#1137). Forwarded to the
171
+ * Pressable as given.
172
+ */
173
+ ref?: Ref<ComponentRef<typeof RNPressable>>
174
+ onFocus?: RNPressableProps['onFocus']
175
+ onBlur?: RNPressableProps['onBlur']
176
+ onHoverIn?: RNPressableProps['onHoverIn']
177
+ onHoverOut?: RNPressableProps['onHoverOut']
178
+ onLongPress?: RNPressableProps['onLongPress']
147
179
  }
148
180
 
149
181
  export type ButtonNativeProps = ButtonProps
@@ -160,14 +192,19 @@ export function Button({
160
192
  prefetch,
161
193
  style,
162
194
  testID,
195
+ nativeID,
196
+ ...metadata
163
197
  }: ButtonProps) {
164
198
  const shared = {
199
+ ...hozoButtonProps(buttonDataProps(metadata)),
200
+ ...buttonTriggerProps(metadata, BUTTON_TRIGGER_PROPS_NATIVE),
165
201
  disabled,
166
202
  accessibilityLabel,
167
203
  accessibilityHint,
168
204
  accessibilityState: disabled === undefined ? undefined : { disabled },
169
205
  style,
170
206
  testID,
207
+ nativeID,
171
208
  }
172
209
  if (href !== undefined) {
173
210
  const NativeLink = HozoLink as unknown as ComponentType<
@@ -192,3 +229,5 @@ export function Button({
192
229
  </RNPressable>
193
230
  )
194
231
  }
232
+ // A label a pressable can hand its text styles to (#876); see `hozoTextStyle`.
233
+ ;(Text as { hozoLabelText?: boolean }).hozoLabelText = true
@@ -14,7 +14,10 @@ import {
14
14
  import {
15
15
  type AriaRole,
16
16
  type CSSProperties,
17
+ type FocusEventHandler,
18
+ type KeyboardEventHandler,
17
19
  type MouseEventHandler,
20
+ type PointerEventHandler,
18
21
  type ReactNode,
19
22
  type Ref,
20
23
  useCallback,
@@ -22,6 +25,12 @@ import {
22
25
  useRef,
23
26
  useState,
24
27
  } from 'react'
28
+ import {
29
+ BUTTON_TRIGGER_PROPS_WEB,
30
+ type ButtonDataProps,
31
+ buttonDataProps,
32
+ buttonTriggerProps,
33
+ } from './button-host-attributes.ts'
25
34
  import { HozoLink } from './link.ts'
26
35
  import { HozoPressable, type HozoPressableProps } from './pressable.ts'
27
36
  import { HozoTextInput, type HozoTextInputProps } from './text-input.ts'
@@ -241,11 +250,44 @@ export function Image({
241
250
  }: ImageProps) {
242
251
  const { setRef } = useLayoutRef<HTMLImageElement>(onLayout, ref)
243
252
  const [failedSource, setFailedSource] = useState<HozoImageSource>()
244
- const webSrc =
245
- (failedSource === src ? undefined : webImageSource(src)) ?? webImageSource(defaultSource)
253
+ const primary = webImageSource(src)
254
+ const fallback = webImageSource(defaultSource)
255
+ const webSrc = (failedSource === src ? undefined : primary) ?? fallback
256
+ // A server-rendered `<img>` starts loading before React hydrates, so its
257
+ // `error` event may already have fired when `onError` is attached (#1156).
258
+ // `complete && naturalWidth === 0` spots that, and `decode()` separates a
259
+ // broken load from a widthless SVG that some browsers report as 0px wide.
260
+ // The caller's `onError` is not synthesized here because the native error
261
+ // event has already come and gone before hydration.
262
+ const stateRef = useRef({ src, primary, fallback, failedSource })
263
+ stateRef.current = { src, primary, fallback, failedSource }
264
+ const imageRef = useCallback(
265
+ (node: HTMLImageElement | null) => {
266
+ setRef(node)
267
+ const current = stateRef.current
268
+ if (
269
+ node &&
270
+ current.primary &&
271
+ current.fallback &&
272
+ current.failedSource !== current.src &&
273
+ node.complete &&
274
+ node.naturalWidth === 0
275
+ ) {
276
+ const failed = current.src
277
+ if (typeof node.decode === 'function') {
278
+ node.decode().then(undefined, () => {
279
+ if (stateRef.current.src === failed) setFailedSource(failed)
280
+ })
281
+ } else {
282
+ setFailedSource(failed)
283
+ }
284
+ }
285
+ },
286
+ [setRef],
287
+ )
246
288
  return (
247
289
  <img
248
- ref={setRef}
290
+ ref={imageRef}
249
291
  className={className}
250
292
  src={webSrc}
251
293
  alt={alt ?? accessibilityLabel ?? ''}
@@ -283,13 +325,14 @@ export interface LinkProps {
283
325
  replace?: boolean
284
326
  prefetch?: boolean
285
327
  onPress?: MouseEventHandler<HTMLAnchorElement>
328
+ disabled?: boolean
286
329
  }
287
330
 
288
331
  export function Link({ children, ...props }: LinkProps) {
289
332
  return <HozoLink {...props}>{children}</HozoLink>
290
333
  }
291
334
 
292
- export interface ButtonProps {
335
+ export interface ButtonProps extends ButtonDataProps {
293
336
  className?: string
294
337
  children?: ReactNode
295
338
  onPress?: MouseEventHandler<HTMLElement>
@@ -304,6 +347,22 @@ export interface ButtonProps {
304
347
  rel?: string
305
348
  download?: boolean | string
306
349
  testID?: string
350
+ /** Stable host ID: DOM id on Web, nativeID on React Native. */
351
+ nativeID?: string
352
+ /**
353
+ * What a wrapper writes to make this a trigger -- `Tooltip` positions
354
+ * against the ref, opens on these handlers, and names its bubble with
355
+ * `aria-describedby` (#1137). Forwarded to the element as given.
356
+ */
357
+ ref?: Ref<HTMLElement>
358
+ onFocus?: FocusEventHandler<HTMLElement>
359
+ onBlur?: FocusEventHandler<HTMLElement>
360
+ onKeyDown?: KeyboardEventHandler<HTMLElement>
361
+ onPointerEnter?: PointerEventHandler<HTMLElement>
362
+ onPointerLeave?: PointerEventHandler<HTMLElement>
363
+ 'aria-describedby'?: string
364
+ /** A roving tab stop, as `Toolbar` hands its items. */
365
+ tabIndex?: number
307
366
  }
308
367
 
309
368
  export function Button({
@@ -321,10 +380,17 @@ export function Button({
321
380
  rel,
322
381
  download,
323
382
  testID,
383
+ nativeID,
384
+ ...metadata
324
385
  }: ButtonProps) {
386
+ const data = {
387
+ ...buttonDataProps(metadata),
388
+ ...buttonTriggerProps(metadata, BUTTON_TRIGGER_PROPS_WEB),
389
+ }
325
390
  if (href != null) {
326
391
  return (
327
392
  <HozoLink
393
+ {...data}
328
394
  href={href}
329
395
  external={external}
330
396
  replace={replace}
@@ -337,6 +403,7 @@ export function Button({
337
403
  accessibilityHint={accessibilityHint}
338
404
  disabled={disabled}
339
405
  testID={testID}
406
+ nativeID={nativeID}
340
407
  onPress={onPress as MouseEventHandler<HTMLAnchorElement>}
341
408
  >
342
409
  {children}
@@ -347,14 +414,17 @@ export function Button({
347
414
  <>
348
415
  {hozoViewBase()}
349
416
  <button
417
+ {...data}
350
418
  type="button"
351
419
  className={className}
352
420
  disabled={disabled}
353
421
  data-hozo-disabled={disabled ? '' : undefined}
422
+ aria-disabled={disabled}
354
423
  data-hozo-pressable={onPress && !disabled ? '' : undefined}
355
424
  aria-label={accessibilityLabel}
356
425
  aria-description={accessibilityHint}
357
426
  data-testid={testID}
427
+ id={nativeID}
358
428
  onClick={onPress as MouseEventHandler<HTMLButtonElement>}
359
429
  >
360
430
  {children}