@nypl/design-system-react-components 1.2.0-rc-2 → 1.2.0-rc-3

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.
@@ -2508,33 +2508,49 @@ var AudioPlayer = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props,
2508
2508
  id = props.id,
2509
2509
  _props$iframeTitle = props.iframeTitle,
2510
2510
  iframeTitle = _props$iframeTitle === void 0 ? null : _props$iframeTitle,
2511
- rest = _objectWithoutPropertiesLoose(props, _excluded$Z); // The root iframe object generated from the embedCode.
2511
+ rest = _objectWithoutPropertiesLoose(props, _excluded$Z);
2512
2512
 
2513
+ var _useState = useState(false),
2514
+ invalidEmbed = _useState[0],
2515
+ setInvalidEmbed = _useState[1];
2513
2516
 
2514
- var iframeDoc = parseIframeEmbedCode(embedCode); // when no embedCode or it was a broken code.
2517
+ var _useState2 = useState(undefined),
2518
+ iframeDoc = _useState2[0],
2519
+ setIframeDoc = _useState2[1];
2520
+ /**
2521
+ * Main hooks to check the embedCode structure.
2522
+ */
2515
2523
 
2516
- var isInvalidEmbed = !embedCode || !iframeDoc || !isValidEmbedCode(iframeDoc);
2517
- var errorMessage = "<strong>Error: </strong>This audio player has not been configured properly. Please contact the site administrator.";
2518
2524
 
2519
- function isValidEmbedCode(doc) {
2520
- var _doc$src;
2525
+ useEffect(function () {
2526
+ // The root iframe object generated from the embedCode.
2527
+ var iframe = parseIframeEmbedCode(embedCode); // when no embedCode or it was a broken code.
2521
2528
 
2522
- return audioType !== "file" && (doc == null ? void 0 : (_doc$src = doc.src) == null ? void 0 : _doc$src.includes(audioType + ".com"));
2523
- } // Only set the iframe title if it doesn't already have it in the iframe.
2529
+ var isInvalidEmbed = !embedCode || !iframe || !isValidEmbedCode(audioType, iframe); // Only set the iframe title if it doesn't already have it in the iframe.
2524
2530
 
2531
+ if (iframe && !iframe.title) {
2532
+ iframe.title = iframeTitle ? iframeTitle : "Embedded audio player";
2533
+ }
2525
2534
 
2526
- if (iframeDoc && !iframeDoc.title) {
2527
- iframeDoc.title = iframeTitle ? iframeTitle : "Embedded audio player";
2528
- }
2535
+ var isThirdPartyService = !!thirdPartyServices.find(function (service) {
2536
+ return service === audioType;
2537
+ });
2538
+ var isThirdPartyWithoutCode = isThirdPartyService && !embedCode;
2529
2539
 
2530
- var isThirdPartyService = !!thirdPartyServices.find(function (service) {
2531
- return service === audioType;
2532
- });
2533
- var isThirdPartyWithoutCode = isThirdPartyService && !embedCode;
2540
+ if (isThirdPartyWithoutCode) {
2541
+ console.warn("NYPL Reservoir AudioPlayer: The `embedCode` prop is required when using a 3rd party streaming service.");
2542
+ isInvalidEmbed = true;
2543
+ }
2544
+
2545
+ setInvalidEmbed(isInvalidEmbed);
2546
+ setIframeDoc(iframe);
2547
+ }, [embedCode, audioType, iframeTitle]);
2548
+ var errorMessage = "<strong>Error: </strong>This audio player has not been configured properly. Please contact the site administrator.";
2549
+
2550
+ function isValidEmbedCode(audioType, doc) {
2551
+ var _doc$src;
2534
2552
 
2535
- if (isThirdPartyWithoutCode) {
2536
- console.warn("NYPL Reservoir AudioPlayer: The `embedCode` prop is required when using a 3rd party streaming service.");
2537
- isInvalidEmbed = true;
2553
+ return audioType !== "file" && (doc == null ? void 0 : (_doc$src = doc.src) == null ? void 0 : _doc$src.includes(audioType + ".com"));
2538
2554
  }
2539
2555
 
2540
2556
  var styles = useMultiStyleConfig("AudioPlayer", {});
@@ -2561,7 +2577,7 @@ var AudioPlayer = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props,
2561
2577
  "data-testid": "audio-player-component",
2562
2578
  ref: ref,
2563
2579
  __css: styles
2564
- }, rest), isInvalidEmbed ? React__default.createElement(Box, {
2580
+ }, rest), invalidEmbed ? React__default.createElement(Box, {
2565
2581
  dangerouslySetInnerHTML: {
2566
2582
  __html: errorMessage
2567
2583
  },
@@ -15587,10 +15603,10 @@ var Tooltip$1 = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
15587
15603
  shouldWrapChildren = props.shouldWrapChildren,
15588
15604
  rest = _objectWithoutPropertiesLoose(props, _excluded$2d);
15589
15605
 
15590
- if (typeof content !== "string") {
15606
+ if (typeof content !== "string" && typeof content !== "number") {
15591
15607
  React__default.Children.map(content, function (contentChild) {
15592
15608
  if (contentChild.type !== Icon || contentChild.type !== Image) {
15593
- console.warn("NYPL Reservoir Tooltip: Pass in a string, DS Icon, or DS Image into the 'content' prop.");
15609
+ console.warn("NYPL Reservoir Tooltip: Pass in a string, number, DS Icon, or DS Image into the 'content' prop.");
15594
15610
  }
15595
15611
  });
15596
15612
  }