@doubao-dev/template 0.8.0-rc.3 → 0.8.0-rc.5
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/README.md +8 -4
- package/dist/checkout-card/index.js +2 -2
- package/dist/components/footer/index.d.ts +3 -0
- package/dist/components/footer/index.js +9 -3
- package/dist/components/header/index.d.ts +9 -1
- package/dist/components/header/index.js +12 -5
- package/dist/components/header/styles.css +1 -1
- package/dist/composite-card/index.d.ts +15 -2
- package/dist/composite-card/index.js +7 -2
- package/dist/composite-card/styles.css +1 -1
- package/dist/content-card/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/map-card/index.js +1 -1
- package/dist/price-action-card/index.d.ts +3 -0
- package/dist/price-action-card/index.js +5 -4
- package/dist/price-action-card/styles.css +1 -1
- package/dist/primitives/agreement/index.d.ts +5 -0
- package/dist/primitives/agreement/index.js +18 -0
- package/dist/primitives/agreement/styles.css +1 -0
- package/dist/primitives/agreement/types.d.ts +17 -0
- package/dist/primitives/agreement/types.js +0 -0
- package/dist/primitives/checkbox/index.d.ts +5 -0
- package/dist/primitives/checkbox/index.js +17 -0
- package/dist/primitives/checkbox/styles.css +1 -0
- package/dist/primitives/checkbox/types.d.ts +10 -0
- package/dist/primitives/checkbox/types.js +0 -0
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.js +2 -0
- package/dist/transit-card/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,11 +44,15 @@ export default function ProductCard() {
|
|
|
44
44
|
| 人工确认选项 | [AskHumanCard](../../../docs/templates/ask-human-card.mdx) |
|
|
45
45
|
| 多种内容组成一张卡片 | [CompositeCard](../../../docs/templates/composite-card.mdx) |
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
标题、标签、价格、选项、数量调节、勾选框和协议声明见 [Primitives](../../../docs/templates/shared-components.mdx#primitives)。
|
|
48
|
+
|
|
49
|
+
`Checkbox`、`Agreement` 从 `@doubao-dev/template/primitives` 导入。
|
|
50
|
+
`PriceActionCardItem.checkbox` 配置右侧勾选框,替换该项操作按钮;不传时保持按钮布局。
|
|
51
|
+
所有使用共享 footer 的卡片可通过 `footer.agreement` 配置按钮下方的协议声明。
|
|
48
52
|
|
|
49
53
|
## 使用约定
|
|
50
54
|
|
|
51
|
-
- 对话流 Widget
|
|
55
|
+
- 对话流 Widget 必须使用平台模板。组合多个已知模块或定制内容区时使用 `CompositeCard` 的 `sections`,卡片外壳、header 和 footer 仍由模板管理;不通过 `children` 自定义整张卡片布局。
|
|
52
56
|
- `header`、内容区和 `footer` 独立配置;`onClick` 作用于卡片根节点。
|
|
53
57
|
- 模板和 Primitives 不声明或暴露组件级 CSS 变量,可以直接使用已有的全局主题 token。
|
|
54
58
|
|
|
@@ -63,11 +67,11 @@ Web 和 Lynx 的 JSX 构建流程会对可静态确定的违规节点输出 `[
|
|
|
63
67
|
- `ContentCardItem.title / subtitle / description`、`TransitCardItem.title`:支持字符串、数字、直接传入的 primitive `Tag` / `Title`。
|
|
64
68
|
- `ContentCardItem.thumbnail`、`CheckoutCardProductItem.image`:支持直接传入的 `<image />` 或 `<svg />`,也可使用对应 URL 字段。
|
|
65
69
|
- `ContentCardItem.action` 仅支持标准操作配置;`TransitCardItem.price` 支持标准价格配置、字符串或数字;中转信息使用 `transferTop / transferBottom`。
|
|
66
|
-
- `CompositeCard`
|
|
70
|
+
- `CompositeCard` 的 `transit`、`content`、`option-group` section 复用上述内容规则;仅 `custom.content` 可传入业务组件,业务组件不能塞入其他受控槽位。
|
|
67
71
|
- 文本槽位类型为 `string | number | ReactElement`,媒体槽位类型为 `ReactElement`。类型只约束值的类别;具体元素白名单由构建检查根据 import 来源校验。
|
|
68
72
|
|
|
69
73
|
检查支持公共/内部包导入、别名、命名空间、当前文件常量、对象成员、对象/数组展开、条件表达式及表达式形式的 map 回调。跨文件数据、动态函数返回值、复杂数据流和无法解析的展开内容会跳过;不对这些值宣称检查通过。检查允许空值或条件表达式不展示内容。
|
|
70
74
|
|
|
71
75
|
卡片、列表项和 footer 不提供 `style` / `className`,构建检查会对这些字段提示 warning。Primitives 同样不提供 `style` / `className`。宿主背景色和模板内部布局仍由模板管理。
|
|
72
76
|
|
|
73
|
-
卡片不能通过导入自定义样式文件覆盖模板。构建检查沿已注册 Widget 的模块依赖链检查 CSS、SCSS、Sass、Less、Stylus 文件(含 CSS Modules),对直接引入、共享组件间接引入和构建器可解析的动态引入输出 `widget.styles` warning
|
|
77
|
+
卡片不能通过导入自定义样式文件覆盖模板。构建检查沿已注册 Widget 的模块依赖链检查 CSS、SCSS、Sass、Less、Stylus 文件(含 CSS Modules),对直接引入、共享组件间接引入和构建器可解析的动态引入输出 `widget.styles` warning。`CompositeCard` 中静态可识别的 `custom.content` 业务组件及其依赖链可维护内容区样式,但不能覆盖模板外壳、header、footer 或模板类名;Widget 入口和无关依赖的样式仍会报警。平台模板、组件及框架包自身的样式依赖放行;仅由普通 Page 引入的样式不告警。此检查基于构建模块图,无法证明样式选择器没有覆盖模板,也不覆盖运行时通过 URL 加载的样式或脚本动态注入的样式。
|
|
@@ -29,13 +29,13 @@ function CheckoutCard(props) {
|
|
|
29
29
|
index
|
|
30
30
|
})).filter((node)=>null != node);
|
|
31
31
|
return <view className={useThemeClassName('doubao-checkout-card')} style={cardStyle} bindtap={onClick} clip-radius="true">
|
|
32
|
-
<TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
32
|
+
<TemplateCardHeader actionText={header?.actionText} statusText={header?.statusText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
33
33
|
|
|
34
34
|
{productNodes.length > 0 && <view className="doubao-checkout-card__products">{productNodes}</view>}
|
|
35
35
|
|
|
36
36
|
<TemplateInfoSection infoItems={infoItems} feeItems={feeItems} totalLabel={totalLabel} totalPrice={totalPrice} valueLayout="column"/>
|
|
37
37
|
|
|
38
|
-
<TemplateCardFooter secondaryActionButton={footer?.secondaryActionButton} primaryActionButton={footer?.primaryActionButton}/>
|
|
38
|
+
<TemplateCardFooter secondaryActionButton={footer?.secondaryActionButton} agreement={footer?.agreement} primaryActionButton={footer?.primaryActionButton}/>
|
|
39
39
|
</view>;
|
|
40
40
|
}
|
|
41
41
|
export { CheckoutCard };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TouchEvent } from '@lynx-js/types';
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
|
+
import { type AgreementProps } from '../../primitives/agreement/index.js';
|
|
3
4
|
import './styles.scss';
|
|
4
5
|
export interface TemplateCardFooterActionButton {
|
|
5
6
|
/** 按钮文案。 */
|
|
@@ -18,6 +19,8 @@ export interface TemplateCardFooterProps {
|
|
|
18
19
|
primaryActionButton?: TemplateCardFooterActionButton;
|
|
19
20
|
/** 底部次按钮;只传一个按钮时占据整行。 */
|
|
20
21
|
secondaryActionButton?: TemplateCardFooterActionButton;
|
|
22
|
+
/** 按钮下方的非阻断式协议声明。 */
|
|
23
|
+
agreement?: AgreementProps;
|
|
21
24
|
}
|
|
22
25
|
export declare function TemplateCardFooter(props: TemplateCardFooterProps): ReactElement | null;
|
|
23
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { Button } from "@byted-doubao-apps/components";
|
|
2
|
+
import { Agreement } from "../../primitives/agreement/index.js";
|
|
2
3
|
import "./styles.css";
|
|
3
4
|
function TemplateCardFooter(props) {
|
|
4
|
-
const { primaryActionButton, secondaryActionButton } = props;
|
|
5
|
+
const { primaryActionButton, secondaryActionButton, agreement } = props;
|
|
5
6
|
const hasPrimaryAction = primaryActionButton?.text != null && primaryActionButton.text.length > 0;
|
|
6
7
|
const hasSecondaryAction = secondaryActionButton?.text != null && secondaryActionButton.text.length > 0;
|
|
7
8
|
const hasDefaultActions = hasPrimaryAction || hasSecondaryAction;
|
|
8
|
-
if (!hasDefaultActions) return null;
|
|
9
|
-
|
|
9
|
+
if (!hasDefaultActions) return agreement ? <Agreement {...agreement}/> : null;
|
|
10
|
+
const actionBar = <view className="doubao-template-action-bar">
|
|
10
11
|
{hasSecondaryAction && <Button className="doubao-template-action-bar__action" type="default" disabled={secondaryActionButton.disabled} loading={secondaryActionButton.loading} throttle={secondaryActionButton.throttle} text={secondaryActionButton.text} onClick={secondaryActionButton.onClick}/>}
|
|
11
12
|
{hasPrimaryAction && <Button className="doubao-template-action-bar__action" type="primary" disabled={primaryActionButton.disabled} loading={primaryActionButton.loading} throttle={primaryActionButton.throttle} text={primaryActionButton.text} onClick={primaryActionButton.onClick}/>}
|
|
12
13
|
</view>;
|
|
14
|
+
if (!agreement) return actionBar;
|
|
15
|
+
return <>
|
|
16
|
+
{actionBar}
|
|
17
|
+
<Agreement {...agreement}/>
|
|
18
|
+
</>;
|
|
13
19
|
}
|
|
14
20
|
export { TemplateCardFooter };
|
|
@@ -4,10 +4,18 @@ import './styles.scss';
|
|
|
4
4
|
export interface TemplateCardHeaderProps {
|
|
5
5
|
/** 标题栏右侧操作文案。 */
|
|
6
6
|
actionText?: string;
|
|
7
|
+
/** 标题栏右侧的静态警告状态文案;传入时优先于 actionText 展示。 */
|
|
8
|
+
statusText?: string;
|
|
7
9
|
/** 是否展示标题栏右侧操作;默认根据 actionText 是否存在决定。 */
|
|
8
10
|
showAction?: boolean;
|
|
9
11
|
/** 点击标题栏右侧操作时触发。 */
|
|
10
12
|
onActionClick?: (event: TouchEvent) => void;
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
interface TemplateCardHeaderRenderProps extends TemplateCardHeaderProps {
|
|
15
|
+
variant?: 'default' | 'floating';
|
|
16
|
+
title?: string;
|
|
17
|
+
iconSrc?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function TemplateCardHeader(props: TemplateCardHeaderRenderProps): ReactElement;
|
|
20
|
+
export {};
|
|
13
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
1
2
|
import { getAppInfo } from "../../utils/app-info.js";
|
|
2
3
|
import { TemplateChevronRightIcon } from "../chevron-right-icon/index.js";
|
|
3
4
|
import "./styles.css";
|
|
@@ -6,16 +7,22 @@ function TemplateCardHeaderIcon({ appIconSrc }) {
|
|
|
6
7
|
return <view className="doubao-template-title-bar__app-icon"/>;
|
|
7
8
|
}
|
|
8
9
|
function TemplateCardHeader(props) {
|
|
9
|
-
const { actionText, showAction = true, onActionClick } = props;
|
|
10
|
+
const { variant = 'default', title, iconSrc, actionText, statusText, showAction = true, onActionClick } = props;
|
|
10
11
|
const appInfo = getAppInfo();
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const hasStatus = 'default' === variant && null != statusText && statusText.length > 0;
|
|
13
|
+
const hasAction = !hasStatus && showAction && null != actionText && actionText.length > 0;
|
|
14
|
+
return <view className={clsx('doubao-template-title-bar', 'floating' === variant && 'doubao-template-title-bar--floating')}>
|
|
13
15
|
<view className="doubao-template-title-bar__app">
|
|
14
|
-
<TemplateCardHeaderIcon appIconSrc={appInfo.appIconSrc}/>
|
|
16
|
+
<TemplateCardHeaderIcon appIconSrc={iconSrc ?? appInfo.appIconSrc}/>
|
|
15
17
|
<text className="doubao-template-title-bar__app-name" text-maxline="1">
|
|
16
|
-
{appInfo.appName}
|
|
18
|
+
{title ?? appInfo.appName}
|
|
17
19
|
</text>
|
|
18
20
|
</view>
|
|
21
|
+
{hasStatus && <view className="doubao-template-title-bar__status">
|
|
22
|
+
<text className="doubao-template-title-bar__status-text" text-maxline="1">
|
|
23
|
+
{statusText}
|
|
24
|
+
</text>
|
|
25
|
+
</view>}
|
|
19
26
|
{hasAction && <view className="doubao-template-title-bar__more" catchtap={onActionClick}>
|
|
20
27
|
<text className="doubao-template-title-bar__more-text" text-maxline="1">
|
|
21
28
|
{actionText}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.doubao-template-title-bar{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;height:40px;padding:12px;box-sizing:border-box;border-bottom:.5px solid var(--neutral-transparent-1)}.doubao-template-title-bar__app{display:flex;flex-direction:row;align-items:center}.doubao-template-title-bar__app-icon{width:16px;height:16px;flex-shrink:0;overflow:hidden;border-radius:4px}.doubao-template-title-bar__app-name,.doubao-template-title-bar__more-text{overflow:hidden;color:var(--neutral-50);font-family:"PingFang SC",sans-serif;font-size:12px;font-style:normal;line-height:18px;text-overflow:ellipsis;white-space:nowrap}.doubao-template-title-bar__app-name{margin-left:6px;font-weight:500}.doubao-template-title-bar__more{display:flex;flex-direction:row;align-items:center;justify-content:flex-end;flex-shrink:0;min-width:62.5px}.doubao-template-title-bar__more-text{font-weight:400}.doubao-template-title-bar__more-chevron{width:12px;height:12px;flex-shrink:0;margin-left:2px}
|
|
1
|
+
.doubao-template-title-bar{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;height:40px;padding:12px;box-sizing:border-box;border-bottom:.5px solid var(--neutral-transparent-1)}.doubao-template-title-bar--floating{position:absolute;z-index:1;top:8px;left:8px;width:auto;max-width:calc(100% - 16px);height:auto;padding:6px 8px;border:0;border-radius:8px;background:var(--bg-base-1);box-shadow:0 4px 10px rgba(0,0,0,.04)}.doubao-template-title-bar__app{display:flex;flex-direction:row;align-items:center;min-width:0}.doubao-template-title-bar__app-icon{width:16px;height:16px;flex-shrink:0;overflow:hidden;border-radius:4px}.doubao-template-title-bar__app-name,.doubao-template-title-bar__more-text{overflow:hidden;color:var(--neutral-50);font-family:"PingFang SC",sans-serif;font-size:12px;font-style:normal;line-height:18px;text-overflow:ellipsis;white-space:nowrap}.doubao-template-title-bar__app-name{margin-left:6px;font-weight:500}.doubao-template-title-bar__more{display:flex;flex-direction:row;align-items:center;justify-content:flex-end;flex-shrink:0;min-width:62.5px}.doubao-template-title-bar__status{display:flex;align-items:center;flex-shrink:0;max-width:50%;height:24px;padding:5px 8px;box-sizing:border-box;overflow:hidden;border-radius:12px;background-color:#fff3e6}.doubao-template-title-bar__status-text{overflow:hidden;color:#f09300;font-family:"PingFang SC",sans-serif;font-size:12px;font-style:normal;font-weight:500;line-height:14px;text-overflow:ellipsis;white-space:nowrap}.doubao-template-title-bar__more-text{font-weight:400}.doubao-template-title-bar__more-chevron{width:12px;height:12px;flex-shrink:0;margin-left:2px}.doubao-theme-dark .doubao-template-title-bar__status{background-color:var(--warning-trans-10)}.doubao-theme-dark .doubao-template-title-bar__status-text{color:var(--conditional-warning-50)}
|
|
@@ -24,10 +24,23 @@ export interface CompositeCardOptionGroupSection {
|
|
|
24
24
|
/** 选项组模块配置。 */
|
|
25
25
|
props: OptionGroupProps;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export interface CompositeCardCustomSection {
|
|
28
|
+
/** 由业务维护的内容区,仍由组合卡管理外壳与标准操作区。 */
|
|
29
|
+
type: 'custom';
|
|
30
|
+
content: ReactElement;
|
|
31
|
+
}
|
|
32
|
+
export interface CompositeCardHeaderProps extends TemplateCardHeaderProps {
|
|
33
|
+
/** 浮层模式覆盖在首个内容区左上角;默认保持独立标题栏。 */
|
|
34
|
+
placement?: 'default' | 'floating';
|
|
35
|
+
/** 浮层品牌名称,不传时使用应用插件名称。 */
|
|
36
|
+
title?: string;
|
|
37
|
+
/** 浮层品牌图标,不传时使用应用插件图标。 */
|
|
38
|
+
iconSrc?: string;
|
|
39
|
+
}
|
|
40
|
+
export type CompositeCardSection = CompositeCardTransitSection | CompositeCardContentSection | CompositeCardOptionGroupSection | CompositeCardCustomSection;
|
|
28
41
|
export interface CompositeCardProps {
|
|
29
42
|
/** 标题栏配置。 */
|
|
30
|
-
header?:
|
|
43
|
+
header?: CompositeCardHeaderProps;
|
|
31
44
|
/** 按顺序展示的卡片模块。 */
|
|
32
45
|
sections: CompositeCardSection[];
|
|
33
46
|
/** 底部操作区配置。 */
|
|
@@ -14,6 +14,8 @@ function isCompositeCardSectionVisible(section) {
|
|
|
14
14
|
return (section.props.items?.length ?? 0) > 0;
|
|
15
15
|
case 'option-group':
|
|
16
16
|
return section.props.items.length > 0;
|
|
17
|
+
case 'custom':
|
|
18
|
+
return null != section.content;
|
|
17
19
|
default:
|
|
18
20
|
return false;
|
|
19
21
|
}
|
|
@@ -28,6 +30,8 @@ function renderCompositeCardSectionContent(section) {
|
|
|
28
30
|
return <view className="doubao-composite-card__option-group">
|
|
29
31
|
<OptionGroup {...section.props}/>
|
|
30
32
|
</view>;
|
|
33
|
+
case 'custom':
|
|
34
|
+
return section.content;
|
|
31
35
|
default:
|
|
32
36
|
return null;
|
|
33
37
|
}
|
|
@@ -42,12 +46,13 @@ function CompositeCard(props) {
|
|
|
42
46
|
const { header, sections, footer, onClick } = props;
|
|
43
47
|
const cardStyle = useHostCardStyle();
|
|
44
48
|
const visibleSections = sections.filter(isCompositeCardSectionVisible);
|
|
49
|
+
const floatingHeader = header?.placement === 'floating';
|
|
45
50
|
return <view className={useThemeClassName('doubao-composite-card')} style={cardStyle} bindtap={onClick}>
|
|
46
|
-
<TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
51
|
+
<TemplateCardHeader variant={floatingHeader ? 'floating' : 'default'} title={floatingHeader ? header?.title : void 0} iconSrc={floatingHeader ? header?.iconSrc : void 0} actionText={header?.actionText} statusText={header?.statusText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
47
52
|
{visibleSections.length > 0 && <view className="doubao-composite-card__sections">
|
|
48
53
|
{visibleSections.map(renderCompositeCardSection)}
|
|
49
54
|
</view>}
|
|
50
|
-
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton}/>
|
|
55
|
+
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton} agreement={footer?.agreement}/>
|
|
51
56
|
</view>;
|
|
52
57
|
}
|
|
53
58
|
export { CompositeCard };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.doubao-composite-card{display:flex;flex-direction:column;align-items:stretch;width:100%;box-sizing:border-box;overflow:hidden;background-color:var(--bg-base-1);border:1px solid var(--bg-base-2-overlay);border-radius:8px}.doubao-composite-card__sections{display:flex;flex-direction:column;width:100%;min-width:0;box-sizing:border-box}.doubao-composite-card__section{display:flex;flex-direction:column;width:100%;min-width:0;box-sizing:border-box}.doubao-composite-card__option-group{width:100%;min-width:0;padding:0 12px 16px;box-sizing:border-box}
|
|
1
|
+
.doubao-composite-card{display:flex;flex-direction:column;align-items:stretch;width:100%;position:relative;box-sizing:border-box;overflow:hidden;background-color:var(--bg-base-1);border:1px solid var(--bg-base-2-overlay);border-radius:8px}.doubao-composite-card__sections{display:flex;flex-direction:column;width:100%;min-width:0;box-sizing:border-box}.doubao-composite-card__section{display:flex;flex-direction:column;width:100%;min-width:0;box-sizing:border-box}.doubao-composite-card__option-group{width:100%;min-width:0;padding:0 12px 16px;box-sizing:border-box}
|
|
@@ -68,9 +68,9 @@ function ContentCard(props) {
|
|
|
68
68
|
const { header, items, footer, onClick } = props;
|
|
69
69
|
const cardStyle = useHostCardStyle();
|
|
70
70
|
return <view className={useThemeClassName('doubao-content-card')} style={cardStyle} bindtap={onClick} clip-radius="true">
|
|
71
|
-
<TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
71
|
+
<TemplateCardHeader actionText={header?.actionText} statusText={header?.statusText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
72
72
|
<ContentCardContent items={items}/>
|
|
73
|
-
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton}/>
|
|
73
|
+
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton} agreement={footer?.agreement}/>
|
|
74
74
|
</view>;
|
|
75
75
|
}
|
|
76
76
|
export { ContentCard, ContentCardContent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ContentCard, type ContentCardItem, type ContentCardProps } from './content-card/index.js';
|
|
2
2
|
export { CouponCard, type CouponCardItem, type CouponCardProps } from './coupon-card/index.js';
|
|
3
|
-
export { CompositeCard, type CompositeCardContentSection, type CompositeCardOptionGroupSection, type CompositeCardProps, type CompositeCardSection, type CompositeCardTransitSection } from './composite-card/index.js';
|
|
3
|
+
export { CompositeCard, type CompositeCardContentSection, type CompositeCardOptionGroupSection, type CompositeCardCustomSection, type CompositeCardHeaderProps, type CompositeCardProps, type CompositeCardSection, type CompositeCardTransitSection } from './composite-card/index.js';
|
|
4
4
|
export type { TemplateCardHeaderProps } from './components/header/index.js';
|
|
5
5
|
export type { TemplateCardFooterActionButton, TemplateCardFooterProps } from './components/footer/index.js';
|
|
6
6
|
export type { TemplateExtraAction, TemplateExtraActionAdd, TemplateExtraActionButton, TemplateExtraActionPlayback, TemplateExtraActionStepper, TemplateExtraActionSwitch } from './components/extra-action/index.js';
|
package/dist/map-card/index.js
CHANGED
|
@@ -38,7 +38,7 @@ function MapCardImpl(props, ref) {
|
|
|
38
38
|
</view> : null}
|
|
39
39
|
</view> : null}
|
|
40
40
|
|
|
41
|
-
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton}/>
|
|
41
|
+
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton} agreement={footer?.agreement}/>
|
|
42
42
|
</view>;
|
|
43
43
|
}
|
|
44
44
|
const MapCard = forwardRef(MapCardImpl);
|
|
@@ -2,6 +2,7 @@ import type { TouchEvent } from '@lynx-js/types';
|
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
3
|
import { type TemplateCardFooterProps } from '../components/footer/index.js';
|
|
4
4
|
import { type TemplateCardHeaderProps } from '../components/header/index.js';
|
|
5
|
+
import { type CheckboxProps } from '../primitives/checkbox/index.js';
|
|
5
6
|
import type { TemplateKey, TemplateText } from '../types.js';
|
|
6
7
|
import './styles.scss';
|
|
7
8
|
export interface PriceActionCardProps {
|
|
@@ -25,6 +26,8 @@ export interface PriceActionCardItem {
|
|
|
25
26
|
infoRows?: PriceActionCardInfoRow[];
|
|
26
27
|
/** 右侧操作按钮文案;不传或传空字符串时不展示。 */
|
|
27
28
|
actionText?: string;
|
|
29
|
+
/** 右侧勾选框配置;配置后替换操作按钮。 */
|
|
30
|
+
checkbox?: CheckboxProps;
|
|
28
31
|
/** 点击列表项时触发。 */
|
|
29
32
|
onClick?: (event: TouchEvent) => void;
|
|
30
33
|
/** 点击列表项右侧操作按钮时触发。 */
|
|
@@ -2,6 +2,7 @@ import { Button, useThemeClassName } from "@byted-doubao-apps/components";
|
|
|
2
2
|
import { clsx } from "clsx";
|
|
3
3
|
import { TemplateCardFooter } from "../components/footer/index.js";
|
|
4
4
|
import { TemplateCardHeader } from "../components/header/index.js";
|
|
5
|
+
import { Checkbox } from "../primitives/checkbox/index.js";
|
|
5
6
|
import { Price } from "../primitives/price/index.js";
|
|
6
7
|
import { useHostCardStyle } from "../utils/use-host-card-style.js";
|
|
7
8
|
import "./styles.css";
|
|
@@ -20,7 +21,7 @@ function PriceActionCardItemView({ item, isLast }) {
|
|
|
20
21
|
const hasBadge = !isPriceActionCardTextEmpty(item.badgeText);
|
|
21
22
|
const hasAction = null != item.actionText && item.actionText.length > 0;
|
|
22
23
|
const infoRows = (item.infoRows ?? []).filter((infoRow)=>!isPriceActionCardTextEmpty(infoRow.text)).slice(0, PRICE_ACTION_CARD_INFO_ROW_LIMIT);
|
|
23
|
-
return <view className={clsx('doubao-price-action-card__item', isLast && 'doubao-price-action-card__item--last')} {...null != item.onClick ? {
|
|
24
|
+
return <view className={clsx('doubao-price-action-card__item', isLast && 'doubao-price-action-card__item--last', null != item.checkbox && 'doubao-price-action-card__item--checkbox')} {...null != item.onClick ? {
|
|
24
25
|
catchtap: item.onClick
|
|
25
26
|
} : {}}>
|
|
26
27
|
<view className="doubao-price-action-card__item-content">
|
|
@@ -35,7 +36,7 @@ function PriceActionCardItemView({ item, isLast }) {
|
|
|
35
36
|
{infoRow.text}
|
|
36
37
|
</text>)}
|
|
37
38
|
</view>
|
|
38
|
-
{hasAction
|
|
39
|
+
{null != item.checkbox ? <Checkbox {...item.checkbox}/> : hasAction ? <Button className="doubao-price-action-card__item-action" type="default" text={item.actionText} onClick={item.onActionClick}/> : null}
|
|
39
40
|
</view>
|
|
40
41
|
</view>;
|
|
41
42
|
}
|
|
@@ -43,13 +44,13 @@ function PriceActionCard(props) {
|
|
|
43
44
|
const { header, items = [], footer, onClick } = props;
|
|
44
45
|
const cardStyle = useHostCardStyle();
|
|
45
46
|
return <view className={useThemeClassName('doubao-price-action-card')} style={cardStyle} bindtap={onClick} clip-radius="true">
|
|
46
|
-
<TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
47
|
+
<TemplateCardHeader actionText={header?.actionText} statusText={header?.statusText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
47
48
|
<view className="doubao-price-action-card__body">
|
|
48
49
|
<view className="doubao-price-action-card__default">
|
|
49
50
|
{items.map((item, index)=><PriceActionCardItemView item={item} isLast={index === items.length - 1} key={item.key ?? index}/>)}
|
|
50
51
|
</view>
|
|
51
52
|
</view>
|
|
52
|
-
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton}/>
|
|
53
|
+
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton} agreement={footer?.agreement}/>
|
|
53
54
|
</view>;
|
|
54
55
|
}
|
|
55
56
|
export { PriceActionCard };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.doubao-price-action-card{display:flex;flex-direction:column;align-items:stretch;width:100%;box-sizing:border-box;overflow:hidden;background-color:var(--bg-base-1);border:1px solid var(--bg-base-2-overlay);border-radius:8px}.doubao-price-action-card__body{width:100%;box-sizing:border-box}.doubao-price-action-card__default{width:100%;box-sizing:border-box}.doubao-price-action-card__item{position:relative;display:flex;flex-direction:row;align-items:center;width:100%;height:82px;padding:20px 12px;box-sizing:border-box}.doubao-price-action-card__item::after{position:absolute;right:0;bottom:0;left:95px;height:.5px;content:"";background-color:var(--neutral-transparent-1)}.doubao-price-action-card__item--last::after{display:none}.doubao-price-action-card__item-content{display:flex;flex-direction:row;align-items:center;width:100%;gap:12px}.doubao-price-action-card__value{display:flex;flex-direction:column;align-items:flex-start;padding:0 4px;width:94px;min-width:0;flex-shrink:0}.doubao-price-action-card__value>.doubao-price{width:100%;min-width:0;overflow:hidden}.doubao-price-action-card__value>.doubao-price .doubao-price__amount,.doubao-price-action-card__value>.doubao-price .doubao-price__main,.doubao-price-action-card__value>.doubao-price .doubao-price__integer-group{max-width:100%;min-width:0;overflow:hidden}.doubao-price-action-card__value>.doubao-price .doubao-price__main,.doubao-price-action-card__value>.doubao-price .doubao-price__integer-group,.doubao-price-action-card__value>.doubao-price .doubao-price__integer{flex-shrink:1}.doubao-price-action-card__value>.doubao-price .doubao-price__integer{min-width:0;overflow:hidden;text-overflow:ellipsis}.doubao-price-action-card__badge{height:20px;max-width:100%;padding:2px 3px;box-sizing:border-box;overflow:hidden;color:var(--pink-500);font-family:"PingFang SC",sans-serif;font-size:11px;font-style:normal;font-weight:400;line-height:14px;text-overflow:ellipsis;white-space:nowrap;background-color:var(--pink-trans-6);border-radius:4px}.doubao-price-action-card__info{display:flex;flex:1 1 0;flex-direction:column;justify-content:center;min-width:0}.doubao-price-action-card__info-row{width:100%;overflow:hidden;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:13px;font-style:normal;font-weight:400;line-height:20px;text-overflow:ellipsis;white-space:nowrap}.doubao-price-action-card__info-row+.doubao-price-action-card__info-row{margin-top:2px}.doubao-price-action-card__item-action{width:auto;min-width:60px;max-width:100px;height:38px;flex-shrink:0;--doubao-button-border-radius: 8px;--doubao-button-default-border-radius: 8px;--doubao-button-default-height: 38px;--doubao-button-default-padding-x: 12px;--doubao-button-default-padding-y: 0;--doubao-button-default-font-size: 14px;--doubao-button-default-line-height: 20px;--doubao-button-default-bg: var(--bg-base-1-overlay);--doubao-button-default-text: var(--neutral-100)}
|
|
1
|
+
.doubao-price-action-card{display:flex;flex-direction:column;align-items:stretch;width:100%;box-sizing:border-box;overflow:hidden;background-color:var(--bg-base-1);border:1px solid var(--bg-base-2-overlay);border-radius:8px}.doubao-price-action-card__body{width:100%;box-sizing:border-box}.doubao-price-action-card__default{width:100%;box-sizing:border-box}.doubao-price-action-card__item{position:relative;display:flex;flex-direction:row;align-items:center;width:100%;height:82px;padding:20px 12px;box-sizing:border-box}.doubao-price-action-card__item::after{position:absolute;right:0;bottom:0;left:95px;height:.5px;content:"";background-color:var(--neutral-transparent-1)}.doubao-price-action-card__item--last::after{display:none}.doubao-price-action-card__item--checkbox{height:74px;padding:16px 12px}.doubao-price-action-card__item--checkbox .doubao-price-action-card__value{width:75px;box-sizing:border-box}.doubao-price-action-card__item-content{display:flex;flex-direction:row;align-items:center;width:100%;gap:12px}.doubao-price-action-card__value{display:flex;flex-direction:column;align-items:flex-start;padding:0 4px;width:94px;min-width:0;flex-shrink:0}.doubao-price-action-card__value>.doubao-price{width:100%;min-width:0;overflow:hidden}.doubao-price-action-card__value>.doubao-price .doubao-price__amount,.doubao-price-action-card__value>.doubao-price .doubao-price__main,.doubao-price-action-card__value>.doubao-price .doubao-price__integer-group{max-width:100%;min-width:0;overflow:hidden}.doubao-price-action-card__value>.doubao-price .doubao-price__main,.doubao-price-action-card__value>.doubao-price .doubao-price__integer-group,.doubao-price-action-card__value>.doubao-price .doubao-price__integer{flex-shrink:1}.doubao-price-action-card__value>.doubao-price .doubao-price__integer{min-width:0;overflow:hidden;text-overflow:ellipsis}.doubao-price-action-card__badge{height:20px;max-width:100%;padding:2px 3px;box-sizing:border-box;overflow:hidden;color:var(--pink-500);font-family:"PingFang SC",sans-serif;font-size:11px;font-style:normal;font-weight:400;line-height:14px;text-overflow:ellipsis;white-space:nowrap;background-color:var(--pink-trans-6);border-radius:4px}.doubao-price-action-card__info{display:flex;flex:1 1 0;flex-direction:column;justify-content:center;min-width:0}.doubao-price-action-card__info-row{width:100%;overflow:hidden;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:13px;font-style:normal;font-weight:400;line-height:20px;text-overflow:ellipsis;white-space:nowrap}.doubao-price-action-card__info-row+.doubao-price-action-card__info-row{margin-top:2px}.doubao-price-action-card__item-action{width:auto;min-width:60px;max-width:100px;height:38px;flex-shrink:0;--doubao-button-border-radius: 8px;--doubao-button-default-border-radius: 8px;--doubao-button-default-height: 38px;--doubao-button-default-padding-x: 12px;--doubao-button-default-padding-y: 0;--doubao-button-default-font-size: 14px;--doubao-button-default-line-height: 20px;--doubao-button-default-bg: var(--bg-base-1-overlay);--doubao-button-default-text: var(--neutral-100)}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useThemeClassName } from "@byted-doubao-apps/components";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
function Agreement({ text: text1 = '点击下单代表同意', links }) {
|
|
4
|
+
const className = useThemeClassName('doubao-agreement');
|
|
5
|
+
const visibleLinks = links.filter((link)=>'' !== link.text);
|
|
6
|
+
if (0 === visibleLinks.length) return null;
|
|
7
|
+
return <view className={className} catchtap={()=>{}}>
|
|
8
|
+
<text className="doubao-agreement__text" text-maxline="2">
|
|
9
|
+
{text1}
|
|
10
|
+
{'' !== text1 && ' '}
|
|
11
|
+
{visibleLinks.map((link, index)=><text className="doubao-agreement__link" key={link.key ?? index} bindtap={link.onClick}>
|
|
12
|
+
{index > 0 ? '、' : ''}
|
|
13
|
+
{link.text}
|
|
14
|
+
</text>)}
|
|
15
|
+
</text>
|
|
16
|
+
</view>;
|
|
17
|
+
}
|
|
18
|
+
export { Agreement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.doubao-agreement{display:flex;flex-direction:column;align-items:center;width:100%;padding:0 12px 14px;box-sizing:border-box;background-color:var(--bg-base-1)}.doubao-agreement__text,.doubao-agreement__link{font-family:"PingFang SC",sans-serif;font-size:13px;font-weight:400;font-style:normal;line-height:20px}.doubao-agreement__text{max-width:100%;overflow:hidden;color:var(--neutral-70);text-overflow:ellipsis}.doubao-agreement__link{color:var(--neutral-100)}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TouchEvent } from '@lynx-js/types';
|
|
2
|
+
import type { TemplateKey, TemplateText } from '../../types.js';
|
|
3
|
+
export interface AgreementLink {
|
|
4
|
+
/** 唯一标识;不传时使用数组下标。 */
|
|
5
|
+
key?: TemplateKey;
|
|
6
|
+
/** 协议名称。 */
|
|
7
|
+
text: TemplateText;
|
|
8
|
+
/** 点击协议时触发;跳转由业务处理。 */
|
|
9
|
+
onClick?: (event: TouchEvent) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface AgreementProps {
|
|
12
|
+
/** 协议前的说明文案。@defaultValue 点击下单代表同意 */
|
|
13
|
+
text?: TemplateText;
|
|
14
|
+
/** 协议列表,按顺序展示,以顿号分隔。 */
|
|
15
|
+
links: AgreementLink[];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useThemeClassName } from "@byted-doubao-apps/components";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const CHECKMARK_CONTENT = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.94847 5.29293C10.1552 4.98835 10.5696 4.90868 10.8743 5.1152C11.1786 5.32194 11.2584 5.73643 11.052 6.04098L7.885 10.708C7.76885 10.879 7.57965 10.9866 7.37328 10.999C7.16695 11.0113 6.96606 10.9273 6.83031 10.7714L4.9973 8.66305C4.7557 8.38525 4.78496 7.96424 5.06273 7.72262C5.34052 7.48102 5.76153 7.51031 6.00316 7.78805L7.26683 9.24215L9.94847 5.29293Z" fill="white"/></svg>';
|
|
5
|
+
function Checkbox({ checked, disabled = false, onChange }) {
|
|
6
|
+
const themeClassName = useThemeClassName();
|
|
7
|
+
const handleTap = (event)=>{
|
|
8
|
+
if (!disabled) onChange?.(!checked, event);
|
|
9
|
+
};
|
|
10
|
+
return <view className={clsx('doubao-checkbox', themeClassName, {
|
|
11
|
+
'doubao-checkbox--checked': checked,
|
|
12
|
+
'doubao-checkbox--disabled': disabled
|
|
13
|
+
})} accessibility-element accessibility-label={checked ? '已选中' : '未选中'} catchtap={handleTap}>
|
|
14
|
+
{checked && <svg className="doubao-checkbox__checkmark" content={CHECKMARK_CONTENT}/>}
|
|
15
|
+
</view>;
|
|
16
|
+
}
|
|
17
|
+
export { Checkbox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.doubao-checkbox{display:flex;align-items:center;justify-content:center;width:16px;height:16px;flex-shrink:0;box-sizing:border-box;border-radius:8px;border:1.33333px solid var(--neutral-transparent-3)}.doubao-checkbox--disabled{background:var(--neutral-10)}.doubao-checkbox--checked{border:none;background:var(--primary-50)}.doubao-checkbox--checked.doubao-checkbox--disabled{opacity:.4}.doubao-checkbox__checkmark{width:16px;height:16px;flex-shrink:0}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TouchEvent } from '@lynx-js/types';
|
|
2
|
+
export interface CheckboxProps {
|
|
3
|
+
/** 是否选中;由业务根据 onChange 更新。 */
|
|
4
|
+
checked: boolean;
|
|
5
|
+
/** 是否禁用。@defaultValue false */
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/** 点击后返回下一次选中状态;禁用时不触发。 */
|
|
8
|
+
onChange?: (checked: boolean, event: TouchEvent) => void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
File without changes
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { Agreement, type AgreementLink, type AgreementProps } from './agreement/index.js';
|
|
2
|
+
export { Checkbox, type CheckboxProps } from './checkbox/index.js';
|
|
1
3
|
export { Icon, type IconName, type IconProps } from './icon/index.js';
|
|
2
4
|
export { OptionGroup, type OptionGroupItem, type OptionGroupLargeItem, type OptionGroupMediumItem, type OptionGroupProps, type OptionGroupSize, type OptionGroupText, type OptionGroupValue } from './option-group/index.js';
|
|
3
5
|
export { Price, type PricePrefixTone, type PriceProps, type PriceTone, type PriceValue } from './price/index.js';
|
package/dist/primitives/index.js
CHANGED
|
@@ -7,9 +7,9 @@ function TransitCard(props) {
|
|
|
7
7
|
const { header, items = [], footer, onClick } = props;
|
|
8
8
|
const cardStyle = useHostCardStyle();
|
|
9
9
|
return <view className={useThemeClassName('doubao-transit-card')} style={cardStyle} bindtap={onClick}>
|
|
10
|
-
<TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
10
|
+
<TemplateCardHeader actionText={header?.actionText} statusText={header?.statusText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
|
|
11
11
|
<TransitCardContent items={items}/>
|
|
12
|
-
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton}/>
|
|
12
|
+
<TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton} agreement={footer?.agreement}/>
|
|
13
13
|
</view>;
|
|
14
14
|
}
|
|
15
15
|
export { TransitCard };
|