rnwind 0.0.1 → 0.0.2
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 +164 -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 +100 -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 +96 -0
- package/lib/cjs/core/parser/length.cjs.map +1 -0
- package/lib/cjs/core/parser/length.d.ts +48 -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 +156 -0
- package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
- package/lib/cjs/core/parser/shorthand.d.ts +61 -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 +414 -0
- package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
- package/lib/cjs/core/parser/theme-vars.d.ts +61 -0
- package/lib/cjs/core/parser/tokens.cjs +304 -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 +1567 -0
- package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
- package/lib/cjs/core/parser/tw-parser.d.ts +194 -0
- package/lib/cjs/core/parser/types.d.ts +37 -0
- package/lib/cjs/core/parser/typography-dispatcher.cjs +93 -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 +397 -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 +251 -0
- package/lib/cjs/metro/state.cjs.map +1 -0
- package/lib/cjs/metro/state.d.ts +72 -0
- package/lib/cjs/metro/transform-ast.cjs +1255 -0
- package/lib/cjs/metro/transform-ast.cjs.map +1 -0
- package/lib/cjs/metro/transform-ast.d.ts +73 -0
- package/lib/cjs/metro/transformer.cjs +345 -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 +57 -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 +162 -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 +98 -0
- package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
- package/lib/esm/core/parser/length.d.ts +48 -0
- package/lib/esm/core/parser/length.mjs +90 -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 +61 -0
- package/lib/esm/core/parser/shorthand.mjs +148 -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 +61 -0
- package/lib/esm/core/parser/theme-vars.mjs +409 -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 +298 -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 +194 -0
- package/lib/esm/core/parser/tw-parser.mjs +1565 -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 +91 -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 +395 -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 +72 -0
- package/lib/esm/metro/state.mjs +243 -0
- package/lib/esm/metro/state.mjs.map +1 -0
- package/lib/esm/metro/transform-ast.d.ts +73 -0
- package/lib/esm/metro/transform-ast.mjs +1234 -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 +322 -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 +57 -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 +79 -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 +157 -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 +92 -0
- package/src/core/parser/length.ts +100 -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 +152 -0
- package/src/core/parser/text-truncate.ts +79 -0
- package/src/core/parser/theme-vars.ts +412 -0
- package/src/core/parser/tokens.ts +286 -0
- package/src/core/parser/transform.ts +195 -0
- package/src/core/parser/tw-parser.ts +1709 -0
- package/src/core/parser/types.ts +45 -0
- package/src/core/parser/typography-dispatcher.ts +83 -0
- package/src/core/parser/typography.ts +83 -0
- package/src/core/style-builder/build-style.ts +442 -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 +257 -0
- package/src/metro/transform-ast.ts +1498 -0
- package/src/metro/transformer.ts +347 -0
- package/src/metro/warn-unknown-classes.ts +79 -0
- package/src/metro/with-config.ts +229 -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,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Haptic-atom extractor.
|
|
3
|
+
*
|
|
4
|
+
* rnwind's haptic utilities are declared in preset.css as `@utility`
|
|
5
|
+
* rules that write a single `--rnwind-haptic: <kind>[-<value>]` custom
|
|
6
|
+
* property. Lightningcss surfaces those custom-property writes on the
|
|
7
|
+
* style rule's declaration list; this module converts the raw marker
|
|
8
|
+
* text into a structured {@link HapticRequest} the transformer can
|
|
9
|
+
* hoist into JSX.
|
|
10
|
+
*
|
|
11
|
+
* Marker vocabulary:
|
|
12
|
+
*
|
|
13
|
+
* --rnwind-haptic: impact-Light | impact-Medium | impact-Heavy | impact-Soft | impact-Rigid;
|
|
14
|
+
* --rnwind-haptic: notification-Success | notification-Warning | notification-Error;
|
|
15
|
+
* --rnwind-haptic: selection;
|
|
16
|
+
*
|
|
17
|
+
* Everything else is returned as `null` so unknown markers don't leak
|
|
18
|
+
* into the transformer's map.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { Declaration as LcDeclaration, TokenOrValue } from 'lightningcss'
|
|
22
|
+
import { serializeTokens } from './tokens'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Structured haptic request the `onHaptics` callback receives. Union
|
|
26
|
+
* members mirror `expo-haptics`'s three entry points 1:1 so consumers
|
|
27
|
+
* can index directly into the enum (`Haptics.ImpactFeedbackStyle[req.style]`).
|
|
28
|
+
*/
|
|
29
|
+
export type HapticRequest =
|
|
30
|
+
| { readonly kind: 'impact'; readonly style: 'Light' | 'Medium' | 'Heavy' | 'Soft' | 'Rigid' }
|
|
31
|
+
| { readonly kind: 'notification'; readonly type: 'Success' | 'Warning' | 'Error' }
|
|
32
|
+
| { readonly kind: 'selection' }
|
|
33
|
+
|
|
34
|
+
/** When during a component's lifecycle the haptic was triggered. */
|
|
35
|
+
export type HapticTrigger = 'mount' | 'pressIn' | 'pressOut' | 'focus' | 'hover'
|
|
36
|
+
|
|
37
|
+
/** User-provided callback fired by rnwind when a haptic atom resolves. */
|
|
38
|
+
export type OnHaptics = (request: HapticRequest, trigger: HapticTrigger) => void
|
|
39
|
+
|
|
40
|
+
const IMPACT_STYLES = new Set(['Light', 'Medium', 'Heavy', 'Soft', 'Rigid'] as const)
|
|
41
|
+
type ImpactStyle = 'Light' | 'Medium' | 'Heavy' | 'Soft' | 'Rigid'
|
|
42
|
+
const NOTIFICATION_TYPES = new Set(['Success', 'Warning', 'Error'] as const)
|
|
43
|
+
type NotificationType = 'Success' | 'Warning' | 'Error'
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Parse the raw marker text (post-serialization) into a
|
|
47
|
+
* {@link HapticRequest}, or `null` when the token is unrecognised.
|
|
48
|
+
* Shape: `impact-<Style>`, `notification-<Type>`, or bare `selection`.
|
|
49
|
+
* @param text Trimmed marker text.
|
|
50
|
+
* @returns Haptic request, or null.
|
|
51
|
+
*/
|
|
52
|
+
function parseMarker(text: string): HapticRequest | null {
|
|
53
|
+
if (text === 'selection') return { kind: 'selection' }
|
|
54
|
+
if (text.startsWith('impact-')) {
|
|
55
|
+
const style = text.slice('impact-'.length)
|
|
56
|
+
if (IMPACT_STYLES.has(style as ImpactStyle)) return { kind: 'impact', style: style as ImpactStyle }
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
if (text.startsWith('notification-')) {
|
|
60
|
+
const typeText = text.slice('notification-'.length)
|
|
61
|
+
if (NOTIFICATION_TYPES.has(typeText as NotificationType)) {
|
|
62
|
+
return { kind: 'notification', type: typeText as NotificationType }
|
|
63
|
+
}
|
|
64
|
+
return null
|
|
65
|
+
}
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Inspect a rule's declaration list for a `--rnwind-haptic: <marker>`
|
|
71
|
+
* custom property and return the structured request. Returns `null`
|
|
72
|
+
* for rules that don't carry the marker.
|
|
73
|
+
* @param declarations Declarations from one lightningcss style rule.
|
|
74
|
+
* @returns Parsed haptic request, or null.
|
|
75
|
+
*/
|
|
76
|
+
function detectHapticAtom(declarations: readonly LcDeclaration[]): HapticRequest | null {
|
|
77
|
+
for (const decl of declarations) {
|
|
78
|
+
if (decl.property !== 'custom') continue
|
|
79
|
+
const custom = decl.value as { name: { name: string } | string; value?: readonly TokenOrValue[] }
|
|
80
|
+
const name = typeof custom.name === 'string' ? custom.name : custom.name.name
|
|
81
|
+
if (name !== '--rnwind-haptic') continue
|
|
82
|
+
const text = serializeTokens(custom.value ?? []).trim()
|
|
83
|
+
return parseMarker(text)
|
|
84
|
+
}
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { detectHapticAtom }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { TailwindParser } from './tw-parser'
|
|
2
|
+
export type { TailwindParserConfig, ParseOptions, ParsedOutput, SchemedStyle, KeyframeBlock, KeyframeStep } from './tw-parser'
|
|
3
|
+
export type { SourceEntry } from '@tailwindcss/oxide'
|
|
4
|
+
export type { RNStyle, RNStyleValue, RNEntry, SafeAreaMarker } from './types'
|
|
5
|
+
export type { GradientAtomInfo, GradientDirection } from './gradient'
|
|
6
|
+
export type { TextTruncateInfo } from './text-truncate'
|
|
7
|
+
export type { HapticRequest, HapticTrigger, OnHaptics } from './haptics'
|
|
8
|
+
export { BASE_SCHEME } from './theme-vars'
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Animation, Declaration as LcDeclaration, KeyframeSelector, KeyframesName } from 'lightningcss'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pull the first keyframe name out of a typed `animation` shorthand.
|
|
5
|
+
* @param animations Parsed animation shorthand entries.
|
|
6
|
+
* @returns First ident name, or `null`.
|
|
7
|
+
*/
|
|
8
|
+
function firstAnimationName(animations: readonly Animation[]): string | null {
|
|
9
|
+
for (const animation of animations) {
|
|
10
|
+
if (animation.name.type === 'ident' || animation.name.type === 'string') return animation.name.value
|
|
11
|
+
}
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Pull the first ident name from a typed `animation-name` longhand.
|
|
17
|
+
* @param names Animation-name list.
|
|
18
|
+
* @returns First name, or `null`.
|
|
19
|
+
*/
|
|
20
|
+
function firstNameFromAnimationNames(names: readonly { type: string; value?: string }[]): string | null {
|
|
21
|
+
for (const name of names) {
|
|
22
|
+
if ((name.type === 'ident' || name.type === 'string') && typeof name.value === 'string') return name.value
|
|
23
|
+
}
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Extract the animation name of an `@keyframes` rule. lightningcss models
|
|
29
|
+
* the name as a discriminated union (`ident` / `custom`); both variants
|
|
30
|
+
* carry the same downstream string.
|
|
31
|
+
* @param raw lightningcss `KeyframesName`.
|
|
32
|
+
* @returns Animation name, or `null` when empty.
|
|
33
|
+
*/
|
|
34
|
+
export function keyframesName(raw: KeyframesName): string | null {
|
|
35
|
+
if (typeof raw.value !== 'string' || raw.value.length === 0) return null
|
|
36
|
+
return raw.value
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Render a keyframe step's selector list back to CSS-text (`'from'`,
|
|
41
|
+
* `'to'`, or `'50%'`). Timeline-range keyframe selectors (CSS Scroll /
|
|
42
|
+
* View Timelines) can't run in React Native — those steps are skipped.
|
|
43
|
+
* @param selectors Step selectors.
|
|
44
|
+
* @returns Step offset, or `null` when unrepresentable in RN.
|
|
45
|
+
*/
|
|
46
|
+
export function keyframeSelectorOffset(selectors: readonly KeyframeSelector[]): string | null {
|
|
47
|
+
const [head] = selectors
|
|
48
|
+
if (!head) return null
|
|
49
|
+
switch (head.type) {
|
|
50
|
+
case 'from': {
|
|
51
|
+
return 'from'
|
|
52
|
+
}
|
|
53
|
+
case 'to': {
|
|
54
|
+
return 'to'
|
|
55
|
+
}
|
|
56
|
+
case 'percentage': {
|
|
57
|
+
return `${head.value * 100}%`
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Extract the referenced `@keyframes` name from a declaration whose
|
|
67
|
+
* property is `animation-name` or a shorthand `animation` that names one.
|
|
68
|
+
* Returns the first ident found inside the value — Tailwind's animate-*
|
|
69
|
+
* utilities emit exactly one animation-name per rule.
|
|
70
|
+
* @param decl One declaration from a style rule.
|
|
71
|
+
* @returns Keyframe name, or `null` when the declaration doesn't reference one.
|
|
72
|
+
*/
|
|
73
|
+
export function pickAnimationName(decl: LcDeclaration): string | null {
|
|
74
|
+
if (decl.property === 'animation') return firstAnimationName(decl.value)
|
|
75
|
+
if (decl.property === 'animation-name') return firstNameFromAnimationNames(decl.value)
|
|
76
|
+
if (decl.property !== 'unparsed') return null
|
|
77
|
+
const targetProperty = decl.value.propertyId.property
|
|
78
|
+
if (targetProperty !== 'animation-name' && targetProperty !== 'animation') return null
|
|
79
|
+
for (const token of decl.value.value) {
|
|
80
|
+
if (token.type === 'token' && token.value.type === 'ident') return token.value.value
|
|
81
|
+
if (token.type === 'dashed-ident') return token.value
|
|
82
|
+
}
|
|
83
|
+
return null
|
|
84
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Declaration as LcDeclaration } from 'lightningcss'
|
|
2
|
+
import type { RNEntry } from './types'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Lower CSS alignment keywords to the strings RN accepts. CSS uses
|
|
6
|
+
* `start`/`end` while RN sticks with the legacy `flex-start`/`flex-end`.
|
|
7
|
+
* Shared between `align-items`, `align-self`, `align-content`, and
|
|
8
|
+
* `justify-content` — the lowering rule is identical for all four.
|
|
9
|
+
* @param css CSS keyword (`center` / `start` / `end` / `baseline` / `stretch`).
|
|
10
|
+
* @returns RN-compatible keyword.
|
|
11
|
+
*/
|
|
12
|
+
function cssToRnAlignment(css: string): string {
|
|
13
|
+
if (css === 'start') return 'flex-start'
|
|
14
|
+
if (css === 'end') return 'flex-end'
|
|
15
|
+
return css
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Alias kept for clarity at the call site. Identical lowering rule. */
|
|
19
|
+
const cssToRnJustify = cssToRnAlignment
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Map lightningcss's `align-items` / `align-self` / `align-content`
|
|
23
|
+
* value (typed as `{type: 'self-position' | 'baseline-position', value: …}`)
|
|
24
|
+
* to the RN keyword RN expects.
|
|
25
|
+
* @param value Typed alignment value.
|
|
26
|
+
* @returns RN alignment string, or `null` when unmappable.
|
|
27
|
+
*/
|
|
28
|
+
function mapAlignKeyword(value: unknown): string | null {
|
|
29
|
+
if (typeof value === 'string') return cssToRnAlignment(value)
|
|
30
|
+
if (typeof value !== 'object' || value === null) return null
|
|
31
|
+
const tagged = value as { type?: string; value?: string }
|
|
32
|
+
if (tagged.type === 'baseline-position') return 'baseline'
|
|
33
|
+
if (typeof tagged.value === 'string') return cssToRnAlignment(tagged.value)
|
|
34
|
+
// Bare-keyword variants like `{type: 'stretch'}` carry the keyword
|
|
35
|
+
// in the `type` field with no separate `value`.
|
|
36
|
+
if (tagged.type === 'stretch' || tagged.type === 'normal') return cssToRnAlignment(tagged.type)
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Map lightningcss's `justify-content` value to the RN keyword.
|
|
42
|
+
* @param value Typed justify value.
|
|
43
|
+
* @returns RN justify string, or `null` when unmappable.
|
|
44
|
+
*/
|
|
45
|
+
function mapJustifyKeyword(value: unknown): string | null {
|
|
46
|
+
if (typeof value === 'string') return cssToRnJustify(value)
|
|
47
|
+
if (typeof value !== 'object' || value === null) return null
|
|
48
|
+
const tagged = value as { type?: string; value?: string }
|
|
49
|
+
if (typeof tagged.value === 'string') return cssToRnJustify(tagged.value)
|
|
50
|
+
return null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Dispatch flexbox-layout declarations (flex-direction, flex-wrap,
|
|
55
|
+
* align-items, align-self, align-content, justify-content). Returns
|
|
56
|
+
* `null` for any property the dispatcher doesn't handle so the caller
|
|
57
|
+
* can fall through to its main switch.
|
|
58
|
+
*
|
|
59
|
+
* RN expects keyword-mapped strings: `flex-start` / `flex-end` instead
|
|
60
|
+
* of CSS's `start` / `end`. We do the lowering here.
|
|
61
|
+
* @param decl One lightningcss declaration.
|
|
62
|
+
* @returns RN entries when the property matched, else `null`.
|
|
63
|
+
*/
|
|
64
|
+
export function dispatchLayoutDeclaration(decl: LcDeclaration): readonly RNEntry[] | null {
|
|
65
|
+
switch (decl.property) {
|
|
66
|
+
case 'flex-direction': {
|
|
67
|
+
return [['flexDirection', String(decl.value)]]
|
|
68
|
+
}
|
|
69
|
+
case 'flex-wrap': {
|
|
70
|
+
return [['flexWrap', String(decl.value)]]
|
|
71
|
+
}
|
|
72
|
+
case 'align-items': {
|
|
73
|
+
const v = mapAlignKeyword(decl.value)
|
|
74
|
+
return v === null ? [] : [['alignItems', v]]
|
|
75
|
+
}
|
|
76
|
+
case 'align-self': {
|
|
77
|
+
const v = mapAlignKeyword(decl.value)
|
|
78
|
+
return v === null ? [] : [['alignSelf', v]]
|
|
79
|
+
}
|
|
80
|
+
case 'align-content': {
|
|
81
|
+
const v = mapAlignKeyword(decl.value)
|
|
82
|
+
return v === null ? [] : [['alignContent', v]]
|
|
83
|
+
}
|
|
84
|
+
case 'justify-content': {
|
|
85
|
+
const v = mapJustifyKeyword(decl.value)
|
|
86
|
+
return v === null ? [] : [['justifyContent', v]]
|
|
87
|
+
}
|
|
88
|
+
default: {
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DimensionPercentageFor_LengthValue as LcDimensionPercentage,
|
|
3
|
+
GapValue,
|
|
4
|
+
LengthPercentageOrAuto,
|
|
5
|
+
LengthValue,
|
|
6
|
+
MaxSize,
|
|
7
|
+
Size,
|
|
8
|
+
} from 'lightningcss'
|
|
9
|
+
import { REM_TO_PX } from './constants'
|
|
10
|
+
|
|
11
|
+
/** Alias for lightningcss's snake_case dimension-or-percentage type. */
|
|
12
|
+
type DimensionPercentage = LcDimensionPercentage
|
|
13
|
+
|
|
14
|
+
/** RN-compatible length/percent result, or `null` when unrepresentable. */
|
|
15
|
+
type LengthResult = number | string | null
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Round a percentage / length float to 4 decimal places so lightningcss's
|
|
19
|
+
* IEEE-754 noise (`0.237 → 0.23700000345…`) doesn't leak into RN style
|
|
20
|
+
* strings. 4 decimals is well below CSS subpixel precision.
|
|
21
|
+
* @param n Raw float.
|
|
22
|
+
* @returns Rounded float with trailing zeros trimmed.
|
|
23
|
+
*/
|
|
24
|
+
function roundFloat(n: number): number {
|
|
25
|
+
return Math.round(n * 10_000) / 10_000
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Convert a lightningcss `LengthValue` to a pixel number. Handles the
|
|
30
|
+
* units Tailwind emits: px, rem, em. Unknown units pass through as the
|
|
31
|
+
* raw numeric value so a later pass can warn.
|
|
32
|
+
* @param length Typed length value.
|
|
33
|
+
* @returns Pixel number.
|
|
34
|
+
*/
|
|
35
|
+
export function lengthToPx(length: LengthValue): number {
|
|
36
|
+
switch (length.unit) {
|
|
37
|
+
case 'px': {
|
|
38
|
+
return length.value
|
|
39
|
+
}
|
|
40
|
+
case 'rem':
|
|
41
|
+
case 'em': {
|
|
42
|
+
return length.value * REM_TO_PX
|
|
43
|
+
}
|
|
44
|
+
default: {
|
|
45
|
+
return length.value
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Collapse a `DimensionPercentageFor_LengthValue` to a number (pixel) or
|
|
52
|
+
* `'N%'` string. `calc()` variants are not evaluated here — they fall
|
|
53
|
+
* through to `null` so the caller can skip or serialize via tokens.
|
|
54
|
+
* @param value Typed dimension-or-percentage.
|
|
55
|
+
* @returns Number, percent string, or `null` when unrepresentable.
|
|
56
|
+
*/
|
|
57
|
+
export function dimensionPercentageToNumber(value: DimensionPercentage): LengthResult {
|
|
58
|
+
if (value.type === 'dimension') return lengthToPx(value.value)
|
|
59
|
+
if (value.type === 'percentage') return `${roundFloat(value.value * 100)}%`
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Convert `LengthPercentageOrAuto` (per-side value type for padding /
|
|
65
|
+
* margin / inset) to an RN scalar. `auto` maps to the string `'auto'`,
|
|
66
|
+
* which RN's margin accepts for centering; non-margin callers can filter
|
|
67
|
+
* it out if they need a number.
|
|
68
|
+
* @param value Typed length-percentage-or-auto.
|
|
69
|
+
* @returns RN scalar or `null` for unrepresentable shapes.
|
|
70
|
+
*/
|
|
71
|
+
export function lengthPercentageOrAutoToValue(value: LengthPercentageOrAuto): LengthResult {
|
|
72
|
+
if (value.type === 'auto') return 'auto'
|
|
73
|
+
return dimensionPercentageToNumber(value.value)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Convert a lightningcss `Size` (used by width/height) or `MaxSize` (used
|
|
78
|
+
* by max-width/max-height) to an RN scalar. Sizing keywords with no RN
|
|
79
|
+
* analog (`min-content`, `fit-content`, `stretch`, …) fall through to
|
|
80
|
+
* `null` so the caller drops them.
|
|
81
|
+
* @param value Typed size value.
|
|
82
|
+
* @returns RN scalar or `null` when unrepresentable.
|
|
83
|
+
*/
|
|
84
|
+
export function sizeLikeToValue(value: Size | MaxSize): LengthResult {
|
|
85
|
+
if (value.type === 'auto' || value.type === 'none') return value.type === 'auto' ? 'auto' : null
|
|
86
|
+
if (value.type === 'length-percentage') return dimensionPercentageToNumber(value.value)
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Convert a lightningcss `GapValue` (per-axis gap, used by `row-gap` /
|
|
92
|
+
* `column-gap`) to an RN scalar. The `normal` keyword has no RN analog
|
|
93
|
+
* and falls through to `null`.
|
|
94
|
+
* @param value Typed gap value.
|
|
95
|
+
* @returns Number, percent string, or `null`.
|
|
96
|
+
*/
|
|
97
|
+
export function gapValueToValue(value: GapValue): LengthResult {
|
|
98
|
+
if (value.type === 'normal') return null
|
|
99
|
+
return dimensionPercentageToNumber(value.value)
|
|
100
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Declaration as LcDeclaration } from 'lightningcss'
|
|
2
|
+
import {
|
|
3
|
+
animationDelayEntries,
|
|
4
|
+
animationDirectionEntries,
|
|
5
|
+
animationDurationEntries,
|
|
6
|
+
animationFillModeEntries,
|
|
7
|
+
animationIterationCountEntries,
|
|
8
|
+
animationNameEntries,
|
|
9
|
+
animationPlayStateEntries,
|
|
10
|
+
animationShorthandToEntries,
|
|
11
|
+
animationTimingFunctionEntries,
|
|
12
|
+
transitionDelayEntries,
|
|
13
|
+
transitionDurationEntries,
|
|
14
|
+
transitionPropertyEntries,
|
|
15
|
+
transitionShorthandToEntries,
|
|
16
|
+
transitionTimingFunctionEntries,
|
|
17
|
+
} from './animation'
|
|
18
|
+
import { rotateToEntries, scaleToEntries, transformFunctionsToEntries, translateToEntries } from './transform'
|
|
19
|
+
import type { RNEntry } from './types'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Dispatch motion-adjacent declarations (animation/transition/transform)
|
|
23
|
+
* to their typed handlers. Returns `null` when the declaration isn't
|
|
24
|
+
* one this dispatcher handles, so the caller can fall through to its
|
|
25
|
+
* main switch.
|
|
26
|
+
* @param decl One lightningcss declaration.
|
|
27
|
+
* @returns RN entries when the property matched, else `null`.
|
|
28
|
+
*/
|
|
29
|
+
export function dispatchMotionDeclaration(decl: LcDeclaration): readonly RNEntry[] | null {
|
|
30
|
+
switch (decl.property) {
|
|
31
|
+
case 'animation': {
|
|
32
|
+
return animationShorthandToEntries(decl.value)
|
|
33
|
+
}
|
|
34
|
+
case 'animation-name': {
|
|
35
|
+
return animationNameEntries(decl.value)
|
|
36
|
+
}
|
|
37
|
+
case 'animation-duration': {
|
|
38
|
+
return animationDurationEntries(decl.value)
|
|
39
|
+
}
|
|
40
|
+
case 'animation-timing-function': {
|
|
41
|
+
return animationTimingFunctionEntries(decl.value)
|
|
42
|
+
}
|
|
43
|
+
case 'animation-iteration-count': {
|
|
44
|
+
return animationIterationCountEntries(decl.value)
|
|
45
|
+
}
|
|
46
|
+
case 'animation-delay': {
|
|
47
|
+
return animationDelayEntries(decl.value)
|
|
48
|
+
}
|
|
49
|
+
case 'animation-direction': {
|
|
50
|
+
return animationDirectionEntries(decl.value)
|
|
51
|
+
}
|
|
52
|
+
case 'animation-fill-mode': {
|
|
53
|
+
return animationFillModeEntries(decl.value)
|
|
54
|
+
}
|
|
55
|
+
case 'animation-play-state': {
|
|
56
|
+
return animationPlayStateEntries(decl.value)
|
|
57
|
+
}
|
|
58
|
+
case 'transition': {
|
|
59
|
+
return transitionShorthandToEntries(decl.value)
|
|
60
|
+
}
|
|
61
|
+
case 'transition-property': {
|
|
62
|
+
return transitionPropertyEntries(decl.value)
|
|
63
|
+
}
|
|
64
|
+
case 'transition-duration': {
|
|
65
|
+
return transitionDurationEntries(decl.value)
|
|
66
|
+
}
|
|
67
|
+
case 'transition-timing-function': {
|
|
68
|
+
return transitionTimingFunctionEntries(decl.value)
|
|
69
|
+
}
|
|
70
|
+
case 'transition-delay': {
|
|
71
|
+
return transitionDelayEntries(decl.value)
|
|
72
|
+
}
|
|
73
|
+
case 'transform': {
|
|
74
|
+
return transformFunctionsToEntries(decl.value)
|
|
75
|
+
}
|
|
76
|
+
case 'rotate': {
|
|
77
|
+
return rotateToEntries(decl.value)
|
|
78
|
+
}
|
|
79
|
+
case 'translate': {
|
|
80
|
+
return translateToEntries(decl.value)
|
|
81
|
+
}
|
|
82
|
+
case 'scale': {
|
|
83
|
+
return scaleToEntries(decl.value)
|
|
84
|
+
}
|
|
85
|
+
default: {
|
|
86
|
+
return null
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ParsedComponent } from 'lightningcss'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Serialize an `@property --x { initial-value: … }` body to plain text —
|
|
5
|
+
* enough for the downstream var() resolver to use as a fallback.
|
|
6
|
+
* @param initial Parsed-component AST node (or null when absent).
|
|
7
|
+
* @returns CSS-value string, or `null` when missing / unsupported shape.
|
|
8
|
+
*/
|
|
9
|
+
export function serializeInitialValue(initial: ParsedComponent | null | undefined): string | null {
|
|
10
|
+
if (!initial) return null
|
|
11
|
+
if (initial.type === 'literal') return initial.value
|
|
12
|
+
if (initial.type === 'custom-ident') return initial.value
|
|
13
|
+
if (initial.type === 'string') return initial.value
|
|
14
|
+
return null
|
|
15
|
+
}
|