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,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic style marker for values that depend on runtime insets.
|
|
3
|
+
* The parser emits one of these in place of a concrete number whenever
|
|
4
|
+
* a declaration uses `env(safe-area-inset-*)`, `max(env(...), n)`, or
|
|
5
|
+
* `calc(env(...) + n)`. The runtime (see `lookup-css.ts` slow path)
|
|
6
|
+
* reads the current insets from `useInsets()` and resolves to a
|
|
7
|
+
* concrete number per render.
|
|
8
|
+
*
|
|
9
|
+
* Marker shape is intentionally object-literal so `JSON.stringify` /
|
|
10
|
+
* style-builder emission roundtrip losslessly. The build-side
|
|
11
|
+
* `envelopeSafeMarkers` converts these markers into the
|
|
12
|
+
* `{__safeStyle: [[cssKey, sideTag, or, offset], ...]}` envelope the
|
|
13
|
+
* runtime checks via a single property read.
|
|
14
|
+
*/
|
|
15
|
+
export interface SafeAreaMarker {
|
|
16
|
+
readonly __safe: 't' | 'r' | 'b' | 'l' | 'screen-minus-y'
|
|
17
|
+
/** `max(env(...), or)` — fallback value in px. */
|
|
18
|
+
readonly or?: number
|
|
19
|
+
/** `calc(env(...) + offset)` — stacked additional value in px. */
|
|
20
|
+
readonly offset?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* RN-compatible style scalar / compound. Covers everything we emit:
|
|
25
|
+
* - primitives (`16`, `'#fff'`, `'flex-start'`)
|
|
26
|
+
* - arrays (`['color', 'opacity']` for `transitionProperty`,
|
|
27
|
+
* `[{rotate: '45deg'}, {scaleX: 2}]` for `transform`)
|
|
28
|
+
* - object records (`{width, height}` for `shadowOffset`)
|
|
29
|
+
* - safe-area markers (`{__safe: 't', or?: 16, offset?: 0}`) — resolved
|
|
30
|
+
* against the active insets at render time.
|
|
31
|
+
*/
|
|
32
|
+
export type RNStyleValue =
|
|
33
|
+
| string
|
|
34
|
+
| number
|
|
35
|
+
| readonly string[]
|
|
36
|
+
| readonly number[]
|
|
37
|
+
| readonly Record<string, string | number>[]
|
|
38
|
+
| { readonly [key: string]: string | number }
|
|
39
|
+
| SafeAreaMarker
|
|
40
|
+
|
|
41
|
+
/** Flat RN style object (what `StyleSheet.create` accepts). */
|
|
42
|
+
export type RNStyle = Record<string, RNStyleValue>
|
|
43
|
+
|
|
44
|
+
/** One `[key, value]` pair the converter emits from a single declaration. */
|
|
45
|
+
export type RNEntry = readonly [string, RNStyleValue]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Declaration as LcDeclaration } from 'lightningcss'
|
|
2
|
+
import { lineHeightToEntries } from './typography'
|
|
3
|
+
import type { RNEntry } from './types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build the RN `textDecorationLine` entry — string identity for the
|
|
7
|
+
* single-line cases, joined-string for the array shape.
|
|
8
|
+
* @param value Typed text-decoration-line.
|
|
9
|
+
* @returns Single-entry list with `textDecorationLine`.
|
|
10
|
+
*/
|
|
11
|
+
function textDecorationLineToEntries(value: LcDeclaration['value']): readonly RNEntry[] {
|
|
12
|
+
if (value === 'none') return [['textDecorationLine', 'none']]
|
|
13
|
+
if (typeof value === 'string') return [['textDecorationLine', value]]
|
|
14
|
+
if (Array.isArray(value)) return [['textDecorationLine', value.join(' ')]]
|
|
15
|
+
return []
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Build the RN `aspectRatio` entry from lightningcss's typed value.
|
|
20
|
+
* Drops `auto` (no RN equivalent).
|
|
21
|
+
* @param value Typed aspect-ratio value.
|
|
22
|
+
* @param value.auto Whether the value resolved to `auto`.
|
|
23
|
+
* @param value.ratio Numeric `[width, height]` ratio (or null/undefined).
|
|
24
|
+
* @returns Single-entry list or empty.
|
|
25
|
+
*/
|
|
26
|
+
function aspectRatioToEntries(value: { auto?: boolean; ratio?: readonly [number, number] | null }): readonly RNEntry[] {
|
|
27
|
+
if (value.auto) return []
|
|
28
|
+
if (!value.ratio) return []
|
|
29
|
+
const [w, h] = value.ratio
|
|
30
|
+
if (h === 0) return []
|
|
31
|
+
return [['aspectRatio', w / h]]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Build the RN `letterSpacing` entry. RN expects pixel numbers; rem
|
|
36
|
+
* lengths are scaled to px (16-px base).
|
|
37
|
+
* @param value Typed letter-spacing value.
|
|
38
|
+
* @returns Single-entry list or empty.
|
|
39
|
+
*/
|
|
40
|
+
function letterSpacingToEntries(value: LcDeclaration['value']): readonly RNEntry[] {
|
|
41
|
+
if (typeof value !== 'object') return []
|
|
42
|
+
const tagged = value as { type?: string; value?: { type?: string; value?: { unit?: string; value?: number } } }
|
|
43
|
+
if (tagged.type === 'normal') return [['letterSpacing', 0]]
|
|
44
|
+
const inner = tagged.value
|
|
45
|
+
if (inner?.type !== 'value' || !inner.value) return []
|
|
46
|
+
const { unit, value: px } = inner.value
|
|
47
|
+
if (typeof px !== 'number') return []
|
|
48
|
+
return [['letterSpacing', unit === 'px' ? px : px * 16]]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Lower a CSS `text-align` keyword to one RN's `textAlign` accepts. RN
|
|
53
|
+
* has no logical `start`/`end`, so map them to physical sides (LTR
|
|
54
|
+
* default); every other keyword (left/right/center/justify/auto) is
|
|
55
|
+
* already valid and passes through.
|
|
56
|
+
* @param align CSS text-align keyword.
|
|
57
|
+
* @returns RN-valid textAlign keyword.
|
|
58
|
+
*/
|
|
59
|
+
function physicalTextAlign(align: string): string {
|
|
60
|
+
if (align === 'start') return 'left'
|
|
61
|
+
if (align === 'end') return 'right'
|
|
62
|
+
return align
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Dispatch typography declarations rnwind cares about (text-align,
|
|
67
|
+
* text-transform, text-decoration-line, line-height, letter-spacing,
|
|
68
|
+
* aspect-ratio). Returns null when the property isn't one of these so
|
|
69
|
+
* the caller can fall through to its main switch.
|
|
70
|
+
* @param decl One lightningcss declaration.
|
|
71
|
+
* @returns RN entries when the property matched, else `null`.
|
|
72
|
+
*/
|
|
73
|
+
export function dispatchTypographyDeclaration(decl: LcDeclaration): readonly RNEntry[] | null {
|
|
74
|
+
switch (decl.property) {
|
|
75
|
+
case 'text-align': {
|
|
76
|
+
return [['textAlign', physicalTextAlign(String(decl.value))]]
|
|
77
|
+
}
|
|
78
|
+
case 'text-transform': {
|
|
79
|
+
return [['textTransform', decl.value.case ?? 'none']]
|
|
80
|
+
}
|
|
81
|
+
case 'text-decoration-line': {
|
|
82
|
+
return textDecorationLineToEntries(decl.value)
|
|
83
|
+
}
|
|
84
|
+
case 'aspect-ratio': {
|
|
85
|
+
return aspectRatioToEntries(decl.value)
|
|
86
|
+
}
|
|
87
|
+
case 'line-height': {
|
|
88
|
+
return lineHeightToEntries(decl.value)
|
|
89
|
+
}
|
|
90
|
+
case 'letter-spacing': {
|
|
91
|
+
return letterSpacingToEntries(decl.value)
|
|
92
|
+
}
|
|
93
|
+
default: {
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Display, FontSize, FontWeight, LineHeight, ZIndex } from 'lightningcss'
|
|
2
|
+
import { dimensionPercentageToNumber } from './length'
|
|
3
|
+
import type { RNEntry } from './types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Expand lightningcss's `Display` typed value to an RN `{display}` entry.
|
|
7
|
+
* - `keyword` variant (`none`, `flex`, `grid`, `inline`, …) passes through.
|
|
8
|
+
* - `pair` variant (the modern CSS model — `{inside: {type}, outside,
|
|
9
|
+
* isListItem}`) collapses to RN's `'flex'` / `'grid'` when the inside
|
|
10
|
+
* type matches, otherwise skips.
|
|
11
|
+
* @param value Typed display value.
|
|
12
|
+
* @returns RN entries (zero or one).
|
|
13
|
+
*/
|
|
14
|
+
export function displayToEntries(value: Display): readonly RNEntry[] {
|
|
15
|
+
if (value.type === 'keyword') return [['display', value.value]]
|
|
16
|
+
if (value.type === 'pair') {
|
|
17
|
+
const inside = value.inside.type
|
|
18
|
+
// `flow` is the default inside mode — maps to `block` / `inline` /
|
|
19
|
+
// `inline-block` based on the outer; RN only distinguishes `block`-ish
|
|
20
|
+
// from `flex`, so collapse the `flow` family to the `outside` keyword.
|
|
21
|
+
if (inside === 'flow') return [['display', value.outside]]
|
|
22
|
+
if (inside === 'flex') return [['display', 'flex']]
|
|
23
|
+
if (inside === 'grid') return [['display', 'grid']]
|
|
24
|
+
}
|
|
25
|
+
return []
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Convert `FontSize` to a pixel number. The `length` variant carries a
|
|
30
|
+
* `DimensionPercentage`; `absolute` / `relative` keyword variants have no
|
|
31
|
+
* RN numeric equivalent and get dropped.
|
|
32
|
+
* @param value Typed font-size value.
|
|
33
|
+
* @returns Pixel size, or `null` when not a pure length.
|
|
34
|
+
*/
|
|
35
|
+
export function fontSizeToPx(value: FontSize): number | null {
|
|
36
|
+
if (value.type !== 'length') return null
|
|
37
|
+
const length = dimensionPercentageToNumber(value.value)
|
|
38
|
+
if (typeof length !== 'number') return null
|
|
39
|
+
return length
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Convert `FontWeight` to the form RN accepts — numbers for absolute
|
|
44
|
+
* weights, `'bolder'` / `'lighter'` keywords pass through as strings.
|
|
45
|
+
* @param value Typed font-weight value.
|
|
46
|
+
* @returns RN font weight.
|
|
47
|
+
*/
|
|
48
|
+
export function fontWeightToValue(value: FontWeight): number | string {
|
|
49
|
+
if (value.type === 'absolute') {
|
|
50
|
+
if (value.value.type === 'weight') return value.value.value
|
|
51
|
+
return value.value.type
|
|
52
|
+
}
|
|
53
|
+
return value.type
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Coerce `z-index` to a number. `{type: 'auto'}` has no RN equivalent so
|
|
58
|
+
* it collapses to 0.
|
|
59
|
+
* @param value Typed z-index value.
|
|
60
|
+
* @returns Integer z-index.
|
|
61
|
+
*/
|
|
62
|
+
export function zIndexToNumber(value: ZIndex): number {
|
|
63
|
+
if (value.type === 'auto') return 0
|
|
64
|
+
return value.value
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Convert lightningcss `LineHeight` into RN's `lineHeight` entry. RN
|
|
69
|
+
* accepts a single number (pixel value). For unitless multipliers we
|
|
70
|
+
* multiply by the default 16-px font size (RN's base); for px values we
|
|
71
|
+
* pass through; percentages are approximated the same way.
|
|
72
|
+
* @param value Typed line-height.
|
|
73
|
+
* @returns RN entry.
|
|
74
|
+
*/
|
|
75
|
+
export function lineHeightToEntries(value: LineHeight): readonly RNEntry[] {
|
|
76
|
+
if (value.type === 'normal') return [['lineHeight', 20]]
|
|
77
|
+
if (value.type === 'number') return [['lineHeight', Math.round(value.value * 16 * 10_000) / 10_000]]
|
|
78
|
+
if (value.type === 'length') {
|
|
79
|
+
const px = dimensionPercentageToNumber(value.value)
|
|
80
|
+
if (typeof px === 'number') return [['lineHeight', Math.round(px * 10_000) / 10_000]]
|
|
81
|
+
}
|
|
82
|
+
return []
|
|
83
|
+
}
|