dce-reactkit 3.2.7 → 3.2.9
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 +52 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/compareArraysByProp.d.ts +12 -0
- package/dist/cjs/types/helpers/extractProp.d.ts +12 -0
- package/dist/cjs/types/index.d.ts +3 -1
- package/dist/esm/index.js +51 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/compareArraysByProp.d.ts +12 -0
- package/dist/esm/types/helpers/extractProp.d.ts +12 -0
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/index.d.ts +25 -1
- package/package.json +1 -1
- package/src/components/SimpleDateChooser.tsx +2 -2
- package/src/helpers/compareArraysByProp.ts +37 -0
- package/src/helpers/extractProp.ts +17 -0
- package/src/index.ts +4 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1387,7 +1387,7 @@ const SimpleDateChooser = (props) => {
|
|
|
1387
1387
|
const dayOptions = [];
|
|
1388
1388
|
choices.forEach((choice) => {
|
|
1389
1389
|
// Create month option
|
|
1390
|
-
monthOptions.push(React__default["default"].createElement("option", { key: choice.month
|
|
1390
|
+
monthOptions.push(React__default["default"].createElement("option", { key: `${choice.year}-${choice.month}`, value: `${choice.month}-${choice.year}`, "aria-label": `choose ${choice.choiceName}`, onSelect: () => {
|
|
1391
1391
|
onChange(choice.month, choice.days[0], choice.year);
|
|
1392
1392
|
} }, choice.choiceName));
|
|
1393
1393
|
if (month === choice.month) {
|
|
@@ -1395,7 +1395,7 @@ const SimpleDateChooser = (props) => {
|
|
|
1395
1395
|
// Create day options
|
|
1396
1396
|
choice.days.forEach((dayChoice) => {
|
|
1397
1397
|
const ordinal = getOrdinal(dayChoice);
|
|
1398
|
-
dayOptions.push(React__default["default"].createElement("option", { key: dayChoice
|
|
1398
|
+
dayOptions.push(React__default["default"].createElement("option", { key: `${choice.year}-${choice.month}-${dayChoice}`, value: dayChoice, "aria-label": `choose date ${dayChoice}` },
|
|
1399
1399
|
dayChoice,
|
|
1400
1400
|
ordinal));
|
|
1401
1401
|
});
|
|
@@ -5533,6 +5533,54 @@ const canReviewLogs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
5533
5533
|
return canReview;
|
|
5534
5534
|
});
|
|
5535
5535
|
|
|
5536
|
+
/**
|
|
5537
|
+
* For every element in an array, extract the value of a prop
|
|
5538
|
+
* (e.g. for all user objects, extract their ages and put that into a new
|
|
5539
|
+
* ages array)
|
|
5540
|
+
* @author Gabe Abrams
|
|
5541
|
+
* @param arr the array of objects to operate on
|
|
5542
|
+
* @param prop the property to extract from each object
|
|
5543
|
+
* @returns new array containing the corresponding values, in order, of each
|
|
5544
|
+
* object in the original array
|
|
5545
|
+
*/
|
|
5546
|
+
const extractProp = (arr, prop) => {
|
|
5547
|
+
return arr.map((item) => {
|
|
5548
|
+
return item[prop];
|
|
5549
|
+
});
|
|
5550
|
+
};
|
|
5551
|
+
|
|
5552
|
+
// Import shared helpers
|
|
5553
|
+
/**
|
|
5554
|
+
* Compare two arrays of objects by only comparing the values in a specific
|
|
5555
|
+
* property (e.g. compare user arrays by comparing their user.id values)
|
|
5556
|
+
* @author Gabe Abrams
|
|
5557
|
+
* @param a the first array
|
|
5558
|
+
* @param b the second array
|
|
5559
|
+
* @param prop the property to compare with
|
|
5560
|
+
* @returns true if the arrays contain the same objects as determined by
|
|
5561
|
+
* the values associated with each object's prop
|
|
5562
|
+
*/
|
|
5563
|
+
const compareArraysByProp = (a, b, prop) => {
|
|
5564
|
+
// Extract values for comparison
|
|
5565
|
+
const aVals = new Set(extractProp(a, prop));
|
|
5566
|
+
const bVals = new Set(extractProp(b, prop));
|
|
5567
|
+
// Compare sizes first
|
|
5568
|
+
if (aVals.size !== bVals.size) {
|
|
5569
|
+
return false;
|
|
5570
|
+
}
|
|
5571
|
+
// Same number of items. Make sure every object in aVals appears in bVals
|
|
5572
|
+
// (if so, they should be equivalent since the sizes are the same)
|
|
5573
|
+
// > Create map of items in bVals
|
|
5574
|
+
const inBVals = {}; // item => true if in bVals
|
|
5575
|
+
Array.from(bVals.values()).forEach((item) => {
|
|
5576
|
+
inBVals[item] = true;
|
|
5577
|
+
});
|
|
5578
|
+
// > Loop through aVals and make sure every item is in bVals
|
|
5579
|
+
return Array.from(aVals.values()).every((item) => {
|
|
5580
|
+
return inBVals[item];
|
|
5581
|
+
});
|
|
5582
|
+
};
|
|
5583
|
+
|
|
5536
5584
|
/**
|
|
5537
5585
|
* Days of the week
|
|
5538
5586
|
* @author Gabe Abrams
|
|
@@ -5588,7 +5636,9 @@ exports.alert = alert$1;
|
|
|
5588
5636
|
exports.avg = avg;
|
|
5589
5637
|
exports.canReviewLogs = canReviewLogs;
|
|
5590
5638
|
exports.ceilToNumDecimals = ceilToNumDecimals;
|
|
5639
|
+
exports.compareArraysByProp = compareArraysByProp;
|
|
5591
5640
|
exports.confirm = confirm;
|
|
5641
|
+
exports.extractProp = extractProp;
|
|
5592
5642
|
exports.floorToNumDecimals = floorToNumDecimals;
|
|
5593
5643
|
exports.forceNumIntoBounds = forceNumIntoBounds;
|
|
5594
5644
|
exports.genCSV = genCSV;
|