@doubao-dev/template 0.6.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,6 +37,7 @@ export default function ProductCard() {
37
37
  | --- | --- |
38
38
  | 商品、服务、内容列表 | [ContentCard](../../../docs/templates/content-card.mdx) |
39
39
  | 报价与方案选择 | [PriceActionCard](../../../docs/templates/price-action-card.mdx) |
40
+ | 优惠券展示与使用 | [CouponCard](../../../docs/templates/coupon-card.mdx) |
40
41
  | 下单、支付确认 | [CheckoutCard](../../../docs/templates/checkout-card.mdx) |
41
42
  | 交通票务列表 | [TransitCard](../../../docs/templates/transit-card.mdx) |
42
43
  | 地图、位置和叫车信息 | [MapCard](../../../docs/templates/map-card.mdx) |
@@ -32,8 +32,12 @@ export interface TemplateTransportSummaryProps {
32
32
  priceActionTone?: TemplateTransportSummaryPriceActionTone;
33
33
  /** 是否展示价格操作文案右侧箭头。 */
34
34
  showPriceActionIcon?: boolean;
35
+ /** 是否展示价格下方区域的加载状态。 */
36
+ priceExtraLoading?: boolean;
35
37
  /** 价格下方的标签内容。 */
36
38
  tag?: ReactNode;
39
+ /** 标签色调,用于下方区域加载图标的配色。 */
40
+ tagTone?: 'marketing' | 'neutral';
37
41
  /** 根节点自定义类名。 */
38
42
  className?: string;
39
43
  /** 点击左侧行程区域时触发。 */
@@ -43,17 +43,32 @@ function renderTemplateTransportSummaryPriceAction(actionText, actionTone, showA
43
43
  {showActionIcon ? <TemplateChevronRightIcon className="doubao-template-transport-summary__price-action-icon" color={'highlight' === actionTone ? '#ff375f' : isDark ? '#bababa' : '#666666'}/> : null}
44
44
  </view>;
45
45
  }
46
- function renderTemplateTransportSummaryPrice(price, tag, actionText, actionTone, showActionIcon, isDark, onPriceClick) {
46
+ function renderTemplateTransportSummaryPrice(price, tag, actionText, actionTone, showActionIcon, loading, tagTone, isDark, onPriceClick) {
47
47
  const hasPrice = !isTemplateTransportSummaryNodeEmpty(price);
48
48
  const hasTag = !isTemplateTransportSummaryNodeEmpty(tag);
49
49
  const actionNode = renderTemplateTransportSummaryPriceAction(actionText, actionTone, showActionIcon, isDark);
50
50
  const hasAction = null != actionNode;
51
+ const extraContent = hasAction ? actionNode : hasTag ? tag : null;
52
+ const loadingTone = hasAction ? actionTone : `tag-${tagTone}`;
51
53
  if (!hasPrice && !hasTag && !hasAction) return null;
52
54
  return <view className={clsx('doubao-template-transport-summary__price', hasAction && 'doubao-template-transport-summary__price--with-action', !hasAction && hasTag && 'doubao-template-transport-summary__price--with-tag')} {...null != onPriceClick ? {
53
55
  catchtap: onPriceClick
54
56
  } : {}}>
55
57
  {hasPrice && price}
56
- {hasAction ? actionNode : hasTag && tag}
58
+ {null != extraContent ? <view className="doubao-template-transport-summary__price-extra" {...loading ? {
59
+ catchtap: ()=>void 0
60
+ } : {}}>
61
+ <view className={clsx('doubao-template-transport-summary__price-extra-content', loading && 'doubao-template-transport-summary__price-extra-content--loading')}>
62
+ {extraContent}
63
+ </view>
64
+ {loading ? <view className="doubao-template-transport-summary__price-extra-loading-overlay">
65
+ <view className={clsx('doubao-template-transport-summary__price-extra-loading', `doubao-template-transport-summary__price-extra-loading--${loadingTone}`)}>
66
+ {Array.from({
67
+ length: 8
68
+ }, (_, index)=><view key={index} className={`doubao-template-transport-summary__price-extra-loading-spoke doubao-template-transport-summary__price-extra-loading-spoke--${index}`}/>)}
69
+ </view>
70
+ </view> : null}
71
+ </view> : null}
57
72
  </view>;
58
73
  }
59
74
  function TemplateTransportSummaryArrowIcon({ showDot }) {
@@ -94,7 +109,7 @@ function renderTemplateTransportSummaryTransfer({ content, topText, showDot, bot
94
109
  }
95
110
  function TemplateTransportSummary(props) {
96
111
  const theme = useTheme();
97
- const { title, departureMain, departureSub, transfer, transferTop, showTransferDot, transferBottom, arrivalMain, arrivalDayOffset, arrivalSub, price, priceActionText, priceActionTone = 'highlight', showPriceActionIcon = true, tag, className, onRouteClick, onPriceClick } = props;
112
+ const { title, departureMain, departureSub, transfer, transferTop, showTransferDot, transferBottom, arrivalMain, arrivalDayOffset, arrivalSub, price, priceActionText, priceActionTone = 'highlight', showPriceActionIcon = true, priceExtraLoading = false, tag, tagTone = 'marketing', className, onRouteClick, onPriceClick } = props;
98
113
  const departureNode = renderTemplateTransportSummaryPoint({
99
114
  mainText: departureMain,
100
115
  subText: departureSub
@@ -116,7 +131,7 @@ function TemplateTransportSummary(props) {
116
131
  {arrivalDayOffsetNode}
117
132
  </view>;
118
133
  const titleNode = renderTemplateTransportSummaryNodeField(title, 'doubao-template-transport-summary__title', 'doubao-template-transport-summary__title-text');
119
- const priceNode = renderTemplateTransportSummaryPrice(price, tag, priceActionText, priceActionTone, showPriceActionIcon, 'dark' === theme, onPriceClick);
134
+ const priceNode = renderTemplateTransportSummaryPrice(price, tag, priceActionText, priceActionTone, showPriceActionIcon, priceExtraLoading, tagTone, 'dark' === theme, onPriceClick);
120
135
  const hasRoute = Boolean(departureNode || transferNode || arrivalNode);
121
136
  const hasRouteRow = hasRoute || null != priceNode;
122
137
  if (null == titleNode && !hasRouteRow) return null;
@@ -1 +1 @@
1
- .doubao-template-transport-summary{position:relative;display:flex;flex-direction:column;justify-content:flex-start;width:100%;min-width:0;box-sizing:border-box;padding:12px 12px 16px}.doubao-template-transport-summary__route-hit-area{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1}.doubao-template-transport-summary__title,.doubao-template-transport-summary__route-point-main,.doubao-template-transport-summary__route-point-sub,.doubao-template-transport-summary__transfer-label,.doubao-template-transport-summary__price{display:flex;flex-direction:row;align-items:center;min-width:0;overflow:hidden;flex-shrink:0}.doubao-template-transport-summary__title{height:20px;max-width:100%;box-sizing:border-box}.doubao-template-transport-summary__title-text,.doubao-template-transport-summary__route-point-main-text,.doubao-template-transport-summary__arrival-day-offset-text,.doubao-template-transport-summary__route-point-sub-text,.doubao-template-transport-summary__transfer-label-text{overflow:hidden;font-family:"PingFang SC",sans-serif;font-style:normal;text-overflow:ellipsis;white-space:nowrap}.doubao-template-transport-summary__title-text{color:var(--neutral-100);font-size:13px;font-weight:400;line-height:20px}.doubao-template-transport-summary__route-row{position:relative;display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;align-content:flex-start;justify-content:space-between;width:100%;height:46px;min-width:0;margin-top:2px;overflow:hidden}.doubao-template-transport-summary__route-point{display:flex;flex-shrink:0;flex-direction:column;justify-content:center;width:66px;min-width:0;height:42px}.doubao-template-transport-summary__route-point--arrival{align-items:flex-end}.doubao-template-transport-summary__arrival{position:relative;display:flex;flex-shrink:0;width:66px;min-width:0;height:42px}.doubao-template-transport-summary__arrival .doubao-template-transport-summary__route-point{width:100%;height:42px}.doubao-template-transport-summary__route-point-main,.doubao-template-transport-summary__route-point-sub{width:100%}.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-main,.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-sub{justify-content:flex-end}.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-main-text,.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-sub-text{text-align:right}.doubao-template-transport-summary__route-point-main{height:22px}.doubao-template-transport-summary__route-point-sub{height:16px;margin-top:2px}.doubao-template-transport-summary__route-point-main-text{min-width:0;color:var(--neutral-100);font-family:"SF Pro",sans-serif;font-size:17px;font-weight:600;line-height:22px}.doubao-template-transport-summary__arrival-day-offset{position:absolute;top:2px;left:100%;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;height:14px}.doubao-template-transport-summary__arrival-day-offset-text{color:var(--neutral-100);font-size:10px;font-weight:400;line-height:normal}.doubao-template-transport-summary__route-point-sub-text{color:var(--neutral-70);font-size:12px;font-weight:400;line-height:16px}.doubao-template-transport-summary__transfer-label-text{color:var(--neutral-50);font-size:10px;font-weight:400;line-height:14px}.doubao-template-transport-summary__transfer{display:flex;flex:none;flex-direction:row;align-items:center;justify-content:center;width:56px;min-width:0;height:42px;box-sizing:border-box}.doubao-template-transport-summary__transfer-inner{display:flex;flex-direction:column;align-items:center;justify-content:center;width:56px;min-width:0;height:38px}.doubao-template-transport-summary__transfer-label{height:14px}.doubao-template-transport-summary__transfer-arrow{display:flex;flex-direction:row;align-items:center;justify-content:center;width:36px;height:6px;flex-shrink:0}.doubao-template-transport-summary__transfer-arrow-icon{width:36px;height:6px;flex-shrink:0}.doubao-template-transport-summary__price{position:relative;z-index:2;flex:0 0 88px;flex-direction:column;align-items:flex-end;justify-content:center;width:88px;height:42px;box-sizing:border-box}.doubao-template-transport-summary__price>.doubao-price{justify-content:flex-end;width:100%;min-width:0;overflow:hidden}.doubao-template-transport-summary__price .doubao-price__amount,.doubao-template-transport-summary__price .doubao-price__main,.doubao-template-transport-summary__price .doubao-price__integer-group{max-width:100%;min-width:0;overflow:hidden}.doubao-template-transport-summary__price .doubao-price__main,.doubao-template-transport-summary__price .doubao-price__integer-group,.doubao-template-transport-summary__price .doubao-price__integer{flex-shrink:1}.doubao-template-transport-summary__price .doubao-price__integer{min-width:0;overflow:hidden;text-overflow:ellipsis}.doubao-template-transport-summary__price--with-action{gap:1px;height:39px}.doubao-template-transport-summary__price-action{display:flex;flex-direction:row;align-items:center;justify-content:flex-end;width:100%;min-width:0;height:16px;overflow:hidden}.doubao-template-transport-summary__price-action-text{min-width:0;overflow:hidden;font-family:"PingFang SC",sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:16px;text-align:right;text-overflow:ellipsis;white-space:nowrap}.doubao-template-transport-summary__price-action-text--highlight{color:#ff375f}.doubao-template-transport-summary__price-action-text--muted{color:var(--neutral-70)}.doubao-template-transport-summary__price-action-icon{width:10px;height:10px;margin-right:-3px;flex-shrink:0;opacity:.34}.doubao-template-transport-summary__price--with-tag{gap:4px;height:46px}
1
+ .doubao-template-transport-summary{position:relative;display:flex;flex-direction:column;justify-content:flex-start;width:100%;min-width:0;box-sizing:border-box;padding:12px 12px 16px}.doubao-template-transport-summary__price-extra{position:relative;display:flex;width:100%;min-width:0}.doubao-template-transport-summary__price-extra-content{display:flex;flex-direction:row;align-items:center;justify-content:flex-end;width:100%;min-width:0}.doubao-template-transport-summary__price-extra-content--loading{visibility:hidden}.doubao-template-transport-summary__price-extra-loading-overlay{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:flex-end}.doubao-template-transport-summary__price-extra-loading{position:relative;width:16px;height:16px;flex-shrink:0}.doubao-template-transport-summary__price-extra-loading-spoke{position:absolute;top:1.333px;left:7.167px;width:1.667px;height:4.167px;border-radius:999px;transform-origin:50% 6.667px;animation:doubao-template-price-extra-loading-fade 1s linear infinite}.doubao-template-transport-summary__price-extra-loading--highlight .doubao-template-transport-summary__price-extra-loading-spoke,.doubao-template-transport-summary__price-extra-loading--tag-marketing .doubao-template-transport-summary__price-extra-loading-spoke{background-color:#ff375f}.doubao-template-transport-summary__price-extra-loading--muted .doubao-template-transport-summary__price-extra-loading-spoke{background-color:var(--neutral-70)}.doubao-template-transport-summary__price-extra-loading--tag-neutral .doubao-template-transport-summary__price-extra-loading-spoke{background-color:#666}.doubao-theme-dark .doubao-template-transport-summary__price-extra-loading--tag-marketing .doubao-template-transport-summary__price-extra-loading-spoke{background-color:#ff5c7c}.doubao-theme-dark .doubao-template-transport-summary__price-extra-loading--tag-neutral .doubao-template-transport-summary__price-extra-loading-spoke{background-color:#bababa}.doubao-template-transport-summary__price-extra-loading-spoke--0{transform:rotate(0deg);animation-delay:0s}.doubao-template-transport-summary__price-extra-loading-spoke--1{transform:rotate(45deg);animation-delay:-0.125s}.doubao-template-transport-summary__price-extra-loading-spoke--2{transform:rotate(90deg);animation-delay:-0.25s}.doubao-template-transport-summary__price-extra-loading-spoke--3{transform:rotate(135deg);animation-delay:-0.375s}.doubao-template-transport-summary__price-extra-loading-spoke--4{transform:rotate(180deg);animation-delay:-0.5s}.doubao-template-transport-summary__price-extra-loading-spoke--5{transform:rotate(225deg);animation-delay:-0.625s}.doubao-template-transport-summary__price-extra-loading-spoke--6{transform:rotate(270deg);animation-delay:-0.75s}.doubao-template-transport-summary__price-extra-loading-spoke--7{transform:rotate(315deg);animation-delay:-0.875s}.doubao-template-transport-summary__route-hit-area{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1}.doubao-template-transport-summary__title,.doubao-template-transport-summary__route-point-main,.doubao-template-transport-summary__route-point-sub,.doubao-template-transport-summary__transfer-label,.doubao-template-transport-summary__price{display:flex;flex-direction:row;align-items:center;min-width:0;overflow:hidden;flex-shrink:0}.doubao-template-transport-summary__title{height:20px;max-width:100%;box-sizing:border-box}.doubao-template-transport-summary__title-text,.doubao-template-transport-summary__route-point-main-text,.doubao-template-transport-summary__arrival-day-offset-text,.doubao-template-transport-summary__route-point-sub-text,.doubao-template-transport-summary__transfer-label-text{overflow:hidden;font-family:"PingFang SC",sans-serif;font-style:normal;text-overflow:ellipsis;white-space:nowrap}.doubao-template-transport-summary__title-text{color:var(--neutral-100);font-size:13px;font-weight:400;line-height:20px}.doubao-template-transport-summary__route-row{position:relative;display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;align-content:flex-start;justify-content:space-between;width:100%;height:46px;min-width:0;margin-top:2px;overflow:hidden}.doubao-template-transport-summary__route-point{display:flex;flex-shrink:0;flex-direction:column;justify-content:center;width:66px;min-width:0;height:42px}.doubao-template-transport-summary__route-point--arrival{align-items:flex-end}.doubao-template-transport-summary__arrival{position:relative;display:flex;flex-shrink:0;width:66px;min-width:0;height:42px}.doubao-template-transport-summary__arrival .doubao-template-transport-summary__route-point{width:100%;height:42px}.doubao-template-transport-summary__route-point-main,.doubao-template-transport-summary__route-point-sub{width:100%}.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-main,.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-sub{justify-content:flex-end}.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-main-text,.doubao-template-transport-summary__route-point--arrival .doubao-template-transport-summary__route-point-sub-text{text-align:right}.doubao-template-transport-summary__route-point-main{height:22px}.doubao-template-transport-summary__route-point-sub{height:16px;margin-top:2px}.doubao-template-transport-summary__route-point-main-text{min-width:0;color:var(--neutral-100);font-family:"SF Pro",sans-serif;font-size:17px;font-weight:600;line-height:22px}.doubao-template-transport-summary__arrival-day-offset{position:absolute;top:2px;left:100%;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;height:14px}.doubao-template-transport-summary__arrival-day-offset-text{color:var(--neutral-100);font-size:10px;font-weight:400;line-height:normal}.doubao-template-transport-summary__route-point-sub-text{color:var(--neutral-70);font-size:12px;font-weight:400;line-height:16px}.doubao-template-transport-summary__transfer-label-text{color:var(--neutral-50);font-size:10px;font-weight:400;line-height:14px}.doubao-template-transport-summary__transfer{display:flex;flex:none;flex-direction:row;align-items:center;justify-content:center;width:56px;min-width:0;height:42px;box-sizing:border-box}.doubao-template-transport-summary__transfer-inner{display:flex;flex-direction:column;align-items:center;justify-content:center;width:56px;min-width:0;height:38px}.doubao-template-transport-summary__transfer-label{height:14px}.doubao-template-transport-summary__transfer-arrow{display:flex;flex-direction:row;align-items:center;justify-content:center;width:36px;height:6px;flex-shrink:0}.doubao-template-transport-summary__transfer-arrow-icon{width:36px;height:6px;flex-shrink:0}.doubao-template-transport-summary__price{position:relative;z-index:2;flex:0 0 88px;flex-direction:column;align-items:flex-end;justify-content:center;width:88px;height:42px;box-sizing:border-box}.doubao-template-transport-summary__price>.doubao-price{justify-content:flex-end;width:100%;min-width:0;overflow:hidden}.doubao-template-transport-summary__price .doubao-price__amount,.doubao-template-transport-summary__price .doubao-price__main,.doubao-template-transport-summary__price .doubao-price__integer-group{max-width:100%;min-width:0;overflow:hidden}.doubao-template-transport-summary__price .doubao-price__main,.doubao-template-transport-summary__price .doubao-price__integer-group,.doubao-template-transport-summary__price .doubao-price__integer{flex-shrink:1}.doubao-template-transport-summary__price .doubao-price__integer{min-width:0;overflow:hidden;text-overflow:ellipsis}.doubao-template-transport-summary__price--with-action{gap:1px;height:39px}.doubao-template-transport-summary__price-action{display:flex;flex-direction:row;align-items:center;justify-content:flex-end;width:100%;min-width:0;height:16px;overflow:hidden}.doubao-template-transport-summary__price-action-text{min-width:0;overflow:hidden;font-family:"PingFang SC",sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:16px;text-align:right;text-overflow:ellipsis;white-space:nowrap}.doubao-template-transport-summary__price-action-text--highlight{color:#ff375f}.doubao-template-transport-summary__price-action-text--muted{color:var(--neutral-70)}.doubao-template-transport-summary__price-action-icon{width:10px;height:10px;margin-right:-3px;flex-shrink:0;opacity:.34}.doubao-template-transport-summary__price--with-tag{gap:4px;height:46px}@keyframes doubao-template-price-extra-loading-fade{0%{opacity:1}100%{opacity:.2}}
@@ -0,0 +1,2 @@
1
+ const divider_namespaceObject = "data:image/svg+xml;base64,PHN2ZyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIiBvdmVyZmxvdz0idmlzaWJsZSIgc3R5bGU9ImRpc3BsYXk6IGJsb2NrOyIgd2lkdGg9IjI2IiBoZWlnaHQ9IjEiIHZpZXdCb3g9IjAgMCAyNiAxIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBpZD0iTGluZSA0OSIgZD0iTTAgMC41SDAuOTI4NTcxTTI2IDAuNUgyNS4wNzE0TTIuNzg1NzEgMC41SDQuNjQyODZNNi41IDAuNUg4LjM1NzE0TTEwLjIxNDMgMC41SDEyLjA3MTRNMTMuOTI4NiAwLjVIMTUuNzg1N00xNy42NDI5IDAuNUgxOS41TTIxLjM1NzEgMC41SDIzLjIxNDMiIHN0cm9rZT0iYmxhY2siIHN0cm9rZS1vcGFjaXR5PSIwLjEiLz4KPC9zdmc+Cg==";
2
+ export default divider_namespaceObject;
@@ -0,0 +1,3 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="26" height="1" viewBox="0 0 26 1" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path id="Line 49" d="M0 0.5H0.928571M26 0.5H25.0714M2.78571 0.5H4.64286M6.5 0.5H8.35714M10.2143 0.5H12.0714M13.9286 0.5H15.7857M17.6429 0.5H19.5M21.3571 0.5H23.2143" stroke="black" stroke-opacity="0.1"/>
3
+ </svg>
@@ -0,0 +1,2 @@
1
+ const title_separator_namespaceObject = "data:image/svg+xml;base64,PHN2ZyBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIiBvdmVyZmxvdz0idmlzaWJsZSIgc3R5bGU9ImRpc3BsYXk6IGJsb2NrOyIgd2lkdGg9IjAuNiIgaGVpZ2h0PSI5LjYiIHZpZXdCb3g9IjAgMCAwLjYgOS42IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBpZD0iUmVjdGFuZ2xlIDM0NjI0MjExNyIgZD0iTTAgMC4zQzAgMC4xMzQzMTUgMC4xMzQzMTUgMCAwLjMgMEMwLjQ2NTY4NiAwIDAuNiAwLjEzNDMxNSAwLjYgMC4zVjkuM0MwLjYgOS40NjU2OSAwLjQ2NTY4NiA5LjYgMC4zIDkuNkMwLjEzNDMxNSA5LjYgMCA5LjQ2NTY5IDAgOS4zVjAuM1oiIGZpbGw9ImJsYWNrIiBmaWxsLW9wYWNpdHk9IjAuMSIvPgo8L3N2Zz4K";
2
+ export default title_separator_namespaceObject;
@@ -0,0 +1,3 @@
1
+ <svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="0.6" height="9.6" viewBox="0 0 0.6 9.6" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path id="Rectangle 346242117" d="M0 0.3C0 0.134315 0.134315 0 0.3 0C0.465686 0 0.6 0.134315 0.6 0.3V9.3C0.6 9.46569 0.465686 9.6 0.3 9.6C0.134315 9.6 0 9.46569 0 9.3V0.3Z" fill="black" fill-opacity="0.1"/>
3
+ </svg>
@@ -0,0 +1,38 @@
1
+ import type { TouchEvent } from '@lynx-js/types';
2
+ import { type ReactElement } from 'react';
3
+ import type { TemplateKey } from '../types.js';
4
+ import './styles.scss';
5
+ export interface CouponCardProps {
6
+ /** 优惠券列表;按数量自动切换单券、双券和多券布局,空数组不展示。 */
7
+ items?: CouponCardItem[];
8
+ /** 点击卡片空白区域时触发;有独立点击回调的券和操作按钮会阻止冒泡。 */
9
+ onClick?: (event: TouchEvent) => void;
10
+ }
11
+ export interface CouponCardItem {
12
+ /** 优惠券唯一标识;不传时使用数组下标。 */
13
+ key?: TemplateKey;
14
+ /** 券面数值,例如 20 或 8.5。 */
15
+ value: string | number;
16
+ /** 数值单位,例如“元”或“折”。@defaultValue '元' */
17
+ unit?: string;
18
+ /** 使用门槛,例如“满20.01可用”或“无门槛”。 */
19
+ condition?: string;
20
+ /** 券来源名称;单券时与标题并列,双券和多券时展示在门槛下方。 */
21
+ sourceName?: string;
22
+ /** 券标题,仅单券布局展示。 */
23
+ title?: string;
24
+ /** 有效期说明,仅单券布局展示。 */
25
+ validityText?: string;
26
+ /** 操作按钮文案;空字符串隐藏按钮。@defaultValue '立即用' */
27
+ actionText?: string;
28
+ /** 是否不可用;整体半透明并禁止券及按钮点击。@defaultValue false */
29
+ disabled?: boolean;
30
+ /** 操作按钮是否加载中;保持按钮宽度并禁止重复点击。@defaultValue false */
31
+ loading?: boolean;
32
+ /** 点击券内容时触发。 */
33
+ onClick?: (event: TouchEvent) => void;
34
+ /** 点击操作按钮时触发,不触发券或卡片的 onClick。 */
35
+ onActionClick?: (event?: TouchEvent) => void;
36
+ }
37
+ export declare function CouponCard({ items, onClick }: CouponCardProps): ReactElement | null;
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,90 @@
1
+ import { Button, ScrollView, useThemeClassName } from "@byted-doubao-apps/components";
2
+ import { clsx } from "clsx";
3
+ import { useState } from "react";
4
+ import { useHostCardStyle } from "../utils/use-host-card-style.js";
5
+ import divider from "./assets/divider.js";
6
+ import title_separator from "./assets/title-separator.js";
7
+ import "./styles.css";
8
+ function CouponValue({ item }) {
9
+ const { value, unit = '元', condition } = item;
10
+ return <view className="doubao-coupon-card__prize">
11
+ <view className="doubao-coupon-card__amount">
12
+ <text className="doubao-coupon-card__value" text-maxline="1">
13
+ {value}
14
+ </text>
15
+ {unit ? <text className="doubao-coupon-card__unit" text-maxline="1">
16
+ {unit}
17
+ </text> : null}
18
+ </view>
19
+ {condition ? <text className="doubao-coupon-card__condition" text-maxline="1">
20
+ {condition}
21
+ </text> : null}
22
+ </view>;
23
+ }
24
+ function CouponItem({ item, layout }) {
25
+ const [pressed, setPressed] = useState(false);
26
+ const { sourceName, title, validityText, actionText = '立即用', disabled = false } = item;
27
+ const single = 'single' === layout;
28
+ const hasInfo = Boolean(sourceName || title || validityText);
29
+ const handleTouchEnd = ()=>setPressed(false);
30
+ const handleTap = (event)=>{
31
+ setPressed(false);
32
+ if (!disabled) item.onClick?.(event);
33
+ };
34
+ return <view className={clsx('doubao-coupon-card__item', {
35
+ 'doubao-coupon-card__item--disabled': disabled,
36
+ 'doubao-coupon-card__item--pressed': pressed && !disabled
37
+ })} {...disabled || item.onClick ? {
38
+ catchtap: handleTap
39
+ } : {}} bindtouchstart={()=>{
40
+ if (!disabled) setPressed(true);
41
+ }} bindtouchend={handleTouchEnd} bindtouchmove={handleTouchEnd} clip-radius="true">
42
+ {single ? <view className="doubao-coupon-card__content">
43
+ <view className="doubao-coupon-card__value-area">
44
+ <CouponValue item={item}/>
45
+ </view>
46
+ {hasInfo ? <view className="doubao-coupon-card__info">
47
+ <view className="doubao-coupon-card__divider-slot">
48
+ <image className="doubao-coupon-card__divider" src={divider}/>
49
+ </view>
50
+ <view className="doubao-coupon-card__details">
51
+ {sourceName || title ? <view className="doubao-coupon-card__heading">
52
+ {sourceName ? <text className="doubao-coupon-card__source" text-maxline="1">
53
+ {sourceName}
54
+ </text> : null}
55
+ {sourceName && title ? <image className="doubao-coupon-card__title-separator" src={title_separator}/> : null}
56
+ {title ? <text className="doubao-coupon-card__title" text-maxline="1">
57
+ {title}
58
+ </text> : null}
59
+ </view> : null}
60
+ {validityText ? <text className="doubao-coupon-card__validity" text-maxline="1">
61
+ {validityText}
62
+ </text> : null}
63
+ </view>
64
+ </view> : null}
65
+ </view> : <view className="doubao-coupon-card__compact-info">
66
+ <CouponValue item={item}/>
67
+ {sourceName ? <text className="doubao-coupon-card__compact-source" text-maxline="1">
68
+ {sourceName}
69
+ </text> : null}
70
+ </view>}
71
+ {actionText ? <Button className="doubao-coupon-card__action" type="plain" size="mini" text={actionText} disabled={disabled} loading={item.loading} showDisabledStyle={false} onClick={item.onActionClick}/> : null}
72
+ </view>;
73
+ }
74
+ function CouponCard({ items = [], onClick }) {
75
+ const themeClassName = useThemeClassName();
76
+ const cardStyle = useHostCardStyle();
77
+ const layout = 1 === items.length ? 'single' : 2 === items.length ? 'double' : 'multiple';
78
+ if (0 === items.length) return null;
79
+ const coupons = items.map((item, index)=><CouponItem key={item.key ?? index} item={item} layout={layout}/>);
80
+ return <view className={clsx('doubao-coupon-card', `doubao-coupon-card--${layout}`, themeClassName)} style={cardStyle} bindtap={onClick}>
81
+ {'multiple' === layout ? <ScrollView className="doubao-coupon-card__scroll" scrollOrientation="horizontal" scrollBarEnable={false}>
82
+ <view className="doubao-coupon-card__items" style={{
83
+ minWidth: `${96 * items.length + (items.length - 1) * 4}px`
84
+ }}>
85
+ {coupons}
86
+ </view>
87
+ </ScrollView> : <view className="doubao-coupon-card__items">{coupons}</view>}
88
+ </view>;
89
+ }
90
+ export { CouponCard };
@@ -0,0 +1 @@
1
+ .doubao-coupon-card{width:100%;min-width:0;box-sizing:border-box}.doubao-coupon-card--single{max-width:400px}.doubao-coupon-card--double{max-width:408px}.doubao-coupon-card__items{display:flex;flex-direction:row;align-items:stretch;gap:8px;width:100%;box-sizing:border-box}.doubao-coupon-card__item{position:relative;display:flex;flex:1 1 0;flex-direction:row;align-items:center;gap:4px;min-width:0;height:80px;padding:0 12px 0 8px;box-sizing:border-box;overflow:hidden;background-color:#fff3ee;border:.5px solid #fae5dc;border-radius:10px}.doubao-coupon-card__item--disabled{opacity:.5}.doubao-coupon-card__item--pressed::after{position:absolute;top:0;right:0;bottom:0;left:0;content:"";pointer-events:none;background-color:var(--neutral-transparent-1)}.doubao-coupon-card__content{display:flex;flex:1 1 0;flex-direction:row;align-items:center;gap:4px;min-width:0}.doubao-coupon-card__value-area{display:flex;align-items:center;justify-content:center;width:74px;height:74px;flex-shrink:0;overflow:hidden}.doubao-coupon-card__prize{display:flex;flex-direction:column;align-items:center;gap:4px;max-width:100%;min-width:0}.doubao-coupon-card__amount{display:flex;flex-direction:row;align-items:flex-end;justify-content:center;gap:1px;max-width:100%;height:22px}.doubao-coupon-card__value,.doubao-coupon-card__unit,.doubao-coupon-card__condition,.doubao-coupon-card__source,.doubao-coupon-card__title,.doubao-coupon-card__validity,.doubao-coupon-card__compact-source{display:block;min-width:0;overflow:hidden;font-family:"PingFang SC",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-style:normal;white-space:nowrap;text-overflow:ellipsis}.doubao-coupon-card__value{flex-shrink:1;color:#ff375f;font-family:"SF Pro",sans-serif;font-size:24px;font-weight:600;line-height:24px;letter-spacing:-0.48px}.doubao-coupon-card__unit{flex-shrink:0;color:#ff375f;font-size:11px;font-weight:600;line-height:17px}.doubao-coupon-card__condition,.doubao-coupon-card__compact-source{max-width:100%;color:#ff375f;font-size:11px;font-weight:400;line-height:17px;letter-spacing:-0.22px;text-align:center}.doubao-coupon-card__info{display:flex;flex:1 1 0;flex-direction:row;align-items:center;gap:8px;min-width:0}.doubao-coupon-card__divider-slot{position:relative;width:0;height:26px;flex-shrink:0}.doubao-coupon-card__divider{position:absolute;top:12.5px;left:-13px;width:26px;height:1px;transform:rotate(90deg)}.doubao-coupon-card__details{display:flex;flex:1 1 0;flex-direction:column;gap:4px;min-width:0}.doubao-coupon-card__heading{display:flex;flex-direction:row;align-items:center;gap:6px;width:100%;min-width:0;height:21px;overflow:hidden}.doubao-coupon-card__source,.doubao-coupon-card__title{flex:0 1 auto;color:var(--neutral-100);font-size:15px;font-weight:500;line-height:21px}.doubao-coupon-card__title-separator{width:.6px;height:9.6px;flex-shrink:0}.doubao-coupon-card__validity{width:100%;color:var(--neutral-80-transparent);font-size:11px;font-weight:400;line-height:15px;letter-spacing:-0.22px}.doubao-coupon-card__compact-info{display:flex;flex:1 1 0;flex-direction:column;align-items:center;justify-content:center;min-width:0;overflow:hidden}.doubao-coupon-card__compact-source{color:var(--neutral-50)}.doubao-coupon-card__action.doubao-button{width:auto;min-width:60px;max-width:100px;height:28px;padding:0 12px;flex-shrink:0;background-color:rgba(0,0,0,0);border:.5px solid var(--neutral-transparent-2);border-radius:40px}.doubao-coupon-card__action.doubao-button .doubao-button-text{min-width:0;flex-shrink:1;overflow:hidden;color:var(--neutral-100);font-size:12px;font-weight:500;line-height:17px;text-overflow:ellipsis}.doubao-coupon-card--double .doubao-coupon-card__item{gap:8px;max-width:200px}.doubao-coupon-card--double .doubao-coupon-card__amount,.doubao-coupon-card--multiple .doubao-coupon-card__amount{height:18px}.doubao-coupon-card--double .doubao-coupon-card__value,.doubao-coupon-card--multiple .doubao-coupon-card__value{line-height:18px}.doubao-coupon-card__scroll{width:100%;height:112px}.doubao-coupon-card--multiple .doubao-coupon-card__items{gap:4px}.doubao-coupon-card--multiple .doubao-coupon-card__item{flex:1 0 0;flex-direction:column;justify-content:center;gap:8px;min-width:96px;max-width:150px;height:112px;padding:16px 4px 8px;border-color:#fae6dd}.doubao-coupon-card--multiple .doubao-coupon-card__compact-info{flex:0 1 auto;width:100%}.doubao-coupon-card--multiple .doubao-coupon-card__action.doubao-button{max-width:100%;height:24px}.doubao-coupon-card.doubao-theme-dark .doubao-coupon-card__item{background-color:var(--bg-base-2-overlay);border-color:var(--neutral-transparent-2)}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { ContentCard, type ContentCardItem, type ContentCardProps } from './content-card/index.js';
2
+ export { CouponCard, type CouponCardItem, type CouponCardProps } from './coupon-card/index.js';
2
3
  export { CompositeCard, type CompositeCardContentSection, type CompositeCardOptionGroupSection, type CompositeCardProps, type CompositeCardSection, type CompositeCardTransitSection } from './composite-card/index.js';
3
4
  export type { TemplateCardHeaderProps } from './components/header/index.js';
4
5
  export type { TemplateCardFooterActionButton, TemplateCardFooterProps } from './components/footer/index.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { ContentCard } from "./content-card/index.js";
2
+ export { CouponCard } from "./coupon-card/index.js";
2
3
  export { CompositeCard } from "./composite-card/index.js";
3
4
  export { AskHumanCard } from "./ask-human-card/index.js";
4
5
  export { CheckoutCard } from "./checkout-card/index.js";
@@ -1 +1 @@
1
- .doubao-title{display:flex;flex-direction:row;align-items:flex-start;width:100%;max-width:100%;min-width:0;color:var(--neutral-100);font-family:"PingFang SC",-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Helvetica Neue",sans-serif;font-style:normal}.doubao-title--loading{align-items:center;width:100%;height:24px}.doubao-title__text{display:block;flex:0 1 auto;width:100%;min-width:0;overflow:hidden;color:var(--neutral-100);font-family:"PingFang SC",-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Helvetica Neue",sans-serif;font-size:16px;font-style:normal;font-weight:500;line-height:24px;text-overflow:clip}.doubao-title__text>inline-truncation{vertical-align:top}.doubao-title__inline-arrow{display:flex;flex-direction:row;align-items:center;justify-content:flex-end;width:14px;height:24px;box-sizing:border-box;vertical-align:top}.doubao-title__truncation{position:relative;width:0;height:24px;overflow:visible;vertical-align:top}.doubao-title__truncation.doubao-title__inline-arrow{width:14px}.doubao-title__fade{position:absolute;top:2px;left:-22px;width:22px;height:19px;background-image:linear-gradient(90deg, transparent, var(--bg-base-1))}.doubao-title__arrow{width:12px;height:12px;flex-shrink:0}.doubao-title__placeholder{width:100%;max-width:40%;height:16px;border-radius:4px;background-image:linear-gradient(90deg, #f7f7f7 0%, #e6e6e6 30%, #f7f7f7 100%);background-size:200% 100%;animation:doubao-title-placeholder-shimmer 1.4s ease-in-out infinite}@keyframes doubao-title-placeholder-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}
1
+ .doubao-title{display:flex;flex-direction:row;align-items:flex-start;width:100%;max-width:100%;min-width:0;color:var(--neutral-100);font-family:"PingFang SC",-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Helvetica Neue",sans-serif;font-style:normal}.doubao-title--loading{align-items:center;width:100%;height:24px}.doubao-title__text{display:block;flex:0 1 auto;width:100%;min-width:0;overflow:hidden;color:var(--neutral-100);font-family:"PingFang SC",-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Helvetica Neue",sans-serif;font-size:16px;font-style:normal;font-weight:500;line-height:24px;text-overflow:clip}.doubao-title__text>inline-truncation{overflow:visible;vertical-align:top}.doubao-title__inline-arrow{display:flex;flex-direction:row;align-items:center;justify-content:flex-end;width:14px;height:24px;box-sizing:border-box;vertical-align:top}.doubao-title__truncation{position:relative;width:0;height:24px;overflow:visible;vertical-align:top}.doubao-title__truncation.doubao-title__inline-arrow{width:14px}.doubao-title__fade{position:absolute;top:2px;left:-22px;width:22px;height:19px;background-image:linear-gradient(90deg, transparent, var(--bg-base-1))}.doubao-title__arrow{width:12px;height:12px;flex-shrink:0}.doubao-title__placeholder{width:100%;max-width:40%;height:16px;border-radius:4px;background-image:linear-gradient(90deg, #f7f7f7 0%, #e6e6e6 30%, #f7f7f7 100%);background-size:200% 100%;animation:doubao-title-placeholder-shimmer 1.4s ease-in-out infinite}@keyframes doubao-title-placeholder-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}
@@ -27,7 +27,7 @@ function renderTransitCardItem({ item, index, isLast }) {
27
27
  return <view className={clsx('doubao-transit-card__item', isLast && 'doubao-transit-card__item--last')} key={item.key ?? index} {...null != item.onClick ? {
28
28
  catchtap: item.onClick
29
29
  } : {}}>
30
- <TemplateTransportSummary className="doubao-template-transport-summary--list" title={item.title} departureMain={item.departureMain} departureSub={item.departureSub} transferTop={item.transferTop} transferBottom={item.transferBottom} arrivalMain={item.arrivalMain} arrivalDayOffset={item.arrivalDayOffset} arrivalSub={item.arrivalSub} price={renderTransitCardPrice(item.price)} priceActionText={item.priceAction?.text} priceActionTone={item.priceAction?.tone} showPriceActionIcon={item.priceAction?.showIcon} tag={renderTransitCardTag(item.tag)} onRouteClick={item.onRouteClick} onPriceClick={item.onPriceClick}/>
30
+ <TemplateTransportSummary className="doubao-template-transport-summary--list" title={item.title} departureMain={item.departureMain} departureSub={item.departureSub} transferTop={item.transferTop} transferBottom={item.transferBottom} arrivalMain={item.arrivalMain} arrivalDayOffset={item.arrivalDayOffset} arrivalSub={item.arrivalSub} price={renderTransitCardPrice(item.price)} priceActionText={item.priceAction?.text} priceActionTone={item.priceAction?.tone} showPriceActionIcon={item.priceAction?.showIcon} priceExtraLoading={item.priceExtraLoading} tag={renderTransitCardTag(item.tag)} tagTone={item.tag?.tone} onRouteClick={item.onRouteClick} onPriceClick={item.onPriceClick}/>
31
31
  {!isLast && <view className="doubao-transit-card__item--spread"/>}
32
32
  </view>;
33
33
  }
@@ -40,6 +40,8 @@ export interface TransitCardItem {
40
40
  priceAction?: TransitCardPriceAction;
41
41
  /** 价格下方的标签配置。 */
42
42
  tag?: TransitCardTag;
43
+ /** 价格下方区域是否加载中;统一替换操作文案或标签,图标颜色跟随当前内容。@defaultValue false */
44
+ priceExtraLoading?: boolean;
43
45
  /** 点击列表项时触发。 */
44
46
  onClick?: (event: TouchEvent) => void;
45
47
  /** 点击左侧行程区域时触发。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doubao-dev/template",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {