rnwind 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/core/parser/animation.cjs +427 -0
- package/lib/cjs/core/parser/animation.cjs.map +1 -0
- package/lib/cjs/core/parser/animation.d.ts +126 -0
- package/lib/cjs/core/parser/border-dispatcher.cjs +180 -0
- package/lib/cjs/core/parser/border-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/border-dispatcher.d.ts +15 -0
- package/lib/cjs/core/parser/case-convert.cjs +15 -0
- package/lib/cjs/core/parser/case-convert.cjs.map +1 -0
- package/lib/cjs/core/parser/case-convert.d.ts +6 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.cjs +84 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/color-properties-dispatcher.d.ts +19 -0
- package/lib/cjs/core/parser/color.cjs +193 -0
- package/lib/cjs/core/parser/color.cjs.map +1 -0
- package/lib/cjs/core/parser/color.d.ts +12 -0
- package/lib/cjs/core/parser/constants.cjs +21 -0
- package/lib/cjs/core/parser/constants.cjs.map +1 -0
- package/lib/cjs/core/parser/constants.d.ts +8 -0
- package/lib/cjs/core/parser/declaration.cjs +347 -0
- package/lib/cjs/core/parser/declaration.cjs.map +1 -0
- package/lib/cjs/core/parser/declaration.d.ts +15 -0
- package/lib/cjs/core/parser/gradient.cjs +132 -0
- package/lib/cjs/core/parser/gradient.cjs.map +1 -0
- package/lib/cjs/core/parser/gradient.d.ts +59 -0
- package/lib/cjs/core/parser/haptics.cjs +73 -0
- package/lib/cjs/core/parser/haptics.cjs.map +1 -0
- package/lib/cjs/core/parser/haptics.d.ts +47 -0
- package/lib/cjs/core/parser/index.d.ts +8 -0
- package/lib/cjs/core/parser/keyframes.cjs +95 -0
- package/lib/cjs/core/parser/keyframes.cjs.map +1 -0
- package/lib/cjs/core/parser/keyframes.d.ts +26 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs +120 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/layout-dispatcher.d.ts +14 -0
- package/lib/cjs/core/parser/length.cjs +110 -0
- package/lib/cjs/core/parser/length.cjs.map +1 -0
- package/lib/cjs/core/parser/length.d.ts +51 -0
- package/lib/cjs/core/parser/motion-dispatcher.cjs +77 -0
- package/lib/cjs/core/parser/motion-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/motion-dispatcher.d.ts +11 -0
- package/lib/cjs/core/parser/property.cjs +22 -0
- package/lib/cjs/core/parser/property.cjs.map +1 -0
- package/lib/cjs/core/parser/property.d.ts +8 -0
- package/lib/cjs/core/parser/safe-area.cjs +404 -0
- package/lib/cjs/core/parser/safe-area.cjs.map +1 -0
- package/lib/cjs/core/parser/safe-area.d.ts +39 -0
- package/lib/cjs/core/parser/selector.cjs +22 -0
- package/lib/cjs/core/parser/selector.cjs.map +1 -0
- package/lib/cjs/core/parser/selector.d.ts +11 -0
- package/lib/cjs/core/parser/shorthand.cjs +188 -0
- package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
- package/lib/cjs/core/parser/shorthand.d.ts +67 -0
- package/lib/cjs/core/parser/text-truncate.cjs +78 -0
- package/lib/cjs/core/parser/text-truncate.cjs.map +1 -0
- package/lib/cjs/core/parser/text-truncate.d.ts +44 -0
- package/lib/cjs/core/parser/theme-vars.cjs +467 -0
- package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
- package/lib/cjs/core/parser/theme-vars.d.ts +82 -0
- package/lib/cjs/core/parser/tokens.cjs +486 -0
- package/lib/cjs/core/parser/tokens.cjs.map +1 -0
- package/lib/cjs/core/parser/tokens.d.ts +45 -0
- package/lib/cjs/core/parser/transform.cjs +198 -0
- package/lib/cjs/core/parser/transform.cjs.map +1 -0
- package/lib/cjs/core/parser/transform.d.ts +36 -0
- package/lib/cjs/core/parser/tw-parser.cjs +1680 -0
- package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
- package/lib/cjs/core/parser/tw-parser.d.ts +210 -0
- package/lib/cjs/core/parser/types.d.ts +37 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs +108 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs.map +1 -0
- package/lib/cjs/core/parser/typography-dispatcher.d.ts +11 -0
- package/lib/cjs/core/parser/typography.cjs +97 -0
- package/lib/cjs/core/parser/typography.cjs.map +1 -0
- package/lib/cjs/core/parser/typography.d.ts +43 -0
- package/lib/cjs/core/style-builder/build-style.cjs +444 -0
- package/lib/cjs/core/style-builder/build-style.cjs.map +1 -0
- package/lib/cjs/core/style-builder/build-style.d.ts +54 -0
- package/lib/cjs/core/style-builder/index.d.ts +3 -0
- package/lib/cjs/core/style-builder/union-builder.cjs +326 -0
- package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -0
- package/lib/cjs/core/style-builder/union-builder.d.ts +128 -0
- package/lib/cjs/core/types.d.ts +14 -0
- package/lib/cjs/metro/dts.cjs +127 -0
- package/lib/cjs/metro/dts.cjs.map +1 -0
- package/lib/cjs/metro/dts.d.ts +16 -0
- package/lib/cjs/metro/index.cjs +19 -0
- package/lib/cjs/metro/index.cjs.map +1 -0
- package/lib/cjs/metro/index.d.ts +9 -0
- package/lib/cjs/metro/resolver.cjs +47 -0
- package/lib/cjs/metro/resolver.cjs.map +1 -0
- package/lib/cjs/metro/resolver.d.ts +22 -0
- package/lib/cjs/metro/state.cjs +301 -0
- package/lib/cjs/metro/state.cjs.map +1 -0
- package/lib/cjs/metro/state.d.ts +88 -0
- package/lib/cjs/metro/transform-ast.cjs +1472 -0
- package/lib/cjs/metro/transform-ast.cjs.map +1 -0
- package/lib/cjs/metro/transform-ast.d.ts +88 -0
- package/lib/cjs/metro/transformer.cjs +372 -0
- package/lib/cjs/metro/transformer.cjs.map +1 -0
- package/lib/cjs/metro/transformer.d.ts +47 -0
- package/lib/cjs/metro/warn-unknown-classes.cjs +86 -0
- package/lib/cjs/metro/warn-unknown-classes.cjs.map +1 -0
- package/lib/cjs/metro/warn-unknown-classes.d.ts +21 -0
- package/lib/cjs/metro/with-config.cjs +196 -0
- package/lib/cjs/metro/with-config.cjs.map +1 -0
- package/lib/cjs/metro/with-config.d.ts +79 -0
- package/lib/cjs/runtime/chain-handlers.cjs +37 -0
- package/lib/cjs/runtime/chain-handlers.cjs.map +1 -0
- package/lib/cjs/runtime/chain-handlers.d.ts +33 -0
- package/lib/cjs/runtime/components/rnwind-provider.cjs +98 -0
- package/lib/cjs/runtime/components/rnwind-provider.cjs.map +1 -0
- package/lib/cjs/runtime/components/rnwind-provider.d.ts +84 -0
- package/lib/cjs/runtime/gradient-types.d.ts +58 -0
- package/lib/cjs/runtime/haptics.cjs +113 -0
- package/lib/cjs/runtime/haptics.cjs.map +1 -0
- package/lib/cjs/runtime/haptics.d.ts +48 -0
- package/lib/cjs/runtime/hooks/use-css.cjs +21 -0
- package/lib/cjs/runtime/hooks/use-css.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-css.d.ts +11 -0
- package/lib/cjs/runtime/hooks/use-interact.cjs +46 -0
- package/lib/cjs/runtime/hooks/use-interact.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-interact.d.ts +42 -0
- package/lib/cjs/runtime/hooks/use-scheme.cjs +68 -0
- package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -0
- package/lib/cjs/runtime/hooks/use-scheme.d.ts +34 -0
- package/lib/cjs/runtime/index.cjs +45 -0
- package/lib/cjs/runtime/index.cjs.map +1 -0
- package/lib/cjs/runtime/index.d.ts +27 -0
- package/lib/cjs/runtime/interactive-box.cjs +35 -0
- package/lib/cjs/runtime/interactive-box.cjs.map +1 -0
- package/lib/cjs/runtime/interactive-box.d.ts +40 -0
- package/lib/cjs/runtime/lookup-css.cjs +542 -0
- package/lib/cjs/runtime/lookup-css.cjs.map +1 -0
- package/lib/cjs/runtime/lookup-css.d.ts +164 -0
- package/lib/cjs/runtime/types.d.ts +29 -0
- package/lib/cjs/testing/index.cjs +367 -0
- package/lib/cjs/testing/index.cjs.map +1 -0
- package/lib/cjs/testing/index.d.ts +145 -0
- package/lib/esm/core/parser/animation.d.ts +126 -0
- package/lib/esm/core/parser/animation.mjs +408 -0
- package/lib/esm/core/parser/animation.mjs.map +1 -0
- package/lib/esm/core/parser/border-dispatcher.d.ts +15 -0
- package/lib/esm/core/parser/border-dispatcher.mjs +178 -0
- package/lib/esm/core/parser/border-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/case-convert.d.ts +6 -0
- package/lib/esm/core/parser/case-convert.mjs +13 -0
- package/lib/esm/core/parser/case-convert.mjs.map +1 -0
- package/lib/esm/core/parser/color-properties-dispatcher.d.ts +19 -0
- package/lib/esm/core/parser/color-properties-dispatcher.mjs +82 -0
- package/lib/esm/core/parser/color-properties-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/color.d.ts +12 -0
- package/lib/esm/core/parser/color.mjs +191 -0
- package/lib/esm/core/parser/color.mjs.map +1 -0
- package/lib/esm/core/parser/constants.d.ts +8 -0
- package/lib/esm/core/parser/constants.mjs +13 -0
- package/lib/esm/core/parser/constants.mjs.map +1 -0
- package/lib/esm/core/parser/declaration.d.ts +15 -0
- package/lib/esm/core/parser/declaration.mjs +345 -0
- package/lib/esm/core/parser/declaration.mjs.map +1 -0
- package/lib/esm/core/parser/gradient.d.ts +59 -0
- package/lib/esm/core/parser/gradient.mjs +130 -0
- package/lib/esm/core/parser/gradient.mjs.map +1 -0
- package/lib/esm/core/parser/haptics.d.ts +47 -0
- package/lib/esm/core/parser/haptics.mjs +71 -0
- package/lib/esm/core/parser/haptics.mjs.map +1 -0
- package/lib/esm/core/parser/index.d.ts +8 -0
- package/lib/esm/core/parser/keyframes.d.ts +26 -0
- package/lib/esm/core/parser/keyframes.mjs +91 -0
- package/lib/esm/core/parser/keyframes.mjs.map +1 -0
- package/lib/esm/core/parser/layout-dispatcher.d.ts +14 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs +118 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/length.d.ts +51 -0
- package/lib/esm/core/parser/length.mjs +104 -0
- package/lib/esm/core/parser/length.mjs.map +1 -0
- package/lib/esm/core/parser/motion-dispatcher.d.ts +11 -0
- package/lib/esm/core/parser/motion-dispatcher.mjs +75 -0
- package/lib/esm/core/parser/motion-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/property.d.ts +8 -0
- package/lib/esm/core/parser/property.mjs +20 -0
- package/lib/esm/core/parser/property.mjs.map +1 -0
- package/lib/esm/core/parser/safe-area.d.ts +39 -0
- package/lib/esm/core/parser/safe-area.mjs +402 -0
- package/lib/esm/core/parser/safe-area.mjs.map +1 -0
- package/lib/esm/core/parser/selector.d.ts +11 -0
- package/lib/esm/core/parser/selector.mjs +20 -0
- package/lib/esm/core/parser/selector.mjs.map +1 -0
- package/lib/esm/core/parser/shorthand.d.ts +67 -0
- package/lib/esm/core/parser/shorthand.mjs +180 -0
- package/lib/esm/core/parser/shorthand.mjs.map +1 -0
- package/lib/esm/core/parser/text-truncate.d.ts +44 -0
- package/lib/esm/core/parser/text-truncate.mjs +75 -0
- package/lib/esm/core/parser/text-truncate.mjs.map +1 -0
- package/lib/esm/core/parser/theme-vars.d.ts +82 -0
- package/lib/esm/core/parser/theme-vars.mjs +461 -0
- package/lib/esm/core/parser/theme-vars.mjs.map +1 -0
- package/lib/esm/core/parser/tokens.d.ts +45 -0
- package/lib/esm/core/parser/tokens.mjs +480 -0
- package/lib/esm/core/parser/tokens.mjs.map +1 -0
- package/lib/esm/core/parser/transform.d.ts +36 -0
- package/lib/esm/core/parser/transform.mjs +193 -0
- package/lib/esm/core/parser/transform.mjs.map +1 -0
- package/lib/esm/core/parser/tw-parser.d.ts +210 -0
- package/lib/esm/core/parser/tw-parser.mjs +1678 -0
- package/lib/esm/core/parser/tw-parser.mjs.map +1 -0
- package/lib/esm/core/parser/types.d.ts +37 -0
- package/lib/esm/core/parser/typography-dispatcher.d.ts +11 -0
- package/lib/esm/core/parser/typography-dispatcher.mjs +106 -0
- package/lib/esm/core/parser/typography-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/typography.d.ts +43 -0
- package/lib/esm/core/parser/typography.mjs +91 -0
- package/lib/esm/core/parser/typography.mjs.map +1 -0
- package/lib/esm/core/style-builder/build-style.d.ts +54 -0
- package/lib/esm/core/style-builder/build-style.mjs +442 -0
- package/lib/esm/core/style-builder/build-style.mjs.map +1 -0
- package/lib/esm/core/style-builder/index.d.ts +3 -0
- package/lib/esm/core/style-builder/union-builder.d.ts +128 -0
- package/lib/esm/core/style-builder/union-builder.mjs +324 -0
- package/lib/esm/core/style-builder/union-builder.mjs.map +1 -0
- package/lib/esm/core/types.d.ts +14 -0
- package/lib/esm/metro/dts.d.ts +16 -0
- package/lib/esm/metro/dts.mjs +125 -0
- package/lib/esm/metro/dts.mjs.map +1 -0
- package/lib/esm/metro/index.d.ts +9 -0
- package/lib/esm/metro/index.mjs +6 -0
- package/lib/esm/metro/index.mjs.map +1 -0
- package/lib/esm/metro/resolver.d.ts +22 -0
- package/lib/esm/metro/resolver.mjs +43 -0
- package/lib/esm/metro/resolver.mjs.map +1 -0
- package/lib/esm/metro/state.d.ts +88 -0
- package/lib/esm/metro/state.mjs +291 -0
- package/lib/esm/metro/state.mjs.map +1 -0
- package/lib/esm/metro/transform-ast.d.ts +88 -0
- package/lib/esm/metro/transform-ast.mjs +1451 -0
- package/lib/esm/metro/transform-ast.mjs.map +1 -0
- package/lib/esm/metro/transformer.d.ts +47 -0
- package/lib/esm/metro/transformer.mjs +349 -0
- package/lib/esm/metro/transformer.mjs.map +1 -0
- package/lib/esm/metro/warn-unknown-classes.d.ts +21 -0
- package/lib/esm/metro/warn-unknown-classes.mjs +84 -0
- package/lib/esm/metro/warn-unknown-classes.mjs.map +1 -0
- package/lib/esm/metro/with-config.d.ts +79 -0
- package/lib/esm/metro/with-config.mjs +194 -0
- package/lib/esm/metro/with-config.mjs.map +1 -0
- package/lib/esm/runtime/chain-handlers.d.ts +33 -0
- package/lib/esm/runtime/chain-handlers.mjs +34 -0
- package/lib/esm/runtime/chain-handlers.mjs.map +1 -0
- package/lib/esm/runtime/components/rnwind-provider.d.ts +84 -0
- package/lib/esm/runtime/components/rnwind-provider.mjs +94 -0
- package/lib/esm/runtime/components/rnwind-provider.mjs.map +1 -0
- package/lib/esm/runtime/gradient-types.d.ts +58 -0
- package/lib/esm/runtime/haptics.d.ts +48 -0
- package/lib/esm/runtime/haptics.mjs +110 -0
- package/lib/esm/runtime/haptics.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-css.d.ts +11 -0
- package/lib/esm/runtime/hooks/use-css.mjs +19 -0
- package/lib/esm/runtime/hooks/use-css.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-interact.d.ts +42 -0
- package/lib/esm/runtime/hooks/use-interact.mjs +44 -0
- package/lib/esm/runtime/hooks/use-interact.mjs.map +1 -0
- package/lib/esm/runtime/hooks/use-scheme.d.ts +34 -0
- package/lib/esm/runtime/hooks/use-scheme.mjs +63 -0
- package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -0
- package/lib/esm/runtime/index.d.ts +27 -0
- package/lib/esm/runtime/index.mjs +18 -0
- package/lib/esm/runtime/index.mjs.map +1 -0
- package/lib/esm/runtime/interactive-box.d.ts +40 -0
- package/lib/esm/runtime/interactive-box.mjs +33 -0
- package/lib/esm/runtime/interactive-box.mjs.map +1 -0
- package/lib/esm/runtime/lookup-css.d.ts +164 -0
- package/lib/esm/runtime/lookup-css.mjs +531 -0
- package/lib/esm/runtime/lookup-css.mjs.map +1 -0
- package/lib/esm/runtime/types.d.ts +29 -0
- package/lib/esm/testing/index.d.ts +145 -0
- package/lib/esm/testing/index.mjs +344 -0
- package/lib/esm/testing/index.mjs.map +1 -0
- package/package.json +80 -13
- package/preset.css +1171 -0
- package/src/core/parser/animation.ts +404 -0
- package/src/core/parser/border-dispatcher.ts +176 -0
- package/src/core/parser/case-convert.ts +10 -0
- package/src/core/parser/color-properties-dispatcher.ts +78 -0
- package/src/core/parser/color.ts +191 -0
- package/src/core/parser/constants.ts +11 -0
- package/src/core/parser/declaration.ts +340 -0
- package/src/core/parser/gradient.ts +148 -0
- package/src/core/parser/haptics.ts +88 -0
- package/src/core/parser/index.ts +8 -0
- package/src/core/parser/keyframes.ts +84 -0
- package/src/core/parser/layout-dispatcher.ts +111 -0
- package/src/core/parser/length.ts +114 -0
- package/src/core/parser/motion-dispatcher.ts +89 -0
- package/src/core/parser/property.ts +15 -0
- package/src/core/parser/safe-area.ts +404 -0
- package/src/core/parser/selector.ts +17 -0
- package/src/core/parser/shorthand.ts +182 -0
- package/src/core/parser/text-truncate.ts +79 -0
- package/src/core/parser/theme-vars.ts +465 -0
- package/src/core/parser/tokens.ts +456 -0
- package/src/core/parser/transform.ts +195 -0
- package/src/core/parser/tw-parser.ts +1828 -0
- package/src/core/parser/types.ts +45 -0
- package/src/core/parser/typography-dispatcher.ts +97 -0
- package/src/core/parser/typography.ts +83 -0
- package/src/core/style-builder/build-style.ts +500 -0
- package/src/core/style-builder/index.ts +3 -0
- package/src/core/style-builder/union-builder.ts +328 -0
- package/src/core/types.ts +15 -0
- package/src/metro/dts.ts +128 -0
- package/src/metro/index.ts +9 -0
- package/src/metro/resolver.ts +42 -0
- package/src/metro/state.ts +305 -0
- package/src/metro/transform-ast.ts +1729 -0
- package/src/metro/transformer.ts +372 -0
- package/src/metro/warn-unknown-classes.ts +79 -0
- package/src/metro/with-config.ts +251 -0
- package/src/runtime/chain-handlers.ts +47 -0
- package/src/runtime/components/rnwind-provider.tsx +144 -0
- package/src/runtime/gradient-types.ts +60 -0
- package/src/runtime/haptics.ts +120 -0
- package/src/runtime/hooks/use-css.ts +16 -0
- package/src/runtime/hooks/use-interact.ts +65 -0
- package/src/runtime/hooks/use-scheme.ts +63 -0
- package/src/runtime/index.ts +54 -0
- package/src/runtime/interactive-box.tsx +57 -0
- package/src/runtime/lookup-css.ts +628 -0
- package/src/runtime/types.ts +32 -0
- package/src/testing/index.ts +507 -0
- package/src/types/tailwindcss-node.d.ts +33 -0
- package/src/index.ts +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react'
|
|
2
|
+
import type { GestureResponderEvent, NativeSyntheticEvent, TargetedEvent } from 'react-native'
|
|
3
|
+
import type { InteractState } from '../lookup-css'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Idle state reference reused across every non-interactive render —
|
|
7
|
+
* when neither `active` nor `focus` is true, every call site returns
|
|
8
|
+
* the exact same object. That's the ~99 % path for a typical list row,
|
|
9
|
+
* so sharing the ref is a legitimate allocation elimination.
|
|
10
|
+
*/
|
|
11
|
+
const IDLE_STATE: InteractState = { active: false, focus: false }
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Live interact-state snapshot plus the press/focus handlers the
|
|
15
|
+
* transformer wires onto the JSX opening element. The state object is
|
|
16
|
+
* referentially stable across renders when the underlying `active` /
|
|
17
|
+
* `focus` flags don't change, which keeps `lookupCss` cache hits
|
|
18
|
+
* aligned with React's render cadence (same state ref → same
|
|
19
|
+
* resolved-array cache key → same reference back, no React diff
|
|
20
|
+
* triggered).
|
|
21
|
+
*/
|
|
22
|
+
export interface UseInteractResult {
|
|
23
|
+
/** Current interact flags — forwarded as the 4th arg to `lookupCss`. */
|
|
24
|
+
state: InteractState
|
|
25
|
+
/** Wired by the transformer onto `<Pressable onPressIn={…}>` etc. */
|
|
26
|
+
onPressIn: (event: GestureResponderEvent) => void
|
|
27
|
+
/** Wired by the transformer onto `<Pressable onPressOut={…}>` etc. */
|
|
28
|
+
onPressOut: (event: GestureResponderEvent) => void
|
|
29
|
+
/** Wired by the transformer onto `<TextInput onFocus={…}>` etc. */
|
|
30
|
+
onFocus: (event: NativeSyntheticEvent<TargetedEvent>) => void
|
|
31
|
+
/** Wired by the transformer onto `<TextInput onBlur={…}>` etc. */
|
|
32
|
+
onBlur: (event: NativeSyntheticEvent<TargetedEvent>) => void
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* React hook driving `active:` / `focus:` variants at runtime. The
|
|
37
|
+
* transformer injects exactly one call per JSX element that uses an
|
|
38
|
+
* interactive classname, caching the hook's result into a component-
|
|
39
|
+
* local `_i` binding so every `lookupCss(…, _i.state)` site shares the
|
|
40
|
+
* same snapshot per render.
|
|
41
|
+
*
|
|
42
|
+
* React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch
|
|
43
|
+
* down / release — the touch-device analogue of CSS `:active`. Text
|
|
44
|
+
* fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;
|
|
45
|
+
* unused handlers on elements that don't emit the corresponding event
|
|
46
|
+
* are harmless no-ops.
|
|
47
|
+
*
|
|
48
|
+
* Result stability: both `state` and the returned wrapper object stay
|
|
49
|
+
* reference-equal across renders unless `active` / `focus` actually
|
|
50
|
+
* flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.
|
|
51
|
+
* @returns Stable state + handler bundle.
|
|
52
|
+
*/
|
|
53
|
+
export function useInteract(): UseInteractResult {
|
|
54
|
+
const [active, setActive] = useState(false)
|
|
55
|
+
const [focus, setFocus] = useState(false)
|
|
56
|
+
const onPressIn = useCallback(() => setActive(true), [])
|
|
57
|
+
const onPressOut = useCallback(() => setActive(false), [])
|
|
58
|
+
const onFocus = useCallback(() => setFocus(true), [])
|
|
59
|
+
const onBlur = useCallback(() => setFocus(false), [])
|
|
60
|
+
const state = useMemo<InteractState>(() => {
|
|
61
|
+
if (!active && !focus) return IDLE_STATE
|
|
62
|
+
return { active, focus }
|
|
63
|
+
}, [active, focus])
|
|
64
|
+
return useMemo(() => ({ state, onPressIn, onPressOut, onFocus, onBlur }), [state, onPressIn, onPressOut, onFocus, onBlur])
|
|
65
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ThemeTable } from '../../core/types'
|
|
2
|
+
import { useRnwind } from '../components/rnwind-provider'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Synthetic scheme name applied when tokens aren't declared under any
|
|
6
|
+
* `@variant` block — the "no active variant" fallback every theme table
|
|
7
|
+
* inherits from.
|
|
8
|
+
*/
|
|
9
|
+
const BASE_SCHEME = 'base'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Access the resolved theme table for the active scheme.
|
|
13
|
+
*
|
|
14
|
+
* Tokens declared outside any `@variant` block live in the `base` table and
|
|
15
|
+
* should apply everywhere — just like the CSS cascade treats `:root` as a
|
|
16
|
+
* default for every ancestor-scoped override. We merge `base` under the
|
|
17
|
+
* active scheme so a scheme that doesn't declare a token still sees the
|
|
18
|
+
* base default, while the scheme's own entries win on overlap.
|
|
19
|
+
* @returns Token table for the active scheme.
|
|
20
|
+
*/
|
|
21
|
+
export function useTheme(): ThemeTable {
|
|
22
|
+
const { scheme, tables } = useRnwind()
|
|
23
|
+
const base = tables[BASE_SCHEME] ?? {}
|
|
24
|
+
const schemeTable = tables[scheme]
|
|
25
|
+
if (!schemeTable) return base
|
|
26
|
+
// Fast path: nothing to merge when the scheme table is empty.
|
|
27
|
+
if (Object.keys(schemeTable).length === 0) return base
|
|
28
|
+
return { ...base, ...schemeTable }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Read a raw CSS custom property's value for the active scheme. Accepts
|
|
33
|
+
* either `--foo` or the bare `foo` form for convenience.
|
|
34
|
+
* @param cssVariable CSS custom property name (with or without the leading `--`).
|
|
35
|
+
* @returns The resolved value, or undefined when the token is missing.
|
|
36
|
+
*/
|
|
37
|
+
export function useToken(cssVariable: string): string | number | undefined {
|
|
38
|
+
const table = useTheme()
|
|
39
|
+
const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`
|
|
40
|
+
return table[name]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Read a color token by shorthand name — `useColor('primary')` resolves
|
|
45
|
+
* `--color-primary` for the active scheme.
|
|
46
|
+
* @param name Token suffix after `--color-`.
|
|
47
|
+
* @returns Resolved color string, or undefined when the token is missing
|
|
48
|
+
* or its value isn't a string.
|
|
49
|
+
*/
|
|
50
|
+
export function useColor(name: string): string | undefined {
|
|
51
|
+
const value = useToken(`--color-${name}`)
|
|
52
|
+
return typeof value === 'string' ? value : undefined
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Read a spacing token by shorthand name — `useSize('4')` resolves
|
|
57
|
+
* `--spacing-4` for the active scheme.
|
|
58
|
+
* @param name Token suffix after `--spacing-`.
|
|
59
|
+
* @returns Resolved spacing value, or undefined when the token is missing.
|
|
60
|
+
*/
|
|
61
|
+
export function useSize(name: string): number | string | undefined {
|
|
62
|
+
return useToken(`--spacing-${name}`)
|
|
63
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
lookupCss,
|
|
7
|
+
registerAtoms,
|
|
8
|
+
registerBreakpoints,
|
|
9
|
+
registerSchemeLoader,
|
|
10
|
+
setWindowHeightProvider,
|
|
11
|
+
getBreakpoints,
|
|
12
|
+
activeBreakpointFor,
|
|
13
|
+
lookupCss as _l,
|
|
14
|
+
} from './lookup-css'
|
|
15
|
+
export { useR_ } from './components/rnwind-provider'
|
|
16
|
+
export type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'
|
|
17
|
+
export { useCss } from './hooks/use-css'
|
|
18
|
+
export { useInteract } from './hooks/use-interact'
|
|
19
|
+
export type { UseInteractResult } from './hooks/use-interact'
|
|
20
|
+
export { chainPress, chainFocus } from './chain-handlers'
|
|
21
|
+
export { InteractiveBox, InteractiveBox as _ib } from './interactive-box'
|
|
22
|
+
export type { InteractiveBoxProps, InteractiveSpec } from './interactive-box'
|
|
23
|
+
export { RnwindProvider, useRnwind } from './components/rnwind-provider'
|
|
24
|
+
export type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'
|
|
25
|
+
export { useMountHaptic, triggerHaptic, triggerHaptic as _ht, useMountHaptic as _hm } from './haptics'
|
|
26
|
+
|
|
27
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
28
|
+
// Internal aliases the babel transformer uses. Underscore-prefixed so
|
|
29
|
+
// user code (which imports the public names above) can never collide
|
|
30
|
+
// with what we inject at JSX sites — even if the user shadows
|
|
31
|
+
// `lookupCss` / `useHaptics` / `InteractiveBox` with a local symbol,
|
|
32
|
+
// the transformer's emitted code still references the private alias.
|
|
33
|
+
// Don't import these in app code.
|
|
34
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
35
|
+
/** @internal */
|
|
36
|
+
|
|
37
|
+
/** @internal */
|
|
38
|
+
|
|
39
|
+
/** @internal */
|
|
40
|
+
|
|
41
|
+
/** @internal */
|
|
42
|
+
|
|
43
|
+
export type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'
|
|
44
|
+
export type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'
|
|
45
|
+
export type { ThemeTable, ThemeTables } from '../core/types'
|
|
46
|
+
export { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'
|
|
47
|
+
export type { Scheme, RnwindConfig } from './types'
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Installed rnwind version, inlined at publish time. Compare against a pinned
|
|
51
|
+
* string when integrating with build tooling that may see multiple rnwind
|
|
52
|
+
* copies (e.g. workspace overrides).
|
|
53
|
+
*/
|
|
54
|
+
export const VERSION = '0.0.1' as const
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createElement, type ComponentType, type ElementType, type ReactElement } from 'react'
|
|
2
|
+
import { chainFocus, chainPress } from './chain-handlers'
|
|
3
|
+
import { useInteract } from './hooks/use-interact'
|
|
4
|
+
import { lookupCss, type HoistedClassName } from './lookup-css'
|
|
5
|
+
import type { RnwindState } from './components/rnwind-provider'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Per-element "interactive" spec the transformer packs into the `_rw`
|
|
9
|
+
* prop on every JSX site it rewrites for active/focus support. Carrying
|
|
10
|
+
* it as one object prop (rather than four sibling props) keeps the
|
|
11
|
+
* rewritten JSX legible and avoids colliding with any host component's
|
|
12
|
+
* own naming.
|
|
13
|
+
*/
|
|
14
|
+
export interface InteractiveSpec {
|
|
15
|
+
/** The original JSX tag (`Pressable`, `TextInput`, `Animated.View`, …). */
|
|
16
|
+
readonly as: ElementType
|
|
17
|
+
/** Hoisted atom-name array (or a dynamic classname string). */
|
|
18
|
+
readonly cn: HoistedClassName | string | null | undefined
|
|
19
|
+
/** Full rnwind context — `_t = useRnwind___()` from the call site. */
|
|
20
|
+
readonly t: RnwindState
|
|
21
|
+
/** Optional caller-supplied style forwarded as `lookupCss`'s 3rd arg. */
|
|
22
|
+
readonly us?: unknown
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Props InteractiveBox accepts — `_rw` plus anything to forward. */
|
|
26
|
+
export interface InteractiveBoxProps {
|
|
27
|
+
/** Compile-time spec packed by the transformer. */
|
|
28
|
+
readonly _rw: InteractiveSpec
|
|
29
|
+
/** Every other prop passes through to the inner component. */
|
|
30
|
+
readonly [key: string]: unknown
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Per-instance wrapper that drives `active:` / `focus:` variants. One
|
|
35
|
+
* `useInteract()` hook per mounted `InteractiveBox` means each element
|
|
36
|
+
* owns its own state — siblings never share `active` / `focus` flags.
|
|
37
|
+
*
|
|
38
|
+
* The transformer replaces
|
|
39
|
+
* `<Pressable className="active:bg-sky-700" onPress={x} />`
|
|
40
|
+
* with
|
|
41
|
+
* `<InteractiveBox _rw={{as: Pressable, cn: _c0, t: _t}} onPress={x} />`.
|
|
42
|
+
* @param props `_rw` spec + any props to forward to the inner component.
|
|
43
|
+
* @returns Rendered element of the inner component with interact wiring.
|
|
44
|
+
*/
|
|
45
|
+
export function InteractiveBox(props: InteractiveBoxProps): ReactElement {
|
|
46
|
+
const { _rw, onPressIn, onPressOut, onFocus, onBlur, ...rest } = props
|
|
47
|
+
const interact = useInteract()
|
|
48
|
+
const merged: Record<string, unknown> = {
|
|
49
|
+
...rest,
|
|
50
|
+
style: lookupCss(_rw.cn, _rw.t, _rw.us, interact.state),
|
|
51
|
+
onPressIn: chainPress(onPressIn as Parameters<typeof chainPress>[0], interact.onPressIn),
|
|
52
|
+
onPressOut: chainPress(onPressOut as Parameters<typeof chainPress>[0], interact.onPressOut),
|
|
53
|
+
onFocus: chainFocus(onFocus as Parameters<typeof chainFocus>[0], interact.onFocus),
|
|
54
|
+
onBlur: chainFocus(onBlur as Parameters<typeof chainFocus>[0], interact.onBlur),
|
|
55
|
+
}
|
|
56
|
+
return createElement(_rw.as as ComponentType<Record<string, unknown>>, merged)
|
|
57
|
+
}
|