dce-reactkit 4.1.4 → 4.1.6

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
 
@@ -2896,12 +2897,12 @@ const SimpleDateChooser = (props) => {
2896
2897
  });
2897
2898
  // Create body
2898
2899
  body = (React__default["default"].createElement("div", { className: "SimpleDateChooser-inner-container d-inline-block", "aria-label": `date chooser with selected date: ${month}/${day}/${year}` },
2899
- React__default["default"].createElement("select", { "aria-label": `month for ${ariaLabel}`, className: "custom-select d-inline-block mr-1", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-month`, value: `${month}-${year}`, onChange: (e) => {
2900
+ React__default["default"].createElement("select", { "aria-label": `month for ${ariaLabel}`, className: "custom-select form-select d-inline-block mr-1", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-month`, value: `${month}-${year}`, onChange: (e) => {
2900
2901
  const choice = choices[e.target.selectedIndex];
2901
2902
  // Change day, month, and year
2902
2903
  onChange(choice.month, choice.days[0], choice.year);
2903
2904
  } }, monthOptions),
2904
- React__default["default"].createElement("select", { "aria-label": `day for ${ariaLabel}`, className: "custom-select d-inline-block", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-day`, value: day, onChange: (e) => {
2905
+ React__default["default"].createElement("select", { "aria-label": `day for ${ariaLabel}`, className: "custom-select form-select d-inline-block", style: { width: 'auto' }, id: `SimpleDateChooser-${name}-day`, value: day, onChange: (e) => {
2905
2906
  // Only change the day
2906
2907
  onChange(month, Number.parseInt(e.target.value, 10), year);
2907
2908
  } }, dayOptions)));
@@ -3034,7 +3035,7 @@ const SimpleTimeChooser = (props) => {
3034
3035
  return (React__default["default"].createElement("option", { key: numMinutesForChoice, value: numMinutesForChoice, "aria-label": `choose ${timeString}` }, timeString));
3035
3036
  });
3036
3037
  return (React__default["default"].createElement("div", { className: "SimpleTimeChooser-container", "aria-label": `time chooser with selected time: ${formatTime(selectedTimeMin)}` },
3037
- React__default["default"].createElement("select", { "aria-label": `time for ${ariaLabel}`, className: "custom-select d-inline-block", style: { width: 'auto' }, id: `SimpleTimeChooser-${name}-time`, value: selectedTimeMin, onChange: (e) => {
3038
+ React__default["default"].createElement("select", { "aria-label": `time for ${ariaLabel}`, className: "custom-select form-select d-inline-block", style: { width: 'auto' }, id: `SimpleTimeChooser-${name}-time`, value: selectedTimeMin, onChange: (e) => {
3038
3039
  // Parse selector value (string)
3039
3040
  const newTime = Number.parseInt(e.target.value, 10);
3040
3041
  // Convert minutes since midnight to hour and minute
@@ -16373,6 +16374,48 @@ const getWordCount = (text) => {
16373
16374
  return trimmedTextWithoutPunctuation.split(/\s+/g).length;
16374
16375
  };
16375
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
+
16376
16419
  /**
16377
16420
  * Days of the week
16378
16421
  * @author Gabe Abrams
@@ -16462,6 +16505,7 @@ exports.getMonthName = getMonthName;
16462
16505
  exports.getOrdinal = getOrdinal;
16463
16506
  exports.getPartOfDay = getPartOfDay;
16464
16507
  exports.getTimeInfoInET = getTimeInfoInET;
16508
+ exports.getTimestampFromTimeInfoInET = getTimestampFromTimeInfoInET;
16465
16509
  exports.getWordCount = getWordCount;
16466
16510
  exports.idify = idify;
16467
16511
  exports.initClient = initClient;