@mezzanine-ui/react 1.0.0-beta.5 → 1.0.0-beta.7
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/Accordion/Accordion.d.ts +23 -1
- package/Accordion/Accordion.js +59 -11
- package/Accordion/AccordionActions.d.ts +13 -0
- package/Accordion/AccordionActions.js +24 -0
- package/Accordion/AccordionContent.d.ts +9 -0
- package/Accordion/{AccordionDetails.js → AccordionContent.js} +4 -6
- package/Accordion/AccordionControlContext.d.ts +2 -2
- package/Accordion/AccordionGroup.d.ts +10 -0
- package/Accordion/AccordionGroup.js +26 -0
- package/Accordion/AccordionTitle.d.ts +14 -0
- package/Accordion/AccordionTitle.js +56 -0
- package/Accordion/index.d.ts +8 -4
- package/Accordion/index.js +4 -2
- package/AutoComplete/AutoComplete.d.ts +25 -6
- package/AutoComplete/AutoComplete.js +119 -30
- package/Backdrop/Backdrop.js +15 -19
- package/Breadcrumb/BreadcrumbDropdown.js +1 -1
- package/Breadcrumb/BreadcrumbItem.js +1 -1
- package/Breadcrumb/BreadcrumbOverflowMenuItem.js +1 -1
- package/Calendar/CalendarDays.js +1 -1
- package/Card/BaseCard.d.ts +11 -0
- package/Card/BaseCard.js +48 -0
- package/Card/BaseCardSkeleton.d.ts +14 -0
- package/Card/BaseCardSkeleton.js +18 -0
- package/Card/CardGroup.d.ts +47 -0
- package/Card/CardGroup.js +147 -0
- package/Card/FourThumbnailCard.d.ts +14 -0
- package/Card/FourThumbnailCard.js +73 -0
- package/Card/FourThumbnailCardSkeleton.d.ts +14 -0
- package/Card/FourThumbnailCardSkeleton.js +20 -0
- package/Card/QuickActionCard.d.ts +12 -0
- package/Card/QuickActionCard.js +23 -0
- package/Card/QuickActionCardSkeleton.d.ts +14 -0
- package/Card/QuickActionCardSkeleton.js +18 -0
- package/Card/SingleThumbnailCard.d.ts +13 -0
- package/Card/SingleThumbnailCard.js +44 -0
- package/Card/SingleThumbnailCardSkeleton.d.ts +19 -0
- package/Card/SingleThumbnailCardSkeleton.js +18 -0
- package/Card/Thumbnail.d.ts +12 -0
- package/Card/Thumbnail.js +18 -0
- package/Card/ThumbnailCardInfo.d.ts +34 -0
- package/Card/ThumbnailCardInfo.js +43 -0
- package/Card/index.d.ts +43 -4
- package/Card/index.js +19 -2
- package/Card/typings.d.ts +442 -0
- package/Checkbox/Checkbox.d.ts +8 -0
- package/Checkbox/Checkbox.js +3 -2
- package/Checkbox/CheckboxGroup.js +1 -1
- package/ContentHeader/ContentHeader.d.ts +22 -70
- package/ContentHeader/ContentHeader.js +1 -1
- package/ContentHeader/ContentHeaderResponsive.d.ts +9 -0
- package/ContentHeader/ContentHeaderResponsive.js +7 -0
- package/ContentHeader/utils.d.ts +3 -3
- package/ContentHeader/utils.js +66 -20
- package/Cropper/Cropper.d.ts +66 -0
- package/Cropper/Cropper.js +115 -0
- package/Cropper/CropperElement.d.ts +10 -0
- package/Cropper/CropperElement.js +892 -0
- package/Cropper/index.d.ts +18 -0
- package/Cropper/index.js +8 -0
- package/Cropper/tools.d.ts +90 -0
- package/Cropper/tools.js +143 -0
- package/Cropper/typings.d.ts +69 -0
- package/Cropper/utils/cropper-calculations.d.ts +39 -0
- package/Cropper/utils/cropper-calculations.js +95 -0
- package/DateTimePicker/DateTimePicker.d.ts +1 -1
- package/DateTimePicker/DateTimePicker.js +22 -5
- package/DateTimeRangePicker/DateTimeRangePicker.d.ts +34 -0
- package/DateTimeRangePicker/DateTimeRangePicker.js +118 -0
- package/DateTimeRangePicker/index.d.ts +2 -0
- package/DateTimeRangePicker/index.js +1 -0
- package/Drawer/Drawer.d.ts +132 -1
- package/Drawer/Drawer.js +47 -3
- package/Dropdown/Dropdown.d.ts +10 -4
- package/Dropdown/Dropdown.js +37 -42
- package/Dropdown/DropdownItem.d.ts +7 -1
- package/Dropdown/DropdownItem.js +36 -6
- package/Dropdown/DropdownItemCard.js +2 -1
- package/FloatingButton/FloatingButton.d.ts +21 -0
- package/FloatingButton/FloatingButton.js +18 -0
- package/FloatingButton/index.d.ts +2 -0
- package/FloatingButton/index.js +1 -0
- package/Form/FormField.d.ts +30 -7
- package/Form/FormField.js +12 -4
- package/Input/Input.js +12 -21
- package/Input/SelectButton/SelectButton.d.ts +25 -4
- package/Input/SelectButton/SelectButton.js +21 -9
- package/Message/Message.js +1 -1
- package/Modal/MediaPreviewModal.d.ts +11 -0
- package/Modal/MediaPreviewModal.js +24 -7
- package/Modal/Modal.d.ts +1 -1
- package/Modal/Modal.js +1 -1
- package/Modal/useModalContainer.js +6 -2
- package/MultipleDatePicker/MultipleDatePicker.d.ts +62 -0
- package/MultipleDatePicker/MultipleDatePicker.js +176 -0
- package/MultipleDatePicker/MultipleDatePickerTrigger.d.ts +56 -0
- package/MultipleDatePicker/MultipleDatePickerTrigger.js +92 -0
- package/MultipleDatePicker/index.d.ts +6 -0
- package/MultipleDatePicker/index.js +3 -0
- package/MultipleDatePicker/useMultipleDatePickerValue.d.ts +55 -0
- package/MultipleDatePicker/useMultipleDatePickerValue.js +68 -0
- package/Navigation/NavigationHeader.js +1 -1
- package/NotificationCenter/NotificationCenterDrawer.d.ts +10 -52
- package/NotificationCenter/NotificationCenterDrawer.js +128 -0
- package/NotificationCenter/index.d.ts +2 -0
- package/NotificationCenter/index.js +1 -0
- package/OverflowTooltip/index.d.ts +2 -2
- package/Picker/FormattedInput.d.ts +1 -1
- package/Picker/FormattedInput.js +2 -1
- package/Picker/PickerTriggerWithSeparator.d.ts +10 -0
- package/Picker/PickerTriggerWithSeparator.js +2 -2
- package/Picker/RangePickerTrigger.js +1 -1
- package/Picker/useDateInputFormatter.d.ts +6 -0
- package/Picker/useDateInputFormatter.js +4 -1
- package/Section/Section.d.ts +32 -0
- package/Section/Section.js +62 -0
- package/Section/index.d.ts +2 -0
- package/Select/Select.d.ts +11 -12
- package/Select/Select.js +13 -34
- package/Select/SelectTrigger.js +21 -7
- package/Select/index.d.ts +0 -4
- package/Select/index.js +0 -2
- package/Select/typings.d.ts +0 -4
- package/Select/useSelectTriggerTags.d.ts +1 -1
- package/Select/useSelectTriggerTags.js +9 -6
- package/Separator/Separator.d.ts +14 -0
- package/Separator/Separator.js +17 -0
- package/Separator/index.d.ts +2 -0
- package/Separator/index.js +1 -0
- package/Table/utils/useTableRowSelection.js +6 -0
- package/Tag/TagGroup.d.ts +4 -2
- package/Tag/TagGroup.js +7 -4
- package/TextField/TextField.d.ts +1 -1
- package/TextField/TextField.js +63 -9
- package/TimePanel/TimePanelColumn.js +30 -21
- package/TimeRangePicker/TimeRangePicker.d.ts +29 -0
- package/TimeRangePicker/TimeRangePicker.js +96 -0
- package/TimeRangePicker/index.d.ts +3 -0
- package/TimeRangePicker/index.js +2 -0
- package/TimeRangePicker/useTimeRangePickerValue.d.ts +30 -0
- package/TimeRangePicker/useTimeRangePickerValue.js +92 -0
- package/Transition/Rotate.js +2 -5
- package/index.d.ts +30 -28
- package/index.js +26 -27
- package/package.json +4 -4
- package/Accordion/AccordionDetails.d.ts +0 -9
- package/Accordion/AccordionSummary.d.ts +0 -18
- package/Accordion/AccordionSummary.js +0 -51
- package/Alert/Alert.d.ts +0 -20
- package/Alert/Alert.js +0 -18
- package/Alert/index.d.ts +0 -3
- package/Alert/index.js +0 -1
- package/AppBar/AppBar.d.ts +0 -14
- package/AppBar/AppBar.js +0 -33
- package/AppBar/AppBarBrand.d.ts +0 -4
- package/AppBar/AppBarBrand.js +0 -11
- package/AppBar/AppBarMain.d.ts +0 -4
- package/AppBar/AppBarMain.js +0 -11
- package/AppBar/AppBarSupport.d.ts +0 -4
- package/AppBar/AppBarSupport.js +0 -11
- package/AppBar/index.d.ts +0 -8
- package/AppBar/index.js +0 -4
- package/Card/Card.d.ts +0 -51
- package/Card/Card.js +0 -20
- package/Card/CardActions.d.ts +0 -34
- package/Card/CardActions.js +0 -15
- package/ConfirmActions/ConfirmActions.d.ts +0 -46
- package/ConfirmActions/ConfirmActions.js +0 -15
- package/ConfirmActions/index.d.ts +0 -2
- package/ConfirmActions/index.js +0 -1
- package/Popconfirm/Popconfirm.d.ts +0 -16
- package/Popconfirm/Popconfirm.js +0 -15
- package/Popconfirm/index.d.ts +0 -2
- package/Popconfirm/index.js +0 -1
- package/Popover/Popover.d.ts +0 -23
- package/Popover/Popover.js +0 -35
- package/Popover/index.d.ts +0 -2
- package/Popover/index.js +0 -1
- package/Select/Option.d.ts +0 -18
- package/Select/Option.js +0 -45
- package/Select/TreeSelect.d.ts +0 -67
- package/Select/TreeSelect.js +0 -198
- package/Tree/Tree.d.ts +0 -70
- package/Tree/Tree.js +0 -139
- package/Tree/TreeNode.d.ts +0 -40
- package/Tree/TreeNode.js +0 -50
- package/Tree/TreeNodeList.d.ts +0 -24
- package/Tree/TreeNodeList.js +0 -28
- package/Tree/getTreeNodeEntities.d.ts +0 -11
- package/Tree/getTreeNodeEntities.js +0 -92
- package/Tree/index.d.ts +0 -13
- package/Tree/index.js +0 -7
- package/Tree/toggleValue.d.ts +0 -4
- package/Tree/toggleValue.js +0 -19
- package/Tree/traverseTree.d.ts +0 -2
- package/Tree/traverseTree.js +0 -11
- package/Tree/typings.d.ts +0 -16
- package/Tree/useTreeExpandedValue.d.ts +0 -14
- package/Tree/useTreeExpandedValue.js +0 -33
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
4
|
+
import { forwardRef, Children, isValidElement } from 'react';
|
|
5
|
+
import BaseCard from './BaseCard.js';
|
|
6
|
+
import BaseCardSkeleton from './BaseCardSkeleton.js';
|
|
7
|
+
import FourThumbnailCard from './FourThumbnailCard.js';
|
|
8
|
+
import FourThumbnailCardSkeleton from './FourThumbnailCardSkeleton.js';
|
|
9
|
+
import QuickActionCard from './QuickActionCard.js';
|
|
10
|
+
import QuickActionCardSkeleton from './QuickActionCardSkeleton.js';
|
|
11
|
+
import SingleThumbnailCard from './SingleThumbnailCard.js';
|
|
12
|
+
import SingleThumbnailCardSkeleton from './SingleThumbnailCardSkeleton.js';
|
|
13
|
+
import cx from 'clsx';
|
|
14
|
+
|
|
15
|
+
// List of allowed child component types
|
|
16
|
+
const ALLOWED_CARD_TYPES = [
|
|
17
|
+
BaseCard,
|
|
18
|
+
FourThumbnailCard,
|
|
19
|
+
QuickActionCard,
|
|
20
|
+
SingleThumbnailCard,
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Get display name of a component for error messages
|
|
24
|
+
*/
|
|
25
|
+
function getComponentDisplayName(child) {
|
|
26
|
+
const { type } = child;
|
|
27
|
+
if (typeof type === 'string') {
|
|
28
|
+
return type;
|
|
29
|
+
}
|
|
30
|
+
return (type.displayName ||
|
|
31
|
+
type.name ||
|
|
32
|
+
'Unknown');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Detect the first valid card type from children
|
|
36
|
+
*/
|
|
37
|
+
function getFirstCardType(children) {
|
|
38
|
+
let firstType = null;
|
|
39
|
+
Children.forEach(children, (child) => {
|
|
40
|
+
if (firstType !== null)
|
|
41
|
+
return;
|
|
42
|
+
if (!isValidElement(child))
|
|
43
|
+
return;
|
|
44
|
+
if (child.type === QuickActionCard) {
|
|
45
|
+
firstType = QuickActionCard;
|
|
46
|
+
}
|
|
47
|
+
else if (child.type === BaseCard) {
|
|
48
|
+
firstType = BaseCard;
|
|
49
|
+
}
|
|
50
|
+
else if (child.type === SingleThumbnailCard) {
|
|
51
|
+
firstType = SingleThumbnailCard;
|
|
52
|
+
}
|
|
53
|
+
else if (child.type === FourThumbnailCard) {
|
|
54
|
+
firstType = FourThumbnailCard;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return firstType;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get the skeleton component based on loading type
|
|
61
|
+
*/
|
|
62
|
+
function getSkeletonComponent(loadingType) {
|
|
63
|
+
switch (loadingType) {
|
|
64
|
+
case 'base':
|
|
65
|
+
return BaseCardSkeleton;
|
|
66
|
+
case 'four-thumbnail':
|
|
67
|
+
return FourThumbnailCardSkeleton;
|
|
68
|
+
case 'quick-action':
|
|
69
|
+
return QuickActionCardSkeleton;
|
|
70
|
+
case 'single-thumbnail':
|
|
71
|
+
return SingleThumbnailCardSkeleton;
|
|
72
|
+
default:
|
|
73
|
+
return BaseCardSkeleton;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the group class modifier based on loading type
|
|
78
|
+
*/
|
|
79
|
+
function getGroupClassFromLoadingType(loadingType) {
|
|
80
|
+
switch (loadingType) {
|
|
81
|
+
case 'four-thumbnail':
|
|
82
|
+
return cardClasses.groupFourThumbnail;
|
|
83
|
+
case 'quick-action':
|
|
84
|
+
return cardClasses.groupQuickAction;
|
|
85
|
+
case 'single-thumbnail':
|
|
86
|
+
return cardClasses.groupSingleThumbnail;
|
|
87
|
+
default:
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* CardGroup is a container for card components.
|
|
93
|
+
* It uses CSS Grid to layout cards in a horizontal row with consistent spacing.
|
|
94
|
+
*/
|
|
95
|
+
const CardGroup = forwardRef(function CardGroup(props, ref) {
|
|
96
|
+
const { className, children, loading = false, loadingCount = 3, loadingThumbnailAspectRatio, loadingThumbnailWidth, loadingType, } = props;
|
|
97
|
+
// Detect first card type to determine min-width class
|
|
98
|
+
const firstCardType = getFirstCardType(children);
|
|
99
|
+
// Validate children at runtime
|
|
100
|
+
const validChildren = Children.map(children, (child) => {
|
|
101
|
+
if (!isValidElement(child)) {
|
|
102
|
+
return child;
|
|
103
|
+
}
|
|
104
|
+
const isAllowedType = ALLOWED_CARD_TYPES.some((allowedType) => child.type === allowedType);
|
|
105
|
+
if (!isAllowedType) {
|
|
106
|
+
const displayName = getComponentDisplayName(child);
|
|
107
|
+
console.warn(`[CardGroup] Invalid child type: <${displayName}>. ` +
|
|
108
|
+
'CardGroup only accepts Card components (BaseCard, FourThumbnailCard, QuickActionCard, SingleThumbnailCard) as children.');
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
return child;
|
|
112
|
+
});
|
|
113
|
+
// Render loading skeletons
|
|
114
|
+
const renderSkeletons = () => {
|
|
115
|
+
if (!loading || !loadingType) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const SkeletonComponent = getSkeletonComponent(loadingType);
|
|
119
|
+
// Build props for thumbnail skeletons
|
|
120
|
+
const thumbnailSkeletonProps = loadingType === 'single-thumbnail' || loadingType === 'four-thumbnail'
|
|
121
|
+
? {
|
|
122
|
+
...(loadingThumbnailAspectRatio && {
|
|
123
|
+
thumbnailAspectRatio: loadingThumbnailAspectRatio,
|
|
124
|
+
}),
|
|
125
|
+
...(loadingThumbnailWidth && {
|
|
126
|
+
thumbnailWidth: loadingThumbnailWidth,
|
|
127
|
+
}),
|
|
128
|
+
}
|
|
129
|
+
: undefined;
|
|
130
|
+
return Array.from({ length: loadingCount }, (_, index) => (jsx(SkeletonComponent, { ...thumbnailSkeletonProps }, `skeleton-${index}`)));
|
|
131
|
+
};
|
|
132
|
+
// Determine group class modifier
|
|
133
|
+
const groupClassModifier = loadingType && loading
|
|
134
|
+
? getGroupClassFromLoadingType(loadingType)
|
|
135
|
+
: undefined;
|
|
136
|
+
return (jsxs("div", { ref: ref, className: cx(cardClasses.group, {
|
|
137
|
+
[cardClasses.groupFourThumbnail]: firstCardType === FourThumbnailCard ||
|
|
138
|
+
groupClassModifier === cardClasses.groupFourThumbnail,
|
|
139
|
+
[cardClasses.groupQuickAction]: firstCardType === QuickActionCard ||
|
|
140
|
+
groupClassModifier === cardClasses.groupQuickAction,
|
|
141
|
+
[cardClasses.groupSingleThumbnail]: firstCardType === SingleThumbnailCard ||
|
|
142
|
+
groupClassModifier === cardClasses.groupSingleThumbnail,
|
|
143
|
+
}, className), children: [validChildren, renderSkeletons()] }));
|
|
144
|
+
});
|
|
145
|
+
CardGroup.displayName = 'CardGroup';
|
|
146
|
+
|
|
147
|
+
export { CardGroup as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ComponentOverridableForwardRefComponentPropsFactory } from '../utils/jsx-types';
|
|
2
|
+
import { FourThumbnailCardComponent, FourThumbnailCardProps } from './typings';
|
|
3
|
+
export type FourThumbnailCardComponentProps<C extends FourThumbnailCardComponent = 'div'> = ComponentOverridableForwardRefComponentPropsFactory<FourThumbnailCardComponent, C, FourThumbnailCardProps>;
|
|
4
|
+
/**
|
|
5
|
+
* FourThumbnailCard displays a 2x2 grid of image thumbnails with optional tag, personal action,
|
|
6
|
+
* and info section. Supports three action types: default, action, and overflow.
|
|
7
|
+
*
|
|
8
|
+
* Children must be Thumbnail components. If less than 4 are provided, empty slots will be rendered.
|
|
9
|
+
* If more than 4 are provided, only the first 4 will be used (with a console warning in development).
|
|
10
|
+
*/
|
|
11
|
+
declare const FourThumbnailCard: import("react").ForwardRefExoticComponent<Omit<Omit<import("../utils/jsx-types").ComponentPropsWithoutKeyAndRef<"div">, "children" | "title" | "className" | "type" | "options" | "actionName" | "onActionClick" | "onOptionSelect" | "filetype" | "subtitle" | "personalActionIcon" | "personalActionActiveIcon" | "personalActionActive" | "personalActionOnClick" | "tag"> & FourThumbnailCardProps, "component"> & {
|
|
12
|
+
component?: FourThumbnailCardComponent | undefined;
|
|
13
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default FourThumbnailCard;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, Children, isValidElement } from 'react';
|
|
4
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import Thumbnail from './Thumbnail.js';
|
|
6
|
+
import ThumbnailCardInfo from './ThumbnailCardInfo.js';
|
|
7
|
+
import Icon from '../Icon/Icon.js';
|
|
8
|
+
import cx from 'clsx';
|
|
9
|
+
|
|
10
|
+
const MAX_THUMBNAILS = 4;
|
|
11
|
+
/**
|
|
12
|
+
* FourThumbnailCard displays a 2x2 grid of image thumbnails with optional tag, personal action,
|
|
13
|
+
* and info section. Supports three action types: default, action, and overflow.
|
|
14
|
+
*
|
|
15
|
+
* Children must be Thumbnail components. If less than 4 are provided, empty slots will be rendered.
|
|
16
|
+
* If more than 4 are provided, only the first 4 will be used (with a console warning in development).
|
|
17
|
+
*/
|
|
18
|
+
const FourThumbnailCard = forwardRef(function FourThumbnailCard(props, ref) {
|
|
19
|
+
const { children, className, component: Component = 'div', filetype, personalActionActive = false, personalActionActiveIcon, personalActionIcon, personalActionOnClick, subtitle, tag, title, type = 'default', ...rest } = props;
|
|
20
|
+
// Process children: filter valid Thumbnail elements and limit to MAX_THUMBNAILS
|
|
21
|
+
const childArray = Children.toArray(children).filter((child) => {
|
|
22
|
+
if (!isValidElement(child))
|
|
23
|
+
return false;
|
|
24
|
+
// Check if the child is a Thumbnail component
|
|
25
|
+
const isThumbnail = child.type === Thumbnail;
|
|
26
|
+
if (!isThumbnail && process.env.NODE_ENV !== 'production') {
|
|
27
|
+
const displayName = typeof child.type === 'string'
|
|
28
|
+
? child.type
|
|
29
|
+
: child.type.displayName ||
|
|
30
|
+
child.type.name ||
|
|
31
|
+
'Unknown';
|
|
32
|
+
console.warn(`[FourThumbnailCard] Invalid child type: <${displayName}>. ` +
|
|
33
|
+
'FourThumbnailCard only accepts Thumbnail components as children.');
|
|
34
|
+
}
|
|
35
|
+
return isThumbnail;
|
|
36
|
+
});
|
|
37
|
+
// Warn if more than MAX_THUMBNAILS children are provided
|
|
38
|
+
if (childArray.length > MAX_THUMBNAILS &&
|
|
39
|
+
process.env.NODE_ENV !== 'production') {
|
|
40
|
+
console.warn(`[FourThumbnailCard] Received ${childArray.length} Thumbnail children, ` +
|
|
41
|
+
`but only the first ${MAX_THUMBNAILS} will be rendered.`);
|
|
42
|
+
}
|
|
43
|
+
// Take only the first MAX_THUMBNAILS
|
|
44
|
+
const thumbnails = childArray.slice(0, MAX_THUMBNAILS);
|
|
45
|
+
// Fill remaining slots with empty placeholders
|
|
46
|
+
const emptySlots = MAX_THUMBNAILS - thumbnails.length;
|
|
47
|
+
const emptyPlaceholders = Array.from({ length: emptySlots }, (_, index) => (jsx("div", { className: cx(cardClasses.fourThumbnailThumbnail, cardClasses.fourThumbnailThumbnailEmpty) }, `empty-${index}`)));
|
|
48
|
+
const hasPersonalAction = Boolean(personalActionIcon);
|
|
49
|
+
const currentPersonalActionIcon = personalActionActive
|
|
50
|
+
? (personalActionActiveIcon !== null && personalActionActiveIcon !== void 0 ? personalActionActiveIcon : personalActionIcon)
|
|
51
|
+
: personalActionIcon;
|
|
52
|
+
const handlePersonalActionClick = (event) => {
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
personalActionOnClick === null || personalActionOnClick === void 0 ? void 0 : personalActionOnClick(event, personalActionActive);
|
|
55
|
+
};
|
|
56
|
+
const getInfoProps = () => {
|
|
57
|
+
if (type === 'action') {
|
|
58
|
+
const { actionName, onActionClick } = props;
|
|
59
|
+
return { actionName, onActionClick };
|
|
60
|
+
}
|
|
61
|
+
if (type === 'overflow') {
|
|
62
|
+
const { onOptionSelect, options } = props;
|
|
63
|
+
return { onOptionSelect, options };
|
|
64
|
+
}
|
|
65
|
+
return {};
|
|
66
|
+
};
|
|
67
|
+
// Filter out type-specific props before spreading
|
|
68
|
+
const { actionName: _actionName, onActionClick: _onActionClick, onOptionSelect: _onOptionSelect, options: _options, type: _type, ...componentProps } = rest;
|
|
69
|
+
return (jsxs(Component, { ...componentProps, ref: ref, className: cx(cardClasses.thumbnail, className), children: [jsxs("div", { className: cardClasses.fourThumbnail, children: [tag && jsx("div", { className: cardClasses.thumbnailTag, children: tag }), hasPersonalAction && currentPersonalActionIcon && (jsx("button", { "aria-label": "Personal Action", className: cardClasses.thumbnailPersonalAction, onClick: handlePersonalActionClick, type: "button", children: jsx(Icon, { icon: currentPersonalActionIcon, size: 24 }) })), thumbnails, emptyPlaceholders] }), jsx(ThumbnailCardInfo, { filetype: filetype, subtitle: subtitle, title: title, type: type, ...getInfoProps() })] }));
|
|
70
|
+
});
|
|
71
|
+
FourThumbnailCard.displayName = 'FourThumbnailCard';
|
|
72
|
+
|
|
73
|
+
export { FourThumbnailCard as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
2
|
+
export interface FourThumbnailCardSkeletonProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
|
|
3
|
+
/**
|
|
4
|
+
* Width of the card skeleton container.
|
|
5
|
+
* @default 200
|
|
6
|
+
*/
|
|
7
|
+
thumbnailWidth?: number | string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Skeleton placeholder for FourThumbnailCard component.
|
|
11
|
+
* Renders a skeleton that mimics the FourThumbnailCard layout.
|
|
12
|
+
*/
|
|
13
|
+
declare const FourThumbnailCardSkeleton: import("react").ForwardRefExoticComponent<FourThumbnailCardSkeletonProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default FourThumbnailCardSkeleton;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import Skeleton from '../Skeleton/Skeleton.js';
|
|
6
|
+
import cx from 'clsx';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Skeleton placeholder for FourThumbnailCard component.
|
|
10
|
+
* Renders a skeleton that mimics the FourThumbnailCard layout.
|
|
11
|
+
*/
|
|
12
|
+
const FourThumbnailCardSkeleton = forwardRef(function FourThumbnailCardSkeleton(props, ref) {
|
|
13
|
+
const { className, thumbnailWidth = 200, ...rest } = props;
|
|
14
|
+
return (jsxs("div", { ...rest, ref: ref, className: cx(cardClasses.thumbnail, className), children: [jsx("div", { className: cardClasses.fourThumbnail, children: Array.from({ length: 4 }, (_, index) => (jsx(Skeleton, { className: cardClasses.fourThumbnailThumbnail, width: thumbnailWidth,
|
|
15
|
+
// For four-thumbnail layout, force to '4/3' to maintain the grid layout.
|
|
16
|
+
style: { aspectRatio: '4/3' } }, index))) }), jsx("div", { className: cardClasses.thumbnailInfo, children: jsx("div", { className: cardClasses.thumbnailInfoMain, children: jsxs("div", { className: cardClasses.thumbnailInfoContent, style: { width: '100%' }, children: [jsx(Skeleton, { height: 20, width: "100%" }), jsx(Skeleton, { height: 16, width: "100%" })] }) }) })] }));
|
|
17
|
+
});
|
|
18
|
+
FourThumbnailCardSkeleton.displayName = 'FourThumbnailCardSkeleton';
|
|
19
|
+
|
|
20
|
+
export { FourThumbnailCardSkeleton as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentOverridableForwardRefComponentPropsFactory } from '../utils/jsx-types';
|
|
2
|
+
import { QuickActionCardComponent, QuickActionCardProps } from './typings';
|
|
3
|
+
export type QuickActionCardComponentProps<C extends QuickActionCardComponent = 'button'> = ComponentOverridableForwardRefComponentPropsFactory<QuickActionCardComponent, C, QuickActionCardProps>;
|
|
4
|
+
/**
|
|
5
|
+
* QuickActionCard is a compact card component for quick actions.
|
|
6
|
+
* It displays an icon with a title and optional subtitle.
|
|
7
|
+
* Either icon or title must be provided.
|
|
8
|
+
*/
|
|
9
|
+
declare const QuickActionCard: import("react").ForwardRefExoticComponent<Omit<Omit<import("../utils/jsx-types").ComponentPropsWithoutKeyAndRef<"button">, "title" | "className" | "icon" | "disabled" | "readOnly" | "mode" | "subtitle"> & QuickActionCardProps, "component"> & {
|
|
10
|
+
component?: QuickActionCardComponent | undefined;
|
|
11
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export default QuickActionCard;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import Icon from '../Icon/Icon.js';
|
|
6
|
+
import cx from 'clsx';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* QuickActionCard is a compact card component for quick actions.
|
|
10
|
+
* It displays an icon with a title and optional subtitle.
|
|
11
|
+
* Either icon or title must be provided.
|
|
12
|
+
*/
|
|
13
|
+
const QuickActionCard = forwardRef(function QuickActionCard(props, ref) {
|
|
14
|
+
const { className, component: Component = 'button', disabled = false, icon, mode = 'horizontal', readOnly = false, subtitle, title, ...rest } = props;
|
|
15
|
+
return (jsxs(Component, { ...rest, ref: ref, "aria-disabled": disabled || undefined, "aria-readonly": readOnly || undefined, className: cx(cardClasses.quickAction, {
|
|
16
|
+
[cardClasses.quickActionDisabled]: disabled,
|
|
17
|
+
[cardClasses.quickActionReadOnly]: readOnly,
|
|
18
|
+
[cardClasses.quickActionVertical]: mode === 'vertical',
|
|
19
|
+
}, className), children: [icon && (jsx(Icon, { icon: icon, size: 24, className: cardClasses.quickActionIcon })), title || subtitle ? (jsxs("div", { className: cardClasses.quickActionContent, children: [title && jsx("span", { className: cardClasses.quickActionTitle, children: title }), subtitle && (jsx("span", { className: cardClasses.quickActionSubtitle, children: subtitle }))] })) : null] }));
|
|
20
|
+
});
|
|
21
|
+
QuickActionCard.displayName = 'QuickActionCard';
|
|
22
|
+
|
|
23
|
+
export { QuickActionCard as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
2
|
+
export interface QuickActionCardSkeletonProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
|
|
3
|
+
/**
|
|
4
|
+
* Layout mode matching QuickActionCard
|
|
5
|
+
* @default 'horizontal'
|
|
6
|
+
*/
|
|
7
|
+
mode?: 'horizontal' | 'vertical';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Skeleton placeholder for QuickActionCard component.
|
|
11
|
+
* Renders a skeleton that mimics the QuickActionCard layout.
|
|
12
|
+
*/
|
|
13
|
+
declare const QuickActionCardSkeleton: import("react").ForwardRefExoticComponent<QuickActionCardSkeletonProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default QuickActionCardSkeleton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import Skeleton from '../Skeleton/Skeleton.js';
|
|
6
|
+
import cx from 'clsx';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Skeleton placeholder for QuickActionCard component.
|
|
10
|
+
* Renders a skeleton that mimics the QuickActionCard layout.
|
|
11
|
+
*/
|
|
12
|
+
const QuickActionCardSkeleton = forwardRef(function QuickActionCardSkeleton(props, ref) {
|
|
13
|
+
const { className, mode = 'horizontal', ...rest } = props;
|
|
14
|
+
return (jsxs("div", { ...rest, ref: ref, className: cx(cardClasses.quickAction, cardClasses.quickActionReadOnly, mode === 'vertical' && cardClasses.quickActionVertical, className), children: [jsx(Skeleton, { circle: true, height: 24, width: 24 }), jsxs("div", { className: cardClasses.quickActionContent, children: [jsx(Skeleton, { height: 20, width: "70%" }), jsx(Skeleton, { height: 16, width: "50%" })] })] }));
|
|
15
|
+
});
|
|
16
|
+
QuickActionCardSkeleton.displayName = 'QuickActionCardSkeleton';
|
|
17
|
+
|
|
18
|
+
export { QuickActionCardSkeleton as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentOverridableForwardRefComponentPropsFactory } from '../utils/jsx-types';
|
|
2
|
+
import { SingleThumbnailCardComponent, SingleThumbnailCardProps } from './typings';
|
|
3
|
+
export type SingleThumbnailCardComponentProps<C extends SingleThumbnailCardComponent = 'div'> = ComponentOverridableForwardRefComponentPropsFactory<SingleThumbnailCardComponent, C, SingleThumbnailCardProps>;
|
|
4
|
+
/**
|
|
5
|
+
* SingleThumbnailCard displays a single image thumbnail with optional tag, personal action,
|
|
6
|
+
* and info section. Supports three action types: default, action, and overflow.
|
|
7
|
+
*
|
|
8
|
+
* The card width is determined by the image child element.
|
|
9
|
+
*/
|
|
10
|
+
declare const SingleThumbnailCard: import("react").ForwardRefExoticComponent<Omit<Omit<import("../utils/jsx-types").ComponentPropsWithoutKeyAndRef<"div">, "children" | "title" | "className" | "type" | "options" | "actionName" | "onActionClick" | "onOptionSelect" | "filetype" | "subtitle" | "personalActionIcon" | "personalActionActiveIcon" | "personalActionActive" | "personalActionOnClick" | "tag"> & SingleThumbnailCardProps, "component"> & {
|
|
11
|
+
component?: SingleThumbnailCardComponent | undefined;
|
|
12
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export default SingleThumbnailCard;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, Children } from 'react';
|
|
4
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import ThumbnailCardInfo from './ThumbnailCardInfo.js';
|
|
6
|
+
import Icon from '../Icon/Icon.js';
|
|
7
|
+
import cx from 'clsx';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* SingleThumbnailCard displays a single image thumbnail with optional tag, personal action,
|
|
11
|
+
* and info section. Supports three action types: default, action, and overflow.
|
|
12
|
+
*
|
|
13
|
+
* The card width is determined by the image child element.
|
|
14
|
+
*/
|
|
15
|
+
const SingleThumbnailCard = forwardRef(function SingleThumbnailCard(props, ref) {
|
|
16
|
+
const { children, className, component: Component = 'div', filetype, personalActionActive = false, personalActionActiveIcon, personalActionIcon, personalActionOnClick, subtitle, tag, title, type = 'default', ...rest } = props;
|
|
17
|
+
// Ensure only one child is provided
|
|
18
|
+
const child = Children.only(children);
|
|
19
|
+
const hasPersonalAction = Boolean(personalActionIcon);
|
|
20
|
+
const currentPersonalActionIcon = personalActionActive
|
|
21
|
+
? (personalActionActiveIcon !== null && personalActionActiveIcon !== void 0 ? personalActionActiveIcon : personalActionIcon)
|
|
22
|
+
: personalActionIcon;
|
|
23
|
+
const handlePersonalActionClick = (event) => {
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
personalActionOnClick === null || personalActionOnClick === void 0 ? void 0 : personalActionOnClick(event, personalActionActive);
|
|
26
|
+
};
|
|
27
|
+
const getInfoProps = () => {
|
|
28
|
+
if (type === 'action') {
|
|
29
|
+
const { actionName, onActionClick } = props;
|
|
30
|
+
return { actionName, onActionClick };
|
|
31
|
+
}
|
|
32
|
+
if (type === 'overflow') {
|
|
33
|
+
const { onOptionSelect, options } = props;
|
|
34
|
+
return { onOptionSelect, options };
|
|
35
|
+
}
|
|
36
|
+
return {};
|
|
37
|
+
};
|
|
38
|
+
// Filter out type-specific props before spreading
|
|
39
|
+
const { actionName: _actionName, onActionClick: _onActionClick, onOptionSelect: _onOptionSelect, options: _options, type: _type, ...componentProps } = rest;
|
|
40
|
+
return (jsxs(Component, { ...componentProps, ref: ref, className: cx(cardClasses.thumbnail, className), children: [jsxs("div", { className: cardClasses.singleThumbnail, children: [tag && jsx("div", { className: cardClasses.thumbnailTag, children: tag }), hasPersonalAction && currentPersonalActionIcon && (jsx("button", { "aria-label": "Personal Action", className: cardClasses.thumbnailPersonalAction, onClick: handlePersonalActionClick, type: "button", children: jsx(Icon, { icon: currentPersonalActionIcon, size: 24 }) })), child, jsx("div", { className: cardClasses.singleThumbnailOverlay })] }), jsx(ThumbnailCardInfo, { filetype: filetype, subtitle: subtitle, title: title, type: type, ...getInfoProps() })] }));
|
|
41
|
+
});
|
|
42
|
+
SingleThumbnailCard.displayName = 'SingleThumbnailCard';
|
|
43
|
+
|
|
44
|
+
export { SingleThumbnailCard as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
2
|
+
export interface SingleThumbnailCardSkeletonProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
|
|
3
|
+
/**
|
|
4
|
+
* Width of the thumbnail skeleton.
|
|
5
|
+
* @default 'var(--mzn-spacing-size-container-slim)'
|
|
6
|
+
*/
|
|
7
|
+
thumbnailWidth?: number | string;
|
|
8
|
+
/**
|
|
9
|
+
* Aspect ratio of the thumbnail skeleton.
|
|
10
|
+
* @default '16/9'
|
|
11
|
+
*/
|
|
12
|
+
thumbnailAspectRatio?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Skeleton placeholder for SingleThumbnailCard component.
|
|
16
|
+
* Renders a skeleton that mimics the SingleThumbnailCard layout.
|
|
17
|
+
*/
|
|
18
|
+
declare const SingleThumbnailCardSkeleton: import("react").ForwardRefExoticComponent<SingleThumbnailCardSkeletonProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
19
|
+
export default SingleThumbnailCardSkeleton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import Skeleton from '../Skeleton/Skeleton.js';
|
|
6
|
+
import cx from 'clsx';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Skeleton placeholder for SingleThumbnailCard component.
|
|
10
|
+
* Renders a skeleton that mimics the SingleThumbnailCard layout.
|
|
11
|
+
*/
|
|
12
|
+
const SingleThumbnailCardSkeleton = forwardRef(function SingleThumbnailCardSkeleton(props, ref) {
|
|
13
|
+
const { className, thumbnailAspectRatio = '16/9', thumbnailWidth = 'var(--mzn-spacing-size-container-slim)', ...rest } = props;
|
|
14
|
+
return (jsxs("div", { ...rest, ref: ref, className: cx(cardClasses.thumbnail, className), children: [jsx("div", { className: cardClasses.singleThumbnail, children: jsx(Skeleton, { height: "100%", style: { aspectRatio: thumbnailAspectRatio }, width: thumbnailWidth }) }), jsx("div", { className: cardClasses.thumbnailInfo, children: jsx("div", { className: cardClasses.thumbnailInfoMain, children: jsxs("div", { className: cardClasses.thumbnailInfoContent, style: { width: '100%' }, children: [jsx(Skeleton, { height: 20, width: "100%" }), jsx(Skeleton, { height: 16, width: "100%" })] }) }) })] }));
|
|
15
|
+
});
|
|
16
|
+
SingleThumbnailCardSkeleton.displayName = 'SingleThumbnailCardSkeleton';
|
|
17
|
+
|
|
18
|
+
export { SingleThumbnailCardSkeleton as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentOverridableForwardRefComponentPropsFactory } from '../utils/jsx-types';
|
|
2
|
+
import { ThumbnailComponent, ThumbnailPropsBase } from './typings';
|
|
3
|
+
export type ThumbnailComponentProps<C extends ThumbnailComponent = 'div'> = ComponentOverridableForwardRefComponentPropsFactory<ThumbnailComponent, C, ThumbnailPropsBase>;
|
|
4
|
+
/**
|
|
5
|
+
* Thumbnail is a child component for FourThumbnailCard.
|
|
6
|
+
* It wraps an image with an overlay that shows the title on hover.
|
|
7
|
+
* Supports polymorphic rendering as 'div', 'a', 'button', or custom components (e.g., Next.js Link).
|
|
8
|
+
*/
|
|
9
|
+
declare const Thumbnail: import("react").ForwardRefExoticComponent<Omit<Omit<import("../utils/jsx-types").ComponentPropsWithoutKeyAndRef<"div">, keyof ThumbnailPropsBase> & ThumbnailPropsBase, "component"> & {
|
|
10
|
+
component?: ThumbnailComponent | undefined;
|
|
11
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
12
|
+
export default Thumbnail;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import cx from 'clsx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Thumbnail is a child component for FourThumbnailCard.
|
|
9
|
+
* It wraps an image with an overlay that shows the title on hover.
|
|
10
|
+
* Supports polymorphic rendering as 'div', 'a', 'button', or custom components (e.g., Next.js Link).
|
|
11
|
+
*/
|
|
12
|
+
const Thumbnail = forwardRef(function Thumbnail(props, ref) {
|
|
13
|
+
const { children, className, component: Component = 'div', title, ...rest } = props;
|
|
14
|
+
return (jsxs(Component, { ...rest, ref: ref, className: cx(cardClasses.fourThumbnailThumbnail, className), children: [children, jsx("div", { className: cardClasses.fourThumbnailOverlay, children: title && jsx("span", { children: title }) })] }));
|
|
15
|
+
});
|
|
16
|
+
Thumbnail.displayName = 'Thumbnail';
|
|
17
|
+
|
|
18
|
+
export { Thumbnail as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
import { SingleThumbnailCardOverflowProps, SingleThumbnailCardProps } from './typings';
|
|
3
|
+
export interface ThumbnailCardInfoProps extends Pick<SingleThumbnailCardProps, 'filetype' | 'subtitle' | 'title' | 'type'> {
|
|
4
|
+
/**
|
|
5
|
+
* Label text for the action button (when type="action")
|
|
6
|
+
*/
|
|
7
|
+
actionName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Custom class name
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the action is disabled
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Click handler for the action button (when type="action")
|
|
18
|
+
*/
|
|
19
|
+
onActionClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Callback when an option is selected (when type="overflow")
|
|
22
|
+
*/
|
|
23
|
+
onOptionSelect?: SingleThumbnailCardOverflowProps['onOptionSelect'];
|
|
24
|
+
/**
|
|
25
|
+
* Dropdown options (when type="overflow")
|
|
26
|
+
*/
|
|
27
|
+
options?: SingleThumbnailCardOverflowProps['options'];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* ThumbnailCardInfo is a shared component for rendering card info section
|
|
31
|
+
* Used by SingleThumbnailCard and FourThumbnailCard
|
|
32
|
+
*/
|
|
33
|
+
declare const ThumbnailCardInfo: import("react").ForwardRefExoticComponent<ThumbnailCardInfoProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
+
export default ThumbnailCardInfo;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { getFileTypeCategory, cardClasses } from '@mezzanine-ui/core/card';
|
|
5
|
+
import { DotHorizontalIcon } from '@mezzanine-ui/icons';
|
|
6
|
+
import Button from '../Button/Button.js';
|
|
7
|
+
import Dropdown from '../Dropdown/Dropdown.js';
|
|
8
|
+
import cx from 'clsx';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ThumbnailCardInfo is a shared component for rendering card info section
|
|
12
|
+
* Used by SingleThumbnailCard and FourThumbnailCard
|
|
13
|
+
*/
|
|
14
|
+
const ThumbnailCardInfo = forwardRef(function ThumbnailCardInfo(props, ref) {
|
|
15
|
+
const { className, disabled = false, filetype, subtitle, title, type = 'default', } = props;
|
|
16
|
+
const filetypeCategory = filetype
|
|
17
|
+
? getFileTypeCategory(filetype)
|
|
18
|
+
: undefined;
|
|
19
|
+
const filetypeClassName = filetypeCategory
|
|
20
|
+
? `${cardClasses.thumbnailInfoFiletype}--${filetypeCategory}`
|
|
21
|
+
: undefined;
|
|
22
|
+
const renderAction = () => {
|
|
23
|
+
if (type === 'default') {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (type === 'action') {
|
|
27
|
+
const { actionName: name, onActionClick: onClick } = props;
|
|
28
|
+
return (jsx("div", { className: cardClasses.thumbnailInfoAction, children: jsx(Button, { disabled: disabled, onClick: (event) => {
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
31
|
+
}, size: "sub", type: "button", variant: "base-text-link", children: name }) }));
|
|
32
|
+
}
|
|
33
|
+
if (type === 'overflow') {
|
|
34
|
+
const { onOptionSelect: onSelect, options: opts } = props;
|
|
35
|
+
return (jsx("div", { className: cardClasses.thumbnailInfoAction, children: jsx(Dropdown, { disabled: disabled, globalPortal: false, mode: "single", onSelect: onSelect, options: opts, children: jsx(Button, { disabled: disabled, icon: DotHorizontalIcon, iconType: "icon-only", size: "sub", type: "button", variant: "base-text-link" }) }) }));
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
return (jsxs("div", { ref: ref, className: cx(cardClasses.thumbnailInfo, className), children: [jsxs("div", { className: cardClasses.thumbnailInfoMain, children: [filetype && (jsx("div", { className: cx(cardClasses.thumbnailInfoFiletype, filetypeClassName), children: filetype.toUpperCase() })), jsxs("div", { className: cardClasses.thumbnailInfoContent, children: [title && (jsx("span", { className: cardClasses.thumbnailInfoTitle, children: title })), subtitle && (jsx("span", { className: cardClasses.thumbnailInfoSubtitle, children: subtitle }))] })] }), renderAction()] }));
|
|
40
|
+
});
|
|
41
|
+
ThumbnailCardInfo.displayName = 'ThumbnailCardInfo';
|
|
42
|
+
|
|
43
|
+
export { ThumbnailCardInfo as default };
|
package/Card/index.d.ts
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
import BaseCard, { BaseCardComponentProps } from './BaseCard';
|
|
3
|
+
import FourThumbnailCard, { FourThumbnailCardComponentProps } from './FourThumbnailCard';
|
|
4
|
+
import QuickActionCard, { QuickActionCardComponentProps } from './QuickActionCard';
|
|
5
|
+
import SingleThumbnailCard, { SingleThumbnailCardComponentProps } from './SingleThumbnailCard';
|
|
6
|
+
import Thumbnail, { ThumbnailComponentProps } from './Thumbnail';
|
|
7
|
+
import { BaseCardComponent, FourThumbnailCardComponent, QuickActionCardComponent, SingleThumbnailCardComponent, ThumbnailComponent } from './typings';
|
|
8
|
+
export { default as CardGroup } from './CardGroup';
|
|
9
|
+
export type { CardGroupLoadingType, CardGroupProps } from './CardGroup';
|
|
10
|
+
export { default as ThumbnailCardInfo } from './ThumbnailCardInfo';
|
|
11
|
+
export type { ThumbnailCardInfoProps } from './ThumbnailCardInfo';
|
|
12
|
+
export { default as BaseCardSkeleton } from './BaseCardSkeleton';
|
|
13
|
+
export type { BaseCardSkeletonProps } from './BaseCardSkeleton';
|
|
14
|
+
export { default as FourThumbnailCardSkeleton } from './FourThumbnailCardSkeleton';
|
|
15
|
+
export type { FourThumbnailCardSkeletonProps } from './FourThumbnailCardSkeleton';
|
|
16
|
+
export { default as QuickActionCardSkeleton } from './QuickActionCardSkeleton';
|
|
17
|
+
export type { QuickActionCardSkeletonProps } from './QuickActionCardSkeleton';
|
|
18
|
+
export { default as SingleThumbnailCardSkeleton } from './SingleThumbnailCardSkeleton';
|
|
19
|
+
export type { SingleThumbnailCardSkeletonProps } from './SingleThumbnailCardSkeleton';
|
|
20
|
+
export type { BaseCardComponentProps, FourThumbnailCardComponentProps, QuickActionCardComponentProps, SingleThumbnailCardComponentProps, ThumbnailComponentProps, };
|
|
21
|
+
export type { BaseCardComponent, BaseCardActionVariant, BaseCardType, BaseCardProps, BaseCardPropsCommon, BaseCardDefaultProps, BaseCardActionProps, BaseCardOverflowProps, BaseCardToggleProps, FourThumbnailCardComponent, FourThumbnailCardType, FourThumbnailCardProps, FourThumbnailCardPropsCommon, FourThumbnailCardDefaultProps, FourThumbnailCardActionProps, FourThumbnailCardOverflowProps, QuickActionCardComponent, QuickActionCardMode, QuickActionCardProps, QuickActionCardPropsCommon, QuickActionCardWithIconProps, QuickActionCardWithTitleProps, SingleThumbnailCardComponent, SingleThumbnailCardType, SingleThumbnailCardProps, SingleThumbnailCardPropsCommon, SingleThumbnailCardDefaultProps, SingleThumbnailCardActionProps, SingleThumbnailCardOverflowProps, ThumbnailComponent, ThumbnailPropsBase, } from './typings';
|
|
22
|
+
/**
|
|
23
|
+
* Type alias for proper generic inference when using component prop
|
|
24
|
+
*/
|
|
25
|
+
type GenericBaseCard = <C extends BaseCardComponent = 'div'>(props: PropsWithoutRef<BaseCardComponentProps<C>> & RefAttributes<HTMLElement>) => ReactElement<any>;
|
|
26
|
+
type GenericFourThumbnailCard = <C extends FourThumbnailCardComponent = 'div'>(props: PropsWithoutRef<FourThumbnailCardComponentProps<C>> & RefAttributes<HTMLElement> & {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
title: string;
|
|
29
|
+
}) => ReactElement<any>;
|
|
30
|
+
type GenericQuickActionCard = <C extends QuickActionCardComponent = 'button'>(props: PropsWithoutRef<QuickActionCardComponentProps<C>> & RefAttributes<HTMLElement>) => ReactElement<any>;
|
|
31
|
+
type GenericSingleThumbnailCard = <C extends SingleThumbnailCardComponent = 'div'>(props: PropsWithoutRef<SingleThumbnailCardComponentProps<C>> & RefAttributes<HTMLElement> & {
|
|
32
|
+
children: ReactElement;
|
|
33
|
+
title: string;
|
|
34
|
+
}) => ReactElement<any>;
|
|
35
|
+
type GenericThumbnail = <C extends ThumbnailComponent = 'div'>(props: PropsWithoutRef<ThumbnailComponentProps<C>> & RefAttributes<HTMLElement> & {
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
}) => ReactElement<any>;
|
|
38
|
+
export { BaseCard, FourThumbnailCard, QuickActionCard, SingleThumbnailCard, Thumbnail, };
|
|
39
|
+
export declare const BaseCardGeneric: GenericBaseCard;
|
|
40
|
+
export declare const FourThumbnailCardGeneric: GenericFourThumbnailCard;
|
|
41
|
+
export declare const QuickActionCardGeneric: GenericQuickActionCard;
|
|
42
|
+
export declare const SingleThumbnailCardGeneric: GenericSingleThumbnailCard;
|
|
43
|
+
export declare const ThumbnailGeneric: GenericThumbnail;
|
package/Card/index.js
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import BaseCard from './BaseCard.js';
|
|
2
|
+
import FourThumbnailCard from './FourThumbnailCard.js';
|
|
3
|
+
import QuickActionCard from './QuickActionCard.js';
|
|
4
|
+
import SingleThumbnailCard from './SingleThumbnailCard.js';
|
|
5
|
+
import Thumbnail from './Thumbnail.js';
|
|
6
|
+
export { default as CardGroup } from './CardGroup.js';
|
|
7
|
+
export { default as ThumbnailCardInfo } from './ThumbnailCardInfo.js';
|
|
8
|
+
export { default as BaseCardSkeleton } from './BaseCardSkeleton.js';
|
|
9
|
+
export { default as FourThumbnailCardSkeleton } from './FourThumbnailCardSkeleton.js';
|
|
10
|
+
export { default as QuickActionCardSkeleton } from './QuickActionCardSkeleton.js';
|
|
11
|
+
export { default as SingleThumbnailCardSkeleton } from './SingleThumbnailCardSkeleton.js';
|
|
12
|
+
|
|
13
|
+
const BaseCardGeneric = BaseCard;
|
|
14
|
+
const FourThumbnailCardGeneric = FourThumbnailCard;
|
|
15
|
+
const QuickActionCardGeneric = QuickActionCard;
|
|
16
|
+
const SingleThumbnailCardGeneric = SingleThumbnailCard;
|
|
17
|
+
const ThumbnailGeneric = Thumbnail;
|
|
18
|
+
|
|
19
|
+
export { BaseCard, BaseCardGeneric, FourThumbnailCard, FourThumbnailCardGeneric, QuickActionCard, QuickActionCardGeneric, SingleThumbnailCard, SingleThumbnailCardGeneric, Thumbnail, ThumbnailGeneric };
|