@hozo/primitives 0.1.0 → 0.3.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 (76) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +24 -2
  3. package/dist/flat-list.native.d.ts +8 -8
  4. package/dist/flat-list.native.d.ts.map +1 -1
  5. package/dist/flat-list.native.js +55 -25
  6. package/dist/flat-list.native.js.map +1 -1
  7. package/dist/foundation.d.ts +7 -4
  8. package/dist/foundation.d.ts.map +1 -1
  9. package/dist/foundation.js +33 -16
  10. package/dist/foundation.js.map +1 -1
  11. package/dist/foundation.native.d.ts +16 -2
  12. package/dist/foundation.native.d.ts.map +1 -1
  13. package/dist/foundation.native.js.map +1 -1
  14. package/dist/index.d.ts +6 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +7 -9
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.native.d.ts +1 -0
  19. package/dist/index.native.d.ts.map +1 -1
  20. package/dist/index.native.js +1 -0
  21. package/dist/index.native.js.map +1 -1
  22. package/dist/link.native.d.ts +16 -7
  23. package/dist/link.native.d.ts.map +1 -1
  24. package/dist/link.native.js +9 -5
  25. package/dist/link.native.js.map +1 -1
  26. package/dist/presence-context.d.ts +15 -0
  27. package/dist/presence-context.d.ts.map +1 -0
  28. package/dist/presence-context.js +11 -0
  29. package/dist/presence-context.js.map +1 -0
  30. package/dist/presence.d.ts +12 -0
  31. package/dist/presence.d.ts.map +1 -0
  32. package/dist/presence.js +45 -0
  33. package/dist/presence.js.map +1 -0
  34. package/dist/presence.native.d.ts +8 -0
  35. package/dist/presence.native.d.ts.map +1 -0
  36. package/dist/presence.native.js +66 -0
  37. package/dist/presence.native.js.map +1 -0
  38. package/dist/pressable.d.ts +9 -2
  39. package/dist/pressable.d.ts.map +1 -1
  40. package/dist/pressable.js +9 -6
  41. package/dist/pressable.js.map +1 -1
  42. package/dist/pressable.native.d.ts.map +1 -1
  43. package/dist/pressable.native.js +181 -195
  44. package/dist/pressable.native.js.map +1 -1
  45. package/dist/runtime-container.native.d.ts +11 -9
  46. package/dist/runtime-container.native.d.ts.map +1 -1
  47. package/dist/runtime-container.native.js +8 -6
  48. package/dist/runtime-container.native.js.map +1 -1
  49. package/dist/runtime-transition.native.d.ts +16 -1
  50. package/dist/runtime-transition.native.d.ts.map +1 -1
  51. package/dist/runtime-transition.native.js +34 -7
  52. package/dist/runtime-transition.native.js.map +1 -1
  53. package/dist/text-input.d.ts +319 -3
  54. package/dist/text-input.d.ts.map +1 -1
  55. package/dist/text-input.js +4 -3
  56. package/dist/text-input.js.map +1 -1
  57. package/dist/view.d.ts +11 -2
  58. package/dist/view.d.ts.map +1 -1
  59. package/dist/view.js +7 -6
  60. package/dist/view.js.map +1 -1
  61. package/package.json +4 -3
  62. package/src/flat-list.native.tsx +69 -47
  63. package/src/foundation.native.tsx +16 -1
  64. package/src/foundation.tsx +66 -25
  65. package/src/index.native.ts +2 -0
  66. package/src/index.ts +209 -219
  67. package/src/link.native.tsx +29 -18
  68. package/src/presence-context.ts +27 -0
  69. package/src/presence.native.tsx +81 -0
  70. package/src/presence.tsx +55 -0
  71. package/src/pressable.native.tsx +251 -243
  72. package/src/pressable.ts +92 -79
  73. package/src/runtime-container.native.tsx +30 -15
  74. package/src/runtime-transition.native.tsx +68 -7
  75. package/src/text-input.ts +74 -72
  76. package/src/view.ts +76 -61
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAA;AAEd,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE;QAAE,MAAM,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,K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C;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAChF,uBAAuB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAA;IACzD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B;;;;;;;OAOG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;CAC1B;AAOD,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,EACvB,GAAG,EAAE,YAAY,EACjB,QAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,QAAQ,EACR,WAAW,EAAE,YAAY,EACzB,IAAI,EACJ,eAAe,EAAE,YAAY,EAC7B,oBAAoB,EAAE,gBAAgB,EACtC,yBAAyB,EACzB,gCAAgC,EAChC,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,6BAA6B,EAC7B,GAAG,KAAK,EACT,EAAE,aAAa,2EAqFf"}
package/dist/view.js CHANGED
@@ -1,5 +1,5 @@
1
- import { hozoDomStyle, useResponderDomProps, } from '@hozo/engine';
2
- import { createElement, forwardRef, useCallback, useEffect, useRef, } from 'react';
1
+ import { hozoDomStyle, hozoViewBase, hozoViewClassName, useResponderDomProps, } from '@hozo/engine';
2
+ import { createElement, Fragment, useCallback, useEffect, useRef, } from 'react';
3
3
  function assignRef(ref, value) {
4
4
  if (typeof ref === 'function')
5
5
  ref(value);
@@ -7,7 +7,7 @@ function assignRef(ref, value) {
7
7
  ref.current = value;
8
8
  }
9
9
  /** A measured/responder-aware View for the Web paths that cannot be a plain div. */
10
- export const HozoView = forwardRef(function HozoView({ children, style, testID, nativeID, pointerEvents, accessibilityLabel, accessibilityHint, accessibilityRole, accessibilityState, accessibilityValue, accessibilityLiveRegion, onLayout, collapsable: _collapsable, role, 'aria-disabled': ariaDisabled, 'data-hozo-disabled': dataHozoDisabled, onStartShouldSetResponder, onStartShouldSetResponderCapture, onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onResponderGrant, onResponderStart, onResponderMove, onResponderEnd, onResponderRelease, onResponderReject, onResponderTerminate, onResponderTerminationRequest, ...props }, forwardedRef) {
10
+ export function HozoView({ ref: forwardedRef, children, style, testID, nativeID, pointerEvents, accessibilityLabel, accessibilityHint, accessibilityRole, accessibilityState, accessibilityValue, accessibilityLiveRegion, onLayout, collapsable: _collapsable, role, 'aria-disabled': ariaDisabled, 'data-hozo-disabled': dataHozoDisabled, onStartShouldSetResponder, onStartShouldSetResponderCapture, onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onResponderGrant, onResponderStart, onResponderMove, onResponderEnd, onResponderRelease, onResponderReject, onResponderTerminate, onResponderTerminationRequest, ...props }) {
11
11
  const elementRef = useRef(null);
12
12
  const layoutCallback = useRef(onLayout);
13
13
  layoutCallback.current = onLayout;
@@ -57,8 +57,9 @@ export const HozoView = forwardRef(function HozoView({ children, style, testID,
57
57
  }, []);
58
58
  const state = accessibilityState;
59
59
  const value = accessibilityValue;
60
- return createElement('div', {
60
+ return createElement(Fragment, null, hozoViewBase(), createElement('div', {
61
61
  ...props,
62
+ className: hozoViewClassName(props.className),
62
63
  ...responder,
63
64
  ref: setRef,
64
65
  role: accessibilityRole ?? role,
@@ -79,6 +80,6 @@ export const HozoView = forwardRef(function HozoView({ children, style, testID,
79
80
  'aria-live': accessibilityLiveRegion === 'none' ? undefined : accessibilityLiveRegion,
80
81
  'aria-label': accessibilityLabel,
81
82
  'aria-description': accessibilityHint,
82
- }, children);
83
- });
83
+ }, children));
84
+ }
84
85
  //# sourceMappingURL=view.js.map
package/dist/view.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"view.js","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAEZ,oBAAoB,GACrB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,aAAa,EACb,UAAU,EAIV,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAA;AA+Bd,SAAS,SAAS,CAAI,GAAuB,EAAE,KAAe;IAC5D,IAAI,OAAO,GAAG,KAAK,UAAU;QAAE,GAAG,CAAC,KAAK,CAAC,CAAA;SACpC,IAAI,GAAG;QAAE,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;AACnC,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAgC,SAAS,QAAQ,CACjF,EACE,QAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,QAAQ,EACR,WAAW,EAAE,YAAY,EACzB,IAAI,EACJ,eAAe,EAAE,YAAY,EAC7B,oBAAoB,EAAE,gBAAgB,EACtC,yBAAyB,EACzB,gCAAgC,EAChC,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,6BAA6B,EAC7B,GAAG,KAAK,EACT,EACD,YAAY;IAEZ,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAC/C,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACvC,cAAc,CAAC,OAAO,GAAG,QAAQ,CAAA;IACjC,MAAM,MAAM,GAAG,WAAW,CACxB,CAAC,OAA8B,EAAE,EAAE;QACjC,UAAU,CAAC,OAAO,GAAG,OAAO,CAA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": "0.3.0",
4
4
  "description": "Canonical universal UI primitives for Hozo applications.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -119,6 +119,7 @@
119
119
  "./package.json": "./package.json"
120
120
  },
121
121
  "files": [
122
+ "CHANGELOG.md",
122
123
  "dist",
123
124
  "src",
124
125
  "!src/**/*.test.ts",
@@ -130,8 +131,8 @@
130
131
  "provenance": true
131
132
  },
132
133
  "dependencies": {
133
- "@hozo/behaviors": "^0.1.0",
134
- "@hozo/engine": "^0.1.0"
134
+ "@hozo/behaviors": "^0.3.0",
135
+ "@hozo/engine": "^0.3.0"
135
136
  },
136
137
  "peerDependencies": {
137
138
  "react": "^19.0.0",
@@ -1,4 +1,4 @@
1
- import { createElement, forwardRef, type ReactElement, type Ref, useMemo } from 'react'
1
+ import { createElement, type ReactElement, type Ref, useMemo } from 'react'
2
2
  import * as ReactNative from 'react-native'
3
3
 
4
4
  // Its own module rather than part of the index, because the index starts
@@ -10,27 +10,24 @@ export type HozoFlatListProps<T> = ReactNative.FlatListProps<T>
10
10
  export type HozoFlatListHandle<T = unknown> = ReactNative.FlatList<T>
11
11
 
12
12
  /**
13
- * What Android's accessibility framework calls a collection.
13
+ * Where a cell sits in the collection Android thinks it is in.
14
14
  *
15
- * `AccessibilityNodeInfo.setCollectionInfo`, which is how TalkBack knows a
16
- * scrolling view is a list of a certain length rather than a box with
17
- * things in it.
15
+ * `AccessibilityNodeInfo.setCollectionItemInfo`, read by
16
+ * `ReactAccessibilityDelegate.kt:107`.
18
17
  *
19
18
  * Typed here because React Native does not type it. The props are real --
20
19
  * `BaseViewConfig.android.js` registers `accessibilityCollection` and
21
- * `accessibilityCollectionItem` as native props, `BaseViewManager` stores
22
- * them as tags, and `ReactScrollViewAccessibilityDelegate` reads them back
23
- * and even works out which children are on screen -- but they appear in no
24
- * `.d.ts` and in no documentation, so nothing that does not go looking for
25
- * them will find them.
20
+ * `accessibilityCollectionItem` as native props and `BaseViewManager`
21
+ * stores them as tags -- but they appear in no `.d.ts` and in no
22
+ * documentation, so nothing that does not go looking for them will find
23
+ * them. The tracking issue for the capability, facebook/react-native#30977,
24
+ * is closed: the native half shipped and no React Native component was ever
25
+ * wired to it.
26
+ *
27
+ * `AndroidCollection`, the list-level counterpart, was here too. It is gone
28
+ * with the prop that used it; see the note in `HozoFlatList` for what it
29
+ * held and why.
26
30
  */
27
- interface AndroidCollection {
28
- itemCount: number
29
- rowCount: number
30
- columnCount: number
31
- hierarchical: boolean
32
- }
33
-
34
31
  interface AndroidCollectionItem {
35
32
  rowIndex: number
36
33
  columnIndex: number
@@ -104,28 +101,68 @@ function collectionCell(columns: number) {
104
101
  }
105
102
  }
106
103
 
107
- function HozoFlatListInner<T>(
108
- props: HozoFlatListProps<T>,
109
- forwardedRef: Ref<ReactNative.FlatList<T>>,
104
+ /**
105
+ * React Native's `FlatList`, with each cell told where it sits.
106
+ *
107
+ * It used to be told how long it was as well, which is the thing a windowed
108
+ * list cannot say for itself: only the rows near the viewport exist as
109
+ * views, so TalkBack counts those. On the Web the answer is `aria-setsize`.
110
+ * Here it was `accessibilityCollection`, and it is not set any more -- the
111
+ * note below the hooks says why, and what to put back.
112
+ */
113
+ export function HozoFlatList<T>(
114
+ props: HozoFlatListProps<T> & { ref?: Ref<ReactNative.FlatList<T>> },
110
115
  ): ReactElement {
111
- const { data, numColumns, CellRendererComponent, ...rest } = props
116
+ const { data, numColumns, CellRendererComponent, ref: forwardedRef, ...rest } = props
112
117
  const android = isAndroid()
113
118
  const columns = Math.max(1, Math.floor(numColumns ?? 1))
114
- const count = data?.length ?? 0
115
119
 
116
120
  // A component identity that only changes when the column count does. A
117
121
  // fresh one every render would remount every cell in the list.
118
122
  const cell = useMemo(() => collectionCell(columns), [columns])
119
123
 
120
- const collection: AndroidCollection | undefined = android
121
- ? {
122
- itemCount: count,
123
- rowCount: Math.ceil(count / columns),
124
- columnCount: columns,
125
- hierarchical: false,
126
- }
127
- : undefined
128
-
124
+ // `accessibilityCollection` is not set, and the list no longer says how
125
+ // long it is. It used to, and a device heard it: "Button, In list Hozo
126
+ // native acceptance screen, 3 items".
127
+ //
128
+ // It crashes the app (#512). React Native's own delegate reads the tag
129
+ // this sets, then walks the content view's children reading each one's
130
+ // `accessibility_collection_item`:
131
+ //
132
+ // // ReactScrollViewAccessibilityDelegate.kt
133
+ // :56 view.getTag(R.id.accessibility_collection) as? ReadableMap ?: return
134
+ // :74 nextChild.getTag(R.id.accessibility_collection_item) as ReadableMap
135
+ // :88 nestedNextChild.getTag(R.id.accessibility_collection_item) as? ReadableMap
136
+ //
137
+ // Line 74 is the only one of the four reads in that file with a non-null
138
+ // cast, two lines above a comment describing the null it forbids. Any
139
+ // child without the tag throws `NullPointerException: null cannot be cast
140
+ // to non-null type ReadableMap`, and in a release build that is the
141
+ // process. Still unfixed on `main` and on `0.87-stable`.
142
+ //
143
+ // Not every child can have the tag. `VirtualizedList` pushes its own
144
+ // `<View key={`$spacer-…`} style={…} />` for the windowed-away regions,
145
+ // and a list header, footer or empty component is a plain child too. The
146
+ // spacers are the reason this cannot be narrowed to "lists without a
147
+ // header": any list long enough to window has them.
148
+ //
149
+ // Line 56 returns early when the tag is absent, so not setting it is what
150
+ // makes the rest unreachable. The cells keep their
151
+ // `accessibilityCollectionItem` -- `ReactAccessibilityDelegate.kt:107`
152
+ // reads that one as `as ReadableMap?` and is not part of this -- so
153
+ // restoring the announcement is putting this back:
154
+ //
155
+ // const collection: AndroidCollection | undefined = android
156
+ // ? {
157
+ // itemCount: count,
158
+ // rowCount: Math.ceil(count / columns),
159
+ // columnCount: columns,
160
+ // hierarchical: false,
161
+ // }
162
+ // : undefined
163
+ //
164
+ // and `accessibilityCollection: collection` below, once a React Native
165
+ // with `as?` on line 74 is the floor.
129
166
  return createElement(
130
167
  ReactNative.FlatList as unknown as never,
131
168
  {
@@ -133,26 +170,11 @@ function HozoFlatListInner<T>(
133
170
  data,
134
171
  numColumns,
135
172
  ref: forwardedRef,
136
- accessibilityCollection: collection,
137
173
  // The caller's own cell renderer wins. Composing would put one view
138
174
  // inside another and hand the outer one the handlers the inner one
139
- // needs; deferring means the list still reports its length, and only
140
- // the per-item position is left unsaid.
175
+ // needs; deferring means only the per-item position is left unsaid.
141
176
  CellRendererComponent:
142
177
  CellRendererComponent ?? (android ? (cell as unknown as never) : undefined),
143
178
  } as never,
144
179
  )
145
180
  }
146
-
147
- /**
148
- * React Native's `FlatList`, told how long it is.
149
- *
150
- * A windowed list has a length its accessibility tree does not: only the
151
- * rows near the viewport exist as views, so TalkBack counts those and
152
- * announces them. On the Web the answer is `aria-setsize`; here it is
153
- * `accessibilityCollection`, and neither is something an app should have to
154
- * write itself when the list already knows.
155
- */
156
- export const HozoFlatList = forwardRef(HozoFlatListInner) as <T>(
157
- props: HozoFlatListProps<T> & { ref?: Ref<ReactNative.FlatList<T>> },
158
- ) => ReactElement
@@ -1,8 +1,9 @@
1
1
  import { hozoTextChildren } from '@hozo/behaviors'
2
2
  import { HozoTextSizeContext } from '@hozo/engine'
3
- import React, { type ComponentType, type ReactNode } from 'react'
3
+ import React, { type ComponentType, type ReactNode, type Ref } from 'react'
4
4
  import {
5
5
  type AccessibilityRole,
6
+ type HostInstance,
6
7
  Pressable as RNPressable,
7
8
  type PressableProps as RNPressableProps,
8
9
  Text as RNText,
@@ -46,6 +47,20 @@ export function Text({ children, style, ...props }: TextProps) {
46
47
  }
47
48
 
48
49
  export interface PressableProps extends RNPressableProps {
50
+ /**
51
+ * The view this press target lands on.
52
+ *
53
+ * Declared rather than inherited, because React Native's own
54
+ * `PressableProps` does not carry it: the `ref` is on the *component*
55
+ * (`(props: Omit<PressableProps, 'ref'> & { ref?: Ref<PressableInstance> })`),
56
+ * so a wrapper whose props are `PressableProps` rejects one. It is spread
57
+ * through to `RNPressable` below either way -- this only stops TypeScript
58
+ * refusing what already worked.
59
+ *
60
+ * A caller needs it to hand the control to something else: `Dialog`'s
61
+ * `restoreFocusTo` is where this came up (#462).
62
+ */
63
+ ref?: Ref<HostInstance>
49
64
  href?: string
50
65
  external?: boolean
51
66
  replace?: boolean
@@ -6,6 +6,8 @@
6
6
  import {
7
7
  type HozoDomStyle,
8
8
  hozoDomStyle,
9
+ hozoViewBase,
10
+ hozoViewClassName,
9
11
  type ResponderProps,
10
12
  useResponderDomProps,
11
13
  } from '@hozo/engine'
@@ -14,6 +16,8 @@ import {
14
16
  type CSSProperties,
15
17
  type MouseEventHandler,
16
18
  type ReactNode,
19
+ type Ref,
20
+ useCallback,
17
21
  useEffect,
18
22
  useRef,
19
23
  useState,
@@ -89,8 +93,29 @@ function universalDomProps(props: UniversalProps) {
89
93
  } as const
90
94
  }
91
95
 
92
- function useLayoutRef<T extends HTMLElement>(onLayout?: (event: HozoLayoutEvent) => void) {
96
+ /**
97
+ * The element, for `onLayout` and the responder, and the caller's `ref` too.
98
+ *
99
+ * React Native's `View` takes a `ref`, and the compiled `<div>` passes one
100
+ * straight through. This fallback held its own ref for `onLayout` and gave
101
+ * the caller nothing, so whether `ref` worked depended on whether the
102
+ * compiler had run. `setRef` hands the node to both.
103
+ */
104
+ function useLayoutRef<T extends HTMLElement>(
105
+ onLayout?: (event: HozoLayoutEvent) => void,
106
+ forwarded?: Ref<T>,
107
+ ) {
93
108
  const elementRef = useRef<T>(null)
109
+ // A new function only when the caller's ref changes, so React detaches the
110
+ // old one and attaches the new rather than re-running both every render.
111
+ const setRef = useCallback(
112
+ (node: T | null) => {
113
+ elementRef.current = node
114
+ if (typeof forwarded === 'function') forwarded(node)
115
+ else if (forwarded) forwarded.current = node
116
+ },
117
+ [forwarded],
118
+ )
94
119
  const callbackRef = useRef(onLayout)
95
120
  callbackRef.current = onLayout
96
121
 
@@ -120,33 +145,43 @@ function useLayoutRef<T extends HTMLElement>(onLayout?: (event: HozoLayoutEvent)
120
145
  return () => observer.disconnect()
121
146
  }, [])
122
147
 
123
- return elementRef
148
+ return { elementRef, setRef }
124
149
  }
125
150
 
126
151
  export interface ViewProps extends UniversalProps, ResponderProps {
127
152
  className?: string
128
153
  children?: ReactNode
154
+ ref?: Ref<HTMLDivElement>
129
155
  }
130
156
 
131
- export function View({ className, children, onLayout, ...universal }: ViewProps) {
132
- const ref = useLayoutRef<HTMLDivElement>(onLayout)
133
- const responder = useResponderDomProps(ref, universal)
157
+ export function View({ className, children, onLayout, ref, ...universal }: ViewProps) {
158
+ const { elementRef, setRef } = useLayoutRef<HTMLDivElement>(onLayout, ref)
159
+ const responder = useResponderDomProps(elementRef, universal)
134
160
  return (
135
- <div ref={ref} className={className} {...universalDomProps(universal)} {...responder}>
136
- {children}
137
- </div>
161
+ <>
162
+ {hozoViewBase()}
163
+ <div
164
+ ref={setRef}
165
+ className={hozoViewClassName(className)}
166
+ {...universalDomProps(universal)}
167
+ {...responder}
168
+ >
169
+ {children}
170
+ </div>
171
+ </>
138
172
  )
139
173
  }
140
174
 
141
175
  export interface TextProps extends UniversalProps {
142
176
  className?: string
143
177
  children?: ReactNode
178
+ ref?: Ref<HTMLSpanElement>
144
179
  }
145
180
 
146
- export function Text({ className, children, onLayout, ...universal }: TextProps) {
147
- const ref = useLayoutRef<HTMLSpanElement>(onLayout)
181
+ export function Text({ className, children, onLayout, ref, ...universal }: TextProps) {
182
+ const { setRef } = useLayoutRef<HTMLSpanElement>(onLayout, ref)
148
183
  return (
149
- <span ref={ref} className={className} {...universalDomProps(universal)}>
184
+ <span ref={setRef} className={className} {...universalDomProps(universal)}>
150
185
  {children}
151
186
  </span>
152
187
  )
@@ -160,6 +195,7 @@ export interface ImageProps extends UniversalProps {
160
195
  accessibilityLabel?: string
161
196
  onLoad?: (event: unknown) => void
162
197
  onError?: (event: unknown) => void
198
+ ref?: Ref<HTMLImageElement>
163
199
  }
164
200
 
165
201
  export interface HozoImageSourceObject {
@@ -200,15 +236,16 @@ export function Image({
200
236
  onLoad,
201
237
  onError,
202
238
  onLayout,
239
+ ref,
203
240
  ...universal
204
241
  }: ImageProps) {
205
- const ref = useLayoutRef<HTMLImageElement>(onLayout)
242
+ const { setRef } = useLayoutRef<HTMLImageElement>(onLayout, ref)
206
243
  const [failedSource, setFailedSource] = useState<HozoImageSource>()
207
244
  const webSrc =
208
245
  (failedSource === src ? undefined : webImageSource(src)) ?? webImageSource(defaultSource)
209
246
  return (
210
247
  <img
211
- ref={ref}
248
+ ref={setRef}
212
249
  className={className}
213
250
  src={webSrc}
214
251
  alt={alt ?? accessibilityLabel ?? ''}
@@ -307,17 +344,21 @@ export function Button({
307
344
  )
308
345
  }
309
346
  return (
310
- <button
311
- type="button"
312
- className={className}
313
- disabled={disabled}
314
- data-hozo-disabled={disabled ? '' : undefined}
315
- aria-label={accessibilityLabel}
316
- aria-description={accessibilityHint}
317
- data-testid={testID}
318
- onClick={onPress as MouseEventHandler<HTMLButtonElement>}
319
- >
320
- {children}
321
- </button>
347
+ <>
348
+ {hozoViewBase()}
349
+ <button
350
+ type="button"
351
+ className={className}
352
+ disabled={disabled}
353
+ data-hozo-disabled={disabled ? '' : undefined}
354
+ data-hozo-pressable={onPress && !disabled ? '' : undefined}
355
+ aria-label={accessibilityLabel}
356
+ aria-description={accessibilityHint}
357
+ data-testid={testID}
358
+ onClick={onPress as MouseEventHandler<HTMLButtonElement>}
359
+ >
360
+ {children}
361
+ </button>
362
+ </>
322
363
  )
323
364
  }
@@ -22,3 +22,5 @@ export type { HozoFlatListRenderInfo as FlatListRenderInfo } from './index.ts'
22
22
  export { HozoFlatList as FlatList, HozoScrollView as ScrollView }
23
23
  export type FlatListProps<T> = import('./flat-list.native.tsx').HozoFlatListProps<T>
24
24
  export type ScrollViewProps = HozoScrollViewProps
25
+
26
+ export { Presence, type PresenceProps } from './presence.native.tsx'