novo-elements 11.1.0-next.2 → 11.1.0-next.3

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.
@@ -21568,6 +21568,11 @@ function Deferred() {
21568
21568
 
21569
21569
  // @dynamic
21570
21570
  class Helpers {
21571
+ /**
21572
+ * Checks if the provided value is an Angular TemplateRef
21573
+ * @param value - The value to check
21574
+ * @returns true if the value is an instance of TemplateRef, false otherwise
21575
+ */
21571
21576
  static isTemplateRef(value) {
21572
21577
  return value instanceof TemplateRef;
21573
21578
  }
@@ -21580,6 +21585,13 @@ class Helpers {
21580
21585
  event.preventDefault();
21581
21586
  }
21582
21587
  }
21588
+ /**
21589
+ * Interpolates a string or function with provided properties
21590
+ * Replaces placeholders in the format $variableName with values from props
21591
+ * @param str - The format string or function to interpolate
21592
+ * @param props - The object containing values to replace placeholders
21593
+ * @returns The interpolated string
21594
+ */
21583
21595
  static interpolate(str, props) {
21584
21596
  if (typeof str === 'function') {
21585
21597
  return str(props);
@@ -21597,6 +21609,14 @@ class Helpers {
21597
21609
  return value !== undefined ? value : '';
21598
21610
  });
21599
21611
  }
21612
+ /**
21613
+ * Interpolates a format string (or array of strings) with provided data
21614
+ * Attempts to replace all variables, returning the first successful interpolation
21615
+ * or an empty string if all attempts fail
21616
+ * @param formatString - A single format string or array of format strings to try
21617
+ * @param data - The object containing values to replace placeholders
21618
+ * @returns The first successfully interpolated string, or an empty string
21619
+ */
21600
21620
  static interpolateWithFallback(formatString, data) {
21601
21621
  // Format string can be an array, it will attempt to interpolate each item
21602
21622
  // in the array, if there is a failure to replace it will mark it as such
@@ -21649,6 +21669,11 @@ class Helpers {
21649
21669
  return props.hasOwnProperty(key.substr(1));
21650
21670
  });
21651
21671
  }
21672
+ /**
21673
+ * Checks if the provided value is a plain object
21674
+ * @param item - The value to check
21675
+ * @returns true if the value is an object but not an array or null, false otherwise
21676
+ */
21652
21677
  static isObject(item) {
21653
21678
  return item && typeof item === 'object' && !Array.isArray(item) && item !== null;
21654
21679
  }
@@ -21658,12 +21683,23 @@ class Helpers {
21658
21683
  static isString(obj) {
21659
21684
  return typeof obj === 'string';
21660
21685
  }
21686
+ /**
21687
+ * Escapes special regex characters in a string
21688
+ * @param obj - The value to escape (if it's a string)
21689
+ * @returns The escaped string if input is a string, otherwise the original value
21690
+ */
21661
21691
  static escapeString(obj) {
21662
21692
  if (Helpers.isString(obj)) {
21663
21693
  return obj.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
21664
21694
  }
21665
21695
  return obj;
21666
21696
  }
21697
+ /**
21698
+ * Checks if a value is a valid number (string or numeric type)
21699
+ * @param val - The value to check
21700
+ * @param includeNegatives - Whether to allow negative numbers (default: false)
21701
+ * @returns true if the value is a valid number, false otherwise
21702
+ */
21667
21703
  static isNumber(val, includeNegatives = false) {
21668
21704
  const numberRegex = includeNegatives ? /^-{0,1}\d*\.?\d*$/ : /^\d*\.?\d*$/;
21669
21705
  if (typeof val === 'string') {
@@ -21703,6 +21739,11 @@ class Helpers {
21703
21739
  static isDate(obj) {
21704
21740
  return obj instanceof Date;
21705
21741
  }
21742
+ /**
21743
+ * Checks if a string is a valid ISO 8601 date format
21744
+ * @param str - The string to validate
21745
+ * @returns true if the string is a valid ISO date, false otherwise
21746
+ */
21706
21747
  static isIsoDate(str) {
21707
21748
  if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(str)) {
21708
21749
  return false;
@@ -21710,6 +21751,11 @@ class Helpers {
21710
21751
  const d = new Date(str);
21711
21752
  return d.toISOString() === str;
21712
21753
  }
21754
+ /**
21755
+ * Converts a value to an array
21756
+ * @param obj - The value to convert
21757
+ * @returns An empty array if undefined, the value wrapped in an array if not already an array, or the array as-is
21758
+ */
21713
21759
  static convertToArray(obj) {
21714
21760
  if (obj === undefined) {
21715
21761
  return [];
@@ -21719,6 +21765,12 @@ class Helpers {
21719
21765
  }
21720
21766
  return obj;
21721
21767
  }
21768
+ /**
21769
+ * Creates a comparator function for sorting objects by specified fields
21770
+ * @param fields - A field name, array of field names, or custom comparator function
21771
+ * @param reverse - Whether to reverse the sort order (default: false for ascending)
21772
+ * @returns A comparator function suitable for use with Array.sort()
21773
+ */
21722
21774
  static sortByField(fields, reverse = false) {
21723
21775
  return (previous, current) => {
21724
21776
  if (Helpers.isFunction(fields)) {
@@ -21756,6 +21808,13 @@ class Helpers {
21756
21808
  return 0;
21757
21809
  };
21758
21810
  }
21811
+ /**
21812
+ * Creates a filter function for filtering objects by field values
21813
+ * Supports exact matching, arrays, ranges, and complex filter objects
21814
+ * @param key - The field key to filter on (supports dot notation for nested properties)
21815
+ * @param value - The filter value (can be a function, array, range object, or regex pattern string)
21816
+ * @returns A filter function suitable for use with Array.filter()
21817
+ */
21759
21818
  static filterByField(key, value) {
21760
21819
  return (item) => {
21761
21820
  const results = [];
@@ -21803,11 +21862,23 @@ class Helpers {
21803
21862
  return results.every((x) => x);
21804
21863
  };
21805
21864
  }
21865
+ /**
21866
+ * Finds the first ancestor element that matches the provided CSS selector
21867
+ * @param element - The starting element to search from
21868
+ * @param selector - The CSS selector to match against
21869
+ * @returns The first matching ancestor element, or undefined if none found
21870
+ */
21806
21871
  static findAncestor(element, selector) {
21807
21872
  while ((element = element.parentElement) && !element.matches.call(element, selector))
21808
21873
  ; // tslint:disable-line
21809
21874
  return element;
21810
21875
  }
21876
+ /**
21877
+ * Creates a deep clone of an object or array
21878
+ * Recursively clones all nested properties and array elements
21879
+ * @param item - The item to clone
21880
+ * @returns A deep clone of the provided item
21881
+ */
21811
21882
  static deepClone(item) {
21812
21883
  if (Array.isArray(item)) {
21813
21884
  const newArr = [];
@@ -21837,6 +21908,13 @@ class Helpers {
21837
21908
  }
21838
21909
  return item;
21839
21910
  }
21911
+ /**
21912
+ * Recursively merges multiple objects into a single object
21913
+ * Nested objects and arrays are merged deeply
21914
+ * @param objs - Two or more objects to merge
21915
+ * @returns A new object with all properties merged
21916
+ * @throws Error if fewer than 2 objects are provided
21917
+ */
21840
21918
  static deepAssign(...objs) {
21841
21919
  if (objs.length < 2) {
21842
21920
  throw new Error('Need two or more objects to merge');
@@ -21906,6 +21984,11 @@ class Helpers {
21906
21984
  return e;
21907
21985
  }
21908
21986
  }
21987
+ /**
21988
+ * Converts a Date object to an object with formatted date and time parts
21989
+ * @param date - The Date object to convert
21990
+ * @returns An object with date components (year, month, day, hour, minute, second, weekday, era, dayPeriod)
21991
+ */
21909
21992
  static dateToObject(date) {
21910
21993
  const dateObj = {
21911
21994
  day: '',
@@ -21937,10 +22020,22 @@ class Helpers {
21937
22020
  return dateObj;
21938
22021
  }
21939
22022
  }
22023
+ /**
22024
+ * Helper class for safe property access using dot notation
22025
+ */
21940
22026
  class Can {
22027
+ /**
22028
+ * Creates a new Can instance
22029
+ * @param obj - The object to wrap for safe property access
22030
+ */
21941
22031
  constructor(obj) {
21942
22032
  this.obj = obj;
21943
22033
  }
22034
+ /**
22035
+ * Safely accesses a property using dot notation
22036
+ * @param key - The property key (supports dot notation for nested properties)
22037
+ * @returns The property value or undefined
22038
+ */
21944
22039
  have(key) {
21945
22040
  const props = key.split('.');
21946
22041
  let item = this.obj;
@@ -21952,14 +22047,32 @@ class Can {
21952
22047
  }
21953
22048
  return item;
21954
22049
  }
22050
+ /**
22051
+ * Checks if a value is defined (not undefined)
22052
+ * @param thing - The value to check
22053
+ * @returns true if the value is defined, false otherwise
22054
+ */
21955
22055
  check(thing) {
21956
22056
  return thing !== void 0;
21957
22057
  }
21958
22058
  }
22059
+ /**
22060
+ * Factory function to create a Can instance for safe property access
22061
+ * @param obj - The object to wrap
22062
+ * @returns A new Can instance
22063
+ */
21959
22064
  function can(obj) {
21960
22065
  return new Can(obj);
21961
22066
  }
21962
- // Assumes data is already sorted
22067
+ /**
22068
+ * Performs a binary search on a sorted array
22069
+ * Note: Assumes the array is already sorted according to the compare function
22070
+ * @param item - The item to search for
22071
+ * @param array - The sorted array to search in
22072
+ * @param compare - Comparator function that returns -1 (item < array[i]), 0 (equal), or 1 (item > array[i])
22073
+ * @returns The matching item if found, undefined otherwise
22074
+ * @throws Error if the item is not comparable to an array element
22075
+ */
21963
22076
  function binarySearch(item, array, compare) {
21964
22077
  return search(0, array.length - 1);
21965
22078
  function search(min, max) {