dce-reactkit 3.5.12 → 3.5.13

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/cjs/index.js CHANGED
@@ -42364,11 +42364,12 @@ const startMinWait = (minWaitMs) => {
42364
42364
  /**
42365
42365
  * Get the current part of day (morning, evening, etc.)
42366
42366
  * @author Gabe Abrams
42367
+ * @returns the part of day (morning, evening, etc.)
42367
42368
  */
42368
42369
  const getPartOfDay = () => {
42369
42370
  // Setup the post-it time of day
42370
42371
  let partOfDay = 'day';
42371
- let hours = new Date().getHours();
42372
+ const hours = new Date().getHours();
42372
42373
  if (hours < 12) {
42373
42374
  partOfDay = 'morning';
42374
42375
  }
@@ -42932,6 +42933,64 @@ const validateString = (input, opts) => {
42932
42933
  });
42933
42934
  };
42934
42935
 
42936
+ // Import React
42937
+ // Regular express that matches urls
42938
+ const urlRegex = /(https?:\/\/)?([a-z0-9-]+\.)+[a-z0-9]{2,6}(:[0-9]{1,5})?(\/\S*)?/g;
42939
+ /**
42940
+ * Given some text, make the links clickable
42941
+ * @author Gabe Abrams
42942
+ * @param text the text to process
42943
+ * @param [opts] options to customize behavior
42944
+ * @param [opts.newTab] if true, links will open in a new tab
42945
+ * @param [opts.preventPropagation] if true, clicks to link will prevent default
42946
+ * and propagation
42947
+ * @returns the processed text
42948
+ */
42949
+ const makeLinksClickable = (text, opts) => {
42950
+ // Search text for links
42951
+ let matches = urlRegex.exec(text);
42952
+ // If no matches, just return the text
42953
+ if (!matches) {
42954
+ return text;
42955
+ }
42956
+ // Check if using new tab
42957
+ const newTab = opts === null || opts === void 0 ? void 0 : opts.newTab;
42958
+ // Next element key
42959
+ let nextKey = 0;
42960
+ // Process each link
42961
+ const elements = [];
42962
+ let lastIndex = 0;
42963
+ while (matches) {
42964
+ // Get the link
42965
+ const link = matches[0];
42966
+ // Get the index of the link
42967
+ const { index } = matches;
42968
+ // Add the text before the link
42969
+ elements.push(React__default["default"].createElement("span", { key: nextKey += 1 }, text.substring(lastIndex, index)));
42970
+ // Add the link
42971
+ elements.push(React__default["default"].createElement("a", { key: nextKey += 1, href: link, target: newTab ? '_blank' : undefined, rel: newTab ? 'noopener noreferrer' : undefined, style: {
42972
+ textDecoration: 'underline',
42973
+ }, onClick: (e) => {
42974
+ // Prevent default and propagation if requested
42975
+ if (opts === null || opts === void 0 ? void 0 : opts.preventPropagation) {
42976
+ e.preventDefault();
42977
+ e.stopPropagation();
42978
+ }
42979
+ } }, link));
42980
+ // Update the last index
42981
+ lastIndex = index + link.length;
42982
+ // Get the next match
42983
+ matches = urlRegex.exec(text);
42984
+ }
42985
+ // Add the last bit of text
42986
+ const remainingText = text.substring(lastIndex);
42987
+ if (remainingText && remainingText.length > 0) {
42988
+ elements.push(React__default["default"].createElement("span", { key: nextKey += 1 }, remainingText));
42989
+ }
42990
+ // Return the elements
42991
+ return elements;
42992
+ };
42993
+
42935
42994
  /**
42936
42995
  * Days of the week
42937
42996
  * @author Gabe Abrams
@@ -43017,6 +43076,7 @@ exports.initServer = initServer;
43017
43076
  exports.isMobileOrTablet = isMobileOrTablet;
43018
43077
  exports.leaveToURL = leaveToURL;
43019
43078
  exports.logClientEvent = logClientEvent;
43079
+ exports.makeLinksClickable = makeLinksClickable;
43020
43080
  exports.onlyKeepLetters = onlyKeepLetters;
43021
43081
  exports.padDecimalZeros = padDecimalZeros;
43022
43082
  exports.padZerosLeft = padZerosLeft;