@tbox.cn/app-module-promotion 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DP2XDOBN.js → chunk-HZIEXNVQ.js} +5 -3
- package/dist/{chunk-AI3K2MST.js → chunk-ONDEOXMY.js} +4 -2
- package/dist/client/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{promotion-6L7HLRC2.css → promotion-ESTNS7IL.css} +4 -0
- package/dist/server/index.js +1 -1
- package/package.json +5 -5
- package/src/client/cards/promotion-offer-list/index.tsx +4 -0
- package/src/client/components/CouponSheet.tsx +4 -2
- package/src/client/styles/promotion.css +4 -0
- package/src/server/cards/promotion-entitlement-list/samples.ts +1 -0
- package/src/server/cards/promotion-offer-list/samples.ts +1 -0
- package/tests/cards-render.test.tsx +32 -0
- package/tests/samples.test.ts +9 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/client/index.ts
|
|
2
|
-
import "./promotion-
|
|
2
|
+
import "./promotion-ESTNS7IL.css";
|
|
3
3
|
|
|
4
4
|
// src/client/cards/promotion-offer-list/index.tsx
|
|
5
5
|
import { CalendarBlank, CalendarDots, CaretDown, Lightbulb, MapPin, Sparkle, Ticket } from "@phosphor-icons/react";
|
|
@@ -91,7 +91,7 @@ function sanitizeActivityHtml(html) {
|
|
|
91
91
|
// src/client/components/CouponSheet.tsx
|
|
92
92
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
93
93
|
function CouponSheet(props) {
|
|
94
|
-
const { title, imageUrl, subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
|
|
94
|
+
const { title, imageUrl, imageFit = "contain", subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
|
|
95
95
|
const [closing, setClosing] = useState2(false);
|
|
96
96
|
const closingRef = useRef(false);
|
|
97
97
|
const closeTimerRef = useRef();
|
|
@@ -136,7 +136,7 @@ function CouponSheet(props) {
|
|
|
136
136
|
children: /* @__PURE__ */ jsxs("div", { className: "promotion-sheet__panel", children: [
|
|
137
137
|
/* @__PURE__ */ jsx2("button", { type: "button", className: "promotion-sheet__close", "aria-label": "\u5173\u95ED\u8BE6\u60C5", onClick: requestClose, children: /* @__PURE__ */ jsx2(X, { size: 18, weight: "bold", "aria-hidden": "true" }) }),
|
|
138
138
|
/* @__PURE__ */ jsxs("div", { className: "promotion-sheet__scroll", children: [
|
|
139
|
-
/* @__PURE__ */ jsx2(ImageWithFallback, { src: imageUrl, alt: title, className: "promotion-sheet__image" }),
|
|
139
|
+
/* @__PURE__ */ jsx2(ImageWithFallback, { src: imageUrl, alt: title, className: `promotion-sheet__image${imageFit === "cover" ? " promotion-sheet__image--cover" : ""}` }),
|
|
140
140
|
(priceMain || aside) && /* @__PURE__ */ jsxs("div", { className: "promotion-sheet__price", children: [
|
|
141
141
|
priceMain && /* @__PURE__ */ jsx2("b", { children: priceMain }),
|
|
142
142
|
priceMain && priceOriginal && /* @__PURE__ */ jsx2("s", { children: priceOriginal }),
|
|
@@ -243,6 +243,7 @@ var couponSubtitleIsTime = (subtitle) => {
|
|
|
243
243
|
const plainText = subtitle.replace(/<[^>]+>/g, " ").replace(/ /gi, " ");
|
|
244
244
|
return /\d{4}\s*[-/.年]\s*\d{1,2}\s*[-/.月]\s*\d{1,2}|\d{1,2}:\d{2}/.test(plainText);
|
|
245
245
|
};
|
|
246
|
+
var sheetImageFit = (offer) => offer.offerRef === "demo:coupon:1001" || offer.offerRef === "demo:groupon:2001" ? "cover" : "contain";
|
|
246
247
|
function PromotionOfferListCard(props) {
|
|
247
248
|
const { data, cardId = "", isHistory = false, actionTokens } = props;
|
|
248
249
|
const [openRef, setOpenRef] = useState3(null);
|
|
@@ -443,6 +444,7 @@ function PromotionOfferListCard(props) {
|
|
|
443
444
|
{
|
|
444
445
|
title: target.title,
|
|
445
446
|
imageUrl: target.imageUrl,
|
|
447
|
+
imageFit: sheetImageFit(target),
|
|
446
448
|
noticeText: target.usageNoticeText,
|
|
447
449
|
guaranteeText: target.guaranteeText,
|
|
448
450
|
subtitle: redirectOnly ? [target.subtitle, target.purchaseUrl ? `\u8BE5\u4F18\u60E0\u9700\u524D\u5F80\u5C0F\u7A0B\u5E8F\u5B8C\u6210${purchaseOnly ? "\u8D2D\u4E70" : "\u9886\u53D6"}` : `\u8BE5\u4F18\u60E0\u7684${purchaseOnly ? "\u62A2\u8D2D" : "\u9886\u53D6"}\u94FE\u63A5\u6682\u4E0D\u53EF\u7528`].filter(Boolean).join(" \xB7 ") : target.subtitle,
|
|
@@ -313,7 +313,8 @@ var samples = [
|
|
|
313
313
|
originalPriceText: "\xA520",
|
|
314
314
|
itemActions: claimAction("\u9886\u53D6", "\u4F1A\u5458\u9650\u5B9A\u6EE1\u51CF\u4F18\u60E0\u5238")
|
|
315
315
|
}]
|
|
316
|
-
}
|
|
316
|
+
},
|
|
317
|
+
hidden: true
|
|
317
318
|
},
|
|
318
319
|
{
|
|
319
320
|
label: "\u9886\u5238\xB7\u6EE4\u6389\u4E0D\u53EF\u9886",
|
|
@@ -417,7 +418,8 @@ var samples2 = [
|
|
|
417
418
|
label: "\u6211\u7684\u5238\xB7\u7F3A\u56FE\u957F\u6587\u6848",
|
|
418
419
|
note: "\u65E0\u56FE\u7247\u3001\u957F\u6807\u9898\u548C UNKNOWN \u72B6\u6001\u7684\u5BB9\u9519\u5F62\u6001",
|
|
419
420
|
group: "\u6211\u7684\u5238",
|
|
420
|
-
data: { items: [{ entitlementRef: "ent:unknown", title: "\u4F1A\u5458\u9650\u5B9A\u8D85\u957F\u540D\u79F0\u6D4B\u8BD5\uFF5C\u6307\u5B9A\u5546\u6237\u5468\u672B\u5230\u5E97\u6D88\u8D39\u4E13\u4EAB\u6743\u76CA", entitlementType: "COUPON", status: "UNKNOWN", codeMasked: "**** 0000", benefitText: "\u6EE1100\u51CF20", usageNotice: "\u4F7F\u7528\u95E8\u5E97\u548C\u9002\u7528\u5546\u54C1\u8BF7\u4EE5\u5238\u8BE6\u60C5\u8BF4\u660E\u4E3A\u51C6", validUntilText: "\u6709\u6548\u671F\u5F85\u54C1\u724C\u65B9\u786E\u8BA4" }] }
|
|
421
|
+
data: { items: [{ entitlementRef: "ent:unknown", title: "\u4F1A\u5458\u9650\u5B9A\u8D85\u957F\u540D\u79F0\u6D4B\u8BD5\uFF5C\u6307\u5B9A\u5546\u6237\u5468\u672B\u5230\u5E97\u6D88\u8D39\u4E13\u4EAB\u6743\u76CA", entitlementType: "COUPON", status: "UNKNOWN", codeMasked: "**** 0000", benefitText: "\u6EE1100\u51CF20", usageNotice: "\u4F7F\u7528\u95E8\u5E97\u548C\u9002\u7528\u5546\u54C1\u8BF7\u4EE5\u5238\u8BE6\u60C5\u8BF4\u660E\u4E3A\u51C6", validUntilText: "\u6709\u6548\u671F\u5F85\u54C1\u724C\u65B9\u786E\u8BA4" }] },
|
|
422
|
+
hidden: true
|
|
421
423
|
},
|
|
422
424
|
{
|
|
423
425
|
label: "\u6211\u7684\u5238\xB7\u7A7A\u6001",
|
package/dist/client/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
resolvePromotionEntitlementsPort,
|
|
8
8
|
resolvePromotionOffersPort,
|
|
9
9
|
serverModule
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ONDEOXMY.js";
|
|
11
11
|
import {
|
|
12
12
|
cards,
|
|
13
13
|
clientModule
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HZIEXNVQ.js";
|
|
15
15
|
export {
|
|
16
16
|
InMemoryPromotionService,
|
|
17
17
|
clientModule,
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-promotion",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "商圈营销模块:资格校验、推荐降级链、券卡(codegen 源)。",
|
|
6
6
|
"exports": {
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tbox.cn/app-contracts": "0.12.
|
|
22
|
-
"@tbox.cn/app-contracts-mall": "0.12.
|
|
21
|
+
"@tbox.cn/app-contracts": "0.12.3",
|
|
22
|
+
"@tbox.cn/app-contracts-mall": "0.12.3",
|
|
23
23
|
"jsbarcode": "^3.12.3",
|
|
24
24
|
"qrcode": "^1.5.4",
|
|
25
|
-
"@tbox.cn/app-agent-sdk-client": "0.1.
|
|
26
|
-
"@tbox.cn/app-agent-sdk-server": "0.1.
|
|
25
|
+
"@tbox.cn/app-agent-sdk-client": "0.1.3",
|
|
26
|
+
"@tbox.cn/app-agent-sdk-server": "0.1.4"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@phosphor-icons/react": "2.1.10",
|
|
@@ -22,6 +22,9 @@ const couponSubtitleIsTime = (subtitle: string) => {
|
|
|
22
22
|
return /\d{4}\s*[-/.年]\s*\d{1,2}\s*[-/.月]\s*\d{1,2}|\d{1,2}:\d{2}/.test(plainText);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
const sheetImageFit = (offer: PromotionOfferListCardData['items'][number]): 'contain' | 'cover' =>
|
|
26
|
+
offer.offerRef === 'demo:coupon:1001' || offer.offerRef === 'demo:groupon:2001' ? 'cover' : 'contain';
|
|
27
|
+
|
|
25
28
|
export function PromotionOfferListCard(props: {
|
|
26
29
|
data: PromotionOfferListCardData;
|
|
27
30
|
cardId?: string;
|
|
@@ -203,6 +206,7 @@ export function PromotionOfferListCard(props: {
|
|
|
203
206
|
<CouponSheet
|
|
204
207
|
title={target.title}
|
|
205
208
|
imageUrl={target.imageUrl}
|
|
209
|
+
imageFit={sheetImageFit(target)}
|
|
206
210
|
noticeText={target.usageNoticeText}
|
|
207
211
|
guaranteeText={target.guaranteeText}
|
|
208
212
|
subtitle={redirectOnly
|
|
@@ -19,6 +19,8 @@ export interface SheetFact {
|
|
|
19
19
|
export function CouponSheet(props: {
|
|
20
20
|
title: string;
|
|
21
21
|
imageUrl?: string;
|
|
22
|
+
/** 团购图有稳定横幅画幅,可裁切铺满;券图默认完整展示。 */
|
|
23
|
+
imageFit?: 'contain' | 'cover';
|
|
22
24
|
subtitle?: string;
|
|
23
25
|
noticeText?: string;
|
|
24
26
|
guaranteeText?: string;
|
|
@@ -36,7 +38,7 @@ export function CouponSheet(props: {
|
|
|
36
38
|
foot?: React.ReactNode;
|
|
37
39
|
onClose: () => void;
|
|
38
40
|
}) {
|
|
39
|
-
const { title, imageUrl, subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
|
|
41
|
+
const { title, imageUrl, imageFit = 'contain', subtitle, noticeText, guaranteeText, priceMain, priceOriginal, aside, facts = [], beforeFacts, extra, foot, onClose } = props;
|
|
40
42
|
const [closing, setClosing] = useState(false);
|
|
41
43
|
const closingRef = useRef(false);
|
|
42
44
|
const closeTimerRef = useRef<number>();
|
|
@@ -83,7 +85,7 @@ export function CouponSheet(props: {
|
|
|
83
85
|
<X size={18} weight="bold" aria-hidden="true" />
|
|
84
86
|
</button>
|
|
85
87
|
<div className="promotion-sheet__scroll">
|
|
86
|
-
<ImageWithFallback src={imageUrl} alt={title} className=
|
|
88
|
+
<ImageWithFallback src={imageUrl} alt={title} className={`promotion-sheet__image${imageFit === 'cover' ? ' promotion-sheet__image--cover' : ''}`} />
|
|
87
89
|
{/* 价格条压在图下沿:与列表行同一组价格语言,浮层里放大一档 */}
|
|
88
90
|
{(priceMain || aside) && (
|
|
89
91
|
<div className="promotion-sheet__price">
|
|
@@ -41,6 +41,7 @@ export const samples: CardSample<PromotionEntitlementListCardData>[] = [
|
|
|
41
41
|
note: '无图片、长标题和 UNKNOWN 状态的容错形态',
|
|
42
42
|
group: '我的券',
|
|
43
43
|
data: { items: [{ entitlementRef: 'ent:unknown', title: '会员限定超长名称测试|指定商户周末到店消费专享权益', entitlementType: 'COUPON', status: 'UNKNOWN', codeMasked: '**** 0000', benefitText: '满100减20', usageNotice: '使用门店和适用商品请以券详情说明为准', validUntilText: '有效期待品牌方确认' }] },
|
|
44
|
+
hidden: true,
|
|
44
45
|
},
|
|
45
46
|
{
|
|
46
47
|
label: '我的券·空态',
|
|
@@ -332,6 +332,38 @@ describe('优惠券链路视觉状态语义', () => {
|
|
|
332
332
|
expect(host.querySelector('.promotion-coupon-row__sub')?.textContent).toBe('商场会员专享');
|
|
333
333
|
});
|
|
334
334
|
|
|
335
|
+
it('演示团购与指定满减券详情图裁切铺满,其他券图保持完整展示', () => {
|
|
336
|
+
const host = render(<PromotionOfferListCard data={{
|
|
337
|
+
mode: 'claimable',
|
|
338
|
+
presentation: 'coupon',
|
|
339
|
+
items: [
|
|
340
|
+
offer,
|
|
341
|
+
{ ...offer, offerRef: 'demo:coupon:1001', title: '满 100 减 20 元券' },
|
|
342
|
+
{ ...offer, offerRef: 'demo:groupon:2001', offerType: 'GROUPON', title: '演示双人套餐' },
|
|
343
|
+
{ ...offer, offerRef: 'vendor:groupon:1', offerType: 'GROUPON', title: '厂商双人套餐' },
|
|
344
|
+
],
|
|
345
|
+
} as never} cardId="coupon-list" />);
|
|
346
|
+
const rows = host.querySelectorAll('.promotion-coupon-row');
|
|
347
|
+
|
|
348
|
+
act(() => (rows[0] as HTMLElement).click());
|
|
349
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).toBeNull();
|
|
350
|
+
act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
|
|
351
|
+
act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
|
|
352
|
+
|
|
353
|
+
act(() => (rows[1] as HTMLElement).click());
|
|
354
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).not.toBeNull();
|
|
355
|
+
act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
|
|
356
|
+
act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
|
|
357
|
+
|
|
358
|
+
act(() => (rows[2] as HTMLElement).click());
|
|
359
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).not.toBeNull();
|
|
360
|
+
act(() => (document.querySelector('.promotion-sheet [aria-label="关闭详情"]') as HTMLElement).click());
|
|
361
|
+
act(() => document.querySelector('.promotion-sheet')?.dispatchEvent(new Event('animationend', { bubbles: true })));
|
|
362
|
+
|
|
363
|
+
act(() => (rows[3] as HTMLElement).click());
|
|
364
|
+
expect(document.querySelector('.promotion-sheet__image--cover')).toBeNull();
|
|
365
|
+
});
|
|
366
|
+
|
|
335
367
|
it('商场券和我的券缺图时共用居中的缩略图兜底', () => {
|
|
336
368
|
const offerHost = render(<PromotionOfferListCard data={{
|
|
337
369
|
mode: 'claimable',
|
package/tests/samples.test.ts
CHANGED
|
@@ -39,4 +39,13 @@ describe('promotion samples 双断言(样本即契约)', () => {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
|
|
43
|
+
it('缺图与 UNKNOWN 降级样本保留质量检查但不进入 Preview', () => {
|
|
44
|
+
expect(
|
|
45
|
+
offerListMeta.samples?.find((sample) => sample.label === '领券·缺图与长文案')?.hidden,
|
|
46
|
+
).toBe(true);
|
|
47
|
+
expect(
|
|
48
|
+
entitlementListMeta.samples?.find((sample) => sample.label === '我的券·缺图长文案')?.hidden,
|
|
49
|
+
).toBe(true);
|
|
50
|
+
});
|
|
42
51
|
});
|