@windstream/react-shared-components 0.2.73 → 0.2.74
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.esm.js +1 -1
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +1 -1
- package/dist/contentful/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +6 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/rich-text-basic/index.tsx +2 -1
- package/src/hooks/contentful/use-contentful-rich-text.test.tsx +55 -0
- package/src/hooks/contentful/use-contentful-rich-text.tsx +15 -8
package/package.json
CHANGED
|
@@ -87,7 +87,8 @@ export const RichTextBasic: FC<RichTextBasicProps> = props => {
|
|
|
87
87
|
}
|
|
88
88
|
className={cx(
|
|
89
89
|
"last:[&_p]:mb-0",
|
|
90
|
-
|
|
90
|
+
// mobile-first: body3/leading-6 below md, body1/leading-normal from md up
|
|
91
|
+
"text-body3 leading-6 md:text-body1 md:leading-normal",
|
|
91
92
|
"[&_b]:font-bold [&_strong]:font-bold [&_i]:italic [&_em]:italic",
|
|
92
93
|
className,
|
|
93
94
|
!enableMaxWidth && "max-w-none"
|
|
@@ -1120,6 +1120,61 @@ describe("renderContentfulRichTextTable", () => {
|
|
|
1120
1120
|
expect(container).toHaveTextContent("Other Title");
|
|
1121
1121
|
});
|
|
1122
1122
|
|
|
1123
|
+
it("renders componentVideoLink inline entry (REST shape, no links prop)", () => {
|
|
1124
|
+
// Regression test: a doc containing both a table and an inline
|
|
1125
|
+
// componentVideoLink entry previously rendered nothing for the video,
|
|
1126
|
+
// since this function's INLINES.EMBEDDED_ENTRY override only resolved
|
|
1127
|
+
// entries via the GraphQL `links` lookup.
|
|
1128
|
+
const doc = makeDoc({
|
|
1129
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
1130
|
+
data: {},
|
|
1131
|
+
content: [
|
|
1132
|
+
makeInlineEntry("componentVideoLink", {
|
|
1133
|
+
link: "https://youtube.com/watch?v=123",
|
|
1134
|
+
}),
|
|
1135
|
+
],
|
|
1136
|
+
});
|
|
1137
|
+
const { container } = render(<>{renderContentfulRichTextTable(doc)}</>);
|
|
1138
|
+
const el = container.querySelector('[data-testid="video-link"]')!;
|
|
1139
|
+
expect(el).toBeInTheDocument();
|
|
1140
|
+
const videoLink = JSON.parse(el.getAttribute("data-video-link")!);
|
|
1141
|
+
expect(videoLink).toMatchObject({
|
|
1142
|
+
link: "https://youtube.com/watch?v=123",
|
|
1143
|
+
});
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
it("renders ComponentVideoLink (GraphQL __typename) inline entry resolved from links in table path", () => {
|
|
1147
|
+
const entryId = "video-inline-1";
|
|
1148
|
+
const doc = makeDoc({
|
|
1149
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
1150
|
+
data: {},
|
|
1151
|
+
content: [
|
|
1152
|
+
{
|
|
1153
|
+
nodeType: INLINES.EMBEDDED_ENTRY,
|
|
1154
|
+
data: { target: { sys: { id: entryId } } },
|
|
1155
|
+
content: [],
|
|
1156
|
+
},
|
|
1157
|
+
],
|
|
1158
|
+
});
|
|
1159
|
+
const links = {
|
|
1160
|
+
entries: {
|
|
1161
|
+
inline: [
|
|
1162
|
+
{
|
|
1163
|
+
sys: { id: entryId },
|
|
1164
|
+
__typename: "ComponentVideoLink",
|
|
1165
|
+
link: "https://youtube.com/watch?v=456",
|
|
1166
|
+
},
|
|
1167
|
+
],
|
|
1168
|
+
},
|
|
1169
|
+
};
|
|
1170
|
+
const { container } = render(
|
|
1171
|
+
<>{renderContentfulRichTextTable(doc, links)}</>
|
|
1172
|
+
);
|
|
1173
|
+
expect(
|
|
1174
|
+
container.querySelector('[data-testid="video-link"]')
|
|
1175
|
+
).toBeInTheDocument();
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1123
1178
|
it("returns null for inline entry not found in links", () => {
|
|
1124
1179
|
const doc = makeDoc({
|
|
1125
1180
|
nodeType: BLOCKS.PARAGRAPH,
|
|
@@ -471,18 +471,21 @@ export function renderContentfulRichTextTable(
|
|
|
471
471
|
);
|
|
472
472
|
},
|
|
473
473
|
[INLINES.EMBEDDED_ENTRY]: node => {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
)
|
|
474
|
+
// resolveEmbeddedEntry/getEntryTypeId/getEntryFields handle both REST
|
|
475
|
+
// (already-resolved target) and GraphQL (`links` lookup) shapes - a
|
|
476
|
+
// plain `links?.entries?.inline` lookup here always returns undefined
|
|
477
|
+
// for REST responses (no `links` prop passed), silently dropping any
|
|
478
|
+
// inline embedded entry (e.g. componentVideoLink) in a doc with a table.
|
|
479
|
+
const entry = resolveEmbeddedEntry(node, links);
|
|
479
480
|
if (!entry) return null;
|
|
481
|
+
const ctid = getEntryTypeId(entry);
|
|
482
|
+
const fields = getEntryFields(entry);
|
|
480
483
|
|
|
481
|
-
if (
|
|
484
|
+
if (ctid === "componentCheckList" || ctid === "ComponentCheckList") {
|
|
482
485
|
// FIX: Don't use a Hook here.
|
|
483
486
|
// Map the items manually or use a non-hook helper function.
|
|
484
487
|
const items =
|
|
485
|
-
entry.list?.items?.map((item: any) =>
|
|
488
|
+
(fields.list?.items ?? entry.list?.items)?.map((item: any) =>
|
|
486
489
|
renderContentfulRichText(
|
|
487
490
|
toDocument(item?.checkListTitle ?? ""),
|
|
488
491
|
true,
|
|
@@ -498,7 +501,11 @@ export function renderContentfulRichTextTable(
|
|
|
498
501
|
);
|
|
499
502
|
}
|
|
500
503
|
|
|
501
|
-
|
|
504
|
+
if (ctid === "componentVideoLink" || ctid === "ComponentVideoLink") {
|
|
505
|
+
return <VideoLink videoLink={toVideoLinkProps(fields)} />;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return <span>{fields?.title ?? entry.title ?? ""}</span>;
|
|
502
509
|
},
|
|
503
510
|
},
|
|
504
511
|
};
|