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,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var rnwindProvider = require('./components/rnwind-provider.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Runtime helpers the transformer injects for haptic utilities.
|
|
8
|
+
*
|
|
9
|
+
* Two entry points:
|
|
10
|
+
*
|
|
11
|
+
* useMountHaptic(requests) — fires each request on mount via
|
|
12
|
+
* `useEffect(() => { ... }, [])`. Used by the transformer for bare
|
|
13
|
+
* `haptic-*` atoms (no variant prefix).
|
|
14
|
+
*
|
|
15
|
+
* triggerHaptic(onHaptics, request, trigger) — thin forwarding
|
|
16
|
+
* helper for event-driven variants (`active:haptic-*`, `focus:...`,
|
|
17
|
+
* `hover:...`). The transformer emits an inline arrow that calls
|
|
18
|
+
* this from `onPressIn` / `onFocus` / etc.
|
|
19
|
+
*
|
|
20
|
+
* Both emit a one-shot dev-mode warning when `onHaptics` is missing —
|
|
21
|
+
* so developers get a clear "you forgot to wire <SchemeProvider
|
|
22
|
+
* onHaptics=...>" signal instead of silently dropping the haptic.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Module-scope set tracking haptic trigger strings we've already
|
|
26
|
+
* warned about. Prevents the "missing onHaptics" warning from
|
|
27
|
+
* spamming the console when the same class appears on many elements.
|
|
28
|
+
*/
|
|
29
|
+
const WARNED_MISSING_HAPTICS = new Set();
|
|
30
|
+
/**
|
|
31
|
+
* Render a `HapticRequest` as a short descriptive tag for log lines.
|
|
32
|
+
* @param request Haptic request.
|
|
33
|
+
* @returns `impact/Light`, `notification/Success`, or `selection`.
|
|
34
|
+
*/
|
|
35
|
+
function hapticTag(request) {
|
|
36
|
+
if (request.kind === 'impact')
|
|
37
|
+
return `impact/${request.style}`;
|
|
38
|
+
if (request.kind === 'notification')
|
|
39
|
+
return `notification/${request.type}`;
|
|
40
|
+
return 'selection';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Warn once per haptic trigger kind when a `haptic-*` atom tries to
|
|
44
|
+
* dispatch without an `onHaptics` provider. Dev-mode only — `__DEV__`
|
|
45
|
+
* is a Metro / Expo / RN global that compiles to `false` in release
|
|
46
|
+
* bundles, so no warn code ships to production.
|
|
47
|
+
* @param request The haptic request that had no provider.
|
|
48
|
+
* @param trigger The lifecycle trigger that tried to fire.
|
|
49
|
+
*/
|
|
50
|
+
function warnMissingOnHaptics(request, trigger) {
|
|
51
|
+
// `__DEV__` is a RN / Metro global — `false` in release, strips the
|
|
52
|
+
// branch entirely. Guarded in case we're evaluated outside of Metro
|
|
53
|
+
// (tests, node scripts) where the global isn't defined.
|
|
54
|
+
const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__;
|
|
55
|
+
if (!isDevelopment)
|
|
56
|
+
return;
|
|
57
|
+
const tag = hapticTag(request);
|
|
58
|
+
const key = `${tag}@${trigger}`;
|
|
59
|
+
if (WARNED_MISSING_HAPTICS.has(key))
|
|
60
|
+
return;
|
|
61
|
+
WARNED_MISSING_HAPTICS.add(key);
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.warn(`rnwind: a haptic utility fired (${tag}, trigger=${trigger}) but no onHaptics callback is wired on <SchemeProvider>. ` +
|
|
64
|
+
`Pass \`onHaptics\` on the provider to forward this to expo-haptics (or any library of your choice).`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Invoke every request in `requests` on mount (once per component
|
|
68
|
+
* mount), using the `onHaptics` dispatcher from the nearest
|
|
69
|
+
* `<SchemeProvider>`. Missing-provider dev warnings fire via
|
|
70
|
+
* {@link warnMissingOnHaptics}.
|
|
71
|
+
*
|
|
72
|
+
* Uses `useEffect(..., [])` — the requests array is identity-stable
|
|
73
|
+
* (hoisted at module scope by the transformer), so re-firing on
|
|
74
|
+
* re-renders isn't a concern.
|
|
75
|
+
* @param requests Hoisted request list for this component.
|
|
76
|
+
*/
|
|
77
|
+
function useMountHaptic(requests) {
|
|
78
|
+
const { onHaptics } = rnwindProvider.useRnwind();
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
for (const request of requests) {
|
|
81
|
+
if (onHaptics)
|
|
82
|
+
onHaptics(request, 'mount');
|
|
83
|
+
else
|
|
84
|
+
warnMissingOnHaptics(request, 'mount');
|
|
85
|
+
}
|
|
86
|
+
// requests is a hoisted stable reference — depending on onHaptics
|
|
87
|
+
// identity keeps the effect fresh if the provider remounts with a
|
|
88
|
+
// different dispatcher, while the hoisted const prevents a remount
|
|
89
|
+
// from an inline `onHaptics={(r) => ...}`.
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
}, [onHaptics]);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Fire one haptic request through the provider dispatcher. Emits the
|
|
95
|
+
* missing-provider dev warning when no dispatcher is wired. Designed
|
|
96
|
+
* for the inline arrows the transformer synthesises:
|
|
97
|
+
*
|
|
98
|
+
* onPressIn={(e) => { triggerHaptic(_h, _HR_xxx, 'pressIn'); user?.(e) }}
|
|
99
|
+
* @param onHaptics Provider dispatcher (may be undefined).
|
|
100
|
+
* @param request Pre-hoisted request object.
|
|
101
|
+
* @param trigger Lifecycle trigger.
|
|
102
|
+
*/
|
|
103
|
+
function triggerHaptic(onHaptics, request, trigger) {
|
|
104
|
+
if (onHaptics) {
|
|
105
|
+
onHaptics(request, trigger);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
warnMissingOnHaptics(request, trigger);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
exports.triggerHaptic = triggerHaptic;
|
|
112
|
+
exports.useMountHaptic = useMountHaptic;
|
|
113
|
+
//# sourceMappingURL=haptics.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"haptics.cjs","sources":["../../../../src/runtime/haptics.ts"],"sourcesContent":["/**\n * Runtime helpers the transformer injects for haptic utilities.\n *\n * Two entry points:\n *\n * useMountHaptic(requests) — fires each request on mount via\n * `useEffect(() => { ... }, [])`. Used by the transformer for bare\n * `haptic-*` atoms (no variant prefix).\n *\n * triggerHaptic(onHaptics, request, trigger) — thin forwarding\n * helper for event-driven variants (`active:haptic-*`, `focus:...`,\n * `hover:...`). The transformer emits an inline arrow that calls\n * this from `onPressIn` / `onFocus` / etc.\n *\n * Both emit a one-shot dev-mode warning when `onHaptics` is missing —\n * so developers get a clear \"you forgot to wire <SchemeProvider\n * onHaptics=...>\" signal instead of silently dropping the haptic.\n */\n\nimport { useEffect } from 'react'\nimport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nimport { useRnwind } from './components/rnwind-provider'\n\n/**\n * Module-scope set tracking haptic trigger strings we've already\n * warned about. Prevents the \"missing onHaptics\" warning from\n * spamming the console when the same class appears on many elements.\n */\nconst WARNED_MISSING_HAPTICS = new Set<string>()\n\n/**\n * Render a `HapticRequest` as a short descriptive tag for log lines.\n * @param request Haptic request.\n * @returns `impact/Light`, `notification/Success`, or `selection`.\n */\nfunction hapticTag(request: HapticRequest): string {\n if (request.kind === 'impact') return `impact/${request.style}`\n if (request.kind === 'notification') return `notification/${request.type}`\n return 'selection'\n}\n\n/**\n * Warn once per haptic trigger kind when a `haptic-*` atom tries to\n * dispatch without an `onHaptics` provider. Dev-mode only — `__DEV__`\n * is a Metro / Expo / RN global that compiles to `false` in release\n * bundles, so no warn code ships to production.\n * @param request The haptic request that had no provider.\n * @param trigger The lifecycle trigger that tried to fire.\n */\nfunction warnMissingOnHaptics(request: HapticRequest, trigger: HapticTrigger): void {\n // `__DEV__` is a RN / Metro global — `false` in release, strips the\n // branch entirely. Guarded in case we're evaluated outside of Metro\n // (tests, node scripts) where the global isn't defined.\n const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__\n if (!isDevelopment) return\n const tag = hapticTag(request)\n const key = `${tag}@${trigger}`\n if (WARNED_MISSING_HAPTICS.has(key)) return\n WARNED_MISSING_HAPTICS.add(key)\n // eslint-disable-next-line no-console\n console.warn(\n `rnwind: a haptic utility fired (${tag}, trigger=${trigger}) but no onHaptics callback is wired on <SchemeProvider>. ` +\n `Pass \\`onHaptics\\` on the provider to forward this to expo-haptics (or any library of your choice).`,\n )\n}\n\n/**\n * Test-only hook — clears the warned-haptics set so successive test\n * runs don't silently swallow their own warnings.\n */\nfunction __resetHapticWarnings(): void {\n WARNED_MISSING_HAPTICS.clear()\n}\n\n/**\n * Invoke every request in `requests` on mount (once per component\n * mount), using the `onHaptics` dispatcher from the nearest\n * `<SchemeProvider>`. Missing-provider dev warnings fire via\n * {@link warnMissingOnHaptics}.\n *\n * Uses `useEffect(..., [])` — the requests array is identity-stable\n * (hoisted at module scope by the transformer), so re-firing on\n * re-renders isn't a concern.\n * @param requests Hoisted request list for this component.\n */\nfunction useMountHaptic(requests: readonly HapticRequest[]): void {\n const { onHaptics } = useRnwind()\n \n useEffect(() => {\n for (const request of requests) {\n if (onHaptics) onHaptics(request, 'mount')\n else warnMissingOnHaptics(request, 'mount')\n }\n // requests is a hoisted stable reference — depending on onHaptics\n // identity keeps the effect fresh if the provider remounts with a\n // different dispatcher, while the hoisted const prevents a remount\n // from an inline `onHaptics={(r) => ...}`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [onHaptics])\n}\n\n/**\n * Fire one haptic request through the provider dispatcher. Emits the\n * missing-provider dev warning when no dispatcher is wired. Designed\n * for the inline arrows the transformer synthesises:\n *\n * onPressIn={(e) => { triggerHaptic(_h, _HR_xxx, 'pressIn'); user?.(e) }}\n * @param onHaptics Provider dispatcher (may be undefined).\n * @param request Pre-hoisted request object.\n * @param trigger Lifecycle trigger.\n */\nfunction triggerHaptic(onHaptics: OnHaptics | undefined, request: HapticRequest, trigger: HapticTrigger): void {\n if (onHaptics) {\n onHaptics(request, trigger)\n return\n }\n warnMissingOnHaptics(request, trigger)\n}\n\nexport { useMountHaptic, triggerHaptic, __resetHapticWarnings }\n"],"names":["useRnwind","useEffect"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;AAiBG;AAMH;;;;AAIG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU;AAEhD;;;;AAIG;AACH,SAAS,SAAS,CAAC,OAAsB,EAAA;AACvC,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,CAAA,OAAA,EAAU,OAAO,CAAC,KAAK,EAAE;AAC/D,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc;AAAE,QAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAC,IAAI,EAAE;AAC1E,IAAA,OAAO,WAAW;AACpB;AAEA;;;;;;;AAOG;AACH,SAAS,oBAAoB,CAAC,OAAsB,EAAE,OAAsB,EAAA;;;;IAI1E,MAAM,aAAa,GAAG,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO;AAC/D,IAAA,IAAI,CAAC,aAAa;QAAE;AACpB,IAAA,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,GAAG,GAAG,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,OAAO,EAAE;AAC/B,IAAA,IAAI,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE;AACrC,IAAA,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC;;AAE/B,IAAA,OAAO,CAAC,IAAI,CACV,mCAAmC,GAAG,CAAA,UAAA,EAAa,OAAO,CAAA,0DAAA,CAA4D;AACpH,QAAA,CAAA,mGAAA,CAAqG,CACxG;AACH;AAUA;;;;;;;;;;AAUG;AACH,SAAS,cAAc,CAAC,QAAkC,EAAA;AACxD,IAAA,MAAM,EAAE,SAAS,EAAE,GAAGA,wBAAS,EAAE;IAEjCC,eAAS,CAAC,MAAK;AACb,QAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;AAC9B,YAAA,IAAI,SAAS;AAAE,gBAAA,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;;AACrC,gBAAA,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC;QAC7C;;;;;;AAMF,IAAA,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AACjB;AAEA;;;;;;;;;AASG;AACH,SAAS,aAAa,CAAC,SAAgC,EAAE,OAAsB,EAAE,OAAsB,EAAA;IACrG,IAAI,SAAS,EAAE;AACb,QAAA,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;QAC3B;IACF;AACA,IAAA,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC;AACxC;;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime helpers the transformer injects for haptic utilities.
|
|
3
|
+
*
|
|
4
|
+
* Two entry points:
|
|
5
|
+
*
|
|
6
|
+
* useMountHaptic(requests) — fires each request on mount via
|
|
7
|
+
* `useEffect(() => { ... }, [])`. Used by the transformer for bare
|
|
8
|
+
* `haptic-*` atoms (no variant prefix).
|
|
9
|
+
*
|
|
10
|
+
* triggerHaptic(onHaptics, request, trigger) — thin forwarding
|
|
11
|
+
* helper for event-driven variants (`active:haptic-*`, `focus:...`,
|
|
12
|
+
* `hover:...`). The transformer emits an inline arrow that calls
|
|
13
|
+
* this from `onPressIn` / `onFocus` / etc.
|
|
14
|
+
*
|
|
15
|
+
* Both emit a one-shot dev-mode warning when `onHaptics` is missing —
|
|
16
|
+
* so developers get a clear "you forgot to wire <SchemeProvider
|
|
17
|
+
* onHaptics=...>" signal instead of silently dropping the haptic.
|
|
18
|
+
*/
|
|
19
|
+
import type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics';
|
|
20
|
+
/**
|
|
21
|
+
* Test-only hook — clears the warned-haptics set so successive test
|
|
22
|
+
* runs don't silently swallow their own warnings.
|
|
23
|
+
*/
|
|
24
|
+
declare function __resetHapticWarnings(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Invoke every request in `requests` on mount (once per component
|
|
27
|
+
* mount), using the `onHaptics` dispatcher from the nearest
|
|
28
|
+
* `<SchemeProvider>`. Missing-provider dev warnings fire via
|
|
29
|
+
* {@link warnMissingOnHaptics}.
|
|
30
|
+
*
|
|
31
|
+
* Uses `useEffect(..., [])` — the requests array is identity-stable
|
|
32
|
+
* (hoisted at module scope by the transformer), so re-firing on
|
|
33
|
+
* re-renders isn't a concern.
|
|
34
|
+
* @param requests Hoisted request list for this component.
|
|
35
|
+
*/
|
|
36
|
+
declare function useMountHaptic(requests: readonly HapticRequest[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* Fire one haptic request through the provider dispatcher. Emits the
|
|
39
|
+
* missing-provider dev warning when no dispatcher is wired. Designed
|
|
40
|
+
* for the inline arrows the transformer synthesises:
|
|
41
|
+
*
|
|
42
|
+
* onPressIn={(e) => { triggerHaptic(_h, _HR_xxx, 'pressIn'); user?.(e) }}
|
|
43
|
+
* @param onHaptics Provider dispatcher (may be undefined).
|
|
44
|
+
* @param request Pre-hoisted request object.
|
|
45
|
+
* @param trigger Lifecycle trigger.
|
|
46
|
+
*/
|
|
47
|
+
declare function triggerHaptic(onHaptics: OnHaptics | undefined, request: HapticRequest, trigger: HapticTrigger): void;
|
|
48
|
+
export { useMountHaptic, triggerHaptic, __resetHapticWarnings };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var rnwindProvider = require('../components/rnwind-provider.cjs');
|
|
4
|
+
var lookupCss = require('../lookup-css.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use
|
|
8
|
+
* inside any component that wants the resolved style array without
|
|
9
|
+
* threading the rnwind context manually. JSX-heavy components should
|
|
10
|
+
* still call `useRnwind()` once and pass it to `lookupCss(...)` per
|
|
11
|
+
* element so React only does a single context read per render.
|
|
12
|
+
* @param className Raw className string or transformer-hoisted atom-name array.
|
|
13
|
+
* @param userStyle Optional caller-supplied style appended last.
|
|
14
|
+
* @returns Frozen style array for React Native's `style` prop.
|
|
15
|
+
*/
|
|
16
|
+
function useCss(className, userStyle) {
|
|
17
|
+
return lookupCss.lookupCss(className, rnwindProvider.useRnwind(), userStyle);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.useCss = useCss;
|
|
21
|
+
//# sourceMappingURL=use-css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-css.cjs","sources":["../../../../../src/runtime/hooks/use-css.ts"],"sourcesContent":["import { useRnwind } from '../components/rnwind-provider'\nimport { lookupCss } from '../lookup-css'\n\n/**\n * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use\n * inside any component that wants the resolved style array without\n * threading the rnwind context manually. JSX-heavy components should\n * still call `useRnwind()` once and pass it to `lookupCss(...)` per\n * element so React only does a single context read per render.\n * @param className Raw className string or transformer-hoisted atom-name array.\n * @param userStyle Optional caller-supplied style appended last.\n * @returns Frozen style array for React Native's `style` prop.\n */\nexport function useCss(className?: string | readonly string[] | null, userStyle?: unknown): readonly unknown[] {\n return lookupCss(className, useRnwind(), userStyle)\n}\n"],"names":["lookupCss","useRnwind"],"mappings":";;;;;AAGA;;;;;;;;;AASG;AACG,SAAU,MAAM,CAAC,SAA6C,EAAE,SAAmB,EAAA;IACvF,OAAOA,mBAAS,CAAC,SAAS,EAAEC,wBAAS,EAAE,EAAE,SAAS,CAAC;AACrD;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use
|
|
3
|
+
* inside any component that wants the resolved style array without
|
|
4
|
+
* threading the rnwind context manually. JSX-heavy components should
|
|
5
|
+
* still call `useRnwind()` once and pass it to `lookupCss(...)` per
|
|
6
|
+
* element so React only does a single context read per render.
|
|
7
|
+
* @param className Raw className string or transformer-hoisted atom-name array.
|
|
8
|
+
* @param userStyle Optional caller-supplied style appended last.
|
|
9
|
+
* @returns Frozen style array for React Native's `style` prop.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useCss(className?: string | readonly string[] | null, userStyle?: unknown): readonly unknown[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
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 = { active: false, focus: false };
|
|
12
|
+
/**
|
|
13
|
+
* React hook driving `active:` / `focus:` variants at runtime. The
|
|
14
|
+
* transformer injects exactly one call per JSX element that uses an
|
|
15
|
+
* interactive classname, caching the hook's result into a component-
|
|
16
|
+
* local `_i` binding so every `lookupCss(…, _i.state)` site shares the
|
|
17
|
+
* same snapshot per render.
|
|
18
|
+
*
|
|
19
|
+
* React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch
|
|
20
|
+
* down / release — the touch-device analogue of CSS `:active`. Text
|
|
21
|
+
* fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;
|
|
22
|
+
* unused handlers on elements that don't emit the corresponding event
|
|
23
|
+
* are harmless no-ops.
|
|
24
|
+
*
|
|
25
|
+
* Result stability: both `state` and the returned wrapper object stay
|
|
26
|
+
* reference-equal across renders unless `active` / `focus` actually
|
|
27
|
+
* flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.
|
|
28
|
+
* @returns Stable state + handler bundle.
|
|
29
|
+
*/
|
|
30
|
+
function useInteract() {
|
|
31
|
+
const [active, setActive] = React.useState(false);
|
|
32
|
+
const [focus, setFocus] = React.useState(false);
|
|
33
|
+
const onPressIn = React.useCallback(() => setActive(true), []);
|
|
34
|
+
const onPressOut = React.useCallback(() => setActive(false), []);
|
|
35
|
+
const onFocus = React.useCallback(() => setFocus(true), []);
|
|
36
|
+
const onBlur = React.useCallback(() => setFocus(false), []);
|
|
37
|
+
const state = React.useMemo(() => {
|
|
38
|
+
if (!active && !focus)
|
|
39
|
+
return IDLE_STATE;
|
|
40
|
+
return { active, focus };
|
|
41
|
+
}, [active, focus]);
|
|
42
|
+
return React.useMemo(() => ({ state, onPressIn, onPressOut, onFocus, onBlur }), [state, onPressIn, onPressOut, onFocus, onBlur]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.useInteract = useInteract;
|
|
46
|
+
//# sourceMappingURL=use-interact.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-interact.cjs","sources":["../../../../../src/runtime/hooks/use-interact.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react'\nimport type { GestureResponderEvent, NativeSyntheticEvent, TargetedEvent } from 'react-native'\nimport type { InteractState } from '../lookup-css'\n\n/**\n * Idle state reference reused across every non-interactive render —\n * when neither `active` nor `focus` is true, every call site returns\n * the exact same object. That's the ~99 % path for a typical list row,\n * so sharing the ref is a legitimate allocation elimination.\n */\nconst IDLE_STATE: InteractState = { active: false, focus: false }\n\n/**\n * Live interact-state snapshot plus the press/focus handlers the\n * transformer wires onto the JSX opening element. The state object is\n * referentially stable across renders when the underlying `active` /\n * `focus` flags don't change, which keeps `lookupCss` cache hits\n * aligned with React's render cadence (same state ref → same\n * resolved-array cache key → same reference back, no React diff\n * triggered).\n */\nexport interface UseInteractResult {\n /** Current interact flags — forwarded as the 4th arg to `lookupCss`. */\n state: InteractState\n /** Wired by the transformer onto `<Pressable onPressIn={…}>` etc. */\n onPressIn: (event: GestureResponderEvent) => void\n /** Wired by the transformer onto `<Pressable onPressOut={…}>` etc. */\n onPressOut: (event: GestureResponderEvent) => void\n /** Wired by the transformer onto `<TextInput onFocus={…}>` etc. */\n onFocus: (event: NativeSyntheticEvent<TargetedEvent>) => void\n /** Wired by the transformer onto `<TextInput onBlur={…}>` etc. */\n onBlur: (event: NativeSyntheticEvent<TargetedEvent>) => void\n}\n\n/**\n * React hook driving `active:` / `focus:` variants at runtime. The\n * transformer injects exactly one call per JSX element that uses an\n * interactive classname, caching the hook's result into a component-\n * local `_i` binding so every `lookupCss(…, _i.state)` site shares the\n * same snapshot per render.\n *\n * React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch\n * down / release — the touch-device analogue of CSS `:active`. Text\n * fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;\n * unused handlers on elements that don't emit the corresponding event\n * are harmless no-ops.\n *\n * Result stability: both `state` and the returned wrapper object stay\n * reference-equal across renders unless `active` / `focus` actually\n * flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.\n * @returns Stable state + handler bundle.\n */\nexport function useInteract(): UseInteractResult {\n const [active, setActive] = useState(false)\n const [focus, setFocus] = useState(false)\n const onPressIn = useCallback(() => setActive(true), [])\n const onPressOut = useCallback(() => setActive(false), [])\n const onFocus = useCallback(() => setFocus(true), [])\n const onBlur = useCallback(() => setFocus(false), [])\n const state = useMemo<InteractState>(() => {\n if (!active && !focus) return IDLE_STATE\n return { active, focus }\n }, [active, focus])\n return useMemo(() => ({ state, onPressIn, onPressOut, onFocus, onBlur }), [state, onPressIn, onPressOut, onFocus, onBlur])\n}\n"],"names":["useState","useCallback","useMemo"],"mappings":";;;;AAIA;;;;;AAKG;AACH,MAAM,UAAU,GAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;AAwBjE;;;;;;;;;;;;;;;;;AAiBG;SACa,WAAW,GAAA;IACzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;AACzC,IAAA,MAAM,SAAS,GAAGC,iBAAW,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AACxD,IAAA,MAAM,UAAU,GAAGA,iBAAW,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAGA,iBAAW,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AACrD,IAAA,MAAM,MAAM,GAAGA,iBAAW,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;AACrD,IAAA,MAAM,KAAK,GAAGC,aAAO,CAAgB,MAAK;AACxC,QAAA,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK;AAAE,YAAA,OAAO,UAAU;AACxC,QAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;AAC1B,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACnB,IAAA,OAAOA,aAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC5H;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { GestureResponderEvent, NativeSyntheticEvent, TargetedEvent } from 'react-native';
|
|
2
|
+
import type { InteractState } from '../lookup-css';
|
|
3
|
+
/**
|
|
4
|
+
* Live interact-state snapshot plus the press/focus handlers the
|
|
5
|
+
* transformer wires onto the JSX opening element. The state object is
|
|
6
|
+
* referentially stable across renders when the underlying `active` /
|
|
7
|
+
* `focus` flags don't change, which keeps `lookupCss` cache hits
|
|
8
|
+
* aligned with React's render cadence (same state ref → same
|
|
9
|
+
* resolved-array cache key → same reference back, no React diff
|
|
10
|
+
* triggered).
|
|
11
|
+
*/
|
|
12
|
+
export interface UseInteractResult {
|
|
13
|
+
/** Current interact flags — forwarded as the 4th arg to `lookupCss`. */
|
|
14
|
+
state: InteractState;
|
|
15
|
+
/** Wired by the transformer onto `<Pressable onPressIn={…}>` etc. */
|
|
16
|
+
onPressIn: (event: GestureResponderEvent) => void;
|
|
17
|
+
/** Wired by the transformer onto `<Pressable onPressOut={…}>` etc. */
|
|
18
|
+
onPressOut: (event: GestureResponderEvent) => void;
|
|
19
|
+
/** Wired by the transformer onto `<TextInput onFocus={…}>` etc. */
|
|
20
|
+
onFocus: (event: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
21
|
+
/** Wired by the transformer onto `<TextInput onBlur={…}>` etc. */
|
|
22
|
+
onBlur: (event: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* React hook driving `active:` / `focus:` variants at runtime. The
|
|
26
|
+
* transformer injects exactly one call per JSX element that uses an
|
|
27
|
+
* interactive classname, caching the hook's result into a component-
|
|
28
|
+
* local `_i` binding so every `lookupCss(…, _i.state)` site shares the
|
|
29
|
+
* same snapshot per render.
|
|
30
|
+
*
|
|
31
|
+
* React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch
|
|
32
|
+
* down / release — the touch-device analogue of CSS `:active`. Text
|
|
33
|
+
* fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;
|
|
34
|
+
* unused handlers on elements that don't emit the corresponding event
|
|
35
|
+
* are harmless no-ops.
|
|
36
|
+
*
|
|
37
|
+
* Result stability: both `state` and the returned wrapper object stay
|
|
38
|
+
* reference-equal across renders unless `active` / `focus` actually
|
|
39
|
+
* flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.
|
|
40
|
+
* @returns Stable state + handler bundle.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useInteract(): UseInteractResult;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var rnwindProvider = require('../components/rnwind-provider.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Synthetic scheme name applied when tokens aren't declared under any
|
|
7
|
+
* `@variant` block — the "no active variant" fallback every theme table
|
|
8
|
+
* inherits from.
|
|
9
|
+
*/
|
|
10
|
+
const BASE_SCHEME = 'base';
|
|
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
|
+
function useTheme() {
|
|
22
|
+
const { scheme, tables } = rnwindProvider.useRnwind();
|
|
23
|
+
const base = tables[BASE_SCHEME] ?? {};
|
|
24
|
+
const schemeTable = tables[scheme];
|
|
25
|
+
if (!schemeTable)
|
|
26
|
+
return base;
|
|
27
|
+
// Fast path: nothing to merge when the scheme table is empty.
|
|
28
|
+
if (Object.keys(schemeTable).length === 0)
|
|
29
|
+
return base;
|
|
30
|
+
return { ...base, ...schemeTable };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read a raw CSS custom property's value for the active scheme. Accepts
|
|
34
|
+
* either `--foo` or the bare `foo` form for convenience.
|
|
35
|
+
* @param cssVariable CSS custom property name (with or without the leading `--`).
|
|
36
|
+
* @returns The resolved value, or undefined when the token is missing.
|
|
37
|
+
*/
|
|
38
|
+
function useToken(cssVariable) {
|
|
39
|
+
const table = useTheme();
|
|
40
|
+
const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`;
|
|
41
|
+
return table[name];
|
|
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
|
+
function useColor(name) {
|
|
51
|
+
const value = useToken(`--color-${name}`);
|
|
52
|
+
return typeof value === 'string' ? value : undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Read a spacing token by shorthand name — `useSize('4')` resolves
|
|
56
|
+
* `--spacing-4` for the active scheme.
|
|
57
|
+
* @param name Token suffix after `--spacing-`.
|
|
58
|
+
* @returns Resolved spacing value, or undefined when the token is missing.
|
|
59
|
+
*/
|
|
60
|
+
function useSize(name) {
|
|
61
|
+
return useToken(`--spacing-${name}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.useColor = useColor;
|
|
65
|
+
exports.useSize = useSize;
|
|
66
|
+
exports.useTheme = useTheme;
|
|
67
|
+
exports.useToken = useToken;
|
|
68
|
+
//# sourceMappingURL=use-scheme.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-scheme.cjs","sources":["../../../../../src/runtime/hooks/use-scheme.ts"],"sourcesContent":["import type { ThemeTable } from '../../core/types'\nimport { useRnwind } from '../components/rnwind-provider'\n\n/**\n * Synthetic scheme name applied when tokens aren't declared under any\n * `@variant` block — the \"no active variant\" fallback every theme table\n * inherits from.\n */\nconst BASE_SCHEME = 'base'\n\n/**\n * Access the resolved theme table for the active scheme.\n *\n * Tokens declared outside any `@variant` block live in the `base` table and\n * should apply everywhere — just like the CSS cascade treats `:root` as a\n * default for every ancestor-scoped override. We merge `base` under the\n * active scheme so a scheme that doesn't declare a token still sees the\n * base default, while the scheme's own entries win on overlap.\n * @returns Token table for the active scheme.\n */\nexport function useTheme(): ThemeTable {\n const { scheme, tables } = useRnwind()\n const base = tables[BASE_SCHEME] ?? {}\n const schemeTable = tables[scheme]\n if (!schemeTable) return base\n // Fast path: nothing to merge when the scheme table is empty.\n if (Object.keys(schemeTable).length === 0) return base\n return { ...base, ...schemeTable }\n}\n\n/**\n * Read a raw CSS custom property's value for the active scheme. Accepts\n * either `--foo` or the bare `foo` form for convenience.\n * @param cssVariable CSS custom property name (with or without the leading `--`).\n * @returns The resolved value, or undefined when the token is missing.\n */\nexport function useToken(cssVariable: string): string | number | undefined {\n const table = useTheme()\n const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`\n return table[name]\n}\n\n/**\n * Read a color token by shorthand name — `useColor('primary')` resolves\n * `--color-primary` for the active scheme.\n * @param name Token suffix after `--color-`.\n * @returns Resolved color string, or undefined when the token is missing\n * or its value isn't a string.\n */\nexport function useColor(name: string): string | undefined {\n const value = useToken(`--color-${name}`)\n return typeof value === 'string' ? value : undefined\n}\n\n/**\n * Read a spacing token by shorthand name — `useSize('4')` resolves\n * `--spacing-4` for the active scheme.\n * @param name Token suffix after `--spacing-`.\n * @returns Resolved spacing value, or undefined when the token is missing.\n */\nexport function useSize(name: string): number | string | undefined {\n return useToken(`--spacing-${name}`)\n}\n"],"names":["useRnwind"],"mappings":";;;;AAGA;;;;AAIG;AACH,MAAM,WAAW,GAAG,MAAM;AAE1B;;;;;;;;;AASG;SACa,QAAQ,GAAA;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAGA,wBAAS,EAAE;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;AACtC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;AAClC,IAAA,IAAI,CAAC,WAAW;AAAE,QAAA,OAAO,IAAI;;IAE7B,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACtD,IAAA,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,EAAE;AACpC;AAEA;;;;;AAKG;AACG,SAAU,QAAQ,CAAC,WAAmB,EAAA;AAC1C,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;AACxB,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,CAAA,EAAA,EAAK,WAAW,EAAE;AAC5E,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB;AAEA;;;;;;AAMG;AACG,SAAU,QAAQ,CAAC,IAAY,EAAA;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,IAAI,CAAA,CAAE,CAAC;AACzC,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,SAAS;AACtD;AAEA;;;;;AAKG;AACG,SAAU,OAAO,CAAC,IAAY,EAAA;AAClC,IAAA,OAAO,QAAQ,CAAC,CAAA,UAAA,EAAa,IAAI,CAAA,CAAE,CAAC;AACtC;;;;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ThemeTable } from '../../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Access the resolved theme table for the active scheme.
|
|
4
|
+
*
|
|
5
|
+
* Tokens declared outside any `@variant` block live in the `base` table and
|
|
6
|
+
* should apply everywhere — just like the CSS cascade treats `:root` as a
|
|
7
|
+
* default for every ancestor-scoped override. We merge `base` under the
|
|
8
|
+
* active scheme so a scheme that doesn't declare a token still sees the
|
|
9
|
+
* base default, while the scheme's own entries win on overlap.
|
|
10
|
+
* @returns Token table for the active scheme.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useTheme(): ThemeTable;
|
|
13
|
+
/**
|
|
14
|
+
* Read a raw CSS custom property's value for the active scheme. Accepts
|
|
15
|
+
* either `--foo` or the bare `foo` form for convenience.
|
|
16
|
+
* @param cssVariable CSS custom property name (with or without the leading `--`).
|
|
17
|
+
* @returns The resolved value, or undefined when the token is missing.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useToken(cssVariable: string): string | number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Read a color token by shorthand name — `useColor('primary')` resolves
|
|
22
|
+
* `--color-primary` for the active scheme.
|
|
23
|
+
* @param name Token suffix after `--color-`.
|
|
24
|
+
* @returns Resolved color string, or undefined when the token is missing
|
|
25
|
+
* or its value isn't a string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useColor(name: string): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Read a spacing token by shorthand name — `useSize('4')` resolves
|
|
30
|
+
* `--spacing-4` for the active scheme.
|
|
31
|
+
* @param name Token suffix after `--spacing-`.
|
|
32
|
+
* @returns Resolved spacing value, or undefined when the token is missing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useSize(name: string): number | string | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lookupCss = require('./lookup-css.cjs');
|
|
4
|
+
var rnwindProvider = require('./components/rnwind-provider.cjs');
|
|
5
|
+
var useCss = require('./hooks/use-css.cjs');
|
|
6
|
+
var useInteract = require('./hooks/use-interact.cjs');
|
|
7
|
+
var chainHandlers = require('./chain-handlers.cjs');
|
|
8
|
+
var interactiveBox = require('./interactive-box.cjs');
|
|
9
|
+
var haptics = require('./haptics.cjs');
|
|
10
|
+
var useScheme = require('./hooks/use-scheme.cjs');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Installed rnwind version, inlined at publish time. Compare against a pinned
|
|
14
|
+
* string when integrating with build tooling that may see multiple rnwind
|
|
15
|
+
* copies (e.g. workspace overrides).
|
|
16
|
+
*/
|
|
17
|
+
const VERSION = '0.0.1';
|
|
18
|
+
|
|
19
|
+
exports._l = lookupCss.lookupCss;
|
|
20
|
+
exports.activeBreakpointFor = lookupCss.activeBreakpointFor;
|
|
21
|
+
exports.getBreakpoints = lookupCss.getBreakpoints;
|
|
22
|
+
exports.lookupCss = lookupCss.lookupCss;
|
|
23
|
+
exports.registerAtoms = lookupCss.registerAtoms;
|
|
24
|
+
exports.registerBreakpoints = lookupCss.registerBreakpoints;
|
|
25
|
+
exports.registerSchemeLoader = lookupCss.registerSchemeLoader;
|
|
26
|
+
exports.setWindowHeightProvider = lookupCss.setWindowHeightProvider;
|
|
27
|
+
exports.RnwindProvider = rnwindProvider.RnwindProvider;
|
|
28
|
+
exports.useR_ = rnwindProvider.useR_;
|
|
29
|
+
exports.useRnwind = rnwindProvider.useRnwind;
|
|
30
|
+
exports.useCss = useCss.useCss;
|
|
31
|
+
exports.useInteract = useInteract.useInteract;
|
|
32
|
+
exports.chainFocus = chainHandlers.chainFocus;
|
|
33
|
+
exports.chainPress = chainHandlers.chainPress;
|
|
34
|
+
exports.InteractiveBox = interactiveBox.InteractiveBox;
|
|
35
|
+
exports._ib = interactiveBox.InteractiveBox;
|
|
36
|
+
exports._hm = haptics.useMountHaptic;
|
|
37
|
+
exports._ht = haptics.triggerHaptic;
|
|
38
|
+
exports.triggerHaptic = haptics.triggerHaptic;
|
|
39
|
+
exports.useMountHaptic = haptics.useMountHaptic;
|
|
40
|
+
exports.useColor = useScheme.useColor;
|
|
41
|
+
exports.useSize = useScheme.useSize;
|
|
42
|
+
exports.useTheme = useScheme.useTheme;
|
|
43
|
+
exports.useToken = useScheme.useToken;
|
|
44
|
+
exports.VERSION = VERSION;
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/runtime/index.ts"],"sourcesContent":["\n\n\n\nexport {\n lookupCss,\n registerAtoms,\n registerBreakpoints,\n registerSchemeLoader,\n setWindowHeightProvider,\n getBreakpoints,\n activeBreakpointFor,\n lookupCss as _l,\n} from './lookup-css'\nexport { useR_ } from './components/rnwind-provider'\nexport type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css'\nexport { useCss } from './hooks/use-css'\nexport { useInteract } from './hooks/use-interact'\nexport type { UseInteractResult } from './hooks/use-interact'\nexport { chainPress, chainFocus } from './chain-handlers'\nexport { InteractiveBox, InteractiveBox as _ib } from './interactive-box'\nexport type { InteractiveBoxProps, InteractiveSpec } from './interactive-box'\nexport { RnwindProvider, useRnwind } from './components/rnwind-provider'\nexport type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider'\nexport { useMountHaptic, triggerHaptic, triggerHaptic as _ht, useMountHaptic as _hm } from './haptics'\n\n// ──────────────────────────────────────────────────────────────────────\n// Internal aliases the babel transformer uses. Underscore-prefixed so\n// user code (which imports the public names above) can never collide\n// with what we inject at JSX sites — even if the user shadows\n// `lookupCss` / `useHaptics` / `InteractiveBox` with a local symbol,\n// the transformer's emitted code still references the private alias.\n// Don't import these in app code.\n// ──────────────────────────────────────────────────────────────────────\n/** @internal */\n\n/** @internal */\n\n/** @internal */\n\n/** @internal */\n\nexport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nexport type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types'\nexport type { ThemeTable, ThemeTables } from '../core/types'\nexport { useTheme, useToken, useColor, useSize } from './hooks/use-scheme'\nexport type { Scheme, RnwindConfig } from './types'\n\n/**\n * Installed rnwind version, inlined at publish time. Compare against a pinned\n * string when integrating with build tooling that may see multiple rnwind\n * copies (e.g. workspace overrides).\n */\nexport const VERSION = '0.0.1' as const\n"],"names":[],"mappings":";;;;;;;;;;;AAgDA;;;;AAIG;AACI,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, lookupCss as _l, } from './lookup-css';
|
|
2
|
+
export { useR_ } from './components/rnwind-provider';
|
|
3
|
+
export type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css';
|
|
4
|
+
export { useCss } from './hooks/use-css';
|
|
5
|
+
export { useInteract } from './hooks/use-interact';
|
|
6
|
+
export type { UseInteractResult } from './hooks/use-interact';
|
|
7
|
+
export { chainPress, chainFocus } from './chain-handlers';
|
|
8
|
+
export { InteractiveBox, InteractiveBox as _ib } from './interactive-box';
|
|
9
|
+
export type { InteractiveBoxProps, InteractiveSpec } from './interactive-box';
|
|
10
|
+
export { RnwindProvider, useRnwind } from './components/rnwind-provider';
|
|
11
|
+
export type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider';
|
|
12
|
+
export { useMountHaptic, triggerHaptic, triggerHaptic as _ht, useMountHaptic as _hm } from './haptics';
|
|
13
|
+
/** @internal */
|
|
14
|
+
/** @internal */
|
|
15
|
+
/** @internal */
|
|
16
|
+
/** @internal */
|
|
17
|
+
export type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics';
|
|
18
|
+
export type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types';
|
|
19
|
+
export type { ThemeTable, ThemeTables } from '../core/types';
|
|
20
|
+
export { useTheme, useToken, useColor, useSize } from './hooks/use-scheme';
|
|
21
|
+
export type { Scheme, RnwindConfig } from './types';
|
|
22
|
+
/**
|
|
23
|
+
* Installed rnwind version, inlined at publish time. Compare against a pinned
|
|
24
|
+
* string when integrating with build tooling that may see multiple rnwind
|
|
25
|
+
* copies (e.g. workspace overrides).
|
|
26
|
+
*/
|
|
27
|
+
export declare const VERSION: "0.0.1";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var chainHandlers = require('./chain-handlers.cjs');
|
|
5
|
+
var useInteract = require('./hooks/use-interact.cjs');
|
|
6
|
+
var lookupCss = require('./lookup-css.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Per-instance wrapper that drives `active:` / `focus:` variants. One
|
|
10
|
+
* `useInteract()` hook per mounted `InteractiveBox` means each element
|
|
11
|
+
* owns its own state — siblings never share `active` / `focus` flags.
|
|
12
|
+
*
|
|
13
|
+
* The transformer replaces
|
|
14
|
+
* `<Pressable className="active:bg-sky-700" onPress={x} />`
|
|
15
|
+
* with
|
|
16
|
+
* `<InteractiveBox _rw={{as: Pressable, cn: _c0, t: _t}} onPress={x} />`.
|
|
17
|
+
* @param props `_rw` spec + any props to forward to the inner component.
|
|
18
|
+
* @returns Rendered element of the inner component with interact wiring.
|
|
19
|
+
*/
|
|
20
|
+
function InteractiveBox(props) {
|
|
21
|
+
const { _rw, onPressIn, onPressOut, onFocus, onBlur, ...rest } = props;
|
|
22
|
+
const interact = useInteract.useInteract();
|
|
23
|
+
const merged = {
|
|
24
|
+
...rest,
|
|
25
|
+
style: lookupCss.lookupCss(_rw.cn, _rw.t, _rw.us, interact.state),
|
|
26
|
+
onPressIn: chainHandlers.chainPress(onPressIn, interact.onPressIn),
|
|
27
|
+
onPressOut: chainHandlers.chainPress(onPressOut, interact.onPressOut),
|
|
28
|
+
onFocus: chainHandlers.chainFocus(onFocus, interact.onFocus),
|
|
29
|
+
onBlur: chainHandlers.chainFocus(onBlur, interact.onBlur),
|
|
30
|
+
};
|
|
31
|
+
return React.createElement(_rw.as, merged);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.InteractiveBox = InteractiveBox;
|
|
35
|
+
//# sourceMappingURL=interactive-box.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive-box.cjs","sources":["../../../../src/runtime/interactive-box.tsx"],"sourcesContent":["import { createElement, type ComponentType, type ElementType, type ReactElement } from 'react'\nimport { chainFocus, chainPress } from './chain-handlers'\nimport { useInteract } from './hooks/use-interact'\nimport { lookupCss, type HoistedClassName } from './lookup-css'\nimport type { RnwindState } from './components/rnwind-provider'\n\n/**\n * Per-element \"interactive\" spec the transformer packs into the `_rw`\n * prop on every JSX site it rewrites for active/focus support. Carrying\n * it as one object prop (rather than four sibling props) keeps the\n * rewritten JSX legible and avoids colliding with any host component's\n * own naming.\n */\nexport interface InteractiveSpec {\n /** The original JSX tag (`Pressable`, `TextInput`, `Animated.View`, …). */\n readonly as: ElementType\n /** Hoisted atom-name array (or a dynamic classname string). */\n readonly cn: HoistedClassName | string | null | undefined\n /** Full rnwind context — `_t = useRnwind___()` from the call site. */\n readonly t: RnwindState\n /** Optional caller-supplied style forwarded as `lookupCss`'s 3rd arg. */\n readonly us?: unknown\n}\n\n/** Props InteractiveBox accepts — `_rw` plus anything to forward. */\nexport interface InteractiveBoxProps {\n /** Compile-time spec packed by the transformer. */\n readonly _rw: InteractiveSpec\n /** Every other prop passes through to the inner component. */\n readonly [key: string]: unknown\n}\n\n/**\n * Per-instance wrapper that drives `active:` / `focus:` variants. One\n * `useInteract()` hook per mounted `InteractiveBox` means each element\n * owns its own state — siblings never share `active` / `focus` flags.\n *\n * The transformer replaces\n * `<Pressable className=\"active:bg-sky-700\" onPress={x} />`\n * with\n * `<InteractiveBox _rw={{as: Pressable, cn: _c0, t: _t}} onPress={x} />`.\n * @param props `_rw` spec + any props to forward to the inner component.\n * @returns Rendered element of the inner component with interact wiring.\n */\nexport function InteractiveBox(props: InteractiveBoxProps): ReactElement {\n const { _rw, onPressIn, onPressOut, onFocus, onBlur, ...rest } = props\n const interact = useInteract()\n const merged: Record<string, unknown> = {\n ...rest,\n style: lookupCss(_rw.cn, _rw.t, _rw.us, interact.state),\n onPressIn: chainPress(onPressIn as Parameters<typeof chainPress>[0], interact.onPressIn),\n onPressOut: chainPress(onPressOut as Parameters<typeof chainPress>[0], interact.onPressOut),\n onFocus: chainFocus(onFocus as Parameters<typeof chainFocus>[0], interact.onFocus),\n onBlur: chainFocus(onBlur as Parameters<typeof chainFocus>[0], interact.onBlur),\n }\n return createElement(_rw.as as ComponentType<Record<string, unknown>>, merged)\n}\n"],"names":["useInteract","lookupCss","chainPress","chainFocus","createElement"],"mappings":";;;;;;;AAgCA;;;;;;;;;;;AAWG;AACG,SAAU,cAAc,CAAC,KAA0B,EAAA;AACvD,IAAA,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK;AACtE,IAAA,MAAM,QAAQ,GAAGA,uBAAW,EAAE;AAC9B,IAAA,MAAM,MAAM,GAA4B;AACtC,QAAA,GAAG,IAAI;AACP,QAAA,KAAK,EAAEC,mBAAS,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC;QACvD,SAAS,EAAEC,wBAAU,CAAC,SAA6C,EAAE,QAAQ,CAAC,SAAS,CAAC;QACxF,UAAU,EAAEA,wBAAU,CAAC,UAA8C,EAAE,QAAQ,CAAC,UAAU,CAAC;QAC3F,OAAO,EAAEC,wBAAU,CAAC,OAA2C,EAAE,QAAQ,CAAC,OAAO,CAAC;QAClF,MAAM,EAAEA,wBAAU,CAAC,MAA0C,EAAE,QAAQ,CAAC,MAAM,CAAC;KAChF;IACD,OAAOC,mBAAa,CAAC,GAAG,CAAC,EAA4C,EAAE,MAAM,CAAC;AAChF;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ElementType, type ReactElement } from 'react';
|
|
2
|
+
import { type HoistedClassName } from './lookup-css';
|
|
3
|
+
import type { RnwindState } from './components/rnwind-provider';
|
|
4
|
+
/**
|
|
5
|
+
* Per-element "interactive" spec the transformer packs into the `_rw`
|
|
6
|
+
* prop on every JSX site it rewrites for active/focus support. Carrying
|
|
7
|
+
* it as one object prop (rather than four sibling props) keeps the
|
|
8
|
+
* rewritten JSX legible and avoids colliding with any host component's
|
|
9
|
+
* own naming.
|
|
10
|
+
*/
|
|
11
|
+
export interface InteractiveSpec {
|
|
12
|
+
/** The original JSX tag (`Pressable`, `TextInput`, `Animated.View`, …). */
|
|
13
|
+
readonly as: ElementType;
|
|
14
|
+
/** Hoisted atom-name array (or a dynamic classname string). */
|
|
15
|
+
readonly cn: HoistedClassName | string | null | undefined;
|
|
16
|
+
/** Full rnwind context — `_t = useRnwind___()` from the call site. */
|
|
17
|
+
readonly t: RnwindState;
|
|
18
|
+
/** Optional caller-supplied style forwarded as `lookupCss`'s 3rd arg. */
|
|
19
|
+
readonly us?: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** Props InteractiveBox accepts — `_rw` plus anything to forward. */
|
|
22
|
+
export interface InteractiveBoxProps {
|
|
23
|
+
/** Compile-time spec packed by the transformer. */
|
|
24
|
+
readonly _rw: InteractiveSpec;
|
|
25
|
+
/** Every other prop passes through to the inner component. */
|
|
26
|
+
readonly [key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Per-instance wrapper that drives `active:` / `focus:` variants. One
|
|
30
|
+
* `useInteract()` hook per mounted `InteractiveBox` means each element
|
|
31
|
+
* owns its own state — siblings never share `active` / `focus` flags.
|
|
32
|
+
*
|
|
33
|
+
* The transformer replaces
|
|
34
|
+
* `<Pressable className="active:bg-sky-700" onPress={x} />`
|
|
35
|
+
* with
|
|
36
|
+
* `<InteractiveBox _rw={{as: Pressable, cn: _c0, t: _t}} onPress={x} />`.
|
|
37
|
+
* @param props `_rw` spec + any props to forward to the inner component.
|
|
38
|
+
* @returns Rendered element of the inner component with interact wiring.
|
|
39
|
+
*/
|
|
40
|
+
export declare function InteractiveBox(props: InteractiveBoxProps): ReactElement;
|