@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,96 @@
1
+ import { blendColor } from '@hozo/engine'
2
+ import { useLayoutEffect, useMemo, useRef, useState } from 'react'
3
+ import { Animated, Easing } from 'react-native'
4
+ import type { HozoTransition } from './pressable.native.tsx'
5
+
6
+ type Spec = Pick<HozoTransition, 'duration' | 'delay' | 'easing'>
7
+
8
+ function easingFor(name: Spec['easing']) {
9
+ switch (name) {
10
+ case 'linear':
11
+ return Easing.linear
12
+ case 'ease-in':
13
+ return Easing.in(Easing.ease)
14
+ case 'ease-out':
15
+ return Easing.out(Easing.ease)
16
+ case 'ease-in-out':
17
+ return Easing.inOut(Easing.ease)
18
+ }
19
+ }
20
+
21
+ /**
22
+ * One colour timeline, reusable by a leaf or an inherited label owner.
23
+ * Progress is not reset when retargeting: the new interpolation starts at the
24
+ * observed position. Resetting a live value to zero would briefly send the
25
+ * previous interpolation back to its old starting colour.
26
+ */
27
+ export function useHozoTextColorTransition(
28
+ target: string | undefined,
29
+ revision: string,
30
+ spec: Spec,
31
+ ) {
32
+ const [progress] = useState(() => new Animated.Value(0))
33
+ const position = useRef(0)
34
+ const animation = useRef<Animated.CompositeAnimation | null>(null)
35
+ const [range, setRange] = useState(() => ({
36
+ from: target ?? '',
37
+ to: target ?? '',
38
+ target,
39
+ revision,
40
+ start: 0,
41
+ animate: false,
42
+ }))
43
+ useLayoutEffect(() => {
44
+ const listener = progress.addListener(({ value }) => {
45
+ position.current = value
46
+ })
47
+ return () => {
48
+ progress.removeListener(listener)
49
+ animation.current?.stop()
50
+ }
51
+ }, [progress])
52
+ useLayoutEffect(() => {
53
+ if (range.target === target && range.revision === revision) return
54
+ animation.current?.stop()
55
+ const start = position.current
56
+ const fraction = Math.max(0, Math.min(1, start - range.start))
57
+ const current = range.from ? blendColor(range.from, range.to, fraction) : (target ?? '')
58
+ // Only committed inputs may replace the range. An abandoned Suspense
59
+ // render must not consume the target or mutate the visible timeline.
60
+ setRange({
61
+ from: target ? current : '',
62
+ to: target ?? '',
63
+ target,
64
+ revision,
65
+ start,
66
+ animate: Boolean(target),
67
+ })
68
+ }, [range, target, revision])
69
+ const { duration, delay = 0, easing } = spec
70
+ useLayoutEffect(() => {
71
+ if (!range.animate) return
72
+ const next = Animated.timing(progress, {
73
+ toValue: range.start + 1,
74
+ duration,
75
+ delay,
76
+ easing: easingFor(easing),
77
+ useNativeDriver: false,
78
+ })
79
+ animation.current = next
80
+ next.start()
81
+ return () => {
82
+ next.stop()
83
+ if (animation.current === next) animation.current = null
84
+ }
85
+ }, [progress, range, duration, delay, easing])
86
+ return useMemo(
87
+ () =>
88
+ range.from
89
+ ? progress.interpolate({
90
+ inputRange: [range.start, range.start + 1],
91
+ outputRange: [range.from, range.to],
92
+ })
93
+ : undefined,
94
+ [progress, range],
95
+ )
96
+ }
@@ -0,0 +1,26 @@
1
+ import type { TextInputProps as RNTextInputProps } from 'react-native'
2
+
3
+ /** Canonical disabled is distinct from an editable/read-only field. */
4
+ export interface NativeTextInputProps extends RNTextInputProps {
5
+ disabled?: boolean
6
+ className?: string
7
+ 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling'
8
+ }
9
+
10
+ /** Shared by value-level and generated hosts; RN has no disabled input prop. */
11
+ export function nativeTextInputProps({
12
+ disabled,
13
+ 'aria-invalid': _invalid,
14
+ ...props
15
+ }: NativeTextInputProps): RNTextInputProps {
16
+ if (!disabled) return props
17
+ // Both RN spellings must prevent editing even if the caller authored
18
+ // readOnly=false. Do not turn ordinary read-only fields into disabled ones.
19
+ return {
20
+ ...props,
21
+ editable: false,
22
+ readOnly: true,
23
+ accessibilityState: { ...props.accessibilityState, disabled: true },
24
+ 'aria-disabled': true,
25
+ }
26
+ }
@@ -0,0 +1,57 @@
1
+ import {
2
+ type HozoPressableInteractionState,
3
+ usePressableInteraction,
4
+ } from '@hozo/behaviors/pressable-interaction'
5
+ import type { ComponentRef, Ref } from 'react'
6
+ import { TextInput, type TextInputProps } from 'react-native'
7
+ import { type NativeTextInputProps, nativeTextInputProps } from './text-input-props.native.ts'
8
+
9
+ export interface HozoTextInputProps extends NativeTextInputProps {
10
+ ref?: Ref<ComponentRef<typeof TextInput>>
11
+ /** Compiler-only style evaluation on this input, not an ancestor Pressable. */
12
+ hozoStyle?: (state: HozoPressableInteractionState) => TextInputProps['style']
13
+ }
14
+
15
+ /**
16
+ * Generated-code host when static or dynamic classes need input focus. Ordinary
17
+ * compiled inputs stay RN TextInput. No extra box, context, animation or
18
+ * subscriptions; the same native field keeps its ref, events and semantics.
19
+ *
20
+ * A keyboard-input field indicates focus even after a pointer/touch focuses
21
+ * it (Selectors 4 §9.4). A button's pointer modality is not its policy.
22
+ */
23
+ export function HozoTextInput(props: HozoTextInputProps) {
24
+ // A prop-only adapter needs no state subscription. The focus child exists
25
+ // only for a compiler callback and still renders exactly one RN field.
26
+ if (!props.hozoStyle) {
27
+ const { hozoStyle: _hozoStyle, ref, ...hostProps } = props
28
+ return <TextInput {...nativeTextInputProps(hostProps)} ref={ref} />
29
+ }
30
+ return <FocusedTextInput {...props} />
31
+ }
32
+
33
+ function FocusedTextInput({
34
+ ref,
35
+ hozoStyle,
36
+ style,
37
+ onFocus,
38
+ onBlur,
39
+ ...props
40
+ }: HozoTextInputProps) {
41
+ const { state, handlers } = usePressableInteraction({ focusVisible: 'keyboard-input' })
42
+ return (
43
+ <TextInput
44
+ {...nativeTextInputProps(props)}
45
+ ref={ref}
46
+ style={[hozoStyle?.(state), style]}
47
+ onFocus={(event) => {
48
+ handlers.focus()
49
+ onFocus?.(event)
50
+ }}
51
+ onBlur={(event) => {
52
+ handlers.blur()
53
+ onBlur?.(event)
54
+ }}
55
+ />
56
+ )
57
+ }
@@ -1,2 +0,0 @@
1
- export { HozoAnimated, type HozoAnimatedProps, type HozoTransitionSpec, } from '../runtime-transition.native.tsx';
2
- //# sourceMappingURL=animated.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"animated.d.ts","sourceRoot":"","sources":["../../src/generated/animated.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,kCAAkC,CAAA"}
@@ -1,3 +0,0 @@
1
- // Native-only. See `./grid.ts`.
2
- export { HozoAnimated, } from '../runtime-transition.native.js';
3
- //# sourceMappingURL=animated.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"animated.js","sourceRoot":"","sources":["../../src/generated/animated.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EACL,YAAY,GAGb,MAAM,iCAAkC,CAAA"}
@@ -1,15 +0,0 @@
1
- export type PresenceState = 'open' | 'closed';
2
- export interface PresenceContextValue {
3
- state: PresenceState;
4
- /**
5
- * Called by an element that will animate out, once, on mount. `Presence`
6
- * waits for every registered element before it removes its child, and
7
- * removes it at once when none registered. The returned function
8
- * unregisters.
9
- */
10
- register(id: symbol, durationMs: number): () => void;
11
- /** Called by a registered element when its exit animation has ended. */
12
- done(id: symbol): void;
13
- }
14
- export declare const PresenceContext: import("react").Context<PresenceContextValue | null>;
15
- //# sourceMappingURL=presence-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presence-context.d.ts","sourceRoot":"","sources":["../src/presence-context.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,CAAA;AAE7C,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,aAAa,CAAA;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,IAAI,CAAA;IACpD,wEAAwE;IACxE,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED,eAAO,MAAM,eAAe,sDAAmD,CAAA"}
@@ -1,11 +0,0 @@
1
- // What `Presence` tells the elements that animate out inside it, on
2
- // Native (decision 007, amendment 1).
3
- //
4
- // On Web the same thing travels as an attribute, `data-state`, and CSS
5
- // does the rest. React Native has no attributes to select on, so the
6
- // state is a context instead, and `HozoAnimated` -- the component the
7
- // compiler puts in place of an element with a `data-[state=closed]:`
8
- // class -- reads it.
9
- import { createContext } from 'react';
10
- export const PresenceContext = createContext(null);
11
- //# sourceMappingURL=presence-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presence-context.js","sourceRoot":"","sources":["../src/presence-context.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,uEAAuE;AACvE,qEAAqE;AACrE,sEAAsE;AACtE,qEAAqE;AACrE,qBAAqB;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAiBrC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAA8B,IAAI,CAAC,CAAA"}
@@ -1,30 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import { type StyleProp, type ViewStyle } from 'react-native';
3
- export interface HozoTransitionSpec {
4
- duration: number;
5
- delay?: number;
6
- easing: 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
7
- }
8
- export interface HozoAnimatedProps {
9
- style?: StyleProp<ViewStyle>;
10
- hozoTransition?: HozoTransitionSpec;
11
- /**
12
- * The first frame of an enter animation, from a `starting:` class
13
- * (decision 007). The element mounts at these values and transitions to
14
- * `style`, which is what `@starting-style` does on Web. Read once, on
15
- * mount: it is where the element enters from, not a style it keeps.
16
- */
17
- hozoStarting?: StyleProp<ViewStyle>;
18
- /**
19
- * The last frame of an exit animation, from a `data-[state=closed]:`
20
- * class (decision 007, amendment 1). Laid over `style` while the
21
- * enclosing `Presence` is closing, which is what the attribute selector
22
- * does on Web; `Presence` removes the element when the transition to it
23
- * ends.
24
- */
25
- hozoExit?: StyleProp<ViewStyle>;
26
- children?: ReactNode;
27
- [key: string]: unknown;
28
- }
29
- export declare function HozoAnimated({ style, hozoTransition, hozoStarting, hozoExit, children, ...props }: HozoAnimatedProps): import("react").JSX.Element;
30
- //# sourceMappingURL=runtime-transition.native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-transition.native.d.ts","sourceRoot":"","sources":["../src/runtime-transition.native.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAAE,KAAK,SAAS,EAAoD,MAAM,OAAO,CAAA;AACxF,OAAO,EAAoB,KAAK,SAAS,EAAc,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAG3F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAA;CAC1D;AA6BD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC5B,cAAc,CAAC,EAAE,kBAAkB,CAAA;IACnC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,iBAAiB,+BA0InB"}
@@ -1,183 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // A transition driven by the style changing, rather than by an
3
- // interaction.
4
- //
5
- // `./pressable.native.tsx` already animates, and it is built the other way
6
- // round: it knows the four interaction booleans, calls the author's `style`
7
- // function for each combination, and animates between the results. That
8
- // shape is right there and wrong here, because the conditions this has to
9
- // serve are ambient -- `dark:`, `md:`, `motion-reduce:` -- and the
10
- // compiler expresses those as a guarded array, `[base, __hozoDark &&
11
- // dark]`, which is already resolved by the time it arrives.
12
- //
13
- // So this one asks a simpler question: what did the style just become, and
14
- // what was it before? Everything that differs and can be interpolated is
15
- // animated to its new value; everything else is passed straight through.
16
- // That covers the interaction case too, in principle, which is why this is
17
- // not named after the conditions that prompted it.
18
- //
19
- // Colours run on the JavaScript driver and opacity and transforms do not.
20
- // React Native cannot interpolate a colour natively, so mixing the two in
21
- // one `Animated.timing` would drag the fast ones onto the slow driver.
22
- // They are separate animations for that reason and not for tidiness.
23
- import { useContext, useEffect, useMemo, useRef, useState } from 'react';
24
- import { Animated, Easing, StyleSheet } from 'react-native';
25
- import { PresenceContext } from './presence-context.js';
26
- /** The colour properties worth animating, in the order they are read. */
27
- const COLOR_KEYS = ['backgroundColor', 'borderColor', 'color'];
28
- /**
29
- * The transform entries, flattened to `{ key: value }`.
30
- *
31
- * React Native's `transform` is an array of one-key objects, which is a
32
- * shape nothing can be diffed against directly -- two arrays with the same
33
- * entries in a different order are the same transform and not equal.
34
- */
35
- function transformMap(style) {
36
- const out = new Map();
37
- const transform = style?.transform;
38
- if (!Array.isArray(transform))
39
- return out;
40
- for (const entry of transform) {
41
- for (const [key, value] of Object.entries(entry)) {
42
- if (typeof value === 'number')
43
- out.set(key, value);
44
- }
45
- }
46
- return out;
47
- }
48
- /** What a transform key means when nothing sets it. */
49
- function identity(key) {
50
- return key.startsWith('scale') ? 1 : 0;
51
- }
52
- export function HozoAnimated({ style, hozoTransition, hozoStarting, hozoExit, children, ...props }) {
53
- const presence = useContext(PresenceContext);
54
- // Only an element that has somewhere to leave to takes part. One without
55
- // `hozoExit` neither waits for `Presence` nor makes it wait.
56
- const exits = presence !== null && hozoExit != null;
57
- const leaving = exits && presence.state === 'closed';
58
- const flat = useMemo(() => StyleSheet.flatten(leaving ? [style, hozoExit] : style) ?? {}, [style, hozoExit, leaving]);
59
- // One progress value per animation rather than one per property. The
60
- // properties change together -- they are the same rule flipping -- so
61
- // animating a single 0 → 1 and interpolating each property from its old
62
- // value to its new one is both cheaper and impossible to get out of
63
- // step with itself.
64
- const progress = useRef(new Animated.Value(1)).current;
65
- // Without `hozoStarting` the first render has nothing to animate from --
66
- // `from` and `to` are the same style, and the mount effect below runs an
67
- // animation that moves nothing. With it, `from` is the starting frame
68
- // laid over the style, so that same mount effect is the enter animation.
69
- const [entersFrom] = useState(() => hozoStarting ? { ...flat, ...(StyleSheet.flatten(hozoStarting) ?? {}) } : flat);
70
- const from = useRef(entersFrom);
71
- const to = useRef(flat);
72
- // What changed, computed during render so the effect below has nothing
73
- // to work out. `JSON.stringify` on the two style objects is enough: they
74
- // are flat, their values are primitives, and the compiler emits the keys
75
- // in a stable order.
76
- const signature = JSON.stringify(flat);
77
- const previous = useRef(signature);
78
- if (previous.current !== signature) {
79
- // The *visible* style becomes the new starting point, not the
80
- // previous target. Interrupting a half-finished fade and restarting
81
- // from where it was going would make it jump backwards first.
82
- from.current = to.current;
83
- to.current = flat;
84
- previous.current = signature;
85
- }
86
- // Registered for as long as it can exit, so `Presence` knows to wait for
87
- // it and how long to wait before giving up.
88
- const [id] = useState(() => Symbol('HozoAnimated'));
89
- const register = exits ? presence.register : undefined;
90
- const exitMs = hozoTransition ? hozoTransition.duration + (hozoTransition.delay ?? 0) : 0;
91
- useEffect(() => register?.(id, exitMs), [register, id, exitMs]);
92
- // Read when the animation ends, which is after this render's values may
93
- // have changed.
94
- const leavingNow = useRef(leaving);
95
- leavingNow.current = leaving;
96
- const done = presence?.done;
97
- const doneNow = useRef(done);
98
- doneNow.current = done;
99
- // `signature` is read above rather than inside, and it is what says the
100
- // style moved -- `hozoTransition` does not change when only the values
101
- // do. Without it a style change starts no transition at all, which is
102
- // the whole feature. `biome check --unsafe` offers to remove it.
103
- // biome-ignore lint/correctness/useExhaustiveDependencies: it is what says the style changed
104
- useEffect(() => {
105
- if (!hozoTransition)
106
- return;
107
- progress.setValue(0);
108
- const animation = Animated.timing(progress, {
109
- toValue: 1,
110
- duration: hozoTransition.duration,
111
- delay: hozoTransition.delay ?? 0,
112
- easing: easingFor(hozoTransition.easing),
113
- // Colours are in here too, and React Native cannot interpolate one
114
- // on the native driver. One animation on the JavaScript driver is
115
- // the honest choice: two drivers running the same rule would drift
116
- // against each other on a busy frame, and a background that arrives
117
- // before the text that sits on it is worse than both arriving late.
118
- useNativeDriver: false,
119
- });
120
- animation.start(({ finished }) => {
121
- if (finished && leavingNow.current)
122
- doneNow.current?.(id);
123
- });
124
- return () => animation.stop();
125
- }, [progress, signature, hozoTransition, id]);
126
- // biome-ignore lint/correctness/useExhaustiveDependencies: as above -- `signature` is what changed
127
- const animated = useMemo(() => {
128
- if (!hozoTransition)
129
- return flat;
130
- const overrides = {};
131
- if (typeof from.current.opacity === 'number' || typeof flat.opacity === 'number') {
132
- const start = typeof from.current.opacity === 'number' ? from.current.opacity : 1;
133
- const end = typeof flat.opacity === 'number' ? flat.opacity : 1;
134
- if (start !== end) {
135
- overrides.opacity = progress.interpolate({ inputRange: [0, 1], outputRange: [start, end] });
136
- }
137
- }
138
- for (const key of COLOR_KEYS) {
139
- // Read through a record: `color` lives on `TextStyle` and the rest
140
- // on `ViewStyle`, and a component that may be either has to look at
141
- // both. The runtime check below is what makes it safe.
142
- const start = from.current[key];
143
- const end = flat[key];
144
- if (typeof start !== 'string' || typeof end !== 'string' || start === end)
145
- continue;
146
- overrides[key] = progress.interpolate({ inputRange: [0, 1], outputRange: [start, end] });
147
- }
148
- const before = transformMap(from.current);
149
- const after = transformMap(flat);
150
- const keys = [...new Set([...before.keys(), ...after.keys()])];
151
- const moved = keys.filter((key) => (before.get(key) ?? identity(key)) !== (after.get(key) ?? identity(key)));
152
- if (moved.length > 0) {
153
- // Every key, not only the moved ones: `transform` is replaced
154
- // wholesale, so leaving one out would reset it to identity halfway
155
- // through the animation of its neighbour.
156
- overrides.transform = keys.map((key) => ({
157
- [key]: progress.interpolate({
158
- inputRange: [0, 1],
159
- outputRange: [before.get(key) ?? identity(key), after.get(key) ?? identity(key)],
160
- }),
161
- }));
162
- }
163
- return [flat, overrides];
164
- }, [flat, hozoTransition, progress, signature]);
165
- return (_jsx(Animated.View, { style: animated, ...props, children: exits ? (_jsx(PresenceContext.Provider, { value: null, children: children })) : (children) }));
166
- }
167
- function easingFor(name) {
168
- // Built here rather than in a module-level table, for the reason
169
- // `hooks.native.ts` does the same: a table calls `Easing.bezier` on
170
- // import, for every project that loads the package and never
171
- // transitions. The import itself is free; the call is not.
172
- switch (name) {
173
- case 'linear':
174
- return Easing.linear;
175
- case 'ease-in':
176
- return Easing.bezier(0.4, 0, 1, 1);
177
- case 'ease-out':
178
- return Easing.bezier(0, 0, 0.2, 1);
179
- default:
180
- return Easing.bezier(0.4, 0, 0.2, 1);
181
- }
182
- }
183
- //# sourceMappingURL=runtime-transition.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-transition.native.js","sourceRoot":"","sources":["../src/runtime-transition.native.tsx"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,eAAe;AACf,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,mEAAmE;AACnE,qEAAqE;AACrE,4DAA4D;AAC5D,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,mDAAmD;AACnD,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,u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,CAAC,CAAA;QACpC;YACE,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;IACxC,CAAC;AACH,CAAC"}
@@ -1,6 +0,0 @@
1
- // Native-only. See `./grid.ts`.
2
- export {
3
- HozoAnimated,
4
- type HozoAnimatedProps,
5
- type HozoTransitionSpec,
6
- } from '../runtime-transition.native.tsx'
@@ -1,27 +0,0 @@
1
- // What `Presence` tells the elements that animate out inside it, on
2
- // Native (decision 007, amendment 1).
3
- //
4
- // On Web the same thing travels as an attribute, `data-state`, and CSS
5
- // does the rest. React Native has no attributes to select on, so the
6
- // state is a context instead, and `HozoAnimated` -- the component the
7
- // compiler puts in place of an element with a `data-[state=closed]:`
8
- // class -- reads it.
9
-
10
- import { createContext } from 'react'
11
-
12
- export type PresenceState = 'open' | 'closed'
13
-
14
- export interface PresenceContextValue {
15
- state: PresenceState
16
- /**
17
- * Called by an element that will animate out, once, on mount. `Presence`
18
- * waits for every registered element before it removes its child, and
19
- * removes it at once when none registered. The returned function
20
- * unregisters.
21
- */
22
- register(id: symbol, durationMs: number): () => void
23
- /** Called by a registered element when its exit animation has ended. */
24
- done(id: symbol): void
25
- }
26
-
27
- export const PresenceContext = createContext<PresenceContextValue | null>(null)