@trackunit/shared-utils 1.15.52 → 1.15.53

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/index.cjs.js CHANGED
@@ -936,6 +936,17 @@ const convertBlobToBase64 = (blob) => {
936
936
  */
937
937
  const isValidImage = (file) => (file.type.match(/image.*/) ? true : false);
938
938
 
939
+ /**
940
+ * Type guard that checks whether a string is a recognised sorting property.
941
+ *
942
+ * @param sortingState - Array of valid sort property names.
943
+ * @param value - The value to check.
944
+ * @returns {boolean} `true` when {@link value} matches one of the entries in {@link sortingState}.
945
+ */
946
+ const isSortByProperty = (sortingState, value) => {
947
+ const sortByPropertyValidated = sortingState.find(validName => validName === value);
948
+ return !!sortByPropertyValidated;
949
+ };
939
950
  /**
940
951
  * Compare two strings
941
952
  *
@@ -1605,6 +1616,7 @@ exports.groupTinyDataToOthers = groupTinyDataToOthers;
1605
1616
  exports.hourIntervals = hourIntervals;
1606
1617
  exports.intersection = intersection;
1607
1618
  exports.isArrayEqual = isArrayEqual;
1619
+ exports.isSortByProperty = isSortByProperty;
1608
1620
  exports.isSorted = isSorted;
1609
1621
  exports.isUUID = isUUID;
1610
1622
  exports.isValidImage = isValidImage;
package/index.esm.js CHANGED
@@ -934,6 +934,17 @@ const convertBlobToBase64 = (blob) => {
934
934
  */
935
935
  const isValidImage = (file) => (file.type.match(/image.*/) ? true : false);
936
936
 
937
+ /**
938
+ * Type guard that checks whether a string is a recognised sorting property.
939
+ *
940
+ * @param sortingState - Array of valid sort property names.
941
+ * @param value - The value to check.
942
+ * @returns {boolean} `true` when {@link value} matches one of the entries in {@link sortingState}.
943
+ */
944
+ const isSortByProperty = (sortingState, value) => {
945
+ const sortByPropertyValidated = sortingState.find(validName => validName === value);
946
+ return !!sortByPropertyValidated;
947
+ };
937
948
  /**
938
949
  * Compare two strings
939
950
  *
@@ -1556,4 +1567,4 @@ const formatUsCustomaryDistance = (value) => {
1556
1567
  }
1557
1568
  };
1558
1569
 
1559
- export { DateTimeFormat, HoursAndMinutesFormat, UnitsOfMeasurementSI, UnitsOfMeasurementUSCustomary, VISIBLE_ONLY_COLUMN_VISIBILITY_KEY, align, alphabeticallySort, arrayLengthCompare, arrayNotEmpty, booleanCompare, calculateImageScaleRatio, capitalize, colorsFromStyleDeclaration, convertBlobToBase64, convertMetersToKilometers, convertMetersToYards, convertYardsToMeters, convertYardsToMiles, dateCompare, deleteUndefinedKeys, difference, doNothing, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, fetchImageAsBase64, filterByMultiple, formatAddress, formatCoordinates, formatSiDistance, formatUsCustomaryDistance, fuzzySearch, getAllColors, getDifferenceBetweenDates, getEndOfDay, getFirstLevelObjectPropertyDifferences, getISOStringFromDate, getLoremIpsum, getMimeTypeFromDataURL, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isArrayEqual, isSorted, isUUID, isValidImage, loadSVGDimensions, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectEntries, objectFromEntries, objectKeys, objectValues, parseTailwindArbitraryValue, pick, preload, removeLeftPadding, removeProperties, removeProperty, replaceNullableNumbersWithZero, resizeBlob, resizeImage, rgb2hex, size, stringCompare, stringCompareFromKey, stringNaturalCompare, stripHiddenCharacters, svgToPNG, titleCase, toID, toIDs, toPNG, toUUID, trimIds, trimPath, truthy, unionArraysByKey, uuidv3, uuidv4, uuidv5 };
1570
+ export { DateTimeFormat, HoursAndMinutesFormat, UnitsOfMeasurementSI, UnitsOfMeasurementUSCustomary, VISIBLE_ONLY_COLUMN_VISIBILITY_KEY, align, alphabeticallySort, arrayLengthCompare, arrayNotEmpty, booleanCompare, calculateImageScaleRatio, capitalize, colorsFromStyleDeclaration, convertBlobToBase64, convertMetersToKilometers, convertMetersToYards, convertYardsToMeters, convertYardsToMiles, dateCompare, deleteUndefinedKeys, difference, doNothing, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, fetchImageAsBase64, filterByMultiple, formatAddress, formatCoordinates, formatSiDistance, formatUsCustomaryDistance, fuzzySearch, getAllColors, getDifferenceBetweenDates, getEndOfDay, getFirstLevelObjectPropertyDifferences, getISOStringFromDate, getLoremIpsum, getMimeTypeFromDataURL, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isArrayEqual, isSortByProperty, isSorted, isUUID, isValidImage, loadSVGDimensions, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectEntries, objectFromEntries, objectKeys, objectValues, parseTailwindArbitraryValue, pick, preload, removeLeftPadding, removeProperties, removeProperty, replaceNullableNumbersWithZero, resizeBlob, resizeImage, rgb2hex, size, stringCompare, stringCompareFromKey, stringNaturalCompare, stripHiddenCharacters, svgToPNG, titleCase, toID, toIDs, toPNG, toUUID, trimIds, trimPath, truthy, unionArraysByKey, uuidv3, uuidv4, uuidv5 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/shared-utils",
3
- "version": "1.15.52",
3
+ "version": "1.15.53",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "engines": {
6
6
  "node": ">=24.x"
@@ -1,4 +1,12 @@
1
1
  import { Maybe } from "../Maybe";
2
+ /**
3
+ * Type guard that checks whether a string is a recognised sorting property.
4
+ *
5
+ * @param sortingState - Array of valid sort property names.
6
+ * @param value - The value to check.
7
+ * @returns {boolean} `true` when {@link value} matches one of the entries in {@link sortingState}.
8
+ */
9
+ export declare const isSortByProperty: <TSortByType extends string>(sortingState: Array<TSortByType>, value?: string) => value is TSortByType;
2
10
  /**
3
11
  * Compare two strings
4
12
  *