dce-reactkit 4.1.3 → 4.1.5

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.
@@ -0,0 +1,17 @@
1
+ # Instructions for Copilot
2
+
3
+ Use the following instructions to complete the code:
4
+
5
+ - Use single quotes for all strings, except when using template literals. Use double quotes only in JSX code for string attributes.
6
+ - Use `const` for variables that are not reassigned.
7
+ - Use `let` only when you need to reassign a variable.
8
+ - Use `===` for equality checks.
9
+ - Use `!==` for inequality checks.
10
+ - Generously document blocks of code with comments, capitalize the first letter of comments, and use full sentences.
11
+ - Use `//` for single-line comments and `/* ... */` for multi-line comments
12
+ - Use `{/* ... */}` for comments in JSX code.
13
+ - Never use `function` keyword; use arrow functions instead.
14
+ - All functions should be defined using arrow function syntax and should use parentheses for parameters, even if there is only one parameter and curly braces for the function body, even if it's a single line function.
15
+ - Use `export default` for the main export of a module.
16
+ - If a function has more than two arguments, switch to using a single `opts` object argument for parameters.
17
+ - Use `import` statements that use single quotes for module paths.
package/dist/cjs/index.js CHANGED
@@ -57,7 +57,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
57
57
  });
58
58
  }
59
59
 
60
- // Highest error code = DRK36
60
+ // Highest error code = DRK37
61
61
  /**
62
62
  * List of error codes built into the react kit
63
63
  * @author Gabe Abrams
@@ -70,6 +70,7 @@ var ReactKitErrorCode;
70
70
  ReactKitErrorCode["NoCACCLSendRequestFunction"] = "DRK7";
71
71
  ReactKitErrorCode["SimpleDateChooserInvalidDateRange"] = "DRK35";
72
72
  ReactKitErrorCode["SimpleDateChooserInvalidNumMonths"] = "DRK36";
73
+ ReactKitErrorCode["ETTimestampInvalid"] = "DRK37";
73
74
  })(ReactKitErrorCode || (ReactKitErrorCode = {}));
74
75
  var ReactKitErrorCode$1 = ReactKitErrorCode;
75
76
 
@@ -3952,7 +3953,8 @@ const genCSV = (data, columns) => {
3952
3953
  let contents;
3953
3954
  const cell = datum[column.param];
3954
3955
  if (typeof cell === 'string'
3955
- || typeof cell === 'number') {
3956
+ || typeof cell === 'number'
3957
+ || typeof cell === 'boolean') {
3956
3958
  contents = String(cell);
3957
3959
  }
3958
3960
  else if (cell === null) {
@@ -3988,7 +3990,7 @@ const CSVDownloadButton = (props) => {
3988
3990
  /*------------------------------------------------------------------------*/
3989
3991
  /* -------------- Props ------------- */
3990
3992
  // Destructure all props
3991
- const { filename, csv, id, className, ariaLabel, style, onClick, children, } = props;
3993
+ const { filename, csv, id, className, ariaLabel, style, onClick, children, label = 'Download CSV', } = props;
3992
3994
  /*------------------------------------------------------------------------*/
3993
3995
  /* ------------------------------- Render ------------------------------- */
3994
3996
  /*------------------------------------------------------------------------*/
@@ -4002,7 +4004,7 @@ const CSVDownloadButton = (props) => {
4002
4004
  !children && (React__default["default"].createElement(React__default["default"].Fragment, null,
4003
4005
  React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faCloudDownloadAlt }),
4004
4006
  ' ',
4005
- "Download CSV")),
4007
+ label)),
4006
4008
  children));
4007
4009
  };
4008
4010
 
@@ -16372,6 +16374,48 @@ const getWordCount = (text) => {
16372
16374
  return trimmedTextWithoutPunctuation.split(/\s+/g).length;
16373
16375
  };
16374
16376
 
16377
+ // Import shared types
16378
+ /**
16379
+ * Get a timestamp (ms since epoch) from time info (year, month, day, hour, minute, etc.) in Eastern Time (ET)
16380
+ * @author Gardenia Liu
16381
+ * @author Gabe Abrams
16382
+ * @param opts object containing all arguments
16383
+ * @param opts.year Year (e.g. 2023)
16384
+ * @param opts.month Month (1-12)
16385
+ * @param opts.day Day of the month (1-31)
16386
+ * @param opts.hour Hour (0-23)
16387
+ * @param opts.minute Minute (0-59))
16388
+ * @returns Timestamp in milliseconds since epoch
16389
+ */
16390
+ const getTimestampFromTimeInfoInET = (opts) => {
16391
+ // Destructure opts
16392
+ const { year, month, day, hour, minute, } = opts;
16393
+ // Determine if the date is in DST in Eastern Time
16394
+ const tempDate = new Date(year, month - 1, day);
16395
+ const janOffset = new Date(year, 0, 1).getTimezoneOffset();
16396
+ const isDST = tempDate.getTimezoneOffset() < janOffset;
16397
+ const etOffset = isDST ? '-04:00' : '-05:00';
16398
+ // Format with leading zeroes
16399
+ const mm = padZerosLeft(month, 2);
16400
+ const dd = padZerosLeft(day, 2);
16401
+ const hh = padZerosLeft(hour, 2);
16402
+ const min = padZerosLeft(minute, 2);
16403
+ // Build ET ISO string and convert to UTC timestamp
16404
+ const etISOString = `${year}-${mm}-${dd}T${hh}:${min}:00${etOffset}`;
16405
+ const timestamp = (new Date(etISOString)).getTime();
16406
+ // Verify that the timestamp is correct
16407
+ const timeInfoInET = getTimeInfoInET(timestamp);
16408
+ if (timeInfoInET.year !== year
16409
+ || timeInfoInET.month !== month
16410
+ || timeInfoInET.day !== day
16411
+ || timeInfoInET.hour !== hour
16412
+ || timeInfoInET.minute !== minute) {
16413
+ throw new ErrorWithCode(`Timestamp mismatch: expected ${year}-${mm}-${dd} ${hh}:${min}, got ${timeInfoInET.year}-${padZerosLeft(timeInfoInET.month, 2)}-${padZerosLeft(timeInfoInET.day, 2)} ${padZerosLeft(timeInfoInET.hour, 2)}:${padZerosLeft(timeInfoInET.minute, 2)}`, ReactKitErrorCode$1.ETTimestampInvalid);
16414
+ }
16415
+ // Valid! Return the timestamp
16416
+ return timestamp;
16417
+ };
16418
+
16375
16419
  /**
16376
16420
  * Days of the week
16377
16421
  * @author Gabe Abrams
@@ -16461,6 +16505,7 @@ exports.getMonthName = getMonthName;
16461
16505
  exports.getOrdinal = getOrdinal;
16462
16506
  exports.getPartOfDay = getPartOfDay;
16463
16507
  exports.getTimeInfoInET = getTimeInfoInET;
16508
+ exports.getTimestampFromTimeInfoInET = getTimestampFromTimeInfoInET;
16464
16509
  exports.getWordCount = getWordCount;
16465
16510
  exports.idify = idify;
16466
16511
  exports.initClient = initClient;