styled-components 6.4.1 → 7.0.0-prerelease-20260511181111
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/README.md +29 -0
- package/dist/base.d.ts +3 -2
- package/dist/constants.d.ts +0 -9
- package/dist/constructors/createGlobalStyle.d.ts +3 -1
- package/dist/constructors/createTheme.d.ts +2 -55
- package/dist/constructors/createTheme.native.d.ts +19 -0
- package/dist/constructors/createTheme.shared.d.ts +15 -0
- package/dist/constructors/createTheme.types.d.ts +30 -0
- package/dist/constructors/css.d.ts +10 -1
- package/dist/hoc/withTheme.d.ts +4 -2
- package/dist/index.d.ts +1 -2
- package/dist/models/Keyframes.d.ts +25 -3
- package/dist/models/NativeStyle.d.ts +7 -0
- package/dist/models/StyleSheetManager.d.ts +29 -41
- package/dist/models/StyledComponent.d.ts +3 -0
- package/dist/models/StyledNativeComponent.d.ts +21 -2
- package/dist/models/ThemeProvider.d.ts +1 -10
- package/dist/models/WebGlobalStyle.d.ts +24 -0
- package/dist/models/WebStyle.d.ts +55 -0
- package/dist/models/compileNative.d.ts +198 -0
- package/dist/native/animation/css-keywords.d.ts +63 -0
- package/dist/native/animation/cssAdapter.d.ts +22 -0
- package/dist/native/animation/index.d.ts +113 -0
- package/dist/native/animation/parse-shorthand.d.ts +46 -0
- package/dist/native/animation/types.d.ts +198 -0
- package/dist/native/bunProfileGlobals.d.ts +7 -0
- package/dist/native/index.d.ts +9 -3
- package/dist/native/polyfills.d.ts +105 -0
- package/dist/native/profile-animation.d.ts +13 -0
- package/dist/native/profile-color-polyfill.d.ts +11 -0
- package/dist/native/profileHarness.d.ts +17 -0
- package/dist/native/reanimated/index.d.ts +3 -0
- package/dist/native/responsive.d.ts +87 -0
- package/dist/native/transform/dev.d.ts +55 -0
- package/dist/native/transform/handlers/border.d.ts +22 -0
- package/dist/native/transform/handlers/flex.d.ts +11 -0
- package/dist/native/transform/handlers/font.d.ts +13 -0
- package/dist/native/transform/handlers/spacing.d.ts +15 -0
- package/dist/native/transform/handlers/text.d.ts +18 -0
- package/dist/native/transform/index.d.ts +18 -0
- package/dist/native/transform/passthrough.d.ts +49 -0
- package/dist/native/transform/polyfills/caretColor.d.ts +1 -0
- package/dist/native/transform/polyfills/colorMath.d.ts +69 -0
- package/dist/native/transform/polyfills/hyphens.d.ts +1 -0
- package/dist/native/transform/polyfills/lineClamp.d.ts +1 -0
- package/dist/native/transform/polyfills/linearEasing.d.ts +6 -0
- package/dist/native/transform/polyfills/logicalShorthand.d.ts +1 -0
- package/dist/native/transform/polyfills/mathFns.d.ts +40 -0
- package/dist/native/transform/polyfills/resolvers.d.ts +59 -0
- package/dist/native/transform/polyfills/standaloneTransform.d.ts +1 -0
- package/dist/native/transform/polyfills/textWrap.d.ts +1 -0
- package/dist/native/transform/sanitize.d.ts +17 -0
- package/dist/native/transform/shorthandHelpers.d.ts +42 -0
- package/dist/native/transform/shorthands.d.ts +11 -0
- package/dist/native/transform/shorthands.register.d.ts +6 -0
- package/dist/native/transform/tokenStream.d.ts +24 -0
- package/dist/native/transform/tokenize.d.ts +18 -0
- package/dist/native/transform/tokens.d.ts +75 -0
- package/dist/native/transform/units.d.ts +11 -0
- package/dist/parser/ast.d.ts +158 -0
- package/dist/parser/compile.d.ts +73 -0
- package/dist/parser/emit-web.d.ts +43 -0
- package/dist/parser/nativePlan.d.ts +38 -0
- package/dist/parser/parser.d.ts +63 -0
- package/dist/parser/source.d.ts +72 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/rsc.d.ts +17 -0
- package/dist/plugins/rscSelectorRewrite.d.ts +6 -0
- package/dist/plugins/rtl.d.ts +16 -0
- package/dist/plugins.cjs.js +2 -0
- package/dist/plugins.cjs.js.map +1 -0
- package/dist/plugins.esm.js +2 -0
- package/dist/plugins.esm.js.map +1 -0
- package/dist/sheet/GroupIDAllocator.d.ts +2 -2
- package/dist/sheet/Sheet.d.ts +3 -11
- package/dist/sheet/Tag.d.ts +4 -21
- package/dist/sheet/types.d.ts +1 -3
- package/dist/styled-components.browser.cjs.js +4 -4
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +4 -4
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +4 -4
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +4 -4
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +3884 -1436
- package/dist/styled-components.js.map +1 -1
- package/dist/styled-components.min.js +4 -4
- package/dist/styled-components.min.js.map +1 -1
- package/dist/types.d.ts +155 -71
- package/dist/utils/charCodes.d.ts +46 -7
- package/dist/utils/compiler.d.ts +26 -0
- package/dist/utils/determineTheme.d.ts +2 -4
- package/dist/utils/domElements.d.ts +1 -1
- package/dist/utils/empties.d.ts +1 -1
- package/dist/utils/escapeStyleSink.d.ts +27 -0
- package/dist/utils/extractCSS.d.ts +19 -0
- package/dist/utils/fifoMap.d.ts +8 -0
- package/dist/utils/generateDisplayName.d.ts +1 -1
- package/dist/utils/getComponentName.d.ts +1 -1
- package/dist/utils/hash.d.ts +0 -1
- package/dist/utils/hoist.d.ts +5 -1
- package/dist/utils/interleave.d.ts +1 -1
- package/dist/utils/isPropValid.d.ts +1 -0
- package/dist/utils/isRsc.d.ts +9 -0
- package/dist/utils/isStaticRules.d.ts +1 -1
- package/dist/utils/isStyledComponent.d.ts +1 -1
- package/dist/utils/isTag.d.ts +1 -1
- package/dist/utils/joinStrings.d.ts +0 -1
- package/dist/utils/normalize.d.ts +8 -0
- package/dist/utils/objectToCSS.d.ts +30 -0
- package/dist/utils/setToString.d.ts +0 -16
- package/dist/utils/shallowEqual.d.ts +10 -0
- package/dist/utils/themePath.d.ts +62 -0
- package/dist/utils/tracePostAttrs.d.ts +8 -0
- package/dist/utils/warnOnce.d.ts +12 -0
- package/native/dist/base.d.ts +3 -2
- package/native/dist/constants.d.ts +0 -9
- package/native/dist/constructors/createGlobalStyle.d.ts +3 -1
- package/native/dist/constructors/createTheme.d.ts +2 -55
- package/native/dist/constructors/createTheme.native.d.ts +19 -0
- package/native/dist/constructors/createTheme.shared.d.ts +15 -0
- package/native/dist/constructors/createTheme.types.d.ts +30 -0
- package/native/dist/constructors/css.d.ts +10 -1
- package/native/dist/hoc/withTheme.d.ts +4 -2
- package/native/dist/index.d.ts +1 -2
- package/native/dist/models/Keyframes.d.ts +25 -3
- package/native/dist/models/NativeStyle.d.ts +7 -0
- package/native/dist/models/StyleSheetManager.d.ts +29 -41
- package/native/dist/models/StyledComponent.d.ts +3 -0
- package/native/dist/models/StyledNativeComponent.d.ts +21 -2
- package/native/dist/models/ThemeProvider.d.ts +1 -10
- package/native/dist/models/WebGlobalStyle.d.ts +24 -0
- package/native/dist/models/WebStyle.d.ts +55 -0
- package/native/dist/models/compileNative.d.ts +198 -0
- package/native/dist/native/animation/css-keywords.d.ts +63 -0
- package/native/dist/native/animation/cssAdapter.d.ts +22 -0
- package/native/dist/native/animation/index.d.ts +113 -0
- package/native/dist/native/animation/parse-shorthand.d.ts +46 -0
- package/native/dist/native/animation/types.d.ts +198 -0
- package/native/dist/native/bunProfileGlobals.d.ts +7 -0
- package/native/dist/native/index.d.ts +9 -3
- package/native/dist/native/polyfills.d.ts +105 -0
- package/native/dist/native/profile-animation.d.ts +13 -0
- package/native/dist/native/profile-color-polyfill.d.ts +11 -0
- package/native/dist/native/profileHarness.d.ts +17 -0
- package/native/dist/native/reanimated/index.d.ts +3 -0
- package/native/dist/native/responsive.d.ts +87 -0
- package/native/dist/native/transform/dev.d.ts +55 -0
- package/native/dist/native/transform/handlers/border.d.ts +22 -0
- package/native/dist/native/transform/handlers/flex.d.ts +11 -0
- package/native/dist/native/transform/handlers/font.d.ts +13 -0
- package/native/dist/native/transform/handlers/spacing.d.ts +15 -0
- package/native/dist/native/transform/handlers/text.d.ts +18 -0
- package/native/dist/native/transform/index.d.ts +18 -0
- package/native/dist/native/transform/passthrough.d.ts +49 -0
- package/native/dist/native/transform/polyfills/caretColor.d.ts +1 -0
- package/native/dist/native/transform/polyfills/colorMath.d.ts +69 -0
- package/native/dist/native/transform/polyfills/hyphens.d.ts +1 -0
- package/native/dist/native/transform/polyfills/lineClamp.d.ts +1 -0
- package/native/dist/native/transform/polyfills/linearEasing.d.ts +6 -0
- package/native/dist/native/transform/polyfills/logicalShorthand.d.ts +1 -0
- package/native/dist/native/transform/polyfills/mathFns.d.ts +40 -0
- package/native/dist/native/transform/polyfills/resolvers.d.ts +59 -0
- package/native/dist/native/transform/polyfills/standaloneTransform.d.ts +1 -0
- package/native/dist/native/transform/polyfills/textWrap.d.ts +1 -0
- package/native/dist/native/transform/sanitize.d.ts +17 -0
- package/native/dist/native/transform/shorthandHelpers.d.ts +42 -0
- package/native/dist/native/transform/shorthands.d.ts +11 -0
- package/native/dist/native/transform/shorthands.register.d.ts +6 -0
- package/native/dist/native/transform/tokenStream.d.ts +24 -0
- package/native/dist/native/transform/tokenize.d.ts +18 -0
- package/native/dist/native/transform/tokens.d.ts +75 -0
- package/native/dist/native/transform/units.d.ts +11 -0
- package/native/dist/parser/ast.d.ts +158 -0
- package/native/dist/parser/compile.d.ts +73 -0
- package/native/dist/parser/emit-web.d.ts +43 -0
- package/native/dist/parser/nativePlan.d.ts +38 -0
- package/native/dist/parser/parser.d.ts +63 -0
- package/native/dist/parser/source.d.ts +72 -0
- package/native/dist/plugins/index.d.ts +3 -0
- package/native/dist/plugins/rsc.d.ts +17 -0
- package/native/dist/plugins/rscSelectorRewrite.d.ts +6 -0
- package/native/dist/plugins/rtl.d.ts +16 -0
- package/native/dist/sheet/GroupIDAllocator.d.ts +2 -2
- package/native/dist/sheet/Sheet.d.ts +3 -11
- package/native/dist/sheet/Tag.d.ts +3 -20
- package/native/dist/sheet/types.d.ts +1 -3
- package/native/dist/styled-components.native.browser.cjs.js +6 -0
- package/native/dist/styled-components.native.browser.cjs.js.map +1 -0
- package/native/dist/styled-components.native.browser.esm.js +6 -0
- package/native/dist/styled-components.native.browser.esm.js.map +1 -0
- package/native/dist/styled-components.native.cjs.js +5 -1
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +5 -1
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/styled-components.native.reanimated.cjs.js +2 -0
- package/native/dist/styled-components.native.reanimated.cjs.js.map +1 -0
- package/native/dist/styled-components.native.reanimated.esm.js +2 -0
- package/native/dist/styled-components.native.reanimated.esm.js.map +1 -0
- package/native/dist/types.d.ts +155 -71
- package/native/dist/utils/charCodes.d.ts +46 -7
- package/native/dist/utils/compiler.d.ts +26 -0
- package/native/dist/utils/determineTheme.d.ts +2 -4
- package/native/dist/utils/domElements.d.ts +1 -1
- package/native/dist/utils/empties.d.ts +1 -1
- package/native/dist/utils/escapeStyleSink.d.ts +27 -0
- package/native/dist/utils/extractCSS.d.ts +19 -0
- package/native/dist/utils/fifoMap.d.ts +8 -0
- package/native/dist/utils/generateDisplayName.d.ts +1 -1
- package/native/dist/utils/getComponentName.d.ts +1 -1
- package/native/dist/utils/hash.d.ts +0 -1
- package/native/dist/utils/hoist.d.ts +5 -1
- package/native/dist/utils/interleave.d.ts +1 -1
- package/native/dist/utils/isPropValid.d.ts +1 -0
- package/native/dist/utils/isRsc.d.ts +9 -0
- package/native/dist/utils/isStaticRules.d.ts +1 -1
- package/native/dist/utils/isStyledComponent.d.ts +1 -1
- package/native/dist/utils/isTag.d.ts +1 -1
- package/native/dist/utils/joinStrings.d.ts +0 -1
- package/native/dist/utils/normalize.d.ts +8 -0
- package/native/dist/utils/objectToCSS.d.ts +30 -0
- package/native/dist/utils/setToString.d.ts +0 -16
- package/native/dist/utils/shallowEqual.d.ts +10 -0
- package/native/dist/utils/themePath.d.ts +62 -0
- package/native/dist/utils/tracePostAttrs.d.ts +8 -0
- package/native/dist/utils/warnOnce.d.ts +12 -0
- package/native/package.json +6 -4
- package/native/reanimated/package.json +7 -0
- package/package.json +24 -28
- package/plugins/package.json +7 -0
- package/test-utils/setupTestFramework.ts +6 -0
- package/dist/bench/bench-utils.d.ts +0 -9
- package/dist/models/ComponentStyle.d.ts +0 -19
- package/dist/models/GlobalStyle.d.ts +0 -23
- package/dist/models/InlineStyle.d.ts +0 -18
- package/dist/utils/cssTagged.d.ts +0 -2
- package/dist/utils/flatten.d.ts +0 -4
- package/dist/utils/isStatelessFunction.d.ts +0 -1
- package/dist/utils/mixinDeep.d.ts +0 -6
- package/dist/utils/stylis.d.ts +0 -27
- package/dist/utils/stylisPluginRSC.d.ts +0 -3
- package/native/dist/bench/bench-utils.d.ts +0 -9
- package/native/dist/dist/base.d.ts +0 -13
- package/native/dist/dist/bench/bench-utils.d.ts +0 -9
- package/native/dist/dist/constants.d.ts +0 -17
- package/native/dist/dist/constructors/constructWithOptions.d.ts +0 -17
- package/native/dist/dist/constructors/createGlobalStyle.d.ts +0 -13
- package/native/dist/dist/constructors/createTheme.d.ts +0 -108
- package/native/dist/dist/constructors/css.d.ts +0 -16
- package/native/dist/dist/constructors/keyframes.d.ts +0 -14
- package/native/dist/dist/constructors/styled.d.ts +0 -25
- package/native/dist/dist/hoc/withTheme.d.ts +0 -7
- package/native/dist/dist/index-standalone.d.ts +0 -3
- package/native/dist/dist/index.d.ts +0 -5
- package/native/dist/dist/models/ComponentStyle.d.ts +0 -19
- package/native/dist/dist/models/GlobalStyle.d.ts +0 -23
- package/native/dist/dist/models/InlineStyle.d.ts +0 -18
- package/native/dist/dist/models/Keyframes.d.ts +0 -12
- package/native/dist/dist/models/ServerStyleSheet.d.ts +0 -16
- package/native/dist/dist/models/StyleSheetManager.d.ts +0 -81
- package/native/dist/dist/models/StyledComponent.d.ts +0 -3
- package/native/dist/dist/models/StyledNativeComponent.d.ts +0 -3
- package/native/dist/dist/models/ThemeProvider.d.ts +0 -47
- package/native/dist/dist/native/index.d.ts +0 -35
- package/native/dist/dist/secretInternals.d.ts +0 -5
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts +0 -4
- package/native/dist/dist/sheet/GroupedTag.d.ts +0 -13
- package/native/dist/dist/sheet/Rehydration.d.ts +0 -10
- package/native/dist/dist/sheet/Sheet.d.ts +0 -43
- package/native/dist/dist/sheet/Tag.d.ts +0 -55
- package/native/dist/dist/sheet/dom.d.ts +0 -7
- package/native/dist/dist/sheet/index.d.ts +0 -1
- package/native/dist/dist/sheet/types.d.ts +0 -37
- package/native/dist/dist/types.d.ts +0 -224
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts +0 -1
- package/native/dist/dist/utils/charCodes.d.ts +0 -16
- package/native/dist/dist/utils/checkDynamicCreation.d.ts +0 -1
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -3
- package/native/dist/dist/utils/cssTagged.d.ts +0 -2
- package/native/dist/dist/utils/determineTheme.d.ts +0 -4
- package/native/dist/dist/utils/domElements.d.ts +0 -4
- package/native/dist/dist/utils/empties.d.ts +0 -3
- package/native/dist/dist/utils/error.d.ts +0 -5
- package/native/dist/dist/utils/errors.d.ts +0 -21
- package/native/dist/dist/utils/escape.d.ts +0 -1
- package/native/dist/dist/utils/flatten.d.ts +0 -4
- package/native/dist/dist/utils/generateAlphabeticName.d.ts +0 -1
- package/native/dist/dist/utils/generateComponentId.d.ts +0 -1
- package/native/dist/dist/utils/generateDisplayName.d.ts +0 -2
- package/native/dist/dist/utils/getComponentName.d.ts +0 -2
- package/native/dist/dist/utils/hash.d.ts +0 -4
- package/native/dist/dist/utils/hoist.d.ts +0 -47
- package/native/dist/dist/utils/hyphenateStyleName.d.ts +0 -14
- package/native/dist/dist/utils/interleave.d.ts +0 -2
- package/native/dist/dist/utils/isFunction.d.ts +0 -1
- package/native/dist/dist/utils/isKeyframes.d.ts +0 -4
- package/native/dist/dist/utils/isPlainObject.d.ts +0 -1
- package/native/dist/dist/utils/isStatelessFunction.d.ts +0 -1
- package/native/dist/dist/utils/isStaticRules.d.ts +0 -2
- package/native/dist/dist/utils/isStyledComponent.d.ts +0 -3
- package/native/dist/dist/utils/isTag.d.ts +0 -2
- package/native/dist/dist/utils/joinStrings.d.ts +0 -8
- package/native/dist/dist/utils/mixinDeep.d.ts +0 -6
- package/native/dist/dist/utils/nonce.d.ts +0 -3
- package/native/dist/dist/utils/rscCache.d.ts +0 -2
- package/native/dist/dist/utils/setToString.d.ts +0 -17
- package/native/dist/dist/utils/stylis.d.ts +0 -27
- package/native/dist/dist/utils/stylisPluginRSC.d.ts +0 -3
- package/native/dist/models/ComponentStyle.d.ts +0 -19
- package/native/dist/models/GlobalStyle.d.ts +0 -23
- package/native/dist/models/InlineStyle.d.ts +0 -18
- package/native/dist/utils/cssTagged.d.ts +0 -2
- package/native/dist/utils/flatten.d.ts +0 -4
- package/native/dist/utils/isStatelessFunction.d.ts +0 -1
- package/native/dist/utils/mixinDeep.d.ts +0 -6
- package/native/dist/utils/stylis.d.ts +0 -27
- package/native/dist/utils/stylisPluginRSC.d.ts +0 -3
package/README.md
CHANGED
|
@@ -188,6 +188,20 @@ const Card = styled.div`
|
|
|
188
188
|
</ThemeProvider>
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
+
Tokens are placeholder references that resolve at render time, not raw values. Interpolate them anywhere a CSS value goes; don't combine them with JS arithmetic. For runtime composition use `calc()`, or reach for `theme.raw.space.md` when you genuinely need the original number in JS.
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
// works
|
|
195
|
+
padding: ${theme.space.md};
|
|
196
|
+
margin: ${theme.space.sm} ${theme.space.md};
|
|
197
|
+
top: calc(${insets.top}px + ${theme.space.md});
|
|
198
|
+
|
|
199
|
+
// breaks: JS `+` produces a malformed string the browser drops
|
|
200
|
+
top: ${insets.top + theme.space.md};
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
See the [createTheme API docs](https://styled-components.com/docs/api#createtheme) for the full composition rules.
|
|
204
|
+
|
|
191
205
|
### Shared styles with `css`
|
|
192
206
|
|
|
193
207
|
Extract reusable style blocks to share across components or apply conditionally.
|
|
@@ -256,6 +270,21 @@ const PasswordInput = styled.input.attrs({
|
|
|
256
270
|
`;
|
|
257
271
|
```
|
|
258
272
|
|
|
273
|
+
The function form receives a second `ast` argument for bridging declarations or theme tokens into props on third-party components. `peek` reads a value; `pop` reads and removes it from the rendered style. Both accept either a CSS property name or a typed dot-separated theme path:
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
import { Path } from 'react-native-svg';
|
|
277
|
+
|
|
278
|
+
const Icon = styled(Path).attrs((_props, ast) => ({
|
|
279
|
+
fill: ast.pop('color'), // lift the CSS color decl
|
|
280
|
+
stroke: ast.peek('palette.brand'), // read from theme via typed path
|
|
281
|
+
}))`
|
|
282
|
+
color: red;
|
|
283
|
+
`;
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Both methods take an optional fallback as the second argument, returned when the value is missing. The lift happens at construction time when the callback's behavior is fully determined by static declarations, so renders pay nothing extra.
|
|
287
|
+
|
|
259
288
|
## Documentation
|
|
260
289
|
|
|
261
290
|
- [Getting started](https://styled-components.com/docs/basics)
|
package/dist/base.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ import css from './constructors/css';
|
|
|
5
5
|
import keyframes from './constructors/keyframes';
|
|
6
6
|
import withTheme from './hoc/withTheme';
|
|
7
7
|
import ServerStyleSheet from './models/ServerStyleSheet';
|
|
8
|
-
import { IStyleSheetContext, IStyleSheetManager,
|
|
8
|
+
import { ICompilerContext, IStyleSheetContext, IStyleSheetManager, StyleSheetConsumer, StyleSheetContext, StyleSheetManager } from './models/StyleSheetManager';
|
|
9
9
|
import ThemeProvider, { ThemeConsumer, ThemeContext, useTheme } from './models/ThemeProvider';
|
|
10
|
+
import extractCSS from './utils/extractCSS';
|
|
10
11
|
import isStyledComponent from './utils/isStyledComponent';
|
|
11
12
|
export * from './secretInternals';
|
|
12
13
|
export { Attrs, DefaultTheme, Keyframes, ShouldForwardProp } from './types';
|
|
13
|
-
export { IStyleSheetContext, IStyleSheetManager,
|
|
14
|
+
export { ICompilerContext, IStyleSheetContext, IStyleSheetManager, ServerStyleSheet, StyleSheetConsumer, StyleSheetContext, StyleSheetManager, ThemeConsumer, ThemeContext, ThemeProvider, createGlobalStyle, createTheme, css, extractCSS, isStyledComponent, keyframes, useTheme, SC_VERSION as version, withTheme, };
|
package/dist/constants.d.ts
CHANGED
|
@@ -4,14 +4,5 @@ export declare const SC_ATTR_VERSION = "data-styled-version";
|
|
|
4
4
|
export declare const SC_VERSION: string;
|
|
5
5
|
export declare const SPLITTER = "/*!sc*/\n";
|
|
6
6
|
export declare const IS_BROWSER: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* True when running in a React Server Component environment (createContext
|
|
9
|
-
* is unavailable). In browser / standalone / native builds the entire
|
|
10
|
-
* expression is replaced with the literal `false` via rollup-plugin-replace
|
|
11
|
-
* with empty delimiters (exact string match), enabling rollup constant
|
|
12
|
-
* inlining and terser dead-code elimination for all RSC branches.
|
|
13
|
-
*/
|
|
14
|
-
export declare const IS_RSC: boolean;
|
|
15
|
-
export declare const DISABLE_SPEEDY: boolean;
|
|
16
7
|
export declare const KEYFRAMES_ID_PREFIX = "sc-keyframes-";
|
|
17
8
|
export declare const STATIC_EXECUTION_CONTEXT: {};
|
|
@@ -10,4 +10,6 @@ import { ExecutionProps, Interpolation, Styles } from '../types';
|
|
|
10
10
|
* // Render <GlobalStyle /> at the root of your app
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export default function createGlobalStyle<Props extends object>(strings: Styles<Props>, ...interpolations: Array<Interpolation<Props>>): React.NamedExoticComponent<ExecutionProps & Props
|
|
13
|
+
export default function createGlobalStyle<Props extends object>(strings: Styles<Props>, ...interpolations: Array<Interpolation<Props>>): React.NamedExoticComponent<ExecutionProps & Props> & {
|
|
14
|
+
styledComponentId: string;
|
|
15
|
+
};
|
|
@@ -1,57 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
type ThemeLeaf = string | number;
|
|
3
|
-
/**
|
|
4
|
-
* Recursively maps a theme object so every leaf value becomes
|
|
5
|
-
* a `var(--sc-path, fallback)` CSS string.
|
|
6
|
-
*/
|
|
7
|
-
type CSSVarTheme<T> = {
|
|
8
|
-
[K in keyof T]: T[K] extends ThemeLeaf ? string : CSSVarTheme<T[K]>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* The object returned by `createTheme`. Same shape as the input theme but
|
|
12
|
-
* every leaf is a CSS `var()` reference. Also carries a `GlobalStyle`
|
|
13
|
-
* component and the original `raw` theme object.
|
|
14
|
-
*/
|
|
15
|
-
type ThemeContract<T> = CSSVarTheme<T> & {
|
|
16
|
-
/**
|
|
17
|
-
* A `createGlobalStyle` component that emits `:root` CSS custom properties
|
|
18
|
-
* from the current ThemeProvider context. Mount this once at the root of
|
|
19
|
-
* your app so RSC components can consume theme values via CSS variables.
|
|
20
|
-
*/
|
|
21
|
-
GlobalStyle: ReturnType<typeof createGlobalStyle>;
|
|
22
|
-
/** The original theme object, for passing to `ThemeProvider`. */
|
|
23
|
-
raw: T;
|
|
24
|
-
/**
|
|
25
|
-
* Same shape as the theme but every leaf is the bare CSS custom property
|
|
26
|
-
* name (e.g. `"--sc-colors-primary"`). Useful for building dark mode
|
|
27
|
-
* overrides without hand-writing variable names.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* const { vars } = createTheme({ colors: { bg: '#fff', text: '#000' } });
|
|
32
|
-
* vars.colors.bg // "--sc-colors-bg"
|
|
33
|
-
*
|
|
34
|
-
* const DarkMode = createGlobalStyle`
|
|
35
|
-
* .dark {
|
|
36
|
-
* ${vars.colors.bg}: #111;
|
|
37
|
-
* ${vars.colors.text}: #eee;
|
|
38
|
-
* }
|
|
39
|
-
* `;
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
vars: CSSVarTheme<T>;
|
|
43
|
-
/**
|
|
44
|
-
* Read the current resolved CSS variable values from the DOM and return
|
|
45
|
-
* an object with the same shape as the original theme. Each leaf is the
|
|
46
|
-
* computed value (e.g. `"#0070f3"`), not the `var()` reference.
|
|
47
|
-
*
|
|
48
|
-
* Optionally pass a target element to read scoped variables from
|
|
49
|
-
* (defaults to `document.documentElement`).
|
|
50
|
-
*
|
|
51
|
-
* Client-only — throws if called on the server.
|
|
52
|
-
*/
|
|
53
|
-
resolve(el?: Element): T;
|
|
54
|
-
};
|
|
1
|
+
import type { ThemeContract } from './createTheme.types';
|
|
55
2
|
interface CreateThemeOptions {
|
|
56
3
|
/**
|
|
57
4
|
* Prefix for CSS variable names. Defaults to `"sc"`.
|
|
@@ -79,7 +26,7 @@ interface CreateThemeOptions {
|
|
|
79
26
|
*
|
|
80
27
|
* Returns an object with the same shape as the input theme, but every leaf value
|
|
81
28
|
* is a `var(--prefix-*, fallback)` CSS string. Use these in styled component
|
|
82
|
-
* templates
|
|
29
|
+
* templates; they work in both client and RSC contexts.
|
|
83
30
|
*
|
|
84
31
|
* Mount the returned `GlobalStyle` component inside your `ThemeProvider` to emit
|
|
85
32
|
* the CSS variables. When the theme changes (e.g. light → dark), the variables
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ThemeContract } from './createTheme.types';
|
|
2
|
+
interface CreateThemeOptions {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
/** Ignored on native; only web uses selector scoping. */
|
|
5
|
+
selector?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* React Native entry for `createTheme`. Leaves are sentinel strings of
|
|
9
|
+
* the form `\0<prefix>:<path>:<fallback>` that the render-time
|
|
10
|
+
* resolver in `src/native/transform/polyfills/resolvers.ts` substitutes
|
|
11
|
+
* with the current `<ThemeProvider>` value. Keeps zero DOM imports so
|
|
12
|
+
* the native bundle can't transitively drag in `createGlobalStyle`.
|
|
13
|
+
*
|
|
14
|
+
* `GlobalStyle` is a no-op null component on native; style variables
|
|
15
|
+
* don't need a cascade-layer root because `<ThemeProvider>` deep-merges
|
|
16
|
+
* overrides into a single resolved theme object each render.
|
|
17
|
+
*/
|
|
18
|
+
export default function createTheme<T extends Record<string, any>>(defaultTheme: T, options?: CreateThemeOptions): ThemeContract<T>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the web (`createTheme.ts`) and native
|
|
3
|
+
* (`createTheme.native.ts`) entry points. Imported by both; keeps the
|
|
4
|
+
* tree-walking + path concatenation logic in one place so changes
|
|
5
|
+
* stay coherent across platforms.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Recursive theme traversal. For each leaf value, calls `leafFn(path, val)`
|
|
9
|
+
* and writes the return into `result` at the matching key. Nested objects
|
|
10
|
+
* recurse, accumulating `path` segments separated by `separator`.
|
|
11
|
+
*
|
|
12
|
+
* Web uses `-` (CSS-friendly: `--sc-colors-bg`).
|
|
13
|
+
* Native uses `.` (dot-path-friendly: `colors.bg`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function walkTheme(obj: Record<string, any>, separator: string, result: Record<string, any>, leafFn: (fullPath: string, val: any) => any, path?: string): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type createGlobalStyle from './createGlobalStyle';
|
|
2
|
+
type ThemeLeaf = string | number;
|
|
3
|
+
/** Every leaf becomes a string (CSS `var()` on web, sentinel on native). */
|
|
4
|
+
export type CSSVarTheme<T> = {
|
|
5
|
+
[K in keyof T]: T[K] extends ThemeLeaf ? string : CSSVarTheme<T[K]>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The object returned by `createTheme`. Same shape as the input theme
|
|
9
|
+
* with every leaf replaced by a string, plus a few auxiliary fields
|
|
10
|
+
* that let consumers wire the theme up to their render tree.
|
|
11
|
+
*/
|
|
12
|
+
export type ThemeContract<T> = CSSVarTheme<T> & {
|
|
13
|
+
/**
|
|
14
|
+
* A component that, when mounted, emits the CSS custom properties on
|
|
15
|
+
* web or acts as a no-op null on native.
|
|
16
|
+
*/
|
|
17
|
+
GlobalStyle: ReturnType<typeof createGlobalStyle>;
|
|
18
|
+
/** The original theme object (unmodified). */
|
|
19
|
+
raw: T;
|
|
20
|
+
/** Bare CSS custom-property names (`"--sc-colors-bg"` etc). */
|
|
21
|
+
vars: CSSVarTheme<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Snapshot the current resolved theme. On web, reads computed CSS
|
|
24
|
+
* values from the target element (or `document.documentElement`).
|
|
25
|
+
* On native, returns the default theme (live overrides are already
|
|
26
|
+
* applied at each render via the resolver pass).
|
|
27
|
+
*/
|
|
28
|
+
resolve(el?: Element): T;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { Interpolation, RuleSet, Styles } from '../types';
|
|
1
|
+
import { BaseObject, Interpolation, RuleSet, Styles } from '../types';
|
|
2
|
+
export { getSource } from '../parser/source';
|
|
3
|
+
/**
|
|
4
|
+
* Body of `css(...)`, accepting interpolations as a pre-built array so
|
|
5
|
+
* the hot call site (`templateFunction` in `constructWithOptions`) can
|
|
6
|
+
* skip the rest→spread→rest dance. Public `css(...)` collects its rest
|
|
7
|
+
* args into an array and forwards here; `templateFunction` already has
|
|
8
|
+
* a rest array and forwards it directly.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cssWithInterpolations<Props extends object = BaseObject>(styles: Styles<NoInfer<Props>>, interpolations: Interpolation<NoInfer<Props>>[]): RuleSet<NoInfer<Props>>;
|
|
2
11
|
/**
|
|
3
12
|
* Tag a CSS template literal for use in styled components, createGlobalStyle, or attrs.
|
|
4
13
|
* Enables interpolation type-checking and shared style blocks.
|
package/dist/hoc/withTheme.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnyComponent, ExecutionProps } from '../types';
|
|
3
3
|
import { NonReactStatics } from '../utils/hoist';
|
|
4
|
-
type WithThemeOuterProps<T extends AnyComponent> = Omit<React.ComponentPropsWithRef<T>, keyof ExecutionProps> & ExecutionProps
|
|
4
|
+
type WithThemeOuterProps<T extends AnyComponent> = Omit<React.ComponentPropsWithRef<T>, keyof ExecutionProps> & ExecutionProps & {
|
|
5
|
+
ref?: React.Ref<any> | undefined;
|
|
6
|
+
};
|
|
5
7
|
/** Higher-order component that injects the current theme as a prop. Prefer `useTheme` in function components. */
|
|
6
|
-
export default function withTheme<T extends AnyComponent>(Component: T): React.
|
|
8
|
+
export default function withTheme<T extends AnyComponent>(Component: T): React.FC<WithThemeOuterProps<T>> & NonReactStatics<T>;
|
|
7
9
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { LibraryStyled, Styled, StyledInstance } from './constructors/styled';
|
|
2
2
|
export * from './base';
|
|
3
|
-
export {
|
|
4
|
-
export { CSSKeyframes, CSSObject, CSSProp, CSSProperties, CSSPseudos, DataAttributes, DefaultTheme, ExecutionContext, ExecutionProps, FastOmit, Interpolation, IStyledComponent, IStyledComponentFactory, IStyledStatics, PolymorphicComponent, PolymorphicComponentProps, RuleSet, Runtime, StyledObject, StyledOptions, StyleFunction, SupportedHTMLElements, WebTarget, } from './types';
|
|
3
|
+
export { CompiledAst, CSSKeyframes, CSSObject, CSSProp, CSSProperties, CSSPseudos, DataAttributes, DefaultTheme, ExecutionContext, ExecutionProps, FastOmit, Interpolation, IStyledComponent, IStyledComponentFactory, IStyledStatics, PolymorphicComponent, PolymorphicComponentProps, RuleSet, Runtime, StyledObject, StyledOptions, StyleFunction, SupportedHTMLElements, WebTarget, } from './types';
|
|
5
4
|
export { styled as default, LibraryStyled, Styled, styled, StyledInstance };
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import StyleSheet from '../sheet';
|
|
2
|
-
import { Keyframes as KeyframesType
|
|
2
|
+
import { Compiler, Keyframes as KeyframesType } from '../types';
|
|
3
3
|
import { KEYFRAMES_SYMBOL } from '../utils/isKeyframes';
|
|
4
|
+
/**
|
|
5
|
+
* Pure compile output for a keyframes interpolation. `id` is the
|
|
6
|
+
* KEYFRAMES_ID_PREFIX-prefixed sheet group ID; `name` is the compiler-resolved
|
|
7
|
+
* keyframes name (used as both the @keyframes identifier and the dedup key);
|
|
8
|
+
* `rules` is the compiled CSS ready for `StyleSheet.insertRules`.
|
|
9
|
+
*/
|
|
10
|
+
export interface CompiledKeyframes {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
rules: string[];
|
|
14
|
+
}
|
|
4
15
|
export default class Keyframes implements KeyframesType {
|
|
5
16
|
readonly [KEYFRAMES_SYMBOL]: true;
|
|
6
17
|
id: string;
|
|
7
18
|
name: string;
|
|
8
19
|
rules: string;
|
|
9
20
|
constructor(name: string, rules: string);
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Pure: produce the compiled CSS without touching any sheet. Callers carry
|
|
23
|
+
* the result through their own generate→inject pipeline so the parser stays
|
|
24
|
+
* side-effect-free.
|
|
25
|
+
*/
|
|
26
|
+
compile(compiler?: Compiler): CompiledKeyframes;
|
|
27
|
+
getName(compiler?: Compiler): string;
|
|
12
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Write a batch of compiled keyframes to the sheet. Idempotent via
|
|
31
|
+
* `hasNameForId`. Shared by `WebStyle.inject` and `WebGlobalStyle.computeRules`
|
|
32
|
+
* so both callers route through one bytecode path.
|
|
33
|
+
*/
|
|
34
|
+
export declare function flushKeyframes(styleSheet: StyleSheet, compiled: CompiledKeyframes[]): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { INativeStyleConstructor, StyleSheet } from '../types';
|
|
2
|
+
import { NativeStyles, cssToStyleObject, resetNativeStyleCache, RN_UNSUPPORTED_VALUES } from './compileNative';
|
|
3
|
+
export { RN_UNSUPPORTED_VALUES, cssToStyleObject };
|
|
4
|
+
export type { NativeStyles };
|
|
5
|
+
/** Clear the cached CSS-to-style-object mappings. Useful in tests or long-running RN apps with highly dynamic styles. */
|
|
6
|
+
export declare const resetStyleCache: typeof resetNativeStyleCache;
|
|
7
|
+
export default function makeNativeStyleClass<Props extends object>(styleSheet: StyleSheet): INativeStyleConstructor<Props>;
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type stylis from 'stylis';
|
|
3
2
|
import StyleSheet from '../sheet';
|
|
4
|
-
import { InsertionTarget, ShouldForwardProp
|
|
3
|
+
import { Compiler, InsertionTarget, ShouldForwardProp } from '../types';
|
|
4
|
+
import { SCPlugin } from '../utils/compiler';
|
|
5
5
|
export declare const mainSheet: StyleSheet;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const mainCompiler: Compiler;
|
|
7
|
+
/**
|
|
8
|
+
* Reset the RSC override slot. Test-only; production code never reads this.
|
|
9
|
+
* `React.cache` scopes the slot per render in true Flight environments, but
|
|
10
|
+
* regular SSR (`ReactDOMServer.renderToString`) doesn't activate that
|
|
11
|
+
* scoping, so the slot persists across sequential calls. Suites that
|
|
12
|
+
* simulate RSC mode call this in `beforeEach` to start each render from a
|
|
13
|
+
* clean default context.
|
|
14
|
+
*/
|
|
15
|
+
export declare function __resetRSCOverrideForTesting(): void;
|
|
7
16
|
export type IStyleSheetContext = {
|
|
8
17
|
shouldForwardProp?: ShouldForwardProp<'web'> | undefined;
|
|
9
18
|
styleSheet: StyleSheet;
|
|
10
|
-
|
|
11
|
-
/** Preserved for inheritance
|
|
12
|
-
*
|
|
13
|
-
|
|
19
|
+
compiler: Compiler;
|
|
20
|
+
/** Preserved for inheritance; inner SSMs that set namespace but not plugins
|
|
21
|
+
* still inherit the parent's plugins. */
|
|
22
|
+
plugins?: SCPlugin[] | undefined;
|
|
14
23
|
};
|
|
15
24
|
export declare const StyleSheetContext: React.Context<IStyleSheetContext>;
|
|
16
25
|
export declare const StyleSheetConsumer: React.Consumer<IStyleSheetContext>;
|
|
17
|
-
export type
|
|
26
|
+
export type ICompilerContext = Compiler | void;
|
|
18
27
|
export declare function useStyleSheetContext(): IStyleSheetContext;
|
|
19
28
|
export type IStyleSheetManager = React.PropsWithChildren<{
|
|
20
|
-
/**
|
|
21
|
-
* If desired, you can pass this prop to disable "speedy" insertion mode, which
|
|
22
|
-
* uses the browser [CSSOM APIs](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet).
|
|
23
|
-
* When disabled, rules are inserted as simple text into style blocks.
|
|
24
|
-
*/
|
|
25
|
-
disableCSSOMInjection?: undefined | boolean;
|
|
26
|
-
/**
|
|
27
|
-
* If you are working exclusively with modern browsers, vendor prefixes can often be omitted
|
|
28
|
-
* to reduce the weight of CSS on the page.
|
|
29
|
-
*/
|
|
30
|
-
enableVendorPrefixes?: undefined | boolean;
|
|
31
29
|
/**
|
|
32
30
|
* Provide an optional selector to be prepended to all generated style rules.
|
|
33
31
|
*/
|
|
@@ -38,35 +36,25 @@ export type IStyleSheetManager = React.PropsWithChildren<{
|
|
|
38
36
|
*/
|
|
39
37
|
sheet?: undefined | StyleSheet;
|
|
40
38
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* When the return value is `true`, props will be forwarded to the DOM/underlying
|
|
48
|
-
* component. If return value is `false`, the prop will be discarded after styles
|
|
49
|
-
* are calculated.
|
|
50
|
-
*
|
|
51
|
-
* Manually composing `styled.{element}.withConfig({shouldForwardProp})` will
|
|
52
|
-
* override this default.
|
|
53
|
-
*
|
|
54
|
-
* When nested inside another `StyleSheetManager`, omitting this prop inherits
|
|
55
|
-
* the parent's function. Pass `undefined` explicitly or a passthrough function
|
|
56
|
-
* to disable inherited behavior for a subtree.
|
|
39
|
+
* Filter which props reach the underlying DOM element. Return `true` to
|
|
40
|
+
* forward, `false` to drop. Prefer transient props (`$prop`) when
|
|
41
|
+
* possible; reach for this when bridging a third-party prop validator.
|
|
42
|
+
* Component-level `withConfig({shouldForwardProp})` overrides this. Nested
|
|
43
|
+
* SSMs inherit the parent's function unless this prop is set to
|
|
44
|
+
* `undefined` or a passthrough.
|
|
57
45
|
*/
|
|
58
46
|
shouldForwardProp?: undefined | IStyleSheetContext['shouldForwardProp'];
|
|
59
47
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
48
|
+
* Plugins to apply during CSS emission. v7 ships first-party plugins via
|
|
49
|
+
* `styled-components/plugins` (`rscPlugin`, `rtlPlugin`); other plugins must
|
|
50
|
+
* implement the v7 `SCPlugin` shape (`{ name, rw?, decl? }`). Legacy stylis
|
|
51
|
+
* plugins are not supported.
|
|
64
52
|
*
|
|
65
53
|
* When nested inside another `StyleSheetManager`, omitting this prop inherits
|
|
66
54
|
* the parent's plugins. Pass an empty array (`[]`) to explicitly disable
|
|
67
55
|
* inherited plugins for a subtree.
|
|
68
56
|
*/
|
|
69
|
-
|
|
57
|
+
plugins?: undefined | SCPlugin[];
|
|
70
58
|
/**
|
|
71
59
|
* CSP nonce to attach to injected `<style>` tags. Overrides auto-detection
|
|
72
60
|
* from `<meta name="sc-nonce">`, `<meta property="csp-nonce">`, or `__webpack_nonce__`.
|
|
@@ -77,5 +65,5 @@ export type IStyleSheetManager = React.PropsWithChildren<{
|
|
|
77
65
|
*/
|
|
78
66
|
target?: undefined | InsertionTarget;
|
|
79
67
|
}>;
|
|
80
|
-
/** Configure style injection for descendant styled components (target element,
|
|
68
|
+
/** Configure style injection for descendant styled components (target element, plugins, prop forwarding). */
|
|
81
69
|
export declare function StyleSheetManager(props: IStyleSheetManager): React.JSX.Element;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { BaseObject, IStyledComponentFactory, RuleSet, StyledOptions, WebTarget } from '../types';
|
|
2
|
+
/** Test-only: clear the per-displayName counter so component IDs stay stable
|
|
3
|
+
* across tests. Not for production use. */
|
|
4
|
+
export declare const resetIdentifiers: () => void;
|
|
2
5
|
declare function createStyledComponent<Target extends WebTarget, OuterProps extends BaseObject, Statics extends BaseObject = BaseObject>(target: Target, options: StyledOptions<'web', OuterProps>, rules: RuleSet<OuterProps>): ReturnType<IStyledComponentFactory<'web', Target, OuterProps, Statics>>;
|
|
3
6
|
export default createStyledComponent;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ContainerContextValue, MediaQueryEnv } from '../native/responsive';
|
|
2
|
+
import type { BaseObject, Dict, ExecutionProps, INativeStyleConstructor, IStyledComponentFactory, NativeTarget, RuleSet, StyledOptions } from '../types';
|
|
3
|
+
import type { NativeStyles } from './compileNative';
|
|
4
|
+
/**
|
|
5
|
+
* Compose a static `base` style with the user-supplied `props.style`. RN's
|
|
6
|
+
* `Pressable`/`TextInput` accept a function for `style` (state callback);
|
|
7
|
+
* pass-through that shape by wrapping the function call.
|
|
8
|
+
*
|
|
9
|
+
* `normalizeStyleForWeb` is invoked on the user-supplied side; it patches
|
|
10
|
+
* around rn-web's translation gaps (e.g. 16-element matrix transforms).
|
|
11
|
+
* It's a no-op on native and returns the same reference when no rewrite
|
|
12
|
+
* is needed, so identity-based caches downstream stay intact.
|
|
13
|
+
*/
|
|
14
|
+
export declare function composeBase(base: object, userStyle: any): any;
|
|
15
|
+
/**
|
|
16
|
+
* Assemble the final `style` value passed to the underlying RN element.
|
|
17
|
+
* Pulled out of the render hook so the cache-hit path can short-circuit
|
|
18
|
+
* to a single property read without paying for any of this work.
|
|
19
|
+
*/
|
|
20
|
+
export declare function assembleFinalStyle(compiled: NativeStyles, env: MediaQueryEnv, containerCtx: ContainerContextValue, theme: Record<string, any>, userStyle: any, props: Record<string, unknown>, baseOverride?: Dict<any>): any;
|
|
21
|
+
declare const _default: (NativeStyle: INativeStyleConstructor<any>) => <Target extends NativeTarget, OuterProps extends ExecutionProps, Statics extends object = BaseObject>(target: Target, options: StyledOptions<"native", OuterProps>, rules: RuleSet<OuterProps>) => ReturnType<IStyledComponentFactory<"native", Target, OuterProps, Statics>>;
|
|
3
22
|
export default _default;
|
|
@@ -32,16 +32,7 @@ type Props = {
|
|
|
32
32
|
};
|
|
33
33
|
export declare const ThemeContext: React.Context<DefaultTheme | undefined>;
|
|
34
34
|
export declare const ThemeConsumer: React.Consumer<DefaultTheme | undefined>;
|
|
35
|
-
/**
|
|
36
|
-
* Returns the current theme (as provided by the closest ancestor `ThemeProvider`.)
|
|
37
|
-
*
|
|
38
|
-
* If no `ThemeProvider` is found, the function will error. If you need access to the theme in an
|
|
39
|
-
* uncertain composition scenario, `React.useContext(ThemeContext)` will not emit an error if there
|
|
40
|
-
* is no `ThemeProvider` ancestor.
|
|
41
|
-
*/
|
|
35
|
+
/** Returns the current theme; throws if no `ThemeProvider` ancestor. */
|
|
42
36
|
export declare function useTheme(): DefaultTheme;
|
|
43
|
-
/**
|
|
44
|
-
* Provide a theme to an entire react component tree via context
|
|
45
|
-
*/
|
|
46
37
|
export default function ThemeProvider(props: Props): React.JSX.Element | null;
|
|
47
38
|
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import StyleSheet from '../sheet';
|
|
2
|
+
import { Compiler, ExecutionContext, RuleSet } from '../types';
|
|
3
|
+
type InstanceEntry = {
|
|
4
|
+
name: string;
|
|
5
|
+
rules: string[];
|
|
6
|
+
};
|
|
7
|
+
export default class WebGlobalStyle<Props extends object> {
|
|
8
|
+
componentId: string;
|
|
9
|
+
isStatic: boolean;
|
|
10
|
+
rules: RuleSet<Props>;
|
|
11
|
+
/** @internal Per-instance rule cache for shared-group rebuild. */
|
|
12
|
+
instanceRules: Map<string, InstanceEntry>;
|
|
13
|
+
constructor(rules: RuleSet<Props>, componentId: string);
|
|
14
|
+
removeStyles(instance: string, styleSheet: StyleSheet): void;
|
|
15
|
+
renderStyles(instance: string, executionContext: ExecutionContext & Props, styleSheet: StyleSheet, compiler: Compiler): void;
|
|
16
|
+
private computeRules;
|
|
17
|
+
/**
|
|
18
|
+
* Clear all CSS rules in the shared group and re-insert from surviving instances.
|
|
19
|
+
* Must run synchronously; no yielding between clear and re-insert.
|
|
20
|
+
* Static globals: all instances share identical CSS, emit once.
|
|
21
|
+
*/
|
|
22
|
+
private rebuildGroup;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import StyleSheet from '../sheet';
|
|
2
|
+
import { Compiler, ExecutionContext, RuleSet } from '../types';
|
|
3
|
+
import { type CompiledKeyframes } from './Keyframes';
|
|
4
|
+
/** Per-level output of `generate()`; one entry per link in the inheritance chain. */
|
|
5
|
+
type GeneratedLevel = {
|
|
6
|
+
componentId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
rules: string[];
|
|
9
|
+
isNew: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type GeneratedStyle = {
|
|
12
|
+
/** Space-joined class name chain (base first, `this` last). */
|
|
13
|
+
className: string;
|
|
14
|
+
/** Inheritance chain output, base first, `this` last. */
|
|
15
|
+
levels: GeneratedLevel[];
|
|
16
|
+
/**
|
|
17
|
+
* Compiled keyframes referenced via `${kf}` interpolation, including those
|
|
18
|
+
* collected by base styles. Order is base-first → this-last so injection
|
|
19
|
+
* preserves the v6 sheet-ordering invariant. Empty when no `${kf}` refs.
|
|
20
|
+
*/
|
|
21
|
+
keyframes: CompiledKeyframes[];
|
|
22
|
+
};
|
|
23
|
+
/** CSS-side state for one styled component (parallel to the React-side `StyledComponent`). */
|
|
24
|
+
export default class WebStyle {
|
|
25
|
+
baseHash: number;
|
|
26
|
+
baseStyle: WebStyle | null | undefined;
|
|
27
|
+
componentId: string;
|
|
28
|
+
rules: RuleSet<any>;
|
|
29
|
+
/** Interp-tuple → class name. Hit skips `buildHashCSS` entirely. */
|
|
30
|
+
interpKeyCache: Map<string, string> | undefined;
|
|
31
|
+
/** Joined-CSS → class name. Hit skips `phash + generateName`. */
|
|
32
|
+
cssKeyCache: Map<string, string> | undefined;
|
|
33
|
+
/** Lazy `getSource(rules)` cache; once read, future renders skip the WeakMap. */
|
|
34
|
+
private resolvedSource;
|
|
35
|
+
/** Reused scratch buffer so warm renders don't allocate fresh `filled[]`. */
|
|
36
|
+
private filledBuffer;
|
|
37
|
+
/** Parallel fragment side-table; allocated lazily on first fragment-bearing render. */
|
|
38
|
+
private fragmentsBuffer;
|
|
39
|
+
/**
|
|
40
|
+
* Pending keyframes collected during `evaluateForFastPath`. Reused across
|
|
41
|
+
* renders; cleared at the top of `generate()`. Only allocated lazily when
|
|
42
|
+
* the source actually carries `${kf}` interpolations.
|
|
43
|
+
*/
|
|
44
|
+
private keyframesBuffer;
|
|
45
|
+
constructor(rules: RuleSet<any>, componentId: string, baseStyle?: WebStyle | undefined);
|
|
46
|
+
/**
|
|
47
|
+
* Produce per-level compiled CSS without writing to the sheet. Walks the
|
|
48
|
+
* inheritance chain so callers get the full chain's output in one pass.
|
|
49
|
+
*/
|
|
50
|
+
generate(executionContext: ExecutionContext, styleSheet: StyleSheet, compiler: Compiler): GeneratedStyle;
|
|
51
|
+
inject(styleSheet: StyleSheet, generated: GeneratedStyle): string;
|
|
52
|
+
/** Compute the inheritance plan and write any new rules to the sheet in one call. */
|
|
53
|
+
flush(executionContext: ExecutionContext, styleSheet: StyleSheet, compiler: Compiler): string;
|
|
54
|
+
}
|
|
55
|
+
export {};
|