styled-components 6.4.3 → 6.4.4

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.
@@ -118,51 +118,50 @@ export interface IStyledStatics<out R extends Runtime, in out OuterProps extends
118
118
  styledComponentId: R extends 'web' ? string : never;
119
119
  warnTooManyClasses?: (R extends 'web' ? ReturnType<typeof createWarnTooManyClasses> : never) | undefined;
120
120
  }
121
+ /** ExecutionProps sans as/forwardedAs, pre-resolved so call sites relate against a concrete interface. */
122
+ interface ThemedExecutionProps {
123
+ theme?: DefaultTheme | undefined;
124
+ }
121
125
  /**
122
126
  * Used by PolymorphicComponent to define prop override cascading order.
123
127
  */
124
128
  export type PolymorphicComponentProps<R extends Runtime, BaseProps extends BaseObject, AsTarget extends StyledTarget<R> | (BaseProps extends {
125
129
  as?: infer A;
126
- } ? A : never) | void, ForwardedAsTarget extends StyledTarget<R> | void, AsTargetProps extends BaseObject = AsTarget extends KnownTarget ? React.ComponentPropsWithRef<AsTarget> : {}, ForwardedAsTargetProps extends BaseObject = ForwardedAsTarget extends KnownTarget ? React.ComponentPropsWithRef<ForwardedAsTarget> : {}> = OverrideStyle<NoInfer<FastOmit<Substitute<BaseProps, Substitute<ForwardedAsTargetProps, AsTargetProps>>, keyof ExecutionProps>> & FastOmit<ExecutionProps, 'as' | 'forwardedAs'> & {
130
+ } ? A : never) | void, ForwardedAsTarget extends StyledTarget<R> | void, AsTargetProps extends BaseObject = AsTarget extends KnownTarget ? React.ComponentPropsWithRef<AsTarget> : {}, ForwardedAsTargetProps extends BaseObject = ForwardedAsTarget extends KnownTarget ? React.ComponentPropsWithRef<ForwardedAsTarget> : {}> = OverrideStyle<NoInfer<FastOmit<Substitute<BaseProps, Substitute<ForwardedAsTargetProps, AsTargetProps>>, keyof ExecutionProps>> & ThemedExecutionProps & {
127
131
  as?: AsTarget;
128
132
  forwardedAs?: ForwardedAsTarget;
129
133
  }>;
130
134
  /**
131
- * Resolves the call-site props for one usage of a polymorphic component,
132
- * branching on the supplied `as` / `forwardedAs` targets into the three prior
133
- * overload shapes:
134
- * - `as` is a real render target (e.g. `as="video"`, `as={Component}`):
135
- * substitute that target's props and require `as`.
136
- * - no `as`, or `as` is the wrapped component's own non-target type (e.g.
137
- * Next.js Link's `as?: Url`): Substitute-free base props so ref callbacks
138
- * infer with spread props (#5687), the wrapped `as` type stays assignable and
139
- * optional (#5734), and BaseProps keys keep completing for plain usage (#5741).
140
- * - `forwardedAs` only: substitute the forwarded target's props.
135
+ * Resolves the call-site props for one usage of a polymorphic component from its
136
+ * `as` / `forwardedAs` targets. An `as` render target substitutes that target's
137
+ * props and requires `as`; plain usage (or `as` being the wrapped component's own
138
+ * non-target type, e.g. Next.js Link's `as?: Url`) keeps Substitute-free base
139
+ * props so ref callbacks infer with spread props (#5687), the wrapped `as` stays
140
+ * assignable (#5734), and BaseProps keys keep completing (#5741); `forwardedAs`
141
+ * substitutes the forwarded target's props.
141
142
  *
142
- * Extracted to a named alias so identical (R, BaseProps, AsTarget,
143
- * ForwardedAsTarget) tuples dedupe across the many JSX call sites in an app.
143
+ * The target test is `string | AnyComponent`, not `KnownTarget`: narrowing it
144
+ * drops custom element strings (`as="my-element"`) out of the target branch.
144
145
  *
145
- * The target test is `string | AnyComponent`, not the broader `WebTarget`
146
- * (`KnownTarget | (string & {})`): both describe the same set (any string or
147
- * component), but comparing against the ~156 literal members of `KnownTarget`
148
- * here costs ~6% more type instantiations across all call sites. Don't narrow it
149
- * to bare `KnownTarget` -- that drops custom element strings (`as="my-element"`)
150
- * out of the target branch and makes them error.
146
+ * Load-bearing shape, do not simplify: two conditionals with `unknown` sibling
147
+ * branches (not one three-way conditional), a leading flat `{ as?; forwardedAs? }`
148
+ * member, and positive `extends [string | AnyComponent]` discriminants. Collapsing
149
+ * the conditionals, dropping the flat member, or using a `[void]` discriminant
150
+ * each regress plain-call-site cost, `as`-target completion, or ref-callback
151
+ * inference (#5687) respectively.
151
152
  */
152
153
  type PolymorphicCallProps<R extends Runtime, BaseProps extends BaseObject, AsTarget extends StyledTarget<R> | (BaseProps extends {
153
154
  as?: infer A;
154
- } ? A : never) | void, ForwardedAsTarget extends StyledTarget<R> | void> = [AsTarget] extends [string | AnyComponent] ? PolymorphicComponentProps<R, BaseProps, AsTarget, ForwardedAsTarget> & {
155
+ } ? A : never) | void, ForwardedAsTarget extends StyledTarget<R> | void> = {
156
+ as?: AsTarget | undefined;
157
+ forwardedAs?: ForwardedAsTarget | undefined;
158
+ } & ([
159
+ AsTarget
160
+ ] extends [string | AnyComponent] ? PolymorphicComponentProps<R, BaseProps, AsTarget, ForwardedAsTarget> & {
155
161
  as: AsTarget;
156
- } : [ForwardedAsTarget] extends [void] ? OverrideStyle<NoInfer<FastOmit<BaseProps, keyof ExecutionProps>> & FastOmit<ExecutionProps, 'as' | 'forwardedAs'> & {
157
- as?: BaseProps extends {
158
- as?: infer A;
159
- } ? A : void;
160
- forwardedAs?: BaseProps extends {
161
- forwardedAs?: infer A;
162
- } ? A : void;
163
- }> : PolymorphicComponentProps<R, BaseProps, void, ForwardedAsTarget> & {
162
+ } : unknown) & ([AsTarget] extends [string | AnyComponent] ? unknown : [ForwardedAsTarget] extends [string | AnyComponent] ? PolymorphicComponentProps<R, BaseProps, void, ForwardedAsTarget> & {
164
163
  forwardedAs: ForwardedAsTarget;
165
- };
164
+ } : OverrideStyle<NoInfer<FastOmit<BaseProps, keyof ExecutionProps>> & ThemedExecutionProps>);
166
165
  /**
167
166
  * This type forms the signature for a forwardRef-enabled component
168
167
  * that accepts the "as" prop to dynamically change the underlying
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styled-components",
3
- "version": "6.4.3",
3
+ "version": "6.4.4",
4
4
  "description": "Fast, expressive styling for React.",
5
5
  "publishConfig": {
6
6
  "access": "public"