@doubao-dev/template 0.4.2 → 0.5.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.
Files changed (52) hide show
  1. package/README.md +42 -525
  2. package/dist/ask-human-card/index.d.ts +1 -9
  3. package/dist/ask-human-card/index.js +6 -5
  4. package/dist/checkout-card/index.d.ts +1 -5
  5. package/dist/checkout-card/index.js +4 -3
  6. package/dist/checkout-card/styles.css +1 -1
  7. package/dist/components/extra-action/index.d.ts +13 -3
  8. package/dist/components/extra-action/index.js +23 -1
  9. package/dist/components/extra-action/styles.css +1 -1
  10. package/dist/components/footer/index.d.ts +1 -5
  11. package/dist/components/footer/index.js +4 -5
  12. package/dist/components/product-summary/index.d.ts +3 -3
  13. package/dist/components/product-summary/styles.css +1 -1
  14. package/dist/composite-card/index.d.ts +1 -5
  15. package/dist/composite-card/index.js +4 -3
  16. package/dist/composite-card/styles.css +1 -1
  17. package/dist/content-card/index.d.ts +12 -30
  18. package/dist/content-card/index.js +20 -25
  19. package/dist/content-card/styles.css +1 -1
  20. package/dist/index.d.ts +1 -2
  21. package/dist/index.js +0 -1
  22. package/dist/map-card/index.d.ts +1 -5
  23. package/dist/map-card/index.js +4 -2
  24. package/dist/map-card/styles.css +1 -1
  25. package/dist/price-action-card/index.d.ts +2 -20
  26. package/dist/price-action-card/index.js +23 -26
  27. package/dist/price-action-card/styles.css +1 -1
  28. package/dist/primitives/icon/index.d.ts +1 -1
  29. package/dist/primitives/icon/index.js +2 -3
  30. package/dist/primitives/icon/types.d.ts +0 -5
  31. package/dist/primitives/option-group/index.js +2 -4
  32. package/dist/primitives/option-group/types.d.ts +3 -9
  33. package/dist/primitives/price/index.d.ts +1 -1
  34. package/dist/primitives/price/index.js +3 -3
  35. package/dist/primitives/price/types.d.ts +0 -5
  36. package/dist/primitives/tag/index.d.ts +1 -1
  37. package/dist/primitives/tag/index.js +3 -3
  38. package/dist/primitives/tag/types.d.ts +0 -5
  39. package/dist/primitives/title/index.d.ts +1 -1
  40. package/dist/primitives/title/index.js +3 -3
  41. package/dist/primitives/title/types.d.ts +0 -5
  42. package/dist/transit-card/content.js +2 -2
  43. package/dist/transit-card/index.d.ts +6 -16
  44. package/dist/transit-card/index.js +4 -3
  45. package/dist/transit-card/styles.css +1 -1
  46. package/dist/utils/icons.d.ts +2 -0
  47. package/dist/utils/icons.js +20 -1
  48. package/package.json +1 -1
  49. package/assets/ticket-order-card.png +0 -0
  50. package/dist/ticket-order-card/index.d.ts +0 -89
  51. package/dist/ticket-order-card/index.js +0 -27
  52. package/dist/ticket-order-card/styles.css +0 -1
@@ -1,5 +1,5 @@
1
1
  import { useThemeClassName } from "@byted-doubao-apps/components";
2
- import { clsx } from "clsx";
2
+ import { useHostCardStyle } from "@byted-doubao-apps/framework";
3
3
  import { TemplateCardFooter } from "../components/footer/index.js";
4
4
  import { TemplateCardHeader } from "../components/header/index.js";
5
5
  import { TemplateInfoSection } from "../components/info-section/index.js";
@@ -22,12 +22,13 @@ function renderCheckoutCardProductItem({ item, index }) {
22
22
  </view>;
23
23
  }
24
24
  function CheckoutCard(props) {
25
- const { header, productItems = [], infoItems = [], feeItems = [], totalLabel, totalPrice, footer, className, style, onClick } = props;
25
+ const { header, productItems = [], infoItems = [], feeItems = [], totalLabel, totalPrice, footer, onClick } = props;
26
+ const cardStyle = useHostCardStyle();
26
27
  const productNodes = productItems.map((item, index)=>renderCheckoutCardProductItem({
27
28
  item,
28
29
  index
29
30
  })).filter((node)=>null != node);
30
- return <view className={useThemeClassName(clsx('doubao-checkout-card', className))} style={style} bindtap={onClick} clip-radius="true">
31
+ return <view className={useThemeClassName('doubao-checkout-card')} style={cardStyle} bindtap={onClick} clip-radius="true">
31
32
  <TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
32
33
 
33
34
  {productNodes.length > 0 && <view className="doubao-checkout-card__products">{productNodes}</view>}
@@ -1 +1 @@
1
- .doubao-checkout-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-checkout-card__products{display:flex;flex-direction:column;align-items:stretch;width:100%;background-color:var(--bg-base-1)}.doubao-checkout-card__product{position:relative}.doubao-checkout-card__product+.doubao-checkout-card__product::before{position:absolute;top:0;right:16px;left:16px;height:1px;background-color:var(--neutral-transparent-1);content:""}
1
+ .doubao-checkout-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-checkout-card__products{display:flex;flex-direction:column;align-items:stretch;width:100%}.doubao-checkout-card__product{position:relative}.doubao-checkout-card__product+.doubao-checkout-card__product::before{position:absolute;top:0;right:16px;left:16px;height:1px;background-color:var(--neutral-transparent-1);content:""}
@@ -1,5 +1,5 @@
1
1
  import type { TouchEvent } from '@lynx-js/types';
2
- import type { ReactNode } from 'react';
2
+ import { type ReactNode } from 'react';
3
3
  import './styles.scss';
4
4
  /** 模板右侧控件:按钮。 */
5
5
  export interface TemplateExtraActionButton {
@@ -13,6 +13,16 @@ export interface TemplateExtraActionButton {
13
13
  /** 点击按钮时触发。 */
14
14
  onClick?: (event?: TouchEvent) => void;
15
15
  }
16
+ /** 模板右侧控件:添加。 */
17
+ export interface TemplateExtraActionAdd {
18
+ type: 'add';
19
+ /** 是否禁用。 */
20
+ disabled?: boolean;
21
+ /** 是否展示加载态。 */
22
+ loading?: boolean;
23
+ /** 点击添加控件时触发。 */
24
+ onClick?: (event?: TouchEvent) => void;
25
+ }
16
26
  /** 模板右侧控件:开关。受控用法,必须传入 checked。 */
17
27
  export interface TemplateExtraActionSwitch {
18
28
  type: 'switch';
@@ -35,8 +45,8 @@ export interface TemplateExtraActionPlayback {
35
45
  /** 切换播放/暂停时触发,参数为切换后的目标状态。 */
36
46
  onToggle?: (playing: boolean) => void;
37
47
  }
38
- /** 模板右侧标准控件配置(判别联合,三选一)。 */
39
- export type TemplateExtraAction = TemplateExtraActionButton | TemplateExtraActionSwitch | TemplateExtraActionPlayback;
48
+ /** 模板右侧标准控件配置(判别联合)。 */
49
+ export type TemplateExtraAction = TemplateExtraActionButton | TemplateExtraActionAdd | TemplateExtraActionSwitch | TemplateExtraActionPlayback;
40
50
  export interface TemplateExtraActionClassNames {
41
51
  button?: string;
42
52
  switch?: string;
@@ -1,8 +1,28 @@
1
1
  import { Button, Switch, useTheme } from "@byted-doubao-apps/components";
2
2
  import { clsx } from "clsx";
3
- import { getTemplatePlaybackIconContent } from "../../utils/icons.js";
3
+ import { useState } from "react";
4
+ import { getTemplateAddIconContent, getTemplateAddLoadingIconContent, getTemplatePlaybackIconContent } from "../../utils/icons.js";
4
5
  import "./styles.css";
5
6
  function stopTemplateExtraActionTap() {}
7
+ function TemplateAddAction({ disabled = false, loading = false, onClick }) {
8
+ const theme = useTheme();
9
+ const [pressed, setPressed] = useState(false);
10
+ const iconColor = 'dark' === theme ? '#ffffff' : '#000000';
11
+ const loadingColor = 'dark' === theme ? '#cccccc' : '#666666';
12
+ const handleTap = (event)=>{
13
+ setPressed(false);
14
+ if (!disabled && !loading) onClick?.(event);
15
+ };
16
+ const handleTouchStart = ()=>{
17
+ if (!disabled && !loading) setPressed(true);
18
+ };
19
+ const handleTouchEnd = ()=>setPressed(false);
20
+ return <view className={clsx('doubao-template-extra-action-add', 'dark' === theme ? 'doubao-theme-dark' : 'doubao-theme-light', pressed && !disabled && !loading && 'doubao-template-extra-action-add--pressed', disabled && 'doubao-template-extra-action-add--disabled', loading && 'doubao-template-extra-action-add--loading')} catchtap={handleTap} bindtouchstart={handleTouchStart} bindtouchend={handleTouchEnd} bindtouchmove={handleTouchEnd}>
21
+ {loading ? <view className="doubao-template-extra-action-add__spinner">
22
+ <svg className="doubao-template-extra-action-add__icon" content={getTemplateAddLoadingIconContent(loadingColor)}/>
23
+ </view> : <svg className="doubao-template-extra-action-add__icon" content={getTemplateAddIconContent(iconColor)}/>}
24
+ </view>;
25
+ }
6
26
  function TemplatePlaybackButton(props) {
7
27
  const { playing, progress, disabled = false, onToggle, className, playingClassName, disabledClassName, iconClassName } = props;
8
28
  const theme = useTheme();
@@ -20,6 +40,8 @@ function renderTemplateExtraAction(action, classNames = {}) {
20
40
  switch(action.type){
21
41
  case 'button':
22
42
  return <Button className={clsx('doubao-template-extra-action-button', classNames.button)} type="default" text={action.text} disabled={action.disabled} loading={action.loading} onClick={action.onClick}/>;
43
+ case 'add':
44
+ return <TemplateAddAction {...action}/>;
23
45
  case 'switch':
24
46
  return <Switch className={classNames.switch} checked={action.checked} disabled={action.disabled} onChange={action.onChange}/>;
25
47
  case 'playback':
@@ -1 +1 @@
1
- .doubao-template-extra-action-button{--doubao-button-border-radius: 8px;--doubao-button-default-border-radius: 8px;--doubao-button-default-height: 36px;--doubao-button-default-padding-x: 12px;--doubao-button-default-padding-y: 8px;--doubao-button-default-font-size: 14px;--doubao-button-default-line-height: 20px}
1
+ .doubao-template-extra-action-button{--doubao-button-border-radius: 8px;--doubao-button-default-border-radius: 8px;--doubao-button-default-height: 36px;--doubao-button-default-padding-x: 12px;--doubao-button-default-padding-y: 8px;--doubao-button-default-font-size: 14px;--doubao-button-default-line-height: 20px}.doubao-template-extra-action-add{display:flex;align-items:center;justify-content:center;width:24px;height:24px;flex-shrink:0;box-sizing:border-box;overflow:hidden;background-color:var(--static-black-transparent-4);border-radius:50%}.doubao-template-extra-action-add:hover:not(.doubao-template-extra-action-add--disabled):not(.doubao-template-extra-action-add--loading):not(.doubao-template-extra-action-add--pressed){background-color:var(--static-black-transparent-6)}.doubao-template-extra-action-add--pressed,.doubao-template-extra-action-add--pressed:hover{background-color:var(--static-black-transparent-10)}.doubao-template-extra-action-add.doubao-theme-dark{background-color:hsla(0,0%,100%,.04)}.doubao-template-extra-action-add.doubao-theme-dark:hover:not(.doubao-template-extra-action-add--disabled):not(.doubao-template-extra-action-add--loading):not(.doubao-template-extra-action-add--pressed){background-color:hsla(0,0%,100%,.06)}.doubao-template-extra-action-add.doubao-theme-dark.doubao-template-extra-action-add--pressed,.doubao-template-extra-action-add.doubao-theme-dark.doubao-template-extra-action-add--pressed:hover{background-color:hsla(0,0%,100%,.1)}.doubao-template-extra-action-add--disabled{opacity:.3}.doubao-template-extra-action-add__icon,.doubao-template-extra-action-add__spinner{width:14px;height:14px;flex-shrink:0}.doubao-template-extra-action-add__spinner{animation:doubao-template-extra-action-add-spin 1s linear infinite}@keyframes doubao-template-extra-action-add-spin{to{transform:rotate(360deg)}}
@@ -1,4 +1,4 @@
1
- import type { CSSProperties, TouchEvent } from '@lynx-js/types';
1
+ import type { TouchEvent } from '@lynx-js/types';
2
2
  import type { ReactElement } from 'react';
3
3
  import './styles.scss';
4
4
  export interface TemplateCardFooterActionButton {
@@ -14,10 +14,6 @@ export interface TemplateCardFooterActionButton {
14
14
  onClick?: (event?: TouchEvent) => void;
15
15
  }
16
16
  export interface TemplateCardFooterProps {
17
- /** 操作区根节点自定义类名。 */
18
- className?: string;
19
- /** 操作区根节点自定义样式。 */
20
- style?: CSSProperties;
21
17
  /** 底部主按钮;只传一个按钮时占据整行。 */
22
18
  primaryActionButton?: TemplateCardFooterActionButton;
23
19
  /** 底部次按钮;只传一个按钮时占据整行。 */
@@ -1,15 +1,14 @@
1
1
  import { Button } from "@byted-doubao-apps/components";
2
- import { clsx } from "clsx";
3
2
  import "./styles.css";
4
3
  function TemplateCardFooter(props) {
5
- const { className, style, primaryActionButton, secondaryActionButton } = props;
4
+ const { primaryActionButton, secondaryActionButton } = props;
6
5
  const hasPrimaryAction = primaryActionButton?.text != null && primaryActionButton.text.length > 0;
7
6
  const hasSecondaryAction = secondaryActionButton?.text != null && secondaryActionButton.text.length > 0;
8
7
  const hasDefaultActions = hasPrimaryAction || hasSecondaryAction;
9
8
  if (!hasDefaultActions) return null;
10
- return <view className={clsx('doubao-template-action-bar', className)} style={style}>
11
- {hasSecondaryAction && <Button className="doubao-template-action-bar__action" type="default" {...secondaryActionButton} text={secondaryActionButton.text} onClick={secondaryActionButton.onClick}/>}
12
- {hasPrimaryAction && <Button className="doubao-template-action-bar__action" type="primary" {...primaryActionButton} text={primaryActionButton.text} onClick={primaryActionButton.onClick}/>}
9
+ return <view className="doubao-template-action-bar">
10
+ {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
+ {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}/>}
13
12
  </view>;
14
13
  }
15
14
  export { TemplateCardFooter };
@@ -1,5 +1,5 @@
1
1
  import type { TouchEvent } from '@lynx-js/types';
2
- import type { ReactElement, ReactNode } from 'react';
2
+ import type { ReactElement } from 'react';
3
3
  import type { TemplateTagTone, TemplateText } from '../../types.js';
4
4
  import './styles.scss';
5
5
  export interface TemplateProductSummaryProps {
@@ -13,8 +13,8 @@ export interface TemplateProductSummaryProps {
13
13
  spec?: string;
14
14
  /** 商品图片地址。 */
15
15
  imageSrc?: string;
16
- /** 商品自定义图片节点;优先级高于 imageSrc。 */
17
- image?: ReactNode;
16
+ /** 商品 image / svg 节点;优先级高于 imageSrc。 */
17
+ image?: ReactElement;
18
18
  /** 商品价格前缀文案,例如「券后」。 */
19
19
  pricePrefix?: string;
20
20
  /** 商品价格。 */
@@ -1 +1 @@
1
- .doubao-template-product-summary{display:flex;flex-direction:row;align-items:center;width:100%;padding:12px;box-sizing:border-box;background-color:var(--bg-base-1)}.doubao-template-product-summary__image{width:80px;height:80px;flex-shrink:0;overflow:hidden;background-color:var(--bg-base-1-overlay);border-radius:5px}.doubao-template-product-summary__content{display:flex;flex:1 1 0;flex-direction:column;min-width:0}.doubao-template-product-summary__content--with-image{margin-left:12px}.doubao-template-product-summary__line-main,.doubao-template-product-summary__line-secondary{display:flex;flex-direction:row;align-items:center;width:100%;min-width:0}.doubao-template-product-summary__line-main{height:24px}.doubao-template-product-summary__line-secondary{height:20px;margin-top:2px}.doubao-template-product-summary__title-wrap{display:flex;flex:1 1 0;flex-direction:row;align-items:center;gap:4px;min-width:0;margin-right:8px}.doubao-template-product-summary__tag{height:18px;padding:2px 4px;box-sizing:border-box;flex-shrink:0;overflow:hidden;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:14px;text-overflow:ellipsis;white-space:nowrap;background-color:var(--bg-base-2-overlay);border-radius:4px}.doubao-template-product-summary__tag--highlight{color:var(--primary-60);background-color:var(--primary-transparent-1)}.doubao-template-product-summary__price-prefix,.doubao-template-product-summary__price-value,.doubao-template-product-summary__spec,.doubao-template-product-summary__quantity{overflow:hidden;font-family:"PingFang SC",sans-serif;font-style:normal;text-overflow:ellipsis;white-space:nowrap}.doubao-template-product-summary__price{display:flex;flex-direction:row;align-items:flex-end;flex-shrink:0;color:var(--neutral-100);font-family:"PingFang SC",sans-serif;font-style:normal;font-weight:500;white-space:nowrap}.doubao-template-product-summary__price-prefix{width:22px;font-size:11px;line-height:17px}.doubao-template-product-summary__price-value{margin-left:2px;font-size:13px;line-height:19px}.doubao-template-product-summary__spec{flex:1 1 0;min-width:0;color:var(--neutral-70);font-size:13px;font-weight:400;line-height:20px}.doubao-template-product-summary__quantity{flex-shrink:0;margin-left:8px;color:var(--neutral-70);font-size:13px;font-weight:400;line-height:20px}
1
+ .doubao-template-product-summary{display:flex;flex-direction:row;align-items:center;width:100%;padding:12px;box-sizing:border-box}.doubao-template-product-summary__image{width:80px;height:80px;flex-shrink:0;overflow:hidden;background-color:var(--bg-base-1-overlay);border-radius:5px}.doubao-template-product-summary__content{display:flex;flex:1 1 0;flex-direction:column;min-width:0}.doubao-template-product-summary__content--with-image{margin-left:12px}.doubao-template-product-summary__line-main,.doubao-template-product-summary__line-secondary{display:flex;flex-direction:row;align-items:center;width:100%;min-width:0}.doubao-template-product-summary__line-main{height:24px}.doubao-template-product-summary__line-secondary{height:20px;margin-top:2px}.doubao-template-product-summary__title-wrap{display:flex;flex:1 1 0;flex-direction:row;align-items:center;gap:4px;min-width:0;margin-right:8px}.doubao-template-product-summary__tag{height:18px;padding:2px 4px;box-sizing:border-box;flex-shrink:0;overflow:hidden;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:14px;text-overflow:ellipsis;white-space:nowrap;background-color:var(--bg-base-2-overlay);border-radius:4px}.doubao-template-product-summary__tag--highlight{color:var(--primary-60);background-color:var(--primary-transparent-1)}.doubao-template-product-summary__price-prefix,.doubao-template-product-summary__price-value,.doubao-template-product-summary__spec,.doubao-template-product-summary__quantity{overflow:hidden;font-family:"PingFang SC",sans-serif;font-style:normal;text-overflow:ellipsis;white-space:nowrap}.doubao-template-product-summary__price{display:flex;flex-direction:row;align-items:flex-end;flex-shrink:0;color:var(--neutral-100);font-family:"PingFang SC",sans-serif;font-style:normal;font-weight:500;white-space:nowrap}.doubao-template-product-summary__price-prefix{width:22px;font-size:11px;line-height:17px}.doubao-template-product-summary__price-value{margin-left:2px;font-size:13px;line-height:19px}.doubao-template-product-summary__spec{flex:1 1 0;min-width:0;color:var(--neutral-70);font-size:13px;font-weight:400;line-height:20px}.doubao-template-product-summary__quantity{flex-shrink:0;margin-left:8px;color:var(--neutral-70);font-size:13px;font-weight:400;line-height:20px}
@@ -1,4 +1,4 @@
1
- import type { CSSProperties, TouchEvent } from '@lynx-js/types';
1
+ 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';
@@ -32,10 +32,6 @@ export interface CompositeCardProps {
32
32
  sections: CompositeCardSection[];
33
33
  /** 底部操作区配置。 */
34
34
  footer?: TemplateCardFooterProps;
35
- /** 卡片根节点自定义类名。 */
36
- className?: string;
37
- /** 卡片根节点自定义样式。 */
38
- style?: CSSProperties;
39
35
  /** 点击卡片根节点时触发。 */
40
36
  onClick?: (event: TouchEvent) => void;
41
37
  }
@@ -1,5 +1,5 @@
1
1
  import { useThemeClassName } from "@byted-doubao-apps/components";
2
- import { clsx } from "clsx";
2
+ import { useHostCardStyle } from "@byted-doubao-apps/framework";
3
3
  import { TemplateCardFooter } from "../components/footer/index.js";
4
4
  import { TemplateCardHeader } from "../components/header/index.js";
5
5
  import { ContentCardContent } from "../content-card/index.js";
@@ -39,9 +39,10 @@ function renderCompositeCardSection(section, index) {
39
39
  </view>;
40
40
  }
41
41
  function CompositeCard(props) {
42
- const { header, sections, footer, className, style, onClick } = props;
42
+ const { header, sections, footer, onClick } = props;
43
+ const cardStyle = useHostCardStyle();
43
44
  const visibleSections = sections.filter(isCompositeCardSectionVisible);
44
- return <view className={useThemeClassName(clsx('doubao-composite-card', className))} style={style} bindtap={onClick}>
45
+ return <view className={useThemeClassName('doubao-composite-card')} style={cardStyle} bindtap={onClick}>
45
46
  <TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
46
47
  {visibleSections.length > 0 && <view className="doubao-composite-card__sections">
47
48
  {visibleSections.map(renderCompositeCardSection)}
@@ -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;background-color:var(--bg-base-1)}.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%;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,5 +1,5 @@
1
- import type { CSSProperties, TouchEvent } from '@lynx-js/types';
2
- import type { ReactElement, ReactNode } from 'react';
1
+ import type { TouchEvent } from '@lynx-js/types';
2
+ import type { ReactElement } from 'react';
3
3
  import { type TemplateExtraAction } from '../components/extra-action/index.js';
4
4
  import { type TemplateCardFooterProps } from '../components/footer/index.js';
5
5
  import { type TemplateCardHeaderProps } from '../components/header/index.js';
@@ -12,42 +12,24 @@ export interface ContentCardProps {
12
12
  items?: ContentCardItem[];
13
13
  /** 底部操作区配置。 */
14
14
  footer?: TemplateCardFooterProps;
15
- /**
16
- * 自定义列表内容区域;传入后不再渲染默认列表内容,标题栏和底部操作区仍由模板渲染。
17
- * @deprecated 仅为兼容旧代码保留。新代码请使用 items。
18
- */
19
- children?: ReactNode;
20
- /** 卡片根节点自定义类名。 */
21
- className?: string;
22
- /** 卡片根节点自定义样式。 */
23
- style?: CSSProperties;
24
15
  /** 点击卡片根节点时触发。 */
25
16
  onClick?: (event: TouchEvent) => void;
26
17
  }
27
18
  export interface ContentCardItem {
28
19
  /** 列表项唯一标识;不传时使用数组下标。 */
29
20
  key?: TemplateKey;
30
- /** 列表项标题。字符串会按默认单行标题样式渲染,传入节点时直接渲染自定义内容。 */
31
- title?: ReactNode;
32
- /** 列表项副标题。字符串会按默认单行副标题样式渲染,传入节点时直接渲染自定义内容。 */
33
- subtitle?: ReactNode;
34
- /** 列表项补充描述。字符串会按默认单行描述样式渲染,传入节点时直接渲染自定义内容。 */
35
- description?: ReactNode;
21
+ /** 列表项标题。字符串会按默认单行标题样式渲染,节点仅支持直接传入的 Tag / Title。 */
22
+ title?: string | number | ReactElement;
23
+ /** 列表项副标题。字符串会按默认单行副标题样式渲染,节点仅支持直接传入的 Tag / Title。 */
24
+ subtitle?: string | number | ReactElement;
25
+ /** 列表项补充描述。字符串会按默认单行描述样式渲染,节点仅支持直接传入的 Tag / Title。 */
26
+ description?: string | number | ReactElement;
36
27
  /** 列表项左侧缩略图地址。 */
37
28
  thumbnailSrc?: string;
38
- /** 列表项左侧缩略视觉内容;优先级高于 thumbnailSrc。 */
39
- thumbnail?: ReactNode;
40
- /**
41
- * 列表项自定义内容;传入后不再渲染默认图文结构。
42
- * @deprecated 仅为兼容旧代码保留。新代码请使用 title、subtitle、description、thumbnail 和 action。
43
- */
44
- children?: ReactNode;
45
- /** 列表项右侧操作区;传标准控件配置时使用模板样式,传节点时直接渲染自定义内容。 */
46
- action?: TemplateExtraAction | ReactNode;
47
- /** 列表项根节点自定义类名。 */
48
- className?: string;
49
- /** 列表项根节点自定义样式。 */
50
- style?: CSSProperties;
29
+ /** 列表项左侧 image / svg 节点;优先级高于 thumbnailSrc。 */
30
+ thumbnail?: ReactElement;
31
+ /** 列表项右侧操作区;使用标准控件配置和模板样式。 */
32
+ action?: TemplateExtraAction;
51
33
  /** 点击列表项时触发。 */
52
34
  onClick?: (event: TouchEvent) => void;
53
35
  }
@@ -1,4 +1,5 @@
1
1
  import { useThemeClassName } from "@byted-doubao-apps/components";
2
+ import { useHostCardStyle } from "@byted-doubao-apps/framework";
2
3
  import { clsx } from "clsx";
3
4
  import { renderTemplateExtraAction, stopTemplateExtraActionTap } from "../components/extra-action/index.js";
4
5
  import { TemplateCardFooter } from "../components/footer/index.js";
@@ -22,15 +23,9 @@ function renderContentCardText(content, className) {
22
23
  </text>;
23
24
  return <view className={`${className}-custom`}>{content}</view>;
24
25
  }
25
- function isTemplateExtraAction(action) {
26
- return null != action && 'object' == typeof action && 'type' in action && ('button' === action.type || 'switch' === action.type || 'playback' === action.type);
27
- }
28
- function isContentCardActionEmpty(action) {
29
- return null == action || 'boolean' == typeof action || '' === action;
30
- }
31
26
  function renderContentCardAction(action) {
32
- if (isContentCardActionEmpty(action)) return null;
33
- if (isTemplateExtraAction(action)) return renderTemplateExtraAction(action, {
27
+ if (null == action) return null;
28
+ return renderTemplateExtraAction(action, {
34
29
  button: 'doubao-content-card__item-action-button',
35
30
  switch: 'doubao-content-card__item-action-switch',
36
31
  playback: 'doubao-content-card__item-action-playback',
@@ -38,7 +33,6 @@ function renderContentCardAction(action) {
38
33
  playbackDisabled: 'doubao-content-card__item-action-playback--disabled',
39
34
  playbackIcon: 'doubao-content-card__item-action-playback-icon'
40
35
  });
41
- return action;
42
36
  }
43
37
  function ContentCardItemView({ item, isLast }) {
44
38
  const { title, subtitle, description } = item;
@@ -46,22 +40,22 @@ function ContentCardItemView({ item, isLast }) {
46
40
  const subtitleNode = renderContentCardText(subtitle, 'doubao-content-card__subtitle');
47
41
  const descriptionNode = renderContentCardText(description, "doubao-content-card__description");
48
42
  const actionNode = renderContentCardAction(item.action);
49
- return <view className={clsx('doubao-content-card__item', isLast && 'doubao-content-card__item--last', !hasThumbnail && 'doubao-content-card__item--without-thumbnail', item.className)} style={item.style} {...null != item.onClick ? {
43
+ return <view className={clsx('doubao-content-card__item', isLast && 'doubao-content-card__item--last', !hasThumbnail && 'doubao-content-card__item--without-thumbnail')} {...null != item.onClick ? {
50
44
  catchtap: item.onClick
51
45
  } : {}}>
52
- {item.children ?? <view className="doubao-content-card__content">
53
- <view className="doubao-content-card__main">
54
- {hasThumbnail && <ContentCardThumbnail thumbnail={item.thumbnail} thumbnailSrc={item.thumbnailSrc}/>}
55
- <view className="doubao-content-card__text">
56
- {renderContentCardText(title, 'doubao-content-card__title')}
57
- {subtitleNode && <view className="doubao-content-card__secondary">{subtitleNode}</view>}
58
- {descriptionNode && <view className="doubao-content-card__tertiary">{descriptionNode}</view>}
59
- </view>
46
+ <view className="doubao-content-card__content">
47
+ <view className="doubao-content-card__main">
48
+ {hasThumbnail && <ContentCardThumbnail thumbnail={item.thumbnail} thumbnailSrc={item.thumbnailSrc}/>}
49
+ <view className="doubao-content-card__text">
50
+ {renderContentCardText(title, 'doubao-content-card__title')}
51
+ {subtitleNode && <view className="doubao-content-card__secondary">{subtitleNode}</view>}
52
+ {descriptionNode && <view className="doubao-content-card__tertiary">{descriptionNode}</view>}
60
53
  </view>
61
- {actionNode && <view className="doubao-content-card__item-action" catchtap={stopTemplateExtraActionTap}>
62
- {actionNode}
63
- </view>}
64
- </view>}
54
+ </view>
55
+ {actionNode && <view className="doubao-content-card__item-action" catchtap={stopTemplateExtraActionTap}>
56
+ {actionNode}
57
+ </view>}
58
+ </view>
65
59
  </view>;
66
60
  }
67
61
  function ContentCardContent({ items }) {
@@ -71,10 +65,11 @@ function ContentCardContent({ items }) {
71
65
  </view>;
72
66
  }
73
67
  function ContentCard(props) {
74
- const { header, items, footer, children, className, style, onClick } = props;
75
- return <view className={useThemeClassName(clsx('doubao-content-card', className))} style={style} bindtap={onClick} clip-radius="true">
68
+ const { header, items, footer, onClick } = props;
69
+ const cardStyle = useHostCardStyle();
70
+ return <view className={useThemeClassName('doubao-content-card')} style={cardStyle} bindtap={onClick} clip-radius="true">
76
71
  <TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
77
- {null == children ? <ContentCardContent items={items}/> : <view className="doubao-content-card__body">{children}</view>}
72
+ <ContentCardContent items={items}/>
78
73
  <TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton}/>
79
74
  </view>;
80
75
  }
@@ -1 +1 @@
1
- .doubao-content-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-content-card__body{width:100%;box-sizing:border-box;background-color:var(--bg-base-1)}.doubao-content-card__item{position:relative;width:100%;padding:12px;box-sizing:border-box;background-color:var(--bg-base-1)}.doubao-content-card__item--without-thumbnail{padding-top:16px;padding-bottom:16px}.doubao-content-card__item::after{position:absolute;right:0;bottom:0;left:104px;height:.5px;content:"";background-color:var(--neutral-transparent-1)}.doubao-content-card__item--last::after{display:none}.doubao-content-card__content{display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;min-width:0}.doubao-content-card__main{display:flex;flex:1 1 0;flex-direction:row;align-items:center;gap:12px;min-width:0}.doubao-content-card__thumbnail{width:80px;height:80px;flex-shrink:0;overflow:hidden;background-color:var(--bg-base-1-overlay);border-radius:5px}.doubao-content-card__thumbnail-image{width:100%;height:100%}.doubao-content-card__text{display:flex;flex:1 1 0;flex-direction:column;align-items:flex-start;gap:2px;min-width:0}.doubao-content-card__title{width:100%;overflow:hidden;color:var(--neutral-100);font-family:"PingFang SC",sans-serif;font-size:16px;font-style:normal;font-weight:500;line-height:24px;text-overflow:ellipsis;white-space:nowrap}.doubao-content-card__title-custom,.doubao-content-card__subtitle-custom,.doubao-content-card__description-custom{display:flex;flex-direction:row;align-items:center;width:100%;max-width:100%;overflow:hidden}.doubao-content-card__secondary,.doubao-content-card__tertiary{display:flex;flex-direction:row;align-items:center;width:100%;min-width:0;overflow:hidden}.doubao-content-card__subtitle,.doubao-content-card__description{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-content-card__item-action{display:flex;flex-shrink:0;flex-direction:row;align-items:center;justify-content:center}.doubao-content-card__item-action-button{width:auto;min-width:60px;max-width:100px}.doubao-content-card__item-action-switch{flex-shrink:0}.doubao-content-card__item-action-playback{display:flex;flex-shrink:0;align-items:center;justify-content:center;width:32px;height:32px}.doubao-content-card__item-action-playback--disabled{opacity:.4}.doubao-content-card__item-action-playback-icon{width:32px;height:32px}
1
+ .doubao-content-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-content-card__body{width:100%;box-sizing:border-box}.doubao-content-card__item{position:relative;width:100%;padding:12px;box-sizing:border-box}.doubao-content-card__item--without-thumbnail{padding-top:16px;padding-bottom:16px}.doubao-content-card__item::after{position:absolute;right:0;bottom:0;left:104px;height:.5px;content:"";background-color:var(--neutral-transparent-1)}.doubao-content-card__item--last::after{display:none}.doubao-content-card__content{display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;min-width:0}.doubao-content-card__main{display:flex;flex:1 1 0;flex-direction:row;align-items:center;gap:12px;min-width:0}.doubao-content-card__thumbnail{width:80px;height:80px;flex-shrink:0;overflow:hidden;background-color:var(--bg-base-1-overlay);border-radius:5px}.doubao-content-card__thumbnail-image{width:100%;height:100%}.doubao-content-card__text{display:flex;flex:1 1 0;flex-direction:column;align-items:flex-start;gap:2px;min-width:0}.doubao-content-card__title{width:100%;overflow:hidden;color:var(--neutral-100);font-family:"PingFang SC",sans-serif;font-size:16px;font-style:normal;font-weight:500;line-height:24px;text-overflow:ellipsis;white-space:nowrap}.doubao-content-card__title-custom,.doubao-content-card__subtitle-custom,.doubao-content-card__description-custom{display:flex;flex-direction:row;align-items:center;width:100%;max-width:100%;overflow:hidden}.doubao-content-card__secondary,.doubao-content-card__tertiary{display:flex;flex-direction:row;align-items:center;width:100%;min-width:0;overflow:hidden}.doubao-content-card__subtitle,.doubao-content-card__description{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-content-card__item-action{display:flex;flex-shrink:0;flex-direction:row;align-items:center;justify-content:center}.doubao-content-card__item-action-button{width:auto;min-width:60px;max-width:100px}.doubao-content-card__item-action-switch{flex-shrink:0}.doubao-content-card__item-action-playback{display:flex;flex-shrink:0;align-items:center;justify-content:center;width:32px;height:32px}.doubao-content-card__item-action-playback--disabled{opacity:.4}.doubao-content-card__item-action-playback-icon{width:32px;height:32px}
package/dist/index.d.ts CHANGED
@@ -2,12 +2,11 @@ export { ContentCard, type ContentCardItem, type ContentCardProps } from './cont
2
2
  export { CompositeCard, type CompositeCardContentSection, type CompositeCardOptionGroupSection, type CompositeCardProps, type CompositeCardSection, type CompositeCardTransitSection } from './composite-card/index.js';
3
3
  export type { TemplateCardHeaderProps } from './components/header/index.js';
4
4
  export type { TemplateCardFooterActionButton, TemplateCardFooterProps } from './components/footer/index.js';
5
- export type { TemplateExtraAction, TemplateExtraActionButton, TemplateExtraActionPlayback, TemplateExtraActionSwitch } from './components/extra-action/index.js';
5
+ export type { TemplateExtraAction, TemplateExtraActionAdd, TemplateExtraActionButton, TemplateExtraActionPlayback, TemplateExtraActionSwitch } from './components/extra-action/index.js';
6
6
  export { AskHumanCard, type AskHumanCardArrowPosition, type AskHumanCardItem, type AskHumanCardProps } from './ask-human-card/index.js';
7
7
  export { CheckoutCard, type CheckoutCardFeeItem, type CheckoutCardInfoItem, type CheckoutCardProductItem, type CheckoutCardProps } from './checkout-card/index.js';
8
8
  export { PriceActionCard, type PriceActionCardInfoRow, type PriceActionCardItem, type PriceActionCardProps } from './price-action-card/index.js';
9
9
  export { MapCard, type MapCardMapProps, type MapCardMetaItem, type MapCardMetaTone, type MapCardProps } from './map-card/index.js';
10
10
  export { TransitCard, type TransitCardItem, type TransitCardPrice, type TransitCardPriceAction, type TransitCardPriceActionTone, type TransitCardProps, type TransitCardTag } from './transit-card/index.js';
11
11
  export type { TemplateKey, TemplateTagTone, TemplateText } from './types.js';
12
- export { TicketOrderCard, type TicketOrderCardFeeItem, type TicketOrderCardInfoItem, type TicketOrderCardProps, type TicketOrderCardRouteItem } from './ticket-order-card/index.js';
13
12
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -5,4 +5,3 @@ export { CheckoutCard } from "./checkout-card/index.js";
5
5
  export { PriceActionCard } from "./price-action-card/index.js";
6
6
  export { MapCard } from "./map-card/index.js";
7
7
  export { TransitCard } from "./transit-card/index.js";
8
- export { TicketOrderCard } from "./ticket-order-card/index.js";
@@ -1,5 +1,5 @@
1
1
  import { type MapProps, type MapRef } from '@byted-doubao-apps/components';
2
- import type { CSSProperties, TouchEvent } from '@lynx-js/types';
2
+ import type { TouchEvent } from '@lynx-js/types';
3
3
  import { type TemplateCardFooterActionButton, type TemplateCardFooterProps } from '../components/footer/index.js';
4
4
  import type { TemplateKey, TemplateText } from '../types.js';
5
5
  import './styles.scss';
@@ -26,10 +26,6 @@ export interface MapCardProps {
26
26
  inlineActions?: TemplateCardFooterActionButton[];
27
27
  /** 底部操作区配置。 */
28
28
  footer?: TemplateCardFooterProps;
29
- /** 卡片根节点自定义类名。 */
30
- className?: string;
31
- /** 卡片根节点自定义样式。 */
32
- style?: CSSProperties;
33
29
  /** 点击卡片根节点时触发。 */
34
30
  onClick?: (event: TouchEvent) => void;
35
31
  }
@@ -1,4 +1,5 @@
1
1
  import { Button, Map, useThemeClassName } from "@byted-doubao-apps/components";
2
+ import { useHostCardStyle } from "@byted-doubao-apps/framework";
2
3
  import { clsx } from "clsx";
3
4
  import { forwardRef } from "react";
4
5
  import { TemplateCardFooter } from "../components/footer/index.js";
@@ -8,12 +9,13 @@ function hasTemplateText(value) {
8
9
  return void 0 !== value && '' !== value;
9
10
  }
10
11
  function MapCardImpl(props, ref) {
11
- const { mapProps, title, showArrow = true, metaItems = [], inlineActions = [], footer, className, style, onClick } = props;
12
+ const { mapProps, title, showArrow = true, metaItems = [], inlineActions = [], footer, onClick } = props;
13
+ const cardStyle = useHostCardStyle();
12
14
  const visibleMetaItems = metaItems.filter((item)=>hasTemplateText(item.text)).slice(0, 2);
13
15
  const visibleInlineActions = inlineActions.filter((action)=>null != action.text && action.text.length > 0).slice(0, 2);
14
16
  const hasTitle = hasTemplateText(title);
15
17
  const hasContent = hasTitle || visibleMetaItems.length > 0 || visibleInlineActions.length > 0;
16
- return <view className={useThemeClassName(clsx('doubao-map-card', className))} style={style} bindtap={onClick} clip-radius="true">
18
+ return <view className={useThemeClassName('doubao-map-card')} style={cardStyle} bindtap={onClick} clip-radius="true">
17
19
  <view className="doubao-map-card__viewport">
18
20
  <Map {...mapProps} ref={ref} className="doubao-map-card__map"/>
19
21
  </view>
@@ -1 +1 @@
1
- .doubao-map-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-map-card__viewport{position:relative;width:100%;height:168px;flex-shrink:0;box-sizing:border-box;overflow:hidden;border:1px solid var(--bg-base-2-overlay)}.doubao-map-card__map{width:100%;height:100%}.doubao-map-card__content{display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;padding:12px;box-sizing:border-box;background-color:var(--bg-base-1);border-radius:8px}.doubao-map-card__text-content{display:flex;flex:1 1 0;flex-direction:column;align-items:flex-start;gap:2px;min-width:0;overflow:hidden}.doubao-map-card__meta{display:flex;flex-direction:row;align-items:center;width:100%;height:22px;flex-shrink:0;min-width:0;overflow:hidden}.doubao-map-card__meta-entry{display:flex;flex:0 1 auto;flex-direction:row;align-items:center;min-width:0;overflow:hidden}.doubao-map-card__meta-separator{margin:0 4px;flex-shrink:0;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:13px;font-weight:400;line-height:1.5}.doubao-map-card__meta-text{min-width:0;overflow:hidden;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:13px;font-style:normal;font-weight:400;line-height:1.5;text-overflow:ellipsis;white-space:nowrap}.doubao-map-card__meta-text--highlight{color:#ff375f}.doubao-map-card__inline-actions{display:flex;flex-shrink:0;flex-direction:row;align-items:center;gap:8px}.doubao-map-card__inline-action{width:auto;min-width:60px;max-width:100px}
1
+ .doubao-map-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-map-card__viewport{position:relative;width:100%;height:168px;flex-shrink:0;box-sizing:border-box;overflow:hidden;border:1px solid var(--bg-base-2-overlay)}.doubao-map-card__map{width:100%;height:100%}.doubao-map-card__content{display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;padding:12px;box-sizing:border-box;border-radius:8px}.doubao-map-card__text-content{display:flex;flex:1 1 0;flex-direction:column;align-items:flex-start;gap:2px;min-width:0;overflow:hidden}.doubao-map-card__meta{display:flex;flex-direction:row;align-items:center;width:100%;height:22px;flex-shrink:0;min-width:0;overflow:hidden}.doubao-map-card__meta-entry{display:flex;flex:0 1 auto;flex-direction:row;align-items:center;min-width:0;overflow:hidden}.doubao-map-card__meta-separator{margin:0 4px;flex-shrink:0;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:13px;font-weight:400;line-height:1.5}.doubao-map-card__meta-text{min-width:0;overflow:hidden;color:var(--neutral-70);font-family:"PingFang SC",sans-serif;font-size:13px;font-style:normal;font-weight:400;line-height:1.5;text-overflow:ellipsis;white-space:nowrap}.doubao-map-card__meta-text--highlight{color:#ff375f}.doubao-map-card__inline-actions{display:flex;flex-shrink:0;flex-direction:row;align-items:center;gap:8px}.doubao-map-card__inline-action{width:auto;min-width:60px;max-width:100px}
@@ -1,5 +1,5 @@
1
- import type { CSSProperties, TouchEvent } from '@lynx-js/types';
2
- import type { ReactElement, ReactNode } from 'react';
1
+ import type { TouchEvent } from '@lynx-js/types';
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
5
  import type { TemplateKey, TemplateText } from '../types.js';
@@ -11,15 +11,6 @@ export interface PriceActionCardProps {
11
11
  items?: PriceActionCardItem[];
12
12
  /** 底部操作区配置。 */
13
13
  footer?: TemplateCardFooterProps;
14
- /**
15
- * 自定义卡片内容;传入后不再渲染默认列表,标题栏和底部操作区仍由模板渲染。
16
- * @deprecated 仅为兼容旧代码保留。新代码请使用 items 的结构化字段。
17
- */
18
- children?: ReactNode;
19
- /** 卡片根节点自定义类名。 */
20
- className?: string;
21
- /** 卡片根节点自定义样式。 */
22
- style?: CSSProperties;
23
14
  /** 点击卡片根节点时触发。 */
24
15
  onClick?: (event: TouchEvent) => void;
25
16
  }
@@ -34,15 +25,6 @@ export interface PriceActionCardItem {
34
25
  infoRows?: PriceActionCardInfoRow[];
35
26
  /** 右侧操作按钮文案;不传或传空字符串时不展示。 */
36
27
  actionText?: string;
37
- /**
38
- * 列表项自定义内容;传入后不再渲染默认三列结构。
39
- * @deprecated 仅为兼容旧代码保留。新代码请使用 price、badgeText、infoRows 和 actionText。
40
- */
41
- children?: ReactNode;
42
- /** 列表项根节点自定义类名。 */
43
- className?: string;
44
- /** 列表项根节点自定义样式。 */
45
- style?: CSSProperties;
46
28
  /** 点击列表项时触发。 */
47
29
  onClick?: (event: TouchEvent) => void;
48
30
  /** 点击列表项右侧操作按钮时触发。 */
@@ -1,4 +1,5 @@
1
1
  import { Button, useThemeClassName } from "@byted-doubao-apps/components";
2
+ import { useHostCardStyle } from "@byted-doubao-apps/framework";
2
3
  import { clsx } from "clsx";
3
4
  import { TemplateCardFooter } from "../components/footer/index.js";
4
5
  import { TemplateCardHeader } from "../components/header/index.js";
@@ -9,48 +10,44 @@ const PRICE_ACTION_CARD_CURRENCY_PATTERN = /^([¥¥$€£])(.+)$/;
9
10
  function isPriceActionCardTextEmpty(content) {
10
11
  return null == content || '' === content;
11
12
  }
12
- function isPriceActionCardNodeEmpty(content) {
13
- return null == content || 'boolean' == typeof content || '' === content;
14
- }
15
13
  function PriceActionCardPrice({ price }) {
16
14
  const priceText = String(price);
17
15
  const [, currency, value] = priceText.match(PRICE_ACTION_CARD_CURRENCY_PATTERN) ?? [];
18
- return <Price className="doubao-price-action-card__price" currency={currency ?? ''} value={value ?? priceText} tone="highlight"/>;
16
+ return <Price currency={currency ?? ''} value={value ?? priceText} tone="highlight"/>;
19
17
  }
20
18
  function PriceActionCardItemView({ item, isLast }) {
21
19
  const hasPrice = !isPriceActionCardTextEmpty(item.price);
22
20
  const hasBadge = !isPriceActionCardTextEmpty(item.badgeText);
23
21
  const hasAction = null != item.actionText && item.actionText.length > 0;
24
- const hasCustomContent = !isPriceActionCardNodeEmpty(item.children);
25
22
  const infoRows = (item.infoRows ?? []).filter((infoRow)=>!isPriceActionCardTextEmpty(infoRow.text)).slice(0, PRICE_ACTION_CARD_INFO_ROW_LIMIT);
26
- return <view className={clsx('doubao-price-action-card__item', isLast && 'doubao-price-action-card__item--last', item.className)} style={item.style} {...null != item.onClick ? {
23
+ return <view className={clsx('doubao-price-action-card__item', isLast && 'doubao-price-action-card__item--last')} {...null != item.onClick ? {
27
24
  catchtap: item.onClick
28
25
  } : {}}>
29
- {hasCustomContent ? item.children : <view className="doubao-price-action-card__item-content">
30
- <view className="doubao-price-action-card__value">
31
- {hasPrice && <PriceActionCardPrice price={item.price ?? ''}/>}
32
- {hasBadge && <text className="doubao-price-action-card__badge" text-maxline="1">
33
- {item.badgeText}
34
- </text>}
35
- </view>
36
- <view className="doubao-price-action-card__info">
37
- {infoRows.map((infoRow, index)=><text className="doubao-price-action-card__info-row" text-maxline="1" key={infoRow.key ?? index}>
38
- {infoRow.text}
39
- </text>)}
40
- </view>
41
- {hasAction && <Button className="doubao-price-action-card__item-action" type="default" text={item.actionText} onClick={item.onActionClick}/>}
42
- </view>}
26
+ <view className="doubao-price-action-card__item-content">
27
+ <view className="doubao-price-action-card__value">
28
+ {hasPrice && <PriceActionCardPrice price={item.price ?? ''}/>}
29
+ {hasBadge && <text className="doubao-price-action-card__badge" text-maxline="1">
30
+ {item.badgeText}
31
+ </text>}
32
+ </view>
33
+ <view className="doubao-price-action-card__info">
34
+ {infoRows.map((infoRow, index)=><text className="doubao-price-action-card__info-row" text-maxline="1" key={infoRow.key ?? index}>
35
+ {infoRow.text}
36
+ </text>)}
37
+ </view>
38
+ {hasAction && <Button className="doubao-price-action-card__item-action" type="default" text={item.actionText} onClick={item.onActionClick}/>}
39
+ </view>
43
40
  </view>;
44
41
  }
45
42
  function PriceActionCard(props) {
46
- const { header, items = [], footer, children, className, style, onClick } = props;
47
- const hasCustomContent = !isPriceActionCardNodeEmpty(children);
48
- return <view className={useThemeClassName(clsx('doubao-price-action-card', className))} style={style} bindtap={onClick} clip-radius="true">
43
+ const { header, items = [], footer, onClick } = props;
44
+ const cardStyle = useHostCardStyle();
45
+ return <view className={useThemeClassName('doubao-price-action-card')} style={cardStyle} bindtap={onClick} clip-radius="true">
49
46
  <TemplateCardHeader actionText={header?.actionText} showAction={header?.showAction} onActionClick={header?.onActionClick}/>
50
47
  <view className="doubao-price-action-card__body">
51
- {hasCustomContent ? children : <view className="doubao-price-action-card__default">
52
- {items.map((item, index)=><PriceActionCardItemView item={item} isLast={index === items.length - 1} key={item.key ?? index}/>)}
53
- </view>}
48
+ <view className="doubao-price-action-card__default">
49
+ {items.map((item, index)=><PriceActionCardItemView item={item} isLast={index === items.length - 1} key={item.key ?? index}/>)}
50
+ </view>
54
51
  </view>
55
52
  <TemplateCardFooter primaryActionButton={footer?.primaryActionButton} secondaryActionButton={footer?.secondaryActionButton}/>
56
53
  </view>;
@@ -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;background-color:var(--bg-base-1)}.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;background-color:var(--bg-base-1)}.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__price.doubao-price{width:100%;min-width:0;overflow:hidden}.doubao-price-action-card__price.doubao-price .doubao-price__amount,.doubao-price-action-card__price.doubao-price .doubao-price__main,.doubao-price-action-card__price.doubao-price .doubao-price__integer-group{max-width:100%;min-width:0;overflow:hidden}.doubao-price-action-card__price.doubao-price .doubao-price__main,.doubao-price-action-card__price.doubao-price .doubao-price__integer-group,.doubao-price-action-card__price.doubao-price .doubao-price__integer{flex-shrink:1}.doubao-price-action-card__price.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-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)}
@@ -2,5 +2,5 @@ import type { IconName, IconProps } from './types.js';
2
2
  import './styles.scss';
3
3
  export type { IconName, IconProps } from './types.js';
4
4
  export declare function isIconSupported(name: string): name is IconName;
5
- export declare function Icon({ name, className, style }: IconProps): any;
5
+ export declare function Icon({ name }: IconProps): any;
6
6
  //# sourceMappingURL=index.d.ts.map