enjanga-components-library 1.0.92 → 1.0.95

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/index.d.mts CHANGED
@@ -239,6 +239,25 @@ declare const SmartText: ({ className, plainText, richText }: SMT_propsType) =>
239
239
 
240
240
  declare const FeatureText: ({ className, heading, smartText, headingMaxLength, plainTextMaxLength, isHidden, }: FTX_propsType) => react_jsx_runtime.JSX.Element;
241
241
 
242
+ /** Metadata for an entry used as an inline hyperlink target. */
243
+ interface CRT_EntryHyperlink {
244
+ sys: {
245
+ id: string;
246
+ };
247
+ /** Contentful __typename (e.g. "BlogPost", "CaseStudy", "Organization"). */
248
+ __typename: string;
249
+ slug: string;
250
+ }
251
+ /** Metadata for a resource (cross-space) hyperlink entry. */
252
+ interface CRT_ResourceHyperlink {
253
+ sys: {
254
+ id: string;
255
+ urn: string;
256
+ };
257
+ /** Contentful __typename (e.g. "BlogPost", "CaseStudy", "Organization"). */
258
+ __typename: string;
259
+ slug: string;
260
+ }
242
261
  interface CRT_propsType {
243
262
  className?: string;
244
263
  data?: {
@@ -258,6 +277,10 @@ interface CRT_propsType {
258
277
  height: number;
259
278
  }[];
260
279
  };
280
+ entries?: {
281
+ hyperlink?: CRT_EntryHyperlink[];
282
+ resourceHyperlink?: CRT_ResourceHyperlink[];
283
+ };
261
284
  };
262
285
  };
263
286
  }
package/dist/index.d.ts CHANGED
@@ -239,6 +239,25 @@ declare const SmartText: ({ className, plainText, richText }: SMT_propsType) =>
239
239
 
240
240
  declare const FeatureText: ({ className, heading, smartText, headingMaxLength, plainTextMaxLength, isHidden, }: FTX_propsType) => react_jsx_runtime.JSX.Element;
241
241
 
242
+ /** Metadata for an entry used as an inline hyperlink target. */
243
+ interface CRT_EntryHyperlink {
244
+ sys: {
245
+ id: string;
246
+ };
247
+ /** Contentful __typename (e.g. "BlogPost", "CaseStudy", "Organization"). */
248
+ __typename: string;
249
+ slug: string;
250
+ }
251
+ /** Metadata for a resource (cross-space) hyperlink entry. */
252
+ interface CRT_ResourceHyperlink {
253
+ sys: {
254
+ id: string;
255
+ urn: string;
256
+ };
257
+ /** Contentful __typename (e.g. "BlogPost", "CaseStudy", "Organization"). */
258
+ __typename: string;
259
+ slug: string;
260
+ }
242
261
  interface CRT_propsType {
243
262
  className?: string;
244
263
  data?: {
@@ -258,6 +277,10 @@ interface CRT_propsType {
258
277
  height: number;
259
278
  }[];
260
279
  };
280
+ entries?: {
281
+ hyperlink?: CRT_EntryHyperlink[];
282
+ resourceHyperlink?: CRT_ResourceHyperlink[];
283
+ };
261
284
  };
262
285
  };
263
286
  }
package/dist/index.js CHANGED
@@ -329,6 +329,20 @@ var BrandLogo = ({
329
329
  );
330
330
  };
331
331
  var BrandLogo_default = BrandLogo;
332
+ var entryTypeToPath = (typename, slug) => {
333
+ const type = typename.toLowerCase();
334
+ if (type === "blogpost" || type === "project" || type === "casestudy") {
335
+ return `/case-studies/${slug}`;
336
+ }
337
+ if (type === "organization") {
338
+ return `/experience/${slug}`;
339
+ }
340
+ return null;
341
+ };
342
+ var extractEntryIdFromUrn = (urn) => {
343
+ const match = urn.match(/\/entries\/([^/]+)$/);
344
+ return match ? match[1] : null;
345
+ };
332
346
  var isExternalLink = (url) => {
333
347
  const appDomain = "enjanga.com";
334
348
  return url.startsWith("http://") && !url.includes("localhost") || url.startsWith("https://") && !url.includes(appDomain);
@@ -447,6 +461,37 @@ var renderContentfulNode = (node, key, options = {}) => {
447
461
  key
448
462
  );
449
463
  }
464
+ case richTextTypes.INLINES.ENTRY_HYPERLINK: {
465
+ const inline = node;
466
+ const entryId = inline.data?.target?.sys?.id;
467
+ const entry = entryId ? options.entries?.[entryId] : void 0;
468
+ const children = inline.content.map(
469
+ (child, i) => renderContentfulNode(child, `${key}-entry-link-${i}`, options)
470
+ );
471
+ if (entry) {
472
+ const href = entryTypeToPath(entry.__typename, entry.slug);
473
+ if (href) {
474
+ return /* @__PURE__ */ jsxRuntime.jsx("a", { href, children }, key);
475
+ }
476
+ }
477
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { children }, key);
478
+ }
479
+ case richTextTypes.INLINES.RESOURCE_HYPERLINK: {
480
+ const inline = node;
481
+ const urn = inline.data?.target?.sys?.urn;
482
+ const entryId = urn ? extractEntryIdFromUrn(urn) : void 0;
483
+ const entry = entryId ? options.entries?.[entryId] : void 0;
484
+ const children = inline.content.map(
485
+ (child, i) => renderContentfulNode(child, `${key}-resource-link-${i}`, options)
486
+ );
487
+ if (entry) {
488
+ const href = entryTypeToPath(entry.__typename, entry.slug);
489
+ if (href) {
490
+ return /* @__PURE__ */ jsxRuntime.jsx("a", { href, children }, key);
491
+ }
492
+ }
493
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { children }, key);
494
+ }
450
495
  case "text": {
451
496
  const textNode = node;
452
497
  let textElement = textNode.value;
@@ -549,8 +594,15 @@ var CMSRichText = ({ data, className }) => {
549
594
  data.links?.assets.block.forEach((asset) => {
550
595
  assetsMap[asset.sys.id] = asset;
551
596
  });
597
+ const entriesMap = {};
598
+ data.links?.entries?.hyperlink?.forEach((entry) => {
599
+ entriesMap[entry.sys.id] = entry;
600
+ });
601
+ data.links?.entries?.resourceHyperlink?.forEach((entry) => {
602
+ entriesMap[entry.sys.id] = entry;
603
+ });
552
604
  return /* @__PURE__ */ jsxRuntime.jsx("article", { className: clsx2__default.default("enj-CMSRichText", className), children: data.json?.content?.map(
553
- (node, index) => renderContentfulNode(node, `node-${index}`, { assets: assetsMap })
605
+ (node, index) => renderContentfulNode(node, `node-${index}`, { assets: assetsMap, entries: entriesMap })
554
606
  ) });
555
607
  };
556
608
  var CMSRichText_default = CMSRichText;
@@ -1653,6 +1705,7 @@ var TilePost = ({
1653
1705
  orgPictogramName
1654
1706
  }) => {
1655
1707
  const componentTitle = getHeadingContent4(featuredText);
1708
+ const displayedOrgTitle = orgTitle.length > 30 ? `${orgTitle.slice(0, 30)}...` : orgTitle;
1656
1709
  const wrapperClassNames = getPostTileCSSClasses();
1657
1710
  const iconContent = getIconContent3({
1658
1711
  title: getHeadingContent4(featuredText),
@@ -1683,7 +1736,7 @@ var TilePost = ({
1683
1736
  const Icon = CarbonIcons__namespace[orgPictogramName];
1684
1737
  return Icon ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "1.5rem", height: "1.5rem", "aria-hidden": "true" }) : null;
1685
1738
  })(),
1686
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: orgTitle })
1739
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: displayedOrgTitle })
1687
1740
  ]
1688
1741
  }
1689
1742
  ),
package/dist/index.mjs CHANGED
@@ -302,6 +302,20 @@ var BrandLogo = ({
302
302
  );
303
303
  };
304
304
  var BrandLogo_default = BrandLogo;
305
+ var entryTypeToPath = (typename, slug) => {
306
+ const type = typename.toLowerCase();
307
+ if (type === "blogpost" || type === "project" || type === "casestudy") {
308
+ return `/case-studies/${slug}`;
309
+ }
310
+ if (type === "organization") {
311
+ return `/experience/${slug}`;
312
+ }
313
+ return null;
314
+ };
315
+ var extractEntryIdFromUrn = (urn) => {
316
+ const match = urn.match(/\/entries\/([^/]+)$/);
317
+ return match ? match[1] : null;
318
+ };
305
319
  var isExternalLink = (url) => {
306
320
  const appDomain = "enjanga.com";
307
321
  return url.startsWith("http://") && !url.includes("localhost") || url.startsWith("https://") && !url.includes(appDomain);
@@ -420,6 +434,37 @@ var renderContentfulNode = (node, key, options = {}) => {
420
434
  key
421
435
  );
422
436
  }
437
+ case INLINES.ENTRY_HYPERLINK: {
438
+ const inline = node;
439
+ const entryId = inline.data?.target?.sys?.id;
440
+ const entry = entryId ? options.entries?.[entryId] : void 0;
441
+ const children = inline.content.map(
442
+ (child, i) => renderContentfulNode(child, `${key}-entry-link-${i}`, options)
443
+ );
444
+ if (entry) {
445
+ const href = entryTypeToPath(entry.__typename, entry.slug);
446
+ if (href) {
447
+ return /* @__PURE__ */ jsx("a", { href, children }, key);
448
+ }
449
+ }
450
+ return /* @__PURE__ */ jsx("span", { children }, key);
451
+ }
452
+ case INLINES.RESOURCE_HYPERLINK: {
453
+ const inline = node;
454
+ const urn = inline.data?.target?.sys?.urn;
455
+ const entryId = urn ? extractEntryIdFromUrn(urn) : void 0;
456
+ const entry = entryId ? options.entries?.[entryId] : void 0;
457
+ const children = inline.content.map(
458
+ (child, i) => renderContentfulNode(child, `${key}-resource-link-${i}`, options)
459
+ );
460
+ if (entry) {
461
+ const href = entryTypeToPath(entry.__typename, entry.slug);
462
+ if (href) {
463
+ return /* @__PURE__ */ jsx("a", { href, children }, key);
464
+ }
465
+ }
466
+ return /* @__PURE__ */ jsx("span", { children }, key);
467
+ }
423
468
  case "text": {
424
469
  const textNode = node;
425
470
  let textElement = textNode.value;
@@ -522,8 +567,15 @@ var CMSRichText = ({ data, className }) => {
522
567
  data.links?.assets.block.forEach((asset) => {
523
568
  assetsMap[asset.sys.id] = asset;
524
569
  });
570
+ const entriesMap = {};
571
+ data.links?.entries?.hyperlink?.forEach((entry) => {
572
+ entriesMap[entry.sys.id] = entry;
573
+ });
574
+ data.links?.entries?.resourceHyperlink?.forEach((entry) => {
575
+ entriesMap[entry.sys.id] = entry;
576
+ });
525
577
  return /* @__PURE__ */ jsx("article", { className: clsx2("enj-CMSRichText", className), children: data.json?.content?.map(
526
- (node, index) => renderContentfulNode(node, `node-${index}`, { assets: assetsMap })
578
+ (node, index) => renderContentfulNode(node, `node-${index}`, { assets: assetsMap, entries: entriesMap })
527
579
  ) });
528
580
  };
529
581
  var CMSRichText_default = CMSRichText;
@@ -1626,6 +1678,7 @@ var TilePost = ({
1626
1678
  orgPictogramName
1627
1679
  }) => {
1628
1680
  const componentTitle = getHeadingContent4(featuredText);
1681
+ const displayedOrgTitle = orgTitle.length > 30 ? `${orgTitle.slice(0, 30)}...` : orgTitle;
1629
1682
  const wrapperClassNames = getPostTileCSSClasses();
1630
1683
  const iconContent = getIconContent3({
1631
1684
  title: getHeadingContent4(featuredText),
@@ -1656,7 +1709,7 @@ var TilePost = ({
1656
1709
  const Icon = CarbonIcons[orgPictogramName];
1657
1710
  return Icon ? /* @__PURE__ */ jsx(Icon, { width: "1.5rem", height: "1.5rem", "aria-hidden": "true" }) : null;
1658
1711
  })(),
1659
- /* @__PURE__ */ jsx("span", { children: orgTitle })
1712
+ /* @__PURE__ */ jsx("span", { children: displayedOrgTitle })
1660
1713
  ]
1661
1714
  }
1662
1715
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enjanga-components-library",
3
- "version": "1.0.92",
3
+ "version": "1.0.95",
4
4
  "description": "Reusable component library for Next.js 13+ projects with Carbon design system.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -123,7 +123,8 @@
123
123
  "storybook": "^8.6.14",
124
124
  "style-loader": "^4.0.0",
125
125
  "tsup": "^8.5.0",
126
- "typescript": "^5.0.0"
126
+ "typescript": "^5.0.0",
127
+ "vitest": "^4.1.5"
127
128
  },
128
129
  "dependencies": {},
129
130
  "repository": {