@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
package/src/view.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import {
2
2
  type HozoDomStyle,
3
3
  hozoDomStyle,
4
+ hozoViewBase,
5
+ hozoViewClassName,
4
6
  type ResponderProps,
5
7
  useResponderDomProps,
6
8
  } from '@hozo/engine'
7
9
  import {
8
10
  createElement,
9
- forwardRef,
11
+ Fragment,
10
12
  type HTMLAttributes,
11
13
  type ReactNode,
12
14
  type Ref,
@@ -42,6 +44,15 @@ export interface HozoViewProps
42
44
  onLayout?: (event: HozoLayoutEvent) => void
43
45
  collapsable?: boolean
44
46
  'data-hozo-disabled'?: string
47
+ /**
48
+ * Declared here rather than supplied by `forwardRef`'s return type.
49
+ *
50
+ * React 19 takes `ref` as an ordinary prop, so the component is a plain
51
+ * function and nothing adds `ref` to its props on the way out. A caller's
52
+ * `ref` is accepted because this line says so, which is also why it has to
53
+ * be destructured below: `...props` would otherwise carry it to the `div`.
54
+ */
55
+ ref?: Ref<HTMLDivElement>
45
56
  }
46
57
 
47
58
  function assignRef<T>(ref: Ref<T> | undefined, value: T | null) {
@@ -50,40 +61,38 @@ function assignRef<T>(ref: Ref<T> | undefined, value: T | null) {
50
61
  }
51
62
 
52
63
  /** A measured/responder-aware View for the Web paths that cannot be a plain div. */
53
- export const HozoView = forwardRef<HTMLDivElement, HozoViewProps>(function HozoView(
54
- {
55
- children,
56
- style,
57
- testID,
58
- nativeID,
59
- pointerEvents,
60
- accessibilityLabel,
61
- accessibilityHint,
62
- accessibilityRole,
63
- accessibilityState,
64
- accessibilityValue,
65
- accessibilityLiveRegion,
66
- onLayout,
67
- collapsable: _collapsable,
68
- role,
69
- 'aria-disabled': ariaDisabled,
70
- 'data-hozo-disabled': dataHozoDisabled,
71
- onStartShouldSetResponder,
72
- onStartShouldSetResponderCapture,
73
- onMoveShouldSetResponder,
74
- onMoveShouldSetResponderCapture,
75
- onResponderGrant,
76
- onResponderStart,
77
- onResponderMove,
78
- onResponderEnd,
79
- onResponderRelease,
80
- onResponderReject,
81
- onResponderTerminate,
82
- onResponderTerminationRequest,
83
- ...props
84
- },
85
- forwardedRef,
86
- ) {
64
+ export function HozoView({
65
+ ref: forwardedRef,
66
+ children,
67
+ style,
68
+ testID,
69
+ nativeID,
70
+ pointerEvents,
71
+ accessibilityLabel,
72
+ accessibilityHint,
73
+ accessibilityRole,
74
+ accessibilityState,
75
+ accessibilityValue,
76
+ accessibilityLiveRegion,
77
+ onLayout,
78
+ collapsable: _collapsable,
79
+ role,
80
+ 'aria-disabled': ariaDisabled,
81
+ 'data-hozo-disabled': dataHozoDisabled,
82
+ onStartShouldSetResponder,
83
+ onStartShouldSetResponderCapture,
84
+ onMoveShouldSetResponder,
85
+ onMoveShouldSetResponderCapture,
86
+ onResponderGrant,
87
+ onResponderStart,
88
+ onResponderMove,
89
+ onResponderEnd,
90
+ onResponderRelease,
91
+ onResponderReject,
92
+ onResponderTerminate,
93
+ onResponderTerminationRequest,
94
+ ...props
95
+ }: HozoViewProps) {
87
96
  const elementRef = useRef<HTMLDivElement>(null)
88
97
  const layoutCallback = useRef(onLayout)
89
98
  layoutCallback.current = onLayout
@@ -136,30 +145,36 @@ export const HozoView = forwardRef<HTMLDivElement, HozoViewProps>(function HozoV
136
145
  const state = accessibilityState
137
146
  const value = accessibilityValue
138
147
  return createElement(
139
- 'div',
140
- {
141
- ...props,
142
- ...responder,
143
- ref: setRef,
144
- role: accessibilityRole ?? role,
145
- style: hozoDomStyle(style),
146
- 'data-testid': testID,
147
- id: nativeID,
148
- 'data-hozo-pointer-events': pointerEvents,
149
- 'data-hozo-disabled': state?.disabled ? '' : dataHozoDisabled,
150
- 'aria-disabled': state?.disabled ? true : ariaDisabled,
151
- 'aria-selected': state?.selected,
152
- 'aria-checked': state?.checked,
153
- 'aria-busy': state?.busy,
154
- 'aria-expanded': state?.expanded,
155
- 'aria-valuemin': value?.min,
156
- 'aria-valuemax': value?.max,
157
- 'aria-valuenow': value?.now,
158
- 'aria-valuetext': value?.text,
159
- 'aria-live': accessibilityLiveRegion === 'none' ? undefined : accessibilityLiveRegion,
160
- 'aria-label': accessibilityLabel,
161
- 'aria-description': accessibilityHint,
162
- },
163
- children,
148
+ Fragment,
149
+ null,
150
+ hozoViewBase(),
151
+ createElement(
152
+ 'div',
153
+ {
154
+ ...props,
155
+ className: hozoViewClassName(props.className),
156
+ ...responder,
157
+ ref: setRef,
158
+ role: accessibilityRole ?? role,
159
+ style: hozoDomStyle(style),
160
+ 'data-testid': testID,
161
+ id: nativeID,
162
+ 'data-hozo-pointer-events': pointerEvents,
163
+ 'data-hozo-disabled': state?.disabled ? '' : dataHozoDisabled,
164
+ 'aria-disabled': state?.disabled ? true : ariaDisabled,
165
+ 'aria-selected': state?.selected,
166
+ 'aria-checked': state?.checked,
167
+ 'aria-busy': state?.busy,
168
+ 'aria-expanded': state?.expanded,
169
+ 'aria-valuemin': value?.min,
170
+ 'aria-valuemax': value?.max,
171
+ 'aria-valuenow': value?.now,
172
+ 'aria-valuetext': value?.text,
173
+ 'aria-live': accessibilityLiveRegion === 'none' ? undefined : accessibilityLiveRegion,
174
+ 'aria-label': accessibilityLabel,
175
+ 'aria-description': accessibilityHint,
176
+ },
177
+ children,
178
+ ),
164
179
  )
165
- })
180
+ }