dce-reactkit 3.5.12 → 3.5.14
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 +62 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/getPartOfDay.d.ts +1 -0
- package/dist/cjs/types/helpers/makeLinksClickable.d.ts +18 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/esm/index.js +62 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/getPartOfDay.d.ts +1 -0
- package/dist/esm/types/helpers/makeLinksClickable.d.ts +18 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/index.d.ts +19 -1
- package/package.json +1 -1
- package/src/helpers/getPartOfDay.ts +2 -1
- package/src/helpers/makeLinksClickable.tsx +100 -0
- package/src/index.ts +2 -0
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
|
-
|
|
42372
|
+
const hours = new Date().getHours();
|
|
42372
42373
|
if (hours < 12) {
|
|
42373
42374
|
partOfDay = 'morning';
|
|
42374
42375
|
}
|
|
@@ -42932,6 +42933,65 @@ 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
|
|
42946
|
+
* propagation
|
|
42947
|
+
* @param [opts.inheritColor] if true, inherit text color for links
|
|
42948
|
+
* @returns the processed text
|
|
42949
|
+
*/
|
|
42950
|
+
const makeLinksClickable = (text, opts) => {
|
|
42951
|
+
// Search text for links
|
|
42952
|
+
let matches = urlRegex.exec(text);
|
|
42953
|
+
// If no matches, just return the text
|
|
42954
|
+
if (!matches) {
|
|
42955
|
+
return text;
|
|
42956
|
+
}
|
|
42957
|
+
// Check if using new tab
|
|
42958
|
+
const newTab = opts === null || opts === void 0 ? void 0 : opts.newTab;
|
|
42959
|
+
// Next element key
|
|
42960
|
+
let nextKey = 0;
|
|
42961
|
+
// Process each link
|
|
42962
|
+
const elements = [];
|
|
42963
|
+
let lastIndex = 0;
|
|
42964
|
+
while (matches) {
|
|
42965
|
+
// Get the link
|
|
42966
|
+
const link = matches[0];
|
|
42967
|
+
// Get the index of the link
|
|
42968
|
+
const { index } = matches;
|
|
42969
|
+
// Add the text before the link
|
|
42970
|
+
elements.push(React__default["default"].createElement("span", { key: nextKey += 1 }, text.substring(lastIndex, index)));
|
|
42971
|
+
// Add the link
|
|
42972
|
+
elements.push(React__default["default"].createElement("a", { key: nextKey += 1, href: link, target: newTab ? '_blank' : undefined, rel: newTab ? 'noopener noreferrer' : undefined, style: {
|
|
42973
|
+
textDecoration: 'underline',
|
|
42974
|
+
color: (opts === null || opts === void 0 ? void 0 : opts.inheritColor) ? 'inherit' : undefined,
|
|
42975
|
+
}, onClick: (e) => {
|
|
42976
|
+
// Prevent propagation if requested
|
|
42977
|
+
if (opts === null || opts === void 0 ? void 0 : opts.preventPropagation) {
|
|
42978
|
+
e.stopPropagation();
|
|
42979
|
+
}
|
|
42980
|
+
} }, link));
|
|
42981
|
+
// Update the last index
|
|
42982
|
+
lastIndex = index + link.length;
|
|
42983
|
+
// Get the next match
|
|
42984
|
+
matches = urlRegex.exec(text);
|
|
42985
|
+
}
|
|
42986
|
+
// Add the last bit of text
|
|
42987
|
+
const remainingText = text.substring(lastIndex);
|
|
42988
|
+
if (remainingText && remainingText.length > 0) {
|
|
42989
|
+
elements.push(React__default["default"].createElement("span", { key: nextKey += 1 }, remainingText));
|
|
42990
|
+
}
|
|
42991
|
+
// Return the elements
|
|
42992
|
+
return elements;
|
|
42993
|
+
};
|
|
42994
|
+
|
|
42935
42995
|
/**
|
|
42936
42996
|
* Days of the week
|
|
42937
42997
|
* @author Gabe Abrams
|
|
@@ -43017,6 +43077,7 @@ exports.initServer = initServer;
|
|
|
43017
43077
|
exports.isMobileOrTablet = isMobileOrTablet;
|
|
43018
43078
|
exports.leaveToURL = leaveToURL;
|
|
43019
43079
|
exports.logClientEvent = logClientEvent;
|
|
43080
|
+
exports.makeLinksClickable = makeLinksClickable;
|
|
43020
43081
|
exports.onlyKeepLetters = onlyKeepLetters;
|
|
43021
43082
|
exports.padDecimalZeros = padDecimalZeros;
|
|
43022
43083
|
exports.padZerosLeft = padZerosLeft;
|