@pk-design/react-tailwind 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import type { JSX, ElementType, ComponentPropsWithoutRef } from 'react';
2
+ import type { PolymorphicRef } from '../common-type';
2
3
  /**
3
4
  * Theme variants applied to the Button component.
4
5
  *
@@ -35,11 +36,6 @@ export type ThemedButtonClass = {
35
36
  [key in ButtonVariant]: string;
36
37
  };
37
38
  };
38
- /**
39
- * Utility: Extract the correct `ref` type for intrinsic elements
40
- * or custom React components.
41
- */
42
- export type PolymorphicRef<C extends ElementType> = ComponentPropsWithoutRef<C>['ref'];
43
39
  /**
44
40
  * Utility: Builds a polymorphic prop type.
45
41
  *
@@ -1,3 +1,2 @@
1
- import React from 'react';
2
- import type { CardProps } from './Card.types';
3
- export declare const Card: React.ForwardRefExoticComponent<Omit<CardProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<Element>>;
1
+ import type { CardComponent } from './Card.types';
2
+ export declare const Card: CardComponent;
@@ -1,23 +1,71 @@
1
- import type { ElementType } from 'react';
2
- import { PolymorphicProps } from '../common-type';
1
+ import type { ComponentPropsWithoutRef, ElementType, JSX } from 'react';
2
+ import { PolymorphicRef } from '../common-type';
3
3
  export type CardBaseProps = {
4
4
  /**
5
- * Make card hoverable (adds shadow transitions)
5
+ * Make card hoverable (adds background transitions)
6
+ * @default false
6
7
  */
7
8
  hoverable?: boolean;
8
9
  /**
9
10
  * Adds border around the card
11
+ * @default true
10
12
  */
11
13
  bordered?: boolean;
12
14
  /**
13
- * Removes default padding
15
+ * Make card compact
16
+ * @default false
14
17
  */
15
- noPadding?: boolean;
18
+ compact?: boolean;
19
+ };
20
+ /**
21
+ * Utility: Builds a polymorphic prop type.
22
+ *
23
+ * This allows the component to accept **any HTML element** or **any custom React component**
24
+ * via the `as` prop while automatically inheriting the correct props.
25
+ *
26
+ * Example:
27
+ * ```tsx
28
+ * <Card as="a" href="/home" />
29
+ * <Card as={MyLink} to="/home" customProp />
30
+ * ```
31
+ */
32
+ export type PolymorphicCardProps<C extends ElementType, Props = {}> = Props & {
16
33
  /**
17
- * Render Card as different element or component
34
+ * The element or component to render.
35
+ *
36
+ * Supports:
37
+ * - HTML elements (e.g., `"a"`, `"div"`)
38
+ * - React components (e.g., `Link`, `NextLink`, `MyCustomCard`)
18
39
  *
19
40
  * @default "div"
20
41
  */
21
- as?: ElementType;
22
- };
23
- export type CardProps<C extends ElementType = 'div'> = PolymorphicProps<C, CardBaseProps>;
42
+ as?: C;
43
+ } & Omit<ComponentPropsWithoutRef<C>, keyof Props | 'as'>;
44
+ /**
45
+ * Complete Card props,
46
+ * supporting **polymorphic rendering** via the `as` prop.
47
+ *
48
+ * Examples:
49
+ *
50
+ * Render as a native card:
51
+ * ```tsx
52
+ * <Card>Card content</Card>
53
+ * ```
54
+ *
55
+ * Render as a link:
56
+ * ```tsx
57
+ * <Card as="a" href="/pricing" target="_blank">Learn More</Card>
58
+ * ```
59
+ *
60
+ * Render as a custom component:
61
+ * ```tsx
62
+ * <Card as={MyCustomComponent} customProp="123">Custom card content</Card>
63
+ * ```
64
+ */
65
+ export type CardProps<C extends ElementType = 'div'> = PolymorphicCardProps<C, CardBaseProps>;
66
+ export interface CardComponent {
67
+ <C extends ElementType = 'div'>(props: CardProps<C> & {
68
+ ref?: PolymorphicRef<C>;
69
+ }): JSX.Element;
70
+ displayName?: string;
71
+ }
@@ -29,4 +29,9 @@ export interface InputCustomProps {
29
29
  */
30
30
  showErrorMessage?: boolean;
31
31
  }
32
+ /**
33
+ * Utility: Extract the correct `ref` type for intrinsic elements
34
+ * or custom React components.
35
+ */
36
+ export type PolymorphicRef<C extends ElementType> = ComponentPropsWithoutRef<C>['ref'];
32
37
  export type PolymorphicProps<C extends ElementType, Props> = Props & Omit<ComponentPropsWithoutRef<C>, keyof Props | 'as'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pk-design/react-tailwind",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "main": "dist/react-tailwind.cjs.js",
5
5
  "module": "dist/react-tailwind.es.js",
6
6
  "types": "dist/types/index.d.ts",