@windstream/react-shared-components 0.2.87 → 0.2.89
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/contentful/index.d.ts +1 -1
- package/dist/contentful/index.esm.js +4 -4
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +4 -4
- package/dist/contentful/index.js.map +1 -1
- package/dist/core.d.ts +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/checklist/index.test.tsx +31 -1
- package/src/components/checklist/index.tsx +1 -0
- package/src/components/checklist/types.ts +2 -0
- package/src/contentful/blocks/cards/product-card/index.test.tsx +29 -4
- package/src/contentful/blocks/cards/product-card/index.tsx +46 -44
- package/src/contentful/blocks/cards/product-card/types.ts +1 -1
- package/src/contentful/blocks/carousel/helper.test.tsx +24 -0
- package/src/contentful/blocks/carousel/helper.tsx +1 -1
- package/src/contentful/blocks/primary-hero/index.test.tsx +263 -4
- package/src/contentful/blocks/primary-hero/index.tsx +48 -4
- package/src/contentful/blocks/primary-hero/primary-hero.stories.tsx +22 -1
- package/src/utils/replace-tokens.test.ts +34 -0
- package/src/utils/replace-tokens.ts +4 -0
|
@@ -45,7 +45,8 @@ const argTypes: ArgTypes<PrimaryHeroProps> = {
|
|
|
45
45
|
},
|
|
46
46
|
price: {
|
|
47
47
|
control: { type: "text" as const },
|
|
48
|
-
description:
|
|
48
|
+
description:
|
|
49
|
+
"Price value (e.g. '24'). Decimal prices such as a resolved price token ('19.99') render the cents with the suffix, without repeating cents the suffix already starts with. The lockup is hidden while any price field still contains an unresolved `${token}`.",
|
|
49
50
|
},
|
|
50
51
|
priceSuffix: {
|
|
51
52
|
control: { type: "text" as const },
|
|
@@ -324,3 +325,23 @@ export const BundleOffer: Story = {
|
|
|
324
325
|
checklist: undefined,
|
|
325
326
|
},
|
|
326
327
|
};
|
|
328
|
+
|
|
329
|
+
/** Tokenized price: a resolved price token ("19.99") renders the same lockup as an authored "19" + "99/mo*". */
|
|
330
|
+
export const TokenizedPrice: Story = {
|
|
331
|
+
parameters: {
|
|
332
|
+
docs: {
|
|
333
|
+
description: {
|
|
334
|
+
story:
|
|
335
|
+
"When the Price field holds a price token (e.g. `${price_fiber_300}`) the consuming app resolves it with `replaceTokens` to a decimal value such as `19.99`. The dollars render large and the cents render with the suffix, matching production heroes authored as Price `19` + Price Suffix `99/mo*`.",
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
args: {
|
|
340
|
+
title: "switch and save this season",
|
|
341
|
+
subTitle: "Make it festive with fast 100% fiber from Kinetic.",
|
|
342
|
+
price: "19.99",
|
|
343
|
+
priceSuffix: "/mo*",
|
|
344
|
+
priceCallout: "fiber plans|start at ",
|
|
345
|
+
textColor: "dark",
|
|
346
|
+
},
|
|
347
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
hasUnresolvedTokens,
|
|
2
3
|
replaceTokens,
|
|
3
4
|
type RichTextDocument,
|
|
4
5
|
type TokenEntry,
|
|
@@ -195,3 +196,36 @@ describe("replaceTokens - rich text", () => {
|
|
|
195
196
|
expect((result.content[1] as any).content[0].value).toBe("50");
|
|
196
197
|
});
|
|
197
198
|
});
|
|
199
|
+
|
|
200
|
+
describe("hasUnresolvedTokens", () => {
|
|
201
|
+
it.each([
|
|
202
|
+
["${price_tier3_2gig}", true],
|
|
203
|
+
["From $${price_tier1_300mbps}/mo", true],
|
|
204
|
+
["39.99", false],
|
|
205
|
+
["plain text", false],
|
|
206
|
+
["${}", false],
|
|
207
|
+
["", false],
|
|
208
|
+
[null, false],
|
|
209
|
+
[undefined, false],
|
|
210
|
+
])("returns %p -> %p", (input, expected) => {
|
|
211
|
+
expect(hasUnresolvedTokens(input)).toBe(expected);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("is false once every token resolves and true for unknown tokens", () => {
|
|
215
|
+
expect(hasUnresolvedTokens(replaceTokens("${reward_50}", tokens))).toBe(
|
|
216
|
+
false
|
|
217
|
+
);
|
|
218
|
+
expect(hasUnresolvedTokens(replaceTokens("${not_a_token}", tokens))).toBe(
|
|
219
|
+
true
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("returns the same result on repeated calls", () => {
|
|
224
|
+
const value = "${price_tier1_300mbps}";
|
|
225
|
+
expect([1, 2, 3].map(() => hasUnresolvedTokens(value))).toEqual([
|
|
226
|
+
true,
|
|
227
|
+
true,
|
|
228
|
+
true,
|
|
229
|
+
]);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
@@ -15,6 +15,10 @@ export type RichTextDocument = {
|
|
|
15
15
|
export type ReplaceTokensResult<T> = T extends string ? string : T;
|
|
16
16
|
|
|
17
17
|
const TOKEN_PATTERN = /\$\{([^${}]+)\}/g;
|
|
18
|
+
const UNRESOLVED_TOKEN_PATTERN = new RegExp(TOKEN_PATTERN.source);
|
|
19
|
+
|
|
20
|
+
export const hasUnresolvedTokens = (input?: string | null): boolean =>
|
|
21
|
+
typeof input === "string" && UNRESOLVED_TOKEN_PATTERN.test(input);
|
|
18
22
|
|
|
19
23
|
const normalizeEntries = (tokens: TokenSource): TokenEntry[] => {
|
|
20
24
|
if (Array.isArray(tokens)) return tokens;
|