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.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Get the current part of day (morning, evening, etc.)
3
3
  * @author Gabe Abrams
4
+ * @returns the part of day (morning, evening, etc.)
4
5
  */
5
6
  declare const getPartOfDay: () => string;
6
7
  export default getPartOfDay;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ /**
3
+ * Given some text, make the links clickable
4
+ * @author Gabe Abrams
5
+ * @param text the text to process
6
+ * @param [opts] options to customize behavior
7
+ * @param [opts.newTab] if true, links will open in a new tab
8
+ * @param [opts.preventPropagation] if true, clicks to link will prevent
9
+ * propagation
10
+ * @param [opts.inheritColor] if true, inherit text color for links
11
+ * @returns the processed text
12
+ */
13
+ declare const makeLinksClickable: (text: string, opts?: {
14
+ newTab?: boolean;
15
+ preventPropagation?: boolean;
16
+ inheritColor?: boolean;
17
+ }) => React.ReactNode;
18
+ export default makeLinksClickable;
@@ -65,6 +65,7 @@ import validateEmail from './helpers/validators/validateEmail';
65
65
  import validatePhoneNumber from './helpers/validators/validatePhoneNumber';
66
66
  import validateString from './helpers/validators/validateString';
67
67
  import idify from './helpers/idify';
68
+ import makeLinksClickable from './helpers/makeLinksClickable';
68
69
  import ModalButtonType from './types/ModalButtonType';
69
70
  import ModalSize from './types/ModalSize';
70
71
  import ModalType from './types/ModalType';
@@ -83,4 +84,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
83
84
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
84
85
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
85
86
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
86
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
87
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
package/dist/esm/index.js CHANGED
@@ -42338,11 +42338,12 @@ const startMinWait = (minWaitMs) => {
42338
42338
  /**
42339
42339
  * Get the current part of day (morning, evening, etc.)
42340
42340
  * @author Gabe Abrams
42341
+ * @returns the part of day (morning, evening, etc.)
42341
42342
  */
42342
42343
  const getPartOfDay = () => {
42343
42344
  // Setup the post-it time of day
42344
42345
  let partOfDay = 'day';
42345
- let hours = new Date().getHours();
42346
+ const hours = new Date().getHours();
42346
42347
  if (hours < 12) {
42347
42348
  partOfDay = 'morning';
42348
42349
  }
@@ -42906,6 +42907,65 @@ const validateString = (input, opts) => {
42906
42907
  });
42907
42908
  };
42908
42909
 
42910
+ // Import React
42911
+ // Regular express that matches urls
42912
+ const urlRegex = /(https?:\/\/)?([a-z0-9-]+\.)+[a-z0-9]{2,6}(:[0-9]{1,5})?(\/\S*)?/g;
42913
+ /**
42914
+ * Given some text, make the links clickable
42915
+ * @author Gabe Abrams
42916
+ * @param text the text to process
42917
+ * @param [opts] options to customize behavior
42918
+ * @param [opts.newTab] if true, links will open in a new tab
42919
+ * @param [opts.preventPropagation] if true, clicks to link will prevent
42920
+ * propagation
42921
+ * @param [opts.inheritColor] if true, inherit text color for links
42922
+ * @returns the processed text
42923
+ */
42924
+ const makeLinksClickable = (text, opts) => {
42925
+ // Search text for links
42926
+ let matches = urlRegex.exec(text);
42927
+ // If no matches, just return the text
42928
+ if (!matches) {
42929
+ return text;
42930
+ }
42931
+ // Check if using new tab
42932
+ const newTab = opts === null || opts === void 0 ? void 0 : opts.newTab;
42933
+ // Next element key
42934
+ let nextKey = 0;
42935
+ // Process each link
42936
+ const elements = [];
42937
+ let lastIndex = 0;
42938
+ while (matches) {
42939
+ // Get the link
42940
+ const link = matches[0];
42941
+ // Get the index of the link
42942
+ const { index } = matches;
42943
+ // Add the text before the link
42944
+ elements.push(React__default.createElement("span", { key: nextKey += 1 }, text.substring(lastIndex, index)));
42945
+ // Add the link
42946
+ elements.push(React__default.createElement("a", { key: nextKey += 1, href: link, target: newTab ? '_blank' : undefined, rel: newTab ? 'noopener noreferrer' : undefined, style: {
42947
+ textDecoration: 'underline',
42948
+ color: (opts === null || opts === void 0 ? void 0 : opts.inheritColor) ? 'inherit' : undefined,
42949
+ }, onClick: (e) => {
42950
+ // Prevent propagation if requested
42951
+ if (opts === null || opts === void 0 ? void 0 : opts.preventPropagation) {
42952
+ e.stopPropagation();
42953
+ }
42954
+ } }, link));
42955
+ // Update the last index
42956
+ lastIndex = index + link.length;
42957
+ // Get the next match
42958
+ matches = urlRegex.exec(text);
42959
+ }
42960
+ // Add the last bit of text
42961
+ const remainingText = text.substring(lastIndex);
42962
+ if (remainingText && remainingText.length > 0) {
42963
+ elements.push(React__default.createElement("span", { key: nextKey += 1 }, remainingText));
42964
+ }
42965
+ // Return the elements
42966
+ return elements;
42967
+ };
42968
+
42909
42969
  /**
42910
42970
  * Days of the week
42911
42971
  * @author Gabe Abrams
@@ -42922,5 +42982,5 @@ var DayOfWeek;
42922
42982
  })(DayOfWeek || (DayOfWeek = {}));
42923
42983
  var DayOfWeek$1 = DayOfWeek;
42924
42984
 
42925
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert$1 as alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
42985
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert$1 as alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
42926
42986
  //# sourceMappingURL=index.js.map