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,11 @@
|
|
|
1
|
+
import type { SelectorComponent } from 'lightningcss';
|
|
2
|
+
/**
|
|
3
|
+
* Pull a bare class name out of a lightningcss selector-part array. Accepts
|
|
4
|
+
* only the simple shape — one `{type: 'class', name}` component — since
|
|
5
|
+
* Tailwind utility rules land as flat single-class selectors once variants
|
|
6
|
+
* are folded in. Compound or pseudo selectors return `null` so the caller
|
|
7
|
+
* skips them.
|
|
8
|
+
* @param selector One selector's component array.
|
|
9
|
+
* @returns Bare class name, or `null` when the selector is anything more complex.
|
|
10
|
+
*/
|
|
11
|
+
export declare function classNameFromSelector(selector: readonly SelectorComponent[]): string | null;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var color = require('./color.cjs');
|
|
4
|
+
var length = require('./length.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Expand `margin` / `padding` shorthand (`{top, right, bottom, left}`) to
|
|
8
|
+
* RN entries. Collapses progressively for a smaller emitted style:
|
|
9
|
+
* - all four equal → single `padding` / `margin`
|
|
10
|
+
* - matching axes → `paddingHorizontal` + `paddingVertical`
|
|
11
|
+
* - one matching axis → that axis collapsed, opposite axis as longhands
|
|
12
|
+
* - otherwise → four longhands
|
|
13
|
+
* @param property `'padding'` or `'margin'`.
|
|
14
|
+
* @param value Typed shorthand record.
|
|
15
|
+
* @returns RN entries.
|
|
16
|
+
*/
|
|
17
|
+
function expandFourSided(property, value) {
|
|
18
|
+
const top = length.lengthPercentageOrAutoToValue(value.top);
|
|
19
|
+
const right = length.lengthPercentageOrAutoToValue(value.right);
|
|
20
|
+
const bottom = length.lengthPercentageOrAutoToValue(value.bottom);
|
|
21
|
+
const left = length.lengthPercentageOrAutoToValue(value.left);
|
|
22
|
+
if (top === null || right === null || bottom === null || left === null)
|
|
23
|
+
return [];
|
|
24
|
+
if (top === right && right === bottom && bottom === left)
|
|
25
|
+
return [[property, top]];
|
|
26
|
+
const horizontalEqual = left === right;
|
|
27
|
+
const verticalEqual = top === bottom;
|
|
28
|
+
if (horizontalEqual && verticalEqual) {
|
|
29
|
+
return [
|
|
30
|
+
[`${property}Vertical`, top],
|
|
31
|
+
[`${property}Horizontal`, left],
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
if (horizontalEqual) {
|
|
35
|
+
return [
|
|
36
|
+
[`${property}Top`, top],
|
|
37
|
+
[`${property}Bottom`, bottom],
|
|
38
|
+
[`${property}Horizontal`, left],
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
if (verticalEqual) {
|
|
42
|
+
return [
|
|
43
|
+
[`${property}Vertical`, top],
|
|
44
|
+
[`${property}Right`, right],
|
|
45
|
+
[`${property}Left`, left],
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
return [
|
|
49
|
+
[`${property}Top`, top],
|
|
50
|
+
[`${property}Right`, right],
|
|
51
|
+
[`${property}Bottom`, bottom],
|
|
52
|
+
[`${property}Left`, left],
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Expand `padding-inline` / `margin-inline` (logical property) into RN's
|
|
57
|
+
* physical pair. RN has no RTL-aware logical props at the style-object
|
|
58
|
+
* level, so we lower at compile time. When both sides match, emit the
|
|
59
|
+
* single `paddingHorizontal` / `marginHorizontal` shorthand for a more
|
|
60
|
+
* compact style.
|
|
61
|
+
* @param property `'padding'` or `'margin'`.
|
|
62
|
+
* @param value Typed inline shorthand.
|
|
63
|
+
* @returns RN entries.
|
|
64
|
+
*/
|
|
65
|
+
function expandLogicalInline(property, value) {
|
|
66
|
+
const start = length.lengthPercentageOrAutoToValue(value.inlineStart);
|
|
67
|
+
const end = length.lengthPercentageOrAutoToValue(value.inlineEnd);
|
|
68
|
+
if (start === null || end === null)
|
|
69
|
+
return [];
|
|
70
|
+
if (start === end)
|
|
71
|
+
return [[`${property}Horizontal`, start]];
|
|
72
|
+
return [
|
|
73
|
+
[`${property}Left`, start],
|
|
74
|
+
[`${property}Right`, end],
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Expand `padding-block` / `margin-block` (logical property) into RN's
|
|
79
|
+
* physical pair. When both sides match, emit `paddingVertical` /
|
|
80
|
+
* `marginVertical` for a more compact style.
|
|
81
|
+
* @param property `'padding'` or `'margin'`.
|
|
82
|
+
* @param value Typed block shorthand.
|
|
83
|
+
* @returns RN entries.
|
|
84
|
+
*/
|
|
85
|
+
function expandLogicalBlock(property, value) {
|
|
86
|
+
const start = length.lengthPercentageOrAutoToValue(value.blockStart);
|
|
87
|
+
const end = length.lengthPercentageOrAutoToValue(value.blockEnd);
|
|
88
|
+
if (start === null || end === null)
|
|
89
|
+
return [];
|
|
90
|
+
if (start === end)
|
|
91
|
+
return [[`${property}Vertical`, start]];
|
|
92
|
+
return [
|
|
93
|
+
[`${property}Top`, start],
|
|
94
|
+
[`${property}Bottom`, end],
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Expand a `border-radius` shorthand into RN corner entries. Each corner
|
|
99
|
+
* is a 2-tuple `[x, y]` in lightningcss; RN exposes one radius per corner
|
|
100
|
+
* so we use the x-axis. When all four corners match, collapse to the
|
|
101
|
+
* single `borderRadius` key.
|
|
102
|
+
* @param value Typed `BorderRadius` record.
|
|
103
|
+
* @returns RN entries.
|
|
104
|
+
*/
|
|
105
|
+
function expandBorderRadius(value) {
|
|
106
|
+
const corners = [
|
|
107
|
+
['borderTopLeftRadius', length.dimensionPercentageToNumber(value.topLeft[0])],
|
|
108
|
+
['borderTopRightRadius', length.dimensionPercentageToNumber(value.topRight[0])],
|
|
109
|
+
['borderBottomRightRadius', length.dimensionPercentageToNumber(value.bottomRight[0])],
|
|
110
|
+
['borderBottomLeftRadius', length.dimensionPercentageToNumber(value.bottomLeft[0])],
|
|
111
|
+
];
|
|
112
|
+
const [first] = corners;
|
|
113
|
+
if (first?.[1] == null)
|
|
114
|
+
return [];
|
|
115
|
+
if (corners.every(([, v]) => v === first[1]))
|
|
116
|
+
return [['borderRadius', first[1]]];
|
|
117
|
+
return corners.filter((entry) => entry[1] !== null);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Expand a `border-color` shorthand into RN longhands. When all four
|
|
121
|
+
* sides match, collapse to a single `borderColor`; otherwise emit per-side
|
|
122
|
+
* props.
|
|
123
|
+
* @param value Typed `BorderColor` record.
|
|
124
|
+
* @returns RN entries.
|
|
125
|
+
*/
|
|
126
|
+
function expandBorderColor(value) {
|
|
127
|
+
const top = color.cssColorToString(value.top);
|
|
128
|
+
const right = color.cssColorToString(value.right);
|
|
129
|
+
const bottom = color.cssColorToString(value.bottom);
|
|
130
|
+
const left = color.cssColorToString(value.left);
|
|
131
|
+
if (top === right && right === bottom && bottom === left)
|
|
132
|
+
return [['borderColor', top]];
|
|
133
|
+
return [
|
|
134
|
+
['borderTopColor', top],
|
|
135
|
+
['borderRightColor', right],
|
|
136
|
+
['borderBottomColor', bottom],
|
|
137
|
+
['borderLeftColor', left],
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Expand `gap` shorthand (`{row, column}`) into RN entries. When both
|
|
142
|
+
* axes equal the same value collapse to the single `gap` key; otherwise
|
|
143
|
+
* emit `rowGap` + `columnGap`.
|
|
144
|
+
* @param value Typed `Gap` record.
|
|
145
|
+
* @returns RN entries.
|
|
146
|
+
*/
|
|
147
|
+
function expandGap(value) {
|
|
148
|
+
const row = length.gapValueToValue(value.row);
|
|
149
|
+
const column = length.gapValueToValue(value.column);
|
|
150
|
+
if (row === null || column === null)
|
|
151
|
+
return [];
|
|
152
|
+
if (row === column)
|
|
153
|
+
return [['gap', row]];
|
|
154
|
+
return [
|
|
155
|
+
['rowGap', row],
|
|
156
|
+
['columnGap', column],
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Convert `Flex` shorthand to RN entries. When the shape matches `flex:
|
|
161
|
+
* 1` (`{grow:1, shrink:1, basis: 0%}`), emit the single `flex` key RN
|
|
162
|
+
* understands. Otherwise expand to the three longhands.
|
|
163
|
+
* @param value Typed `Flex` record.
|
|
164
|
+
* @returns RN entries.
|
|
165
|
+
*/
|
|
166
|
+
function flexToEntries(value) {
|
|
167
|
+
const basis = length.lengthPercentageOrAutoToValue(value.basis);
|
|
168
|
+
if (basis === null)
|
|
169
|
+
return [];
|
|
170
|
+
if (value.grow === 1 && value.shrink === 1 && basis === '0%')
|
|
171
|
+
return [['flex', 1]];
|
|
172
|
+
const entries = [
|
|
173
|
+
['flexGrow', value.grow],
|
|
174
|
+
['flexShrink', value.shrink],
|
|
175
|
+
];
|
|
176
|
+
if (basis !== 'auto')
|
|
177
|
+
entries.push(['flexBasis', basis]);
|
|
178
|
+
return entries;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
exports.expandBorderColor = expandBorderColor;
|
|
182
|
+
exports.expandBorderRadius = expandBorderRadius;
|
|
183
|
+
exports.expandFourSided = expandFourSided;
|
|
184
|
+
exports.expandGap = expandGap;
|
|
185
|
+
exports.expandLogicalBlock = expandLogicalBlock;
|
|
186
|
+
exports.expandLogicalInline = expandLogicalInline;
|
|
187
|
+
exports.flexToEntries = flexToEntries;
|
|
188
|
+
//# sourceMappingURL=shorthand.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shorthand.cjs","sources":["../../../../../src/core/parser/shorthand.ts"],"sourcesContent":["import type {\n BorderColor,\n BorderRadius,\n Flex,\n Gap,\n Margin,\n MarginBlock,\n MarginInline,\n Padding,\n PaddingBlock,\n PaddingInline,\n} from 'lightningcss'\nimport { cssColorToString } from './color'\nimport { dimensionPercentageToNumber, gapValueToValue, lengthPercentageOrAutoToValue } from './length'\nimport type { RNEntry } from './types'\n\n/**\n * Expand `margin` / `padding` shorthand (`{top, right, bottom, left}`) to\n * RN entries. Collapses progressively for a smaller emitted style:\n * - all four equal → single `padding` / `margin`\n * - matching axes → `paddingHorizontal` + `paddingVertical`\n * - one matching axis → that axis collapsed, opposite axis as longhands\n * - otherwise → four longhands\n * @param property `'padding'` or `'margin'`.\n * @param value Typed shorthand record.\n * @returns RN entries.\n */\nexport function expandFourSided(property: 'padding' | 'margin', value: Padding | Margin): readonly RNEntry[] {\n const top = lengthPercentageOrAutoToValue(value.top)\n const right = lengthPercentageOrAutoToValue(value.right)\n const bottom = lengthPercentageOrAutoToValue(value.bottom)\n const left = lengthPercentageOrAutoToValue(value.left)\n if (top === null || right === null || bottom === null || left === null) return []\n if (top === right && right === bottom && bottom === left) return [[property, top]]\n const horizontalEqual = left === right\n const verticalEqual = top === bottom\n if (horizontalEqual && verticalEqual) {\n return [\n [`${property}Vertical`, top],\n [`${property}Horizontal`, left],\n ]\n }\n if (horizontalEqual) {\n return [\n [`${property}Top`, top],\n [`${property}Bottom`, bottom],\n [`${property}Horizontal`, left],\n ]\n }\n if (verticalEqual) {\n return [\n [`${property}Vertical`, top],\n [`${property}Right`, right],\n [`${property}Left`, left],\n ]\n }\n return [\n [`${property}Top`, top],\n [`${property}Right`, right],\n [`${property}Bottom`, bottom],\n [`${property}Left`, left],\n ]\n}\n\n/**\n * Expand `padding-inline` / `margin-inline` (logical property) into RN's\n * physical pair. RN has no RTL-aware logical props at the style-object\n * level, so we lower at compile time. When both sides match, emit the\n * single `paddingHorizontal` / `marginHorizontal` shorthand for a more\n * compact style.\n * @param property `'padding'` or `'margin'`.\n * @param value Typed inline shorthand.\n * @returns RN entries.\n */\nexport function expandLogicalInline(property: 'padding' | 'margin', value: PaddingInline | MarginInline): readonly RNEntry[] {\n const start = lengthPercentageOrAutoToValue(value.inlineStart)\n const end = lengthPercentageOrAutoToValue(value.inlineEnd)\n if (start === null || end === null) return []\n if (start === end) return [[`${property}Horizontal`, start]]\n return [\n [`${property}Left`, start],\n [`${property}Right`, end],\n ]\n}\n\n/**\n * Expand `padding-block` / `margin-block` (logical property) into RN's\n * physical pair. When both sides match, emit `paddingVertical` /\n * `marginVertical` for a more compact style.\n * @param property `'padding'` or `'margin'`.\n * @param value Typed block shorthand.\n * @returns RN entries.\n */\nexport function expandLogicalBlock(property: 'padding' | 'margin', value: PaddingBlock | MarginBlock): readonly RNEntry[] {\n const start = lengthPercentageOrAutoToValue(value.blockStart)\n const end = lengthPercentageOrAutoToValue(value.blockEnd)\n if (start === null || end === null) return []\n if (start === end) return [[`${property}Vertical`, start]]\n return [\n [`${property}Top`, start],\n [`${property}Bottom`, end],\n ]\n}\n\n/**\n * Expand a `border-radius` shorthand into RN corner entries. Each corner\n * is a 2-tuple `[x, y]` in lightningcss; RN exposes one radius per corner\n * so we use the x-axis. When all four corners match, collapse to the\n * single `borderRadius` key.\n * @param value Typed `BorderRadius` record.\n * @returns RN entries.\n */\nexport function expandBorderRadius(value: BorderRadius): readonly RNEntry[] {\n const corners: Array<[string, number | string | null]> = [\n ['borderTopLeftRadius', dimensionPercentageToNumber(value.topLeft[0])],\n ['borderTopRightRadius', dimensionPercentageToNumber(value.topRight[0])],\n ['borderBottomRightRadius', dimensionPercentageToNumber(value.bottomRight[0])],\n ['borderBottomLeftRadius', dimensionPercentageToNumber(value.bottomLeft[0])],\n ]\n const [first] = corners\n if (first?.[1] == null) return []\n if (corners.every(([, v]) => v === first[1])) return [['borderRadius', first[1]]]\n return corners.filter((entry): entry is [string, number | string] => entry[1] !== null)\n}\n\n/**\n * Expand a `border-color` shorthand into RN longhands. When all four\n * sides match, collapse to a single `borderColor`; otherwise emit per-side\n * props.\n * @param value Typed `BorderColor` record.\n * @returns RN entries.\n */\nexport function expandBorderColor(value: BorderColor): readonly RNEntry[] {\n const top = cssColorToString(value.top)\n const right = cssColorToString(value.right)\n const bottom = cssColorToString(value.bottom)\n const left = cssColorToString(value.left)\n if (top === right && right === bottom && bottom === left) return [['borderColor', top]]\n return [\n ['borderTopColor', top],\n ['borderRightColor', right],\n ['borderBottomColor', bottom],\n ['borderLeftColor', left],\n ]\n}\n\n/**\n * Expand `gap` shorthand (`{row, column}`) into RN entries. When both\n * axes equal the same value collapse to the single `gap` key; otherwise\n * emit `rowGap` + `columnGap`.\n * @param value Typed `Gap` record.\n * @returns RN entries.\n */\nexport function expandGap(value: Gap): readonly RNEntry[] {\n const row = gapValueToValue(value.row)\n const column = gapValueToValue(value.column)\n if (row === null || column === null) return []\n if (row === column) return [['gap', row]]\n return [\n ['rowGap', row],\n ['columnGap', column],\n ]\n}\n\n/**\n * Convert `Flex` shorthand to RN entries. When the shape matches `flex:\n * 1` (`{grow:1, shrink:1, basis: 0%}`), emit the single `flex` key RN\n * understands. Otherwise expand to the three longhands.\n * @param value Typed `Flex` record.\n * @returns RN entries.\n */\nexport function flexToEntries(value: Flex): readonly RNEntry[] {\n const basis = lengthPercentageOrAutoToValue(value.basis)\n if (basis === null) return []\n if (value.grow === 1 && value.shrink === 1 && basis === '0%') return [['flex', 1]]\n const entries: RNEntry[] = [\n ['flexGrow', value.grow],\n ['flexShrink', value.shrink],\n ]\n if (basis !== 'auto') entries.push(['flexBasis', basis])\n return entries\n}\n"],"names":["lengthPercentageOrAutoToValue","dimensionPercentageToNumber","cssColorToString","gapValueToValue"],"mappings":";;;;;AAgBA;;;;;;;;;;AAUG;AACG,SAAU,eAAe,CAAC,QAA8B,EAAE,KAAuB,EAAA;IACrF,MAAM,GAAG,GAAGA,oCAA6B,CAAC,KAAK,CAAC,GAAG,CAAC;IACpD,MAAM,KAAK,GAAGA,oCAA6B,CAAC,KAAK,CAAC,KAAK,CAAC;IACxD,MAAM,MAAM,GAAGA,oCAA6B,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1D,MAAM,IAAI,GAAGA,oCAA6B,CAAC,KAAK,CAAC,IAAI,CAAC;AACtD,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,KA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7B;IACD,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACxD,IAAA,OAAO,OAAO;AAChB;;;;;;;;;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { BorderColor, BorderRadius, Flex, Gap, Margin, MarginBlock, MarginInline, Padding, PaddingBlock, PaddingInline } from 'lightningcss';
|
|
2
|
+
import type { RNEntry } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Expand `margin` / `padding` shorthand (`{top, right, bottom, left}`) to
|
|
5
|
+
* RN entries. Collapses progressively for a smaller emitted style:
|
|
6
|
+
* - all four equal → single `padding` / `margin`
|
|
7
|
+
* - matching axes → `paddingHorizontal` + `paddingVertical`
|
|
8
|
+
* - one matching axis → that axis collapsed, opposite axis as longhands
|
|
9
|
+
* - otherwise → four longhands
|
|
10
|
+
* @param property `'padding'` or `'margin'`.
|
|
11
|
+
* @param value Typed shorthand record.
|
|
12
|
+
* @returns RN entries.
|
|
13
|
+
*/
|
|
14
|
+
export declare function expandFourSided(property: 'padding' | 'margin', value: Padding | Margin): readonly RNEntry[];
|
|
15
|
+
/**
|
|
16
|
+
* Expand `padding-inline` / `margin-inline` (logical property) into RN's
|
|
17
|
+
* physical pair. RN has no RTL-aware logical props at the style-object
|
|
18
|
+
* level, so we lower at compile time. When both sides match, emit the
|
|
19
|
+
* single `paddingHorizontal` / `marginHorizontal` shorthand for a more
|
|
20
|
+
* compact style.
|
|
21
|
+
* @param property `'padding'` or `'margin'`.
|
|
22
|
+
* @param value Typed inline shorthand.
|
|
23
|
+
* @returns RN entries.
|
|
24
|
+
*/
|
|
25
|
+
export declare function expandLogicalInline(property: 'padding' | 'margin', value: PaddingInline | MarginInline): readonly RNEntry[];
|
|
26
|
+
/**
|
|
27
|
+
* Expand `padding-block` / `margin-block` (logical property) into RN's
|
|
28
|
+
* physical pair. When both sides match, emit `paddingVertical` /
|
|
29
|
+
* `marginVertical` for a more compact style.
|
|
30
|
+
* @param property `'padding'` or `'margin'`.
|
|
31
|
+
* @param value Typed block shorthand.
|
|
32
|
+
* @returns RN entries.
|
|
33
|
+
*/
|
|
34
|
+
export declare function expandLogicalBlock(property: 'padding' | 'margin', value: PaddingBlock | MarginBlock): readonly RNEntry[];
|
|
35
|
+
/**
|
|
36
|
+
* Expand a `border-radius` shorthand into RN corner entries. Each corner
|
|
37
|
+
* is a 2-tuple `[x, y]` in lightningcss; RN exposes one radius per corner
|
|
38
|
+
* so we use the x-axis. When all four corners match, collapse to the
|
|
39
|
+
* single `borderRadius` key.
|
|
40
|
+
* @param value Typed `BorderRadius` record.
|
|
41
|
+
* @returns RN entries.
|
|
42
|
+
*/
|
|
43
|
+
export declare function expandBorderRadius(value: BorderRadius): readonly RNEntry[];
|
|
44
|
+
/**
|
|
45
|
+
* Expand a `border-color` shorthand into RN longhands. When all four
|
|
46
|
+
* sides match, collapse to a single `borderColor`; otherwise emit per-side
|
|
47
|
+
* props.
|
|
48
|
+
* @param value Typed `BorderColor` record.
|
|
49
|
+
* @returns RN entries.
|
|
50
|
+
*/
|
|
51
|
+
export declare function expandBorderColor(value: BorderColor): readonly RNEntry[];
|
|
52
|
+
/**
|
|
53
|
+
* Expand `gap` shorthand (`{row, column}`) into RN entries. When both
|
|
54
|
+
* axes equal the same value collapse to the single `gap` key; otherwise
|
|
55
|
+
* emit `rowGap` + `columnGap`.
|
|
56
|
+
* @param value Typed `Gap` record.
|
|
57
|
+
* @returns RN entries.
|
|
58
|
+
*/
|
|
59
|
+
export declare function expandGap(value: Gap): readonly RNEntry[];
|
|
60
|
+
/**
|
|
61
|
+
* Convert `Flex` shorthand to RN entries. When the shape matches `flex:
|
|
62
|
+
* 1` (`{grow:1, shrink:1, basis: 0%}`), emit the single `flex` key RN
|
|
63
|
+
* understands. Otherwise expand to the three longhands.
|
|
64
|
+
* @param value Typed `Flex` record.
|
|
65
|
+
* @returns RN entries.
|
|
66
|
+
*/
|
|
67
|
+
export declare function flexToEntries(value: Flex): readonly RNEntry[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Text-truncate atom detector.
|
|
5
|
+
*
|
|
6
|
+
* React Native's `<Text>` exposes two props that cover every case
|
|
7
|
+
* Tailwind's text-truncation utilities express:
|
|
8
|
+
*
|
|
9
|
+
* numberOfLines — clamp after N lines (1 for single-line ellipsis)
|
|
10
|
+
* ellipsizeMode — 'tail' (ellipsis) or 'clip' at the truncation point
|
|
11
|
+
*
|
|
12
|
+
* rnwind treats the Tailwind classes as **metadata**: the transformer
|
|
13
|
+
* strips the truncate atoms from the JSX site's className and emits
|
|
14
|
+
* `numberOfLines={N}` / `ellipsizeMode="tail"` props on the element.
|
|
15
|
+
*
|
|
16
|
+
* Covered atoms:
|
|
17
|
+
* truncate → { numberOfLines: 1, ellipsizeMode: 'tail' }
|
|
18
|
+
* text-ellipsis → { ellipsizeMode: 'tail' }
|
|
19
|
+
* text-clip → { ellipsizeMode: 'clip' }
|
|
20
|
+
* line-clamp-<N> → { numberOfLines: <N> }
|
|
21
|
+
* line-clamp-none → { numberOfLines: 0 } (reset — overrides prior)
|
|
22
|
+
*
|
|
23
|
+
* Detection is pure name matching — no CSS inspection — because every
|
|
24
|
+
* relevant piece of data lives in the class name itself.
|
|
25
|
+
*/
|
|
26
|
+
/** Regex matching `line-clamp-<N>` with a positive-integer N. */
|
|
27
|
+
const LINE_CLAMP_RE = /^line-clamp-(\d+)$/;
|
|
28
|
+
/** Regex matching Tailwind v4's `line-clamp-[<value>]` arbitrary form. */
|
|
29
|
+
const LINE_CLAMP_ARBITRARY_RE = /^line-clamp-\[([^\]]+)\]$/;
|
|
30
|
+
/**
|
|
31
|
+
* Inspect one class-name token and return the text-truncate metadata it
|
|
32
|
+
* contributes, or `null` when the atom isn't a truncate utility.
|
|
33
|
+
* @param atom Single class-name token (no variant prefix).
|
|
34
|
+
* @returns The atom's contribution, or null.
|
|
35
|
+
*/
|
|
36
|
+
function detectTextTruncate(atom) {
|
|
37
|
+
if (atom === 'truncate')
|
|
38
|
+
return { numberOfLines: 1, ellipsizeMode: 'tail' };
|
|
39
|
+
if (atom === 'text-ellipsis')
|
|
40
|
+
return { ellipsizeMode: 'tail' };
|
|
41
|
+
if (atom === 'text-clip')
|
|
42
|
+
return { ellipsizeMode: 'clip' };
|
|
43
|
+
if (atom === 'line-clamp-none')
|
|
44
|
+
return { numberOfLines: 0 };
|
|
45
|
+
const numeric = LINE_CLAMP_RE.exec(atom);
|
|
46
|
+
if (numeric)
|
|
47
|
+
return { numberOfLines: Number(numeric[1]) };
|
|
48
|
+
const arbitrary = LINE_CLAMP_ARBITRARY_RE.exec(atom);
|
|
49
|
+
if (arbitrary) {
|
|
50
|
+
const n = Number.parseInt(arbitrary[1], 10);
|
|
51
|
+
if (Number.isFinite(n) && n >= 0)
|
|
52
|
+
return { numberOfLines: n };
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Fast pre-check — returns true when ANY atom in the list could be a
|
|
58
|
+
* truncate utility, false when none can. Lets callers skip the
|
|
59
|
+
* allocation of the merge pass for the common "no truncate" case.
|
|
60
|
+
* @param atoms Tokenised atom list from a literal className.
|
|
61
|
+
* @returns Whether to run the full per-atom detection.
|
|
62
|
+
*/
|
|
63
|
+
function mayContainTextTruncate(atoms) {
|
|
64
|
+
for (const atom of atoms) {
|
|
65
|
+
if (atom === 'truncate' ||
|
|
66
|
+
atom === 'text-ellipsis' ||
|
|
67
|
+
atom === 'text-clip' ||
|
|
68
|
+
atom === 'line-clamp-none' ||
|
|
69
|
+
atom.startsWith('line-clamp-')) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
exports.detectTextTruncate = detectTextTruncate;
|
|
77
|
+
exports.mayContainTextTruncate = mayContainTextTruncate;
|
|
78
|
+
//# sourceMappingURL=text-truncate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-truncate.cjs","sources":["../../../../../src/core/parser/text-truncate.ts"],"sourcesContent":["/**\n * Text-truncate atom detector.\n *\n * React Native's `<Text>` exposes two props that cover every case\n * Tailwind's text-truncation utilities express:\n *\n * numberOfLines — clamp after N lines (1 for single-line ellipsis)\n * ellipsizeMode — 'tail' (ellipsis) or 'clip' at the truncation point\n *\n * rnwind treats the Tailwind classes as **metadata**: the transformer\n * strips the truncate atoms from the JSX site's className and emits\n * `numberOfLines={N}` / `ellipsizeMode=\"tail\"` props on the element.\n *\n * Covered atoms:\n * truncate → { numberOfLines: 1, ellipsizeMode: 'tail' }\n * text-ellipsis → { ellipsizeMode: 'tail' }\n * text-clip → { ellipsizeMode: 'clip' }\n * line-clamp-<N> → { numberOfLines: <N> }\n * line-clamp-none → { numberOfLines: 0 } (reset — overrides prior)\n *\n * Detection is pure name matching — no CSS inspection — because every\n * relevant piece of data lives in the class name itself.\n */\n\n/** Text-truncate metadata produced by a single atom. */\nexport interface TextTruncateInfo {\n readonly numberOfLines?: number\n readonly ellipsizeMode?: 'tail' | 'clip'\n}\n\n/** Regex matching `line-clamp-<N>` with a positive-integer N. */\nconst LINE_CLAMP_RE = /^line-clamp-(\\d+)$/\n/** Regex matching Tailwind v4's `line-clamp-[<value>]` arbitrary form. */\nconst LINE_CLAMP_ARBITRARY_RE = /^line-clamp-\\[([^\\]]+)\\]$/\n\n/**\n * Inspect one class-name token and return the text-truncate metadata it\n * contributes, or `null` when the atom isn't a truncate utility.\n * @param atom Single class-name token (no variant prefix).\n * @returns The atom's contribution, or null.\n */\nfunction detectTextTruncate(atom: string): TextTruncateInfo | null {\n if (atom === 'truncate') return { numberOfLines: 1, ellipsizeMode: 'tail' }\n if (atom === 'text-ellipsis') return { ellipsizeMode: 'tail' }\n if (atom === 'text-clip') return { ellipsizeMode: 'clip' }\n if (atom === 'line-clamp-none') return { numberOfLines: 0 }\n const numeric = LINE_CLAMP_RE.exec(atom)\n if (numeric) return { numberOfLines: Number(numeric[1]) }\n const arbitrary = LINE_CLAMP_ARBITRARY_RE.exec(atom)\n if (arbitrary) {\n const n = Number.parseInt(arbitrary[1]!, 10)\n if (Number.isFinite(n) && n >= 0) return { numberOfLines: n }\n }\n return null\n}\n\n/**\n * Fast pre-check — returns true when ANY atom in the list could be a\n * truncate utility, false when none can. Lets callers skip the\n * allocation of the merge pass for the common \"no truncate\" case.\n * @param atoms Tokenised atom list from a literal className.\n * @returns Whether to run the full per-atom detection.\n */\nfunction mayContainTextTruncate(atoms: readonly string[]): boolean {\n for (const atom of atoms) {\n if (\n atom === 'truncate' ||\n atom === 'text-ellipsis' ||\n atom === 'text-clip' ||\n atom === 'line-clamp-none' ||\n atom.startsWith('line-clamp-')\n ) {\n return true\n }\n }\n return false\n}\n\nexport { detectTextTruncate, mayContainTextTruncate }\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AAQH;AACA,MAAM,aAAa,GAAG,oBAAoB;AAC1C;AACA,MAAM,uBAAuB,GAAG,2BAA2B;AAE3D;;;;;AAKG;AACH,SAAS,kBAAkB,CAAC,IAAY,EAAA;IACtC,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE;IAC3E,IAAI,IAAI,KAAK,eAAe;AAAE,QAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE;IAC9D,IAAI,IAAI,KAAK,WAAW;AAAE,QAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE;IAC1D,IAAI,IAAI,KAAK,iBAAiB;AAAE,QAAA,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE;IAC3D,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;AACxC,IAAA,IAAI,OAAO;QAAE,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;IACzD,MAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;IACpD,IAAI,SAAS,EAAE;AACb,QAAA,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC;QAC5C,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,YAAA,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE;IAC/D;AACA,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMG;AACH,SAAS,sBAAsB,CAAC,KAAwB,EAAA;AACtD,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IACE,IAAI,KAAK,UAAU;AACnB,YAAA,IAAI,KAAK,eAAe;AACxB,YAAA,IAAI,KAAK,WAAW;AACpB,YAAA,IAAI,KAAK,iBAAiB;AAC1B,YAAA,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAC9B;AACA,YAAA,OAAO,IAAI;QACb;IACF;AACA,IAAA,OAAO,KAAK;AACd;;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text-truncate atom detector.
|
|
3
|
+
*
|
|
4
|
+
* React Native's `<Text>` exposes two props that cover every case
|
|
5
|
+
* Tailwind's text-truncation utilities express:
|
|
6
|
+
*
|
|
7
|
+
* numberOfLines — clamp after N lines (1 for single-line ellipsis)
|
|
8
|
+
* ellipsizeMode — 'tail' (ellipsis) or 'clip' at the truncation point
|
|
9
|
+
*
|
|
10
|
+
* rnwind treats the Tailwind classes as **metadata**: the transformer
|
|
11
|
+
* strips the truncate atoms from the JSX site's className and emits
|
|
12
|
+
* `numberOfLines={N}` / `ellipsizeMode="tail"` props on the element.
|
|
13
|
+
*
|
|
14
|
+
* Covered atoms:
|
|
15
|
+
* truncate → { numberOfLines: 1, ellipsizeMode: 'tail' }
|
|
16
|
+
* text-ellipsis → { ellipsizeMode: 'tail' }
|
|
17
|
+
* text-clip → { ellipsizeMode: 'clip' }
|
|
18
|
+
* line-clamp-<N> → { numberOfLines: <N> }
|
|
19
|
+
* line-clamp-none → { numberOfLines: 0 } (reset — overrides prior)
|
|
20
|
+
*
|
|
21
|
+
* Detection is pure name matching — no CSS inspection — because every
|
|
22
|
+
* relevant piece of data lives in the class name itself.
|
|
23
|
+
*/
|
|
24
|
+
/** Text-truncate metadata produced by a single atom. */
|
|
25
|
+
export interface TextTruncateInfo {
|
|
26
|
+
readonly numberOfLines?: number;
|
|
27
|
+
readonly ellipsizeMode?: 'tail' | 'clip';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Inspect one class-name token and return the text-truncate metadata it
|
|
31
|
+
* contributes, or `null` when the atom isn't a truncate utility.
|
|
32
|
+
* @param atom Single class-name token (no variant prefix).
|
|
33
|
+
* @returns The atom's contribution, or null.
|
|
34
|
+
*/
|
|
35
|
+
declare function detectTextTruncate(atom: string): TextTruncateInfo | null;
|
|
36
|
+
/**
|
|
37
|
+
* Fast pre-check — returns true when ANY atom in the list could be a
|
|
38
|
+
* truncate utility, false when none can. Lets callers skip the
|
|
39
|
+
* allocation of the merge pass for the common "no truncate" case.
|
|
40
|
+
* @param atoms Tokenised atom list from a literal className.
|
|
41
|
+
* @returns Whether to run the full per-atom detection.
|
|
42
|
+
*/
|
|
43
|
+
declare function mayContainTextTruncate(atoms: readonly string[]): boolean;
|
|
44
|
+
export { detectTextTruncate, mayContainTextTruncate };
|