musae 1.2.0 → 1.3.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/components/card/actions.cjs +31 -0
- package/dist/components/card/actions.d.ts +31 -0
- package/dist/components/card/actions.mjs +27 -0
- package/dist/components/card/body.cjs +30 -0
- package/dist/components/card/body.d.ts +18 -0
- package/dist/components/card/body.mjs +26 -0
- package/dist/components/card/card.cjs +76 -140
- package/dist/components/card/card.d.ts +23 -150
- package/dist/components/card/card.mjs +67 -135
- package/dist/components/card/content.cjs +33 -0
- package/dist/components/card/content.d.ts +33 -0
- package/dist/components/card/content.mjs +29 -0
- package/dist/components/card/context.cjs +14 -1
- package/dist/components/card/context.d.ts +15 -1
- package/dist/components/card/context.mjs +13 -2
- package/dist/components/card/header.cjs +79 -0
- package/dist/components/card/header.d.ts +58 -0
- package/dist/components/card/header.mjs +75 -0
- package/dist/components/card/headline.cjs +30 -0
- package/dist/components/card/headline.d.ts +18 -0
- package/dist/components/card/headline.mjs +26 -0
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/card/media.cjs +50 -0
- package/dist/components/card/media.d.ts +42 -0
- package/dist/components/card/media.mjs +46 -0
- package/dist/components/card/styles.cjs +133 -14
- package/dist/components/card/styles.d.ts +88 -28
- package/dist/components/card/styles.mjs +133 -14
- package/dist/components/card/subhead.cjs +30 -0
- package/dist/components/card/subhead.d.ts +18 -0
- package/dist/components/card/subhead.mjs +26 -0
- package/dist/components/card/title.cjs +30 -0
- package/dist/components/card/title.d.ts +18 -0
- package/dist/components/card/title.mjs +26 -0
- package/dist/components/theme/tokens.stylex.cjs +4 -1
- package/dist/components/theme/tokens.stylex.d.ts +9 -1
- package/dist/components/theme/tokens.stylex.mjs +4 -1
- package/dist/styles.css +68 -23
- package/dist/types/card.d.ts +39 -2
- package/package.json +1 -3
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
4
|
+
import React, { forwardRef, useState, useCallback } from 'react';
|
|
4
5
|
import { stringify } from '@aiszlab/relax/class-name';
|
|
5
6
|
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
6
7
|
import { OPACITY } from '../theme/tokens.stylex.mjs';
|
|
7
|
-
import { useTheme } from '../theme/hooks.mjs';
|
|
8
8
|
import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
9
9
|
import { useThemeColorVars } from '../../hooks/use-theme-color-vars.mjs';
|
|
10
|
-
import { CLASS_NAMES } from './context.mjs';
|
|
10
|
+
import { CLASS_NAMES, CardContext } from './context.mjs';
|
|
11
11
|
import styles from './styles.mjs';
|
|
12
|
+
import CardHeader from './header.mjs';
|
|
13
|
+
import CardMedia from './media.mjs';
|
|
14
|
+
import CardContent from './content.mjs';
|
|
15
|
+
import CardHeadline from './headline.mjs';
|
|
16
|
+
import CardTitle from './title.mjs';
|
|
17
|
+
import CardSubhead from './subhead.mjs';
|
|
18
|
+
import CardBody from './body.mjs';
|
|
19
|
+
import CardActions from './actions.mjs';
|
|
12
20
|
|
|
13
|
-
var _excluded = ["children", "className", "style", "variant", "onClick", "disabled"]
|
|
14
|
-
_excluded2 = ["className", "style", "src", "alt", "children"];
|
|
21
|
+
var _excluded = ["children", "className", "style", "variant", "layout", "onClick", "disabled", "dragged", "draggable", "onDragStart", "onDragEnd"];
|
|
15
22
|
/**
|
|
16
|
-
* @zh
|
|
17
|
-
*
|
|
23
|
+
* @zh 卡片组件,用于在一个容器中展示内容和操作。卡片支持多种样式变体(描边、浮起、填充)
|
|
24
|
+
* 和布局变体(垂直堆叠、水平排布),并在悬停、聚焦、按下、拖拽时展示交互状态层与 elevation 变化。
|
|
18
25
|
*
|
|
19
26
|
* @en Card component for displaying content and actions in a single container.
|
|
20
|
-
* Cards support multiple style variants (outlined, elevated, filled) and
|
|
21
|
-
*
|
|
27
|
+
* Cards support multiple style variants (outlined, elevated, filled) and layout
|
|
28
|
+
* variants (stacked, horizontal), with state-based elevation and state-layer
|
|
29
|
+
* transitions on hover, focus, press, and drag.
|
|
22
30
|
*/
|
|
23
31
|
var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
24
32
|
var children = _ref.children,
|
|
@@ -26,151 +34,75 @@ var Card = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
26
34
|
style = _ref.style,
|
|
27
35
|
_ref$variant = _ref.variant,
|
|
28
36
|
variant = _ref$variant === void 0 ? "outlined" : _ref$variant,
|
|
37
|
+
_ref$layout = _ref.layout,
|
|
38
|
+
layout = _ref$layout === void 0 ? "stacked" : _ref$layout,
|
|
29
39
|
onClick = _ref.onClick,
|
|
30
40
|
disabled = _ref.disabled,
|
|
41
|
+
draggedProp = _ref.dragged,
|
|
42
|
+
_ref$draggable = _ref.draggable,
|
|
43
|
+
draggable = _ref$draggable === void 0 ? false : _ref$draggable,
|
|
44
|
+
onDragStartProp = _ref.onDragStart,
|
|
45
|
+
onDragEndProp = _ref.onDragEnd,
|
|
31
46
|
props$1 = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
-
useTheme();
|
|
33
47
|
var classNames = useClassNames(CLASS_NAMES);
|
|
34
|
-
var themeColorVars = useThemeColorVars(["surface", "surface-container-low", "surface-container-highest", "outline-variant", "on-surface", ["on-surface", OPACITY.thin], ["on-surface", OPACITY.medium], ["on-surface", OPACITY.thick]]);
|
|
48
|
+
var themeColorVars = useThemeColorVars(["surface", "surface-container-low", "surface-container-highest", "primary-container", "on-primary-container", "outline-variant", "on-surface", ["on-surface", OPACITY.thin], ["on-surface", OPACITY.medium], ["on-surface", OPACITY.thick]]);
|
|
49
|
+
// Auto-detect drag state via HTML5 events when `draggable` is true.
|
|
50
|
+
var _useState = useState(false),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
autoDragged = _useState2[0],
|
|
53
|
+
setAutoDragged = _useState2[1];
|
|
54
|
+
var isDragged = draggedProp !== null && draggedProp !== void 0 ? draggedProp : autoDragged;
|
|
55
|
+
var handleDragStart = useCallback(function (event) {
|
|
56
|
+
if (draggable) setAutoDragged(true);
|
|
57
|
+
onDragStartProp === null || onDragStartProp === void 0 || onDragStartProp(event);
|
|
58
|
+
}, [draggable, onDragStartProp]);
|
|
59
|
+
var handleDragEnd = useCallback(function (event) {
|
|
60
|
+
if (draggable) setAutoDragged(false);
|
|
61
|
+
onDragEndProp === null || onDragEndProp === void 0 || onDragEndProp(event);
|
|
62
|
+
}, [draggable, onDragEndProp]);
|
|
35
63
|
var interactive = !!onClick && !disabled;
|
|
36
|
-
var
|
|
37
|
-
|
|
64
|
+
var handleClick = useCallback(function (event) {
|
|
65
|
+
if (disabled) return;
|
|
66
|
+
onClick === null || onClick === void 0 || onClick(event);
|
|
67
|
+
}, [disabled, onClick]);
|
|
68
|
+
var styled = props(styles.card["default"], styles.card[layout], styles.card[variant], interactive && styles.card.interactive, disabled && styles.card.disabled,
|
|
69
|
+
// state-based elevation (only meaningful when interactive or dragged)
|
|
70
|
+
interactive && variant === "outlined" && styles.elevationState.outlinedHover, isDragged && variant === "outlined" && styles.elevationState.outlinedDragged, interactive && variant === "elevated" && styles.elevationState.elevatedHover, isDragged && variant === "elevated" && styles.elevationState.elevatedDragged, isDragged && variant === "filled" && styles.elevationState.filledDragged,
|
|
71
|
+
// state layer
|
|
72
|
+
interactive && !isDragged && styles.stateLayer.hover, interactive && !isDragged && styles.stateLayer.focus, interactive && !isDragged && styles.stateLayer.press);
|
|
73
|
+
return /*#__PURE__*/React.createElement(CardContext.Provider, {
|
|
74
|
+
value: {
|
|
75
|
+
layout: layout,
|
|
76
|
+
disabled: disabled
|
|
77
|
+
}
|
|
78
|
+
}, /*#__PURE__*/React.createElement("div", _objectSpread({
|
|
38
79
|
ref: ref,
|
|
39
80
|
className: stringify(classNames.card, className, styled.className),
|
|
40
81
|
style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, styled.style), style), themeColorVars), {}, {
|
|
41
82
|
"--color-state-layer-hover": "color-mix(in srgb, var(--color-on-surface) 8%, transparent)",
|
|
42
83
|
"--color-state-layer-focus": "color-mix(in srgb, var(--color-on-surface) 12%, transparent)",
|
|
43
84
|
"--color-state-layer-press": "color-mix(in srgb, var(--color-on-surface) 12%, transparent)"
|
|
85
|
+
}, isDragged && {
|
|
86
|
+
"--card-state-layer": "color-mix(in srgb, var(--color-on-surface) 16%, transparent)"
|
|
44
87
|
}),
|
|
45
|
-
onClick:
|
|
88
|
+
onClick: handleClick,
|
|
89
|
+
onDragStart: handleDragStart,
|
|
90
|
+
onDragEnd: handleDragEnd,
|
|
46
91
|
tabIndex: interactive ? 0 : undefined,
|
|
47
92
|
role: interactive ? "button" : undefined,
|
|
48
|
-
"aria-disabled": disabled
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
* @zh 卡片头部,包含字母头像、标题、副标题和可选的操作区
|
|
53
|
-
* @en Card header with monogram, title, subhead, and optional action area
|
|
54
|
-
*/
|
|
55
|
-
var CardHeader = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
56
|
-
var className = _ref2.className,
|
|
57
|
-
style = _ref2.style,
|
|
58
|
-
children = _ref2.children,
|
|
59
|
-
action = _ref2.action,
|
|
60
|
-
monogram = _ref2.monogram,
|
|
61
|
-
monogramText = _ref2.monogramText,
|
|
62
|
-
title = _ref2.title,
|
|
63
|
-
subhead = _ref2.subhead;
|
|
64
|
-
var classNames = useClassNames(CLASS_NAMES);
|
|
65
|
-
var headerStyled = props(styles.header["default"]);
|
|
66
|
-
var contentStyled = props(styles.headerContent["default"]);
|
|
67
|
-
var textStyled = props(styles.headerText["default"]);
|
|
68
|
-
var titleStyled = props(styles.headerTitle["default"]);
|
|
69
|
-
var subheadStyled = props(styles.headerSubhead["default"]);
|
|
70
|
-
if (children) {
|
|
71
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
-
ref: ref,
|
|
73
|
-
className: stringify(classNames.header, className, headerStyled.className),
|
|
74
|
-
style: _objectSpread(_objectSpread({}, headerStyled.style), style)
|
|
75
|
-
}, children);
|
|
76
|
-
}
|
|
77
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
78
|
-
ref: ref,
|
|
79
|
-
className: stringify(classNames.header, className, headerStyled.className),
|
|
80
|
-
style: _objectSpread(_objectSpread({}, headerStyled.style), style)
|
|
81
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
82
|
-
className: stringify(classNames.headerContent, contentStyled.className),
|
|
83
|
-
style: contentStyled.style
|
|
84
|
-
}, (monogram || monogramText) && (/*#__PURE__*/React.createElement("div", {
|
|
85
|
-
className: classNames.headerMonogram
|
|
86
|
-
}, monogram ? (/*#__PURE__*/React.createElement("img", {
|
|
87
|
-
alt: "",
|
|
88
|
-
src: monogram,
|
|
89
|
-
style: {
|
|
90
|
-
width: "100%",
|
|
91
|
-
height: "100%",
|
|
92
|
-
display: "block"
|
|
93
|
-
}
|
|
94
|
-
})) : monogramText)), /*#__PURE__*/React.createElement("div", {
|
|
95
|
-
className: stringify(classNames.headerText, textStyled.className),
|
|
96
|
-
style: textStyled.style
|
|
97
|
-
}, title && (/*#__PURE__*/React.createElement("div", {
|
|
98
|
-
className: stringify(classNames.headerTitle, titleStyled.className),
|
|
99
|
-
style: titleStyled.style
|
|
100
|
-
}, title)), subhead && (/*#__PURE__*/React.createElement("div", {
|
|
101
|
-
className: stringify(classNames.headerSubhead, subheadStyled.className),
|
|
102
|
-
style: subheadStyled.style
|
|
103
|
-
}, subhead)))), action && /*#__PURE__*/React.createElement("div", {
|
|
104
|
-
className: classNames.headerAction
|
|
105
|
-
}, action));
|
|
106
|
-
});
|
|
107
|
-
/**
|
|
108
|
-
* @zh 卡片媒体区,用于展示图片或自定义内容
|
|
109
|
-
* @en Card media area for displaying images or custom content
|
|
110
|
-
*/
|
|
111
|
-
var CardMedia = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
112
|
-
var className = _ref3.className,
|
|
113
|
-
style = _ref3.style,
|
|
114
|
-
src = _ref3.src,
|
|
115
|
-
alt = _ref3.alt,
|
|
116
|
-
children = _ref3.children,
|
|
117
|
-
imgProps = _objectWithoutProperties(_ref3, _excluded2);
|
|
118
|
-
var classNames = useClassNames(CLASS_NAMES);
|
|
119
|
-
var mediaStyled = props(styles.media["default"]);
|
|
120
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
121
|
-
ref: ref,
|
|
122
|
-
className: stringify(classNames.media, className, mediaStyled.className),
|
|
123
|
-
style: _objectSpread(_objectSpread({}, mediaStyled.style), style)
|
|
124
|
-
}, children || src && (/*#__PURE__*/React.createElement("img", _objectSpread(_objectSpread({
|
|
125
|
-
alt: alt,
|
|
126
|
-
src: src
|
|
127
|
-
}, imgProps), {}, {
|
|
128
|
-
style: {
|
|
129
|
-
position: "absolute",
|
|
130
|
-
inset: 0,
|
|
131
|
-
width: "100%",
|
|
132
|
-
height: "100%",
|
|
133
|
-
objectFit: "cover"
|
|
134
|
-
}
|
|
135
|
-
}))));
|
|
136
|
-
});
|
|
137
|
-
/**
|
|
138
|
-
* @zh 卡片内容区,用于展示文本内容
|
|
139
|
-
* @en Card content area for displaying text content
|
|
140
|
-
*/
|
|
141
|
-
var CardContent = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
142
|
-
var className = _ref4.className,
|
|
143
|
-
style = _ref4.style,
|
|
144
|
-
children = _ref4.children;
|
|
145
|
-
var classNames = useClassNames(CLASS_NAMES);
|
|
146
|
-
var contentStyled = props(styles.content["default"]);
|
|
147
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
148
|
-
ref: ref,
|
|
149
|
-
className: stringify(classNames.content, className, contentStyled.className),
|
|
150
|
-
style: _objectSpread(_objectSpread({}, contentStyled.style), style)
|
|
151
|
-
}, children);
|
|
152
|
-
});
|
|
153
|
-
/**
|
|
154
|
-
* @zh 卡片操作区,通常包含按钮等交互元素
|
|
155
|
-
* @en Card actions area, typically containing buttons and other interactive elements
|
|
156
|
-
*/
|
|
157
|
-
var CardActions = /*#__PURE__*/forwardRef(function (_ref5, ref) {
|
|
158
|
-
var className = _ref5.className,
|
|
159
|
-
style = _ref5.style,
|
|
160
|
-
children = _ref5.children;
|
|
161
|
-
var classNames = useClassNames(CLASS_NAMES);
|
|
162
|
-
var actionsStyled = props(styles.actions["default"]);
|
|
163
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
164
|
-
ref: ref,
|
|
165
|
-
className: stringify(classNames.actions, className, actionsStyled.className),
|
|
166
|
-
style: _objectSpread(_objectSpread({}, actionsStyled.style), style)
|
|
167
|
-
}, children);
|
|
93
|
+
"aria-disabled": disabled,
|
|
94
|
+
draggable: draggable || undefined
|
|
95
|
+
}, props$1), children));
|
|
168
96
|
});
|
|
169
97
|
var _Card = Object.assign(Card, {
|
|
170
98
|
Header: CardHeader,
|
|
171
99
|
Media: CardMedia,
|
|
172
100
|
Content: CardContent,
|
|
101
|
+
Headline: CardHeadline,
|
|
102
|
+
Title: CardTitle,
|
|
103
|
+
Subhead: CardSubhead,
|
|
104
|
+
Body: CardBody,
|
|
173
105
|
Actions: CardActions
|
|
174
106
|
});
|
|
175
107
|
|
|
176
|
-
export { Card, CardActions, CardContent, CardHeader, CardMedia, _Card as default };
|
|
108
|
+
export { Card, CardActions, CardBody, CardContent, CardHeader, CardHeadline, CardMedia, CardSubhead, CardTitle, _Card as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var className = require('@aiszlab/relax/class-name');
|
|
8
|
+
var stylex = require('../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.cjs');
|
|
9
|
+
var useClassNames = require('../../hooks/use-class-names.cjs');
|
|
10
|
+
var context = require('./context.cjs');
|
|
11
|
+
var styles = require('./styles.cjs');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @zh 卡片内容区,用于展示结构化文本(padding 16, gap 32)。
|
|
15
|
+
* 推荐组合:Headline(Title + Subhead) + Body + Actions。
|
|
16
|
+
*
|
|
17
|
+
* @en Card content area for displaying structured text (padding 16, gap 32).
|
|
18
|
+
* Recommended composition: Headline (Title + Subhead) + Body + Actions.
|
|
19
|
+
*/
|
|
20
|
+
var CardContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
21
|
+
var className$1 = _ref.className,
|
|
22
|
+
style = _ref.style,
|
|
23
|
+
children = _ref.children;
|
|
24
|
+
var classNames = useClassNames.useClassNames(context.CLASS_NAMES);
|
|
25
|
+
var contentStyled = stylex.props(styles.default.content["default"]);
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
ref: ref,
|
|
28
|
+
className: className.stringify(classNames.content, className$1, contentStyled.className),
|
|
29
|
+
style: _objectSpread(_objectSpread({}, contentStyled.style), style)
|
|
30
|
+
}, children);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
exports.default = CardContent;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReactNode, CSSProperties } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* @zh 卡片内容区属性
|
|
5
|
+
* @en Card content props
|
|
6
|
+
*/
|
|
7
|
+
interface CardContentProps {
|
|
8
|
+
/**
|
|
9
|
+
* @zh 自定义类名
|
|
10
|
+
* @en Custom class name
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* @zh 自定义样式
|
|
15
|
+
* @en Custom style
|
|
16
|
+
*/
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
/**
|
|
19
|
+
* @zh 内容
|
|
20
|
+
* @en Content
|
|
21
|
+
*/
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @zh 卡片内容区,用于展示结构化文本(padding 16, gap 32)。
|
|
26
|
+
* 推荐组合:Headline(Title + Subhead) + Body + Actions。
|
|
27
|
+
*
|
|
28
|
+
* @en Card content area for displaying structured text (padding 16, gap 32).
|
|
29
|
+
* Recommended composition: Headline (Title + Subhead) + Body + Actions.
|
|
30
|
+
*/
|
|
31
|
+
declare const CardContent: React.ForwardRefExoticComponent<CardContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export default CardContent;
|
|
33
|
+
export type { CardContentProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { stringify } from '@aiszlab/relax/class-name';
|
|
4
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
5
|
+
import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
6
|
+
import { CLASS_NAMES } from './context.mjs';
|
|
7
|
+
import styles from './styles.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @zh 卡片内容区,用于展示结构化文本(padding 16, gap 32)。
|
|
11
|
+
* 推荐组合:Headline(Title + Subhead) + Body + Actions。
|
|
12
|
+
*
|
|
13
|
+
* @en Card content area for displaying structured text (padding 16, gap 32).
|
|
14
|
+
* Recommended composition: Headline (Title + Subhead) + Body + Actions.
|
|
15
|
+
*/
|
|
16
|
+
var CardContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
17
|
+
var className = _ref.className,
|
|
18
|
+
style = _ref.style,
|
|
19
|
+
children = _ref.children;
|
|
20
|
+
var classNames = useClassNames(CLASS_NAMES);
|
|
21
|
+
var contentStyled = props(styles.content["default"]);
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
ref: ref,
|
|
24
|
+
className: stringify(classNames.content, className, contentStyled.className),
|
|
25
|
+
style: _objectSpread(_objectSpread({}, contentStyled.style), style)
|
|
26
|
+
}, children);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { CardContent as default };
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @description
|
|
5
7
|
* class names
|
|
6
8
|
*/
|
|
7
9
|
var CLASS_NAMES = {
|
|
8
10
|
card: "card",
|
|
9
|
-
stateLayer: "card__state-layer",
|
|
10
11
|
header: "card__header",
|
|
11
12
|
media: "card__media",
|
|
12
13
|
content: "card__content",
|
|
14
|
+
headline: "card__headline",
|
|
15
|
+
title: "card__title",
|
|
16
|
+
subhead: "card__subhead",
|
|
17
|
+
body: "card__body",
|
|
13
18
|
actions: "card__actions",
|
|
14
19
|
headerContent: "card__header-content",
|
|
15
20
|
headerText: "card__header-text",
|
|
@@ -18,5 +23,13 @@ var CLASS_NAMES = {
|
|
|
18
23
|
headerMonogram: "card__header-monogram",
|
|
19
24
|
headerAction: "card__header-action"
|
|
20
25
|
};
|
|
26
|
+
var CardContext = /*#__PURE__*/React.createContext({
|
|
27
|
+
layout: "stacked"
|
|
28
|
+
});
|
|
29
|
+
var useCardContext = function useCardContext() {
|
|
30
|
+
return React.useContext(CardContext);
|
|
31
|
+
};
|
|
21
32
|
|
|
22
33
|
exports.CLASS_NAMES = CLASS_NAMES;
|
|
34
|
+
exports.CardContext = CardContext;
|
|
35
|
+
exports.useCardContext = useCardContext;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import type { CardLayout } from "../../types/card";
|
|
1
2
|
/**
|
|
2
3
|
* @description
|
|
3
4
|
* class names
|
|
4
5
|
*/
|
|
5
6
|
declare const CLASS_NAMES: {
|
|
6
7
|
card: string;
|
|
7
|
-
stateLayer: string;
|
|
8
8
|
header: string;
|
|
9
9
|
media: string;
|
|
10
10
|
content: string;
|
|
11
|
+
headline: string;
|
|
12
|
+
title: string;
|
|
13
|
+
subhead: string;
|
|
14
|
+
body: string;
|
|
11
15
|
actions: string;
|
|
12
16
|
headerContent: string;
|
|
13
17
|
headerText: string;
|
|
@@ -17,3 +21,13 @@ declare const CLASS_NAMES: {
|
|
|
17
21
|
headerAction: string;
|
|
18
22
|
};
|
|
19
23
|
export { CLASS_NAMES };
|
|
24
|
+
/**
|
|
25
|
+
* @zh 卡片内部 context,用于在嵌套子组件中传递 layout 与 disabled 状态
|
|
26
|
+
* @en Card internal context, used to propagate layout and disabled state to nested subcomponents
|
|
27
|
+
*/
|
|
28
|
+
export interface CardContextValue {
|
|
29
|
+
layout: CardLayout;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare const CardContext: import("react").Context<CardContextValue>;
|
|
33
|
+
export declare const useCardContext: () => CardContextValue;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @description
|
|
3
5
|
* class names
|
|
4
6
|
*/
|
|
5
7
|
var CLASS_NAMES = {
|
|
6
8
|
card: "card",
|
|
7
|
-
stateLayer: "card__state-layer",
|
|
8
9
|
header: "card__header",
|
|
9
10
|
media: "card__media",
|
|
10
11
|
content: "card__content",
|
|
12
|
+
headline: "card__headline",
|
|
13
|
+
title: "card__title",
|
|
14
|
+
subhead: "card__subhead",
|
|
15
|
+
body: "card__body",
|
|
11
16
|
actions: "card__actions",
|
|
12
17
|
headerContent: "card__header-content",
|
|
13
18
|
headerText: "card__header-text",
|
|
@@ -16,5 +21,11 @@ var CLASS_NAMES = {
|
|
|
16
21
|
headerMonogram: "card__header-monogram",
|
|
17
22
|
headerAction: "card__header-action"
|
|
18
23
|
};
|
|
24
|
+
var CardContext = /*#__PURE__*/createContext({
|
|
25
|
+
layout: "stacked"
|
|
26
|
+
});
|
|
27
|
+
var useCardContext = function useCardContext() {
|
|
28
|
+
return useContext(CardContext);
|
|
29
|
+
};
|
|
19
30
|
|
|
20
|
-
export { CLASS_NAMES };
|
|
31
|
+
export { CLASS_NAMES, CardContext, useCardContext };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var className = require('@aiszlab/relax/class-name');
|
|
8
|
+
var stylex = require('../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.cjs');
|
|
9
|
+
var useClassNames = require('../../hooks/use-class-names.cjs');
|
|
10
|
+
var context = require('./context.cjs');
|
|
11
|
+
var styles = require('./styles.cjs');
|
|
12
|
+
var iconButton = require('../icon-button/icon-button.cjs');
|
|
13
|
+
var moreVert = require('../icon/icons/navigation/more-vert.cjs');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @zh 卡片头部,包含字母头像、标题、副标题和可选的操作区。Horizontal 布局下自动应用
|
|
17
|
+
* 全 16px padding,Stacked 布局下应用 12/4/12/16 padding。
|
|
18
|
+
*
|
|
19
|
+
* @en Card header with monogram, title, subhead, and optional action area.
|
|
20
|
+
* Applies 16px padding on all sides in horizontal layout, and 12/4/12/16 in stacked.
|
|
21
|
+
*/
|
|
22
|
+
var CardHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
23
|
+
var className$1 = _ref.className,
|
|
24
|
+
style = _ref.style,
|
|
25
|
+
children = _ref.children,
|
|
26
|
+
monogram = _ref.monogram,
|
|
27
|
+
monogramText = _ref.monogramText,
|
|
28
|
+
title = _ref.title,
|
|
29
|
+
subhead = _ref.subhead;
|
|
30
|
+
var classNames = useClassNames.useClassNames(context.CLASS_NAMES);
|
|
31
|
+
var _useCardContext = context.useCardContext(),
|
|
32
|
+
layout = _useCardContext.layout;
|
|
33
|
+
var headerStyled = stylex.props(styles.default.header["default"], styles.default.header[layout]);
|
|
34
|
+
var contentStyled = stylex.props(styles.default.headerContent["default"]);
|
|
35
|
+
var textStyled = stylex.props(styles.default.headerText["default"]);
|
|
36
|
+
var titleStyled = stylex.props(styles.default.headerTitle["default"]);
|
|
37
|
+
var subheadStyled = stylex.props(styles.default.headerSubhead["default"]);
|
|
38
|
+
stylex.props(styles.default.headerAction["default"]);
|
|
39
|
+
if (children) {
|
|
40
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
ref: ref,
|
|
42
|
+
className: className.stringify(classNames.header, className$1, headerStyled.className),
|
|
43
|
+
style: _objectSpread(_objectSpread({}, headerStyled.style), style)
|
|
44
|
+
}, children);
|
|
45
|
+
}
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
ref: ref,
|
|
48
|
+
className: className.stringify(classNames.header, className$1, headerStyled.className),
|
|
49
|
+
style: _objectSpread(_objectSpread({}, headerStyled.style), style)
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: className.stringify(classNames.headerContent, contentStyled.className),
|
|
52
|
+
style: contentStyled.style
|
|
53
|
+
}, (monogram || monogramText) && (/*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: classNames.headerMonogram
|
|
55
|
+
}, monogram ? (/*#__PURE__*/React.createElement("img", {
|
|
56
|
+
alt: "",
|
|
57
|
+
src: monogram,
|
|
58
|
+
style: {
|
|
59
|
+
width: "100%",
|
|
60
|
+
height: "100%",
|
|
61
|
+
display: "block"
|
|
62
|
+
}
|
|
63
|
+
})) : monogramText)), /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: className.stringify(classNames.headerText, textStyled.className),
|
|
65
|
+
style: textStyled.style
|
|
66
|
+
}, title && (/*#__PURE__*/React.createElement("div", {
|
|
67
|
+
className: className.stringify(classNames.headerTitle, titleStyled.className),
|
|
68
|
+
style: titleStyled.style
|
|
69
|
+
}, title)), subhead && (/*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: className.stringify(classNames.headerSubhead, subheadStyled.className),
|
|
71
|
+
style: subheadStyled.style
|
|
72
|
+
}, subhead)))), /*#__PURE__*/React.createElement(iconButton.default, {
|
|
73
|
+
variant: "text"
|
|
74
|
+
}, /*#__PURE__*/React.createElement(moreVert.default, {
|
|
75
|
+
size: "large"
|
|
76
|
+
})));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
exports.default = CardHeader;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReactNode, CSSProperties } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* @zh 卡片头部属性
|
|
5
|
+
* @en Card header props
|
|
6
|
+
*/
|
|
7
|
+
interface CardHeaderProps {
|
|
8
|
+
/**
|
|
9
|
+
* @zh 自定义类名
|
|
10
|
+
* @en Custom class name
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* @zh 自定义样式
|
|
15
|
+
* @en Custom style
|
|
16
|
+
*/
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
/**
|
|
19
|
+
* @zh 头部内容
|
|
20
|
+
* @en Header content
|
|
21
|
+
*/
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* @zh 尾部操作区,例如 IconButton(会自动包 48x48 容器)
|
|
25
|
+
* @en Trailing action area, e.g. IconButton (auto-wrapped in 48x48 container)
|
|
26
|
+
*/
|
|
27
|
+
action?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* @zh 头像/字母缩写图片地址
|
|
30
|
+
* @en Monogram image source
|
|
31
|
+
*/
|
|
32
|
+
monogram?: string;
|
|
33
|
+
/**
|
|
34
|
+
* @zh 字母缩写文本
|
|
35
|
+
* @en Monogram text (e.g. initials)
|
|
36
|
+
*/
|
|
37
|
+
monogramText?: string;
|
|
38
|
+
/**
|
|
39
|
+
* @zh 标题
|
|
40
|
+
* @en Title
|
|
41
|
+
*/
|
|
42
|
+
title?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* @zh 副标题
|
|
45
|
+
* @en Subhead
|
|
46
|
+
*/
|
|
47
|
+
subhead?: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @zh 卡片头部,包含字母头像、标题、副标题和可选的操作区。Horizontal 布局下自动应用
|
|
51
|
+
* 全 16px padding,Stacked 布局下应用 12/4/12/16 padding。
|
|
52
|
+
*
|
|
53
|
+
* @en Card header with monogram, title, subhead, and optional action area.
|
|
54
|
+
* Applies 16px padding on all sides in horizontal layout, and 12/4/12/16 in stacked.
|
|
55
|
+
*/
|
|
56
|
+
declare const CardHeader: React.ForwardRefExoticComponent<CardHeaderProps & React.RefAttributes<HTMLDivElement>>;
|
|
57
|
+
export default CardHeader;
|
|
58
|
+
export type { CardHeaderProps };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { stringify } from '@aiszlab/relax/class-name';
|
|
4
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
5
|
+
import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
6
|
+
import { CLASS_NAMES, useCardContext } from './context.mjs';
|
|
7
|
+
import styles from './styles.mjs';
|
|
8
|
+
import IconButton from '../icon-button/icon-button.mjs';
|
|
9
|
+
import IconMoreVert from '../icon/icons/navigation/more-vert.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @zh 卡片头部,包含字母头像、标题、副标题和可选的操作区。Horizontal 布局下自动应用
|
|
13
|
+
* 全 16px padding,Stacked 布局下应用 12/4/12/16 padding。
|
|
14
|
+
*
|
|
15
|
+
* @en Card header with monogram, title, subhead, and optional action area.
|
|
16
|
+
* Applies 16px padding on all sides in horizontal layout, and 12/4/12/16 in stacked.
|
|
17
|
+
*/
|
|
18
|
+
var CardHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
style = _ref.style,
|
|
21
|
+
children = _ref.children,
|
|
22
|
+
monogram = _ref.monogram,
|
|
23
|
+
monogramText = _ref.monogramText,
|
|
24
|
+
title = _ref.title,
|
|
25
|
+
subhead = _ref.subhead;
|
|
26
|
+
var classNames = useClassNames(CLASS_NAMES);
|
|
27
|
+
var _useCardContext = useCardContext(),
|
|
28
|
+
layout = _useCardContext.layout;
|
|
29
|
+
var headerStyled = props(styles.header["default"], styles.header[layout]);
|
|
30
|
+
var contentStyled = props(styles.headerContent["default"]);
|
|
31
|
+
var textStyled = props(styles.headerText["default"]);
|
|
32
|
+
var titleStyled = props(styles.headerTitle["default"]);
|
|
33
|
+
var subheadStyled = props(styles.headerSubhead["default"]);
|
|
34
|
+
props(styles.headerAction["default"]);
|
|
35
|
+
if (children) {
|
|
36
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
ref: ref,
|
|
38
|
+
className: stringify(classNames.header, className, headerStyled.className),
|
|
39
|
+
style: _objectSpread(_objectSpread({}, headerStyled.style), style)
|
|
40
|
+
}, children);
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
ref: ref,
|
|
44
|
+
className: stringify(classNames.header, className, headerStyled.className),
|
|
45
|
+
style: _objectSpread(_objectSpread({}, headerStyled.style), style)
|
|
46
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: stringify(classNames.headerContent, contentStyled.className),
|
|
48
|
+
style: contentStyled.style
|
|
49
|
+
}, (monogram || monogramText) && (/*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: classNames.headerMonogram
|
|
51
|
+
}, monogram ? (/*#__PURE__*/React.createElement("img", {
|
|
52
|
+
alt: "",
|
|
53
|
+
src: monogram,
|
|
54
|
+
style: {
|
|
55
|
+
width: "100%",
|
|
56
|
+
height: "100%",
|
|
57
|
+
display: "block"
|
|
58
|
+
}
|
|
59
|
+
})) : monogramText)), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: stringify(classNames.headerText, textStyled.className),
|
|
61
|
+
style: textStyled.style
|
|
62
|
+
}, title && (/*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: stringify(classNames.headerTitle, titleStyled.className),
|
|
64
|
+
style: titleStyled.style
|
|
65
|
+
}, title)), subhead && (/*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: stringify(classNames.headerSubhead, subheadStyled.className),
|
|
67
|
+
style: subheadStyled.style
|
|
68
|
+
}, subhead)))), /*#__PURE__*/React.createElement(IconButton, {
|
|
69
|
+
variant: "text"
|
|
70
|
+
}, /*#__PURE__*/React.createElement(IconMoreVert, {
|
|
71
|
+
size: "large"
|
|
72
|
+
})));
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export { CardHeader as default };
|