@react-hive/honey-style 6.2.0 → 7.0.0
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/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +54 -0
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styled.d.ts +68 -7
- package/package.json +1 -1
package/dist/styled.d.ts
CHANGED
|
@@ -1,15 +1,76 @@
|
|
|
1
|
-
import type { ComponentProps,
|
|
2
|
-
import type { FastOmit,
|
|
1
|
+
import type { ComponentProps, ElementType, ReactElement } from 'react';
|
|
2
|
+
import type { FastOmit, HoneyStyledContext, HoneyStyledInterpolation, HoneyStyledPropsWithAs, Override } from './types';
|
|
3
3
|
import { HONEY_STYLED_COMPONENT_ID_PROP } from './constants';
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type HoneyStyledComponent<OverrideTarget extends ElementType, Props extends object> = (<AsElement extends ElementType = OverrideTarget>(props: HoneyStyledPublicComponentProps<AsElement, Props>) => Nullable<ReactElement<Props>>) & {
|
|
4
|
+
type DefaultPropsResolver<Target extends ElementType, DefaultProps extends object, Props extends object, CombinedProps extends object = FastOmit<Override<DefaultProps, Props>, 'as'>> = HoneyStyledPropsWithAs<Target, Partial<CombinedProps>> | ((props: HoneyStyledContext<HoneyStyledPropsWithAs<Target, CombinedProps>>) => HoneyStyledPropsWithAs<Target, Partial<CombinedProps>>);
|
|
5
|
+
type HoneyStyledPublicComponentProps<AsElement extends ElementType, Props extends object> = HoneyStyledPropsWithAs<AsElement, Override<ComponentProps<AsElement>, Props>>;
|
|
6
|
+
type HoneyStyledComponent<OverrideTarget extends ElementType, Props extends object> = (<AsElement extends ElementType = OverrideTarget>(props: HoneyStyledPublicComponentProps<AsElement, FastOmit<Props, 'as'>>) => ReactElement<Props>) & {
|
|
8
7
|
[HONEY_STYLED_COMPONENT_ID_PROP]: string;
|
|
9
8
|
displayName?: string;
|
|
10
9
|
};
|
|
11
10
|
interface StyledOptions {
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether a prop should be removed before being forwarded
|
|
13
|
+
* to the rendered element.
|
|
14
|
+
*
|
|
15
|
+
* @param propName - The prop name to check.
|
|
16
|
+
*
|
|
17
|
+
* @returns Returns true if the prop should be omitted.
|
|
18
|
+
*/
|
|
19
|
+
omitProps?: (propName: string) => boolean;
|
|
13
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a Honey-styled component from an HTML element or React component.
|
|
23
|
+
*
|
|
24
|
+
* The returned function accepts a tagged template literal with static CSS and dynamic
|
|
25
|
+
* interpolations. Interpolations receive the resolved styled context, including the
|
|
26
|
+
* current theme, default props, and props passed to the component.
|
|
27
|
+
*
|
|
28
|
+
* The generated component supports the polymorphic `as` prop, so the rendered element
|
|
29
|
+
* can be changed while preserving the native props of the selected element.
|
|
30
|
+
*
|
|
31
|
+
* Default props can be provided as either an object or a resolver function. Props passed
|
|
32
|
+
* directly to the rendered styled component override default props.
|
|
33
|
+
*
|
|
34
|
+
* @template TargetProps - The custom props available to style interpolations.
|
|
35
|
+
* @template Target - The base HTML element or React component used for rendering.
|
|
36
|
+
* @template OverrideTarget - The default polymorphic element used for public prop inference.
|
|
37
|
+
*
|
|
38
|
+
* @param target - The base HTML element or React component to style.
|
|
39
|
+
* @param defaultProps - Optional default props or a function that resolves default props from context.
|
|
40
|
+
* @param options - Optional styled component options.
|
|
41
|
+
*
|
|
42
|
+
* @returns A tagged template function that creates a styled component.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const Box = styled('div')`
|
|
47
|
+
* color: red;
|
|
48
|
+
* `;
|
|
49
|
+
*
|
|
50
|
+
* <Box data-testid="box">Content</Box>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* const Button = styled<{ variant: 'primary' | 'secondary' }, 'button'>('button')`
|
|
56
|
+
* ${({ variant }) => css`
|
|
57
|
+
* color: ${variant === 'primary' ? 'white' : 'black'};
|
|
58
|
+
* `}
|
|
59
|
+
* `;
|
|
60
|
+
*
|
|
61
|
+
* <Button variant="primary" type="button" />
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* const LinkBox = styled('div')`
|
|
67
|
+
* color: blue;
|
|
68
|
+
* `;
|
|
69
|
+
*
|
|
70
|
+
* <LinkBox as="a" href="https://example.com">
|
|
71
|
+
* Link
|
|
72
|
+
* </LinkBox>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
14
75
|
export declare const styled: <TargetProps extends object, Target extends ElementType = ElementType, OverrideTarget extends ElementType = Target>(target: Target, defaultProps?: DefaultPropsResolver<OverrideTarget, ComponentProps<OverrideTarget>, TargetProps>, { omitProps }?: StyledOptions) => <Props extends object = TargetProps>(strings: TemplateStringsArray, ...interpolations: HoneyStyledInterpolation<Override<ComponentProps<OverrideTarget>, Props>>[]) => HoneyStyledComponent<OverrideTarget, Props>;
|
|
15
76
|
export {};
|