@heroui/card 2.2.11 → 2.2.13

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.
@@ -0,0 +1,151 @@
1
+ "use client";
2
+
3
+ // src/use-card.ts
4
+ import { card } from "@heroui/theme";
5
+ import { useCallback, useMemo } from "react";
6
+ import { chain, mergeProps } from "@react-aria/utils";
7
+ import { useFocusRing } from "@react-aria/focus";
8
+ import { useHover } from "@react-aria/interactions";
9
+ import { useAriaButton } from "@heroui/use-aria-button";
10
+ import { mapPropsVariants, useProviderContext } from "@heroui/system";
11
+ import { clsx, dataAttr, objectToDeps } from "@heroui/shared-utils";
12
+ import { filterDOMProps } from "@heroui/react-utils";
13
+ import { useDOMRef } from "@heroui/react-utils";
14
+ import { useRipple } from "@heroui/ripple";
15
+ function useCard(originalProps) {
16
+ var _a, _b, _c, _d;
17
+ const globalContext = useProviderContext();
18
+ const [props, variantProps] = mapPropsVariants(originalProps, card.variantKeys);
19
+ const {
20
+ ref,
21
+ as,
22
+ children,
23
+ onClick,
24
+ onPress,
25
+ autoFocus,
26
+ className,
27
+ classNames,
28
+ allowTextSelectionOnPress = true,
29
+ ...otherProps
30
+ } = props;
31
+ const domRef = useDOMRef(ref);
32
+ const Component = as || (originalProps.isPressable ? "button" : "div");
33
+ const shouldFilterDOMProps = typeof Component === "string";
34
+ const disableAnimation = (_b = (_a = originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
35
+ const disableRipple = (_d = (_c = originalProps.disableRipple) != null ? _c : globalContext == null ? void 0 : globalContext.disableRipple) != null ? _d : false;
36
+ const baseStyles = clsx(classNames == null ? void 0 : classNames.base, className);
37
+ const { onClear: onClearRipple, onPress: onRipplePressHandler, ripples } = useRipple();
38
+ const handlePress = useCallback(
39
+ (e) => {
40
+ if (disableRipple || disableAnimation) return;
41
+ domRef.current && onRipplePressHandler(e);
42
+ },
43
+ [disableRipple, disableAnimation, domRef, onRipplePressHandler]
44
+ );
45
+ const { buttonProps, isPressed } = useAriaButton(
46
+ {
47
+ onPress: chain(onPress, handlePress),
48
+ elementType: as,
49
+ isDisabled: !originalProps.isPressable,
50
+ onClick,
51
+ allowTextSelectionOnPress,
52
+ ...otherProps
53
+ },
54
+ domRef
55
+ );
56
+ const { hoverProps, isHovered } = useHover({
57
+ isDisabled: !originalProps.isHoverable,
58
+ ...otherProps
59
+ });
60
+ const { isFocusVisible, isFocused, focusProps } = useFocusRing({
61
+ autoFocus
62
+ });
63
+ const slots = useMemo(
64
+ () => card({
65
+ ...variantProps,
66
+ disableAnimation
67
+ }),
68
+ [objectToDeps(variantProps), disableAnimation]
69
+ );
70
+ const context = useMemo(
71
+ () => ({
72
+ slots,
73
+ classNames,
74
+ disableAnimation,
75
+ isDisabled: originalProps.isDisabled,
76
+ isFooterBlurred: originalProps.isFooterBlurred,
77
+ fullWidth: originalProps.fullWidth
78
+ }),
79
+ [
80
+ slots,
81
+ classNames,
82
+ originalProps.isDisabled,
83
+ originalProps.isFooterBlurred,
84
+ disableAnimation,
85
+ originalProps.fullWidth
86
+ ]
87
+ );
88
+ const getCardProps = useCallback(
89
+ (props2 = {}) => {
90
+ return {
91
+ ref: domRef,
92
+ className: slots.base({ class: baseStyles }),
93
+ tabIndex: originalProps.isPressable ? 0 : -1,
94
+ "data-hover": dataAttr(isHovered),
95
+ "data-pressed": dataAttr(isPressed),
96
+ "data-focus": dataAttr(isFocused),
97
+ "data-focus-visible": dataAttr(isFocusVisible),
98
+ "data-disabled": dataAttr(originalProps.isDisabled),
99
+ ...mergeProps(
100
+ originalProps.isPressable ? { ...buttonProps, ...focusProps, role: "button" } : {},
101
+ originalProps.isHoverable ? hoverProps : {},
102
+ filterDOMProps(otherProps, {
103
+ enabled: shouldFilterDOMProps
104
+ }),
105
+ filterDOMProps(props2)
106
+ )
107
+ };
108
+ },
109
+ [
110
+ domRef,
111
+ slots,
112
+ baseStyles,
113
+ shouldFilterDOMProps,
114
+ originalProps.isPressable,
115
+ originalProps.isHoverable,
116
+ originalProps.isDisabled,
117
+ isHovered,
118
+ isPressed,
119
+ isFocusVisible,
120
+ buttonProps,
121
+ focusProps,
122
+ hoverProps,
123
+ otherProps
124
+ ]
125
+ );
126
+ const getRippleProps = useCallback(
127
+ () => ({ ripples, onClear: onClearRipple }),
128
+ [ripples, onClearRipple]
129
+ );
130
+ return {
131
+ context,
132
+ domRef,
133
+ Component,
134
+ classNames,
135
+ children,
136
+ isHovered,
137
+ isPressed,
138
+ disableAnimation,
139
+ isPressable: originalProps.isPressable,
140
+ isHoverable: originalProps.isHoverable,
141
+ disableRipple,
142
+ handlePress,
143
+ isFocusVisible,
144
+ getCardProps,
145
+ getRippleProps
146
+ };
147
+ }
148
+
149
+ export {
150
+ useCard
151
+ };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import {
3
+ useCardContext
4
+ } from "./chunk-XHGGCEVJ.mjs";
5
+
6
+ // src/card-footer.tsx
7
+ import { forwardRef } from "@heroui/system";
8
+ import { useDOMRef } from "@heroui/react-utils";
9
+ import { clsx } from "@heroui/shared-utils";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var CardFooter = forwardRef((props, ref) => {
12
+ var _a;
13
+ const { as, className, children, ...otherProps } = props;
14
+ const Component = as || "div";
15
+ const domRef = useDOMRef(ref);
16
+ const { slots, classNames } = useCardContext();
17
+ const footerStyles = clsx(classNames == null ? void 0 : classNames.footer, className);
18
+ return /* @__PURE__ */ jsx(Component, { ref: domRef, className: (_a = slots.footer) == null ? void 0 : _a.call(slots, { class: footerStyles }), ...otherProps, children });
19
+ });
20
+ CardFooter.displayName = "HeroUI.CardFooter";
21
+ var card_footer_default = CardFooter;
22
+
23
+ export {
24
+ card_footer_default
25
+ };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+
3
+ // src/card-context.ts
4
+ import { createContext } from "@heroui/react-utils";
5
+ var [CardProvider, useCardContext] = createContext({
6
+ name: "CardContext",
7
+ strict: true,
8
+ errorMessage: "useCardContext: `context` is undefined. Seems you forgot to wrap component within <Card />"
9
+ });
10
+
11
+ export {
12
+ CardProvider,
13
+ useCardContext
14
+ };
@@ -0,0 +1,13 @@
1
+ export { default as Card, CardProps } from './card.mjs';
2
+ export { default as CardFooter, CardFooterProps } from './card-footer.mjs';
3
+ export { useCard } from './use-card.mjs';
4
+ export { CardProvider, useCardContext } from './card-context.mjs';
5
+ export { default as CardHeader } from './card-header.mjs';
6
+ export { default as CardBody } from './card-body.mjs';
7
+ import '@heroui/system';
8
+ import 'react';
9
+ import '@react-types/shared';
10
+ import '@heroui/theme';
11
+ import '@heroui/ripple';
12
+ import '@react-aria/interactions';
13
+ import '@heroui/react-utils';
@@ -0,0 +1,13 @@
1
+ export { default as Card, CardProps } from './card.js';
2
+ export { default as CardFooter, CardFooterProps } from './card-footer.js';
3
+ export { useCard } from './use-card.js';
4
+ export { CardProvider, useCardContext } from './card-context.js';
5
+ export { default as CardHeader } from './card-header.js';
6
+ export { default as CardBody } from './card-body.js';
7
+ import '@heroui/system';
8
+ import 'react';
9
+ import '@react-types/shared';
10
+ import '@heroui/theme';
11
+ import '@heroui/ripple';
12
+ import '@react-aria/interactions';
13
+ import '@heroui/react-utils';
package/dist/index.js ADDED
@@ -0,0 +1,270 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Card: () => card_default,
25
+ CardBody: () => card_body_default,
26
+ CardFooter: () => card_footer_default,
27
+ CardHeader: () => card_header_default,
28
+ CardProvider: () => CardProvider,
29
+ useCard: () => useCard,
30
+ useCardContext: () => useCardContext
31
+ });
32
+ module.exports = __toCommonJS(index_exports);
33
+
34
+ // src/use-card.ts
35
+ var import_theme = require("@heroui/theme");
36
+ var import_react = require("react");
37
+ var import_utils = require("@react-aria/utils");
38
+ var import_focus = require("@react-aria/focus");
39
+ var import_interactions = require("@react-aria/interactions");
40
+ var import_use_aria_button = require("@heroui/use-aria-button");
41
+ var import_system = require("@heroui/system");
42
+ var import_shared_utils = require("@heroui/shared-utils");
43
+ var import_react_utils = require("@heroui/react-utils");
44
+ var import_react_utils2 = require("@heroui/react-utils");
45
+ var import_ripple = require("@heroui/ripple");
46
+ function useCard(originalProps) {
47
+ var _a, _b, _c, _d;
48
+ const globalContext = (0, import_system.useProviderContext)();
49
+ const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.card.variantKeys);
50
+ const {
51
+ ref,
52
+ as,
53
+ children,
54
+ onClick,
55
+ onPress,
56
+ autoFocus,
57
+ className,
58
+ classNames,
59
+ allowTextSelectionOnPress = true,
60
+ ...otherProps
61
+ } = props;
62
+ const domRef = (0, import_react_utils2.useDOMRef)(ref);
63
+ const Component = as || (originalProps.isPressable ? "button" : "div");
64
+ const shouldFilterDOMProps = typeof Component === "string";
65
+ const disableAnimation = (_b = (_a = originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
66
+ const disableRipple = (_d = (_c = originalProps.disableRipple) != null ? _c : globalContext == null ? void 0 : globalContext.disableRipple) != null ? _d : false;
67
+ const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className);
68
+ const { onClear: onClearRipple, onPress: onRipplePressHandler, ripples } = (0, import_ripple.useRipple)();
69
+ const handlePress = (0, import_react.useCallback)(
70
+ (e) => {
71
+ if (disableRipple || disableAnimation) return;
72
+ domRef.current && onRipplePressHandler(e);
73
+ },
74
+ [disableRipple, disableAnimation, domRef, onRipplePressHandler]
75
+ );
76
+ const { buttonProps, isPressed } = (0, import_use_aria_button.useAriaButton)(
77
+ {
78
+ onPress: (0, import_utils.chain)(onPress, handlePress),
79
+ elementType: as,
80
+ isDisabled: !originalProps.isPressable,
81
+ onClick,
82
+ allowTextSelectionOnPress,
83
+ ...otherProps
84
+ },
85
+ domRef
86
+ );
87
+ const { hoverProps, isHovered } = (0, import_interactions.useHover)({
88
+ isDisabled: !originalProps.isHoverable,
89
+ ...otherProps
90
+ });
91
+ const { isFocusVisible, isFocused, focusProps } = (0, import_focus.useFocusRing)({
92
+ autoFocus
93
+ });
94
+ const slots = (0, import_react.useMemo)(
95
+ () => (0, import_theme.card)({
96
+ ...variantProps,
97
+ disableAnimation
98
+ }),
99
+ [(0, import_shared_utils.objectToDeps)(variantProps), disableAnimation]
100
+ );
101
+ const context = (0, import_react.useMemo)(
102
+ () => ({
103
+ slots,
104
+ classNames,
105
+ disableAnimation,
106
+ isDisabled: originalProps.isDisabled,
107
+ isFooterBlurred: originalProps.isFooterBlurred,
108
+ fullWidth: originalProps.fullWidth
109
+ }),
110
+ [
111
+ slots,
112
+ classNames,
113
+ originalProps.isDisabled,
114
+ originalProps.isFooterBlurred,
115
+ disableAnimation,
116
+ originalProps.fullWidth
117
+ ]
118
+ );
119
+ const getCardProps = (0, import_react.useCallback)(
120
+ (props2 = {}) => {
121
+ return {
122
+ ref: domRef,
123
+ className: slots.base({ class: baseStyles }),
124
+ tabIndex: originalProps.isPressable ? 0 : -1,
125
+ "data-hover": (0, import_shared_utils.dataAttr)(isHovered),
126
+ "data-pressed": (0, import_shared_utils.dataAttr)(isPressed),
127
+ "data-focus": (0, import_shared_utils.dataAttr)(isFocused),
128
+ "data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible),
129
+ "data-disabled": (0, import_shared_utils.dataAttr)(originalProps.isDisabled),
130
+ ...(0, import_utils.mergeProps)(
131
+ originalProps.isPressable ? { ...buttonProps, ...focusProps, role: "button" } : {},
132
+ originalProps.isHoverable ? hoverProps : {},
133
+ (0, import_react_utils.filterDOMProps)(otherProps, {
134
+ enabled: shouldFilterDOMProps
135
+ }),
136
+ (0, import_react_utils.filterDOMProps)(props2)
137
+ )
138
+ };
139
+ },
140
+ [
141
+ domRef,
142
+ slots,
143
+ baseStyles,
144
+ shouldFilterDOMProps,
145
+ originalProps.isPressable,
146
+ originalProps.isHoverable,
147
+ originalProps.isDisabled,
148
+ isHovered,
149
+ isPressed,
150
+ isFocusVisible,
151
+ buttonProps,
152
+ focusProps,
153
+ hoverProps,
154
+ otherProps
155
+ ]
156
+ );
157
+ const getRippleProps = (0, import_react.useCallback)(
158
+ () => ({ ripples, onClear: onClearRipple }),
159
+ [ripples, onClearRipple]
160
+ );
161
+ return {
162
+ context,
163
+ domRef,
164
+ Component,
165
+ classNames,
166
+ children,
167
+ isHovered,
168
+ isPressed,
169
+ disableAnimation,
170
+ isPressable: originalProps.isPressable,
171
+ isHoverable: originalProps.isHoverable,
172
+ disableRipple,
173
+ handlePress,
174
+ isFocusVisible,
175
+ getCardProps,
176
+ getRippleProps
177
+ };
178
+ }
179
+
180
+ // src/card-context.ts
181
+ var import_react_utils3 = require("@heroui/react-utils");
182
+ var [CardProvider, useCardContext] = (0, import_react_utils3.createContext)({
183
+ name: "CardContext",
184
+ strict: true,
185
+ errorMessage: "useCardContext: `context` is undefined. Seems you forgot to wrap component within <Card />"
186
+ });
187
+
188
+ // src/card.tsx
189
+ var import_system2 = require("@heroui/system");
190
+ var import_ripple2 = require("@heroui/ripple");
191
+ var import_jsx_runtime = require("react/jsx-runtime");
192
+ var Card = (0, import_system2.forwardRef)((props, ref) => {
193
+ const {
194
+ children,
195
+ context,
196
+ Component,
197
+ isPressable,
198
+ disableAnimation,
199
+ disableRipple,
200
+ getCardProps,
201
+ getRippleProps
202
+ } = useCard({ ...props, ref });
203
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Component, { ...getCardProps(), children: [
204
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardProvider, { value: context, children }),
205
+ isPressable && !disableAnimation && !disableRipple && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ripple2.Ripple, { ...getRippleProps() })
206
+ ] });
207
+ });
208
+ Card.displayName = "HeroUI.Card";
209
+ var card_default = Card;
210
+
211
+ // src/card-header.tsx
212
+ var import_system3 = require("@heroui/system");
213
+ var import_react_utils4 = require("@heroui/react-utils");
214
+ var import_shared_utils2 = require("@heroui/shared-utils");
215
+ var import_jsx_runtime2 = require("react/jsx-runtime");
216
+ var CardHeader = (0, import_system3.forwardRef)((props, ref) => {
217
+ var _a;
218
+ const { as, className, children, ...otherProps } = props;
219
+ const Component = as || "div";
220
+ const domRef = (0, import_react_utils4.useDOMRef)(ref);
221
+ const { slots, classNames } = useCardContext();
222
+ const headerStyles = (0, import_shared_utils2.clsx)(classNames == null ? void 0 : classNames.header, className);
223
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, { ref: domRef, className: (_a = slots.header) == null ? void 0 : _a.call(slots, { class: headerStyles }), ...otherProps, children });
224
+ });
225
+ CardHeader.displayName = "HeroUI.CardHeader";
226
+ var card_header_default = CardHeader;
227
+
228
+ // src/card-body.tsx
229
+ var import_system4 = require("@heroui/system");
230
+ var import_react_utils5 = require("@heroui/react-utils");
231
+ var import_shared_utils3 = require("@heroui/shared-utils");
232
+ var import_jsx_runtime3 = require("react/jsx-runtime");
233
+ var CardBody = (0, import_system4.forwardRef)((props, ref) => {
234
+ var _a;
235
+ const { as, className, children, ...otherProps } = props;
236
+ const Component = as || "div";
237
+ const domRef = (0, import_react_utils5.useDOMRef)(ref);
238
+ const { slots, classNames } = useCardContext();
239
+ const bodyStyles = (0, import_shared_utils3.clsx)(classNames == null ? void 0 : classNames.body, className);
240
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ref: domRef, className: (_a = slots.body) == null ? void 0 : _a.call(slots, { class: bodyStyles }), ...otherProps, children });
241
+ });
242
+ CardBody.displayName = "HeroUI.CardBody";
243
+ var card_body_default = CardBody;
244
+
245
+ // src/card-footer.tsx
246
+ var import_system5 = require("@heroui/system");
247
+ var import_react_utils6 = require("@heroui/react-utils");
248
+ var import_shared_utils4 = require("@heroui/shared-utils");
249
+ var import_jsx_runtime4 = require("react/jsx-runtime");
250
+ var CardFooter = (0, import_system5.forwardRef)((props, ref) => {
251
+ var _a;
252
+ const { as, className, children, ...otherProps } = props;
253
+ const Component = as || "div";
254
+ const domRef = (0, import_react_utils6.useDOMRef)(ref);
255
+ const { slots, classNames } = useCardContext();
256
+ const footerStyles = (0, import_shared_utils4.clsx)(classNames == null ? void 0 : classNames.footer, className);
257
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, { ref: domRef, className: (_a = slots.footer) == null ? void 0 : _a.call(slots, { class: footerStyles }), ...otherProps, children });
258
+ });
259
+ CardFooter.displayName = "HeroUI.CardFooter";
260
+ var card_footer_default = CardFooter;
261
+ // Annotate the CommonJS export names for ESM import in node:
262
+ 0 && (module.exports = {
263
+ Card,
264
+ CardBody,
265
+ CardFooter,
266
+ CardHeader,
267
+ CardProvider,
268
+ useCard,
269
+ useCardContext
270
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import {
3
+ card_body_default
4
+ } from "./chunk-LGSBTEIA.mjs";
5
+ import {
6
+ card_footer_default
7
+ } from "./chunk-TE6SZS6W.mjs";
8
+ import {
9
+ card_header_default
10
+ } from "./chunk-D5XJWRAV.mjs";
11
+ import {
12
+ card_default
13
+ } from "./chunk-MW56SEHC.mjs";
14
+ import {
15
+ CardProvider,
16
+ useCardContext
17
+ } from "./chunk-XHGGCEVJ.mjs";
18
+ import {
19
+ useCard
20
+ } from "./chunk-NVHFBF4D.mjs";
21
+ export {
22
+ card_default as Card,
23
+ card_body_default as CardBody,
24
+ card_footer_default as CardFooter,
25
+ card_header_default as CardHeader,
26
+ CardProvider,
27
+ useCard,
28
+ useCardContext
29
+ };
@@ -0,0 +1,80 @@
1
+ import * as _heroui_system from '@heroui/system';
2
+ import { HTMLHeroUIProps, PropGetter } from '@heroui/system';
3
+ import * as react from 'react';
4
+ import { ReactNode, MouseEventHandler } from 'react';
5
+ import { PressEvents, FocusableProps } from '@react-types/shared';
6
+ import { SlotsToClasses, CardSlots, CardVariantProps, CardReturnType } from '@heroui/theme';
7
+ import { RippleProps } from '@heroui/ripple';
8
+ import { PressEvent } from '@react-aria/interactions';
9
+ import { ReactRef } from '@heroui/react-utils';
10
+
11
+ interface Props extends Omit<HTMLHeroUIProps<"div">, "onClick"> {
12
+ /**
13
+ * Ref to the DOM node.
14
+ */
15
+ ref?: ReactRef<HTMLDivElement | null>;
16
+ /**
17
+ * Usually the Card parts, `CardHeader`, `CardBody` and `CardFooter`.
18
+ */
19
+ children?: ReactNode | ReactNode[];
20
+ /**
21
+ * Whether the card should show a ripple animation on press, this prop is ignored if `disableAnimation` is true or `isPressable` is false.
22
+ * @default false
23
+ */
24
+ disableRipple?: boolean;
25
+ /**
26
+ * Whether the card should allow text selection on press. (only for pressable cards)
27
+ * @default true
28
+ */
29
+ allowTextSelectionOnPress?: boolean;
30
+ /**
31
+ * The native button click event handler.
32
+ * use `onPress` instead.
33
+ * @deprecated
34
+ */
35
+ onClick?: MouseEventHandler<HTMLButtonElement>;
36
+ /**
37
+ * Classname or List of classes to change the classNames of the element.
38
+ * if `className` is passed, it will be added to the base slot.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * <Card classNames={{
43
+ * base:"base-classes",
44
+ * header: "dot-classes",
45
+ * body: "content-classes",
46
+ * footer: "avatar-classes",
47
+ * }} />
48
+ * ```
49
+ */
50
+ classNames?: SlotsToClasses<CardSlots>;
51
+ }
52
+ type UseCardProps = Props & PressEvents & FocusableProps & CardVariantProps;
53
+ type ContextType = {
54
+ slots: CardReturnType;
55
+ classNames?: SlotsToClasses<CardSlots>;
56
+ isDisabled?: CardVariantProps["isDisabled"];
57
+ isFooterBlurred?: CardVariantProps["isFooterBlurred"];
58
+ disableAnimation?: CardVariantProps["disableAnimation"];
59
+ fullWidth?: CardVariantProps["fullWidth"];
60
+ };
61
+ declare function useCard(originalProps: UseCardProps): {
62
+ context: ContextType;
63
+ domRef: react.RefObject<HTMLDivElement>;
64
+ Component: _heroui_system.As<any>;
65
+ classNames: SlotsToClasses<"base" | "body" | "footer" | "header"> | undefined;
66
+ children: ReactNode | ReactNode[];
67
+ isHovered: boolean;
68
+ isPressed: boolean;
69
+ disableAnimation: boolean;
70
+ isPressable: boolean | undefined;
71
+ isHoverable: boolean | undefined;
72
+ disableRipple: boolean;
73
+ handlePress: (e: PressEvent) => void;
74
+ isFocusVisible: boolean;
75
+ getCardProps: PropGetter;
76
+ getRippleProps: () => RippleProps;
77
+ };
78
+ type UseCardReturn = ReturnType<typeof useCard>;
79
+
80
+ export { type ContextType, type Props, type UseCardProps, type UseCardReturn, useCard };
@@ -0,0 +1,80 @@
1
+ import * as _heroui_system from '@heroui/system';
2
+ import { HTMLHeroUIProps, PropGetter } from '@heroui/system';
3
+ import * as react from 'react';
4
+ import { ReactNode, MouseEventHandler } from 'react';
5
+ import { PressEvents, FocusableProps } from '@react-types/shared';
6
+ import { SlotsToClasses, CardSlots, CardVariantProps, CardReturnType } from '@heroui/theme';
7
+ import { RippleProps } from '@heroui/ripple';
8
+ import { PressEvent } from '@react-aria/interactions';
9
+ import { ReactRef } from '@heroui/react-utils';
10
+
11
+ interface Props extends Omit<HTMLHeroUIProps<"div">, "onClick"> {
12
+ /**
13
+ * Ref to the DOM node.
14
+ */
15
+ ref?: ReactRef<HTMLDivElement | null>;
16
+ /**
17
+ * Usually the Card parts, `CardHeader`, `CardBody` and `CardFooter`.
18
+ */
19
+ children?: ReactNode | ReactNode[];
20
+ /**
21
+ * Whether the card should show a ripple animation on press, this prop is ignored if `disableAnimation` is true or `isPressable` is false.
22
+ * @default false
23
+ */
24
+ disableRipple?: boolean;
25
+ /**
26
+ * Whether the card should allow text selection on press. (only for pressable cards)
27
+ * @default true
28
+ */
29
+ allowTextSelectionOnPress?: boolean;
30
+ /**
31
+ * The native button click event handler.
32
+ * use `onPress` instead.
33
+ * @deprecated
34
+ */
35
+ onClick?: MouseEventHandler<HTMLButtonElement>;
36
+ /**
37
+ * Classname or List of classes to change the classNames of the element.
38
+ * if `className` is passed, it will be added to the base slot.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * <Card classNames={{
43
+ * base:"base-classes",
44
+ * header: "dot-classes",
45
+ * body: "content-classes",
46
+ * footer: "avatar-classes",
47
+ * }} />
48
+ * ```
49
+ */
50
+ classNames?: SlotsToClasses<CardSlots>;
51
+ }
52
+ type UseCardProps = Props & PressEvents & FocusableProps & CardVariantProps;
53
+ type ContextType = {
54
+ slots: CardReturnType;
55
+ classNames?: SlotsToClasses<CardSlots>;
56
+ isDisabled?: CardVariantProps["isDisabled"];
57
+ isFooterBlurred?: CardVariantProps["isFooterBlurred"];
58
+ disableAnimation?: CardVariantProps["disableAnimation"];
59
+ fullWidth?: CardVariantProps["fullWidth"];
60
+ };
61
+ declare function useCard(originalProps: UseCardProps): {
62
+ context: ContextType;
63
+ domRef: react.RefObject<HTMLDivElement>;
64
+ Component: _heroui_system.As<any>;
65
+ classNames: SlotsToClasses<"base" | "body" | "footer" | "header"> | undefined;
66
+ children: ReactNode | ReactNode[];
67
+ isHovered: boolean;
68
+ isPressed: boolean;
69
+ disableAnimation: boolean;
70
+ isPressable: boolean | undefined;
71
+ isHoverable: boolean | undefined;
72
+ disableRipple: boolean;
73
+ handlePress: (e: PressEvent) => void;
74
+ isFocusVisible: boolean;
75
+ getCardProps: PropGetter;
76
+ getRippleProps: () => RippleProps;
77
+ };
78
+ type UseCardReturn = ReturnType<typeof useCard>;
79
+
80
+ export { type ContextType, type Props, type UseCardProps, type UseCardReturn, useCard };