@northlight/ui 2.31.2 → 2.32.1

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.
@@ -458,6 +458,21 @@
458
458
 
459
459
  const clamp = (minValue, maxValue, value) => Math.min(Math.max(value, minValue), maxValue);
460
460
 
461
+ const availableColorSchemes = ramda.keys(ramda.omit(["mono"], tokens.palette));
462
+ const djb2Hash = (str, colors) => {
463
+ let hash = 5381;
464
+ for (let i = 0; i < str.length; i += 1) {
465
+ const char = str.charCodeAt(i);
466
+ hash = (hash << 5) + hash + char;
467
+ hash &= hash;
468
+ }
469
+ return Math.abs(hash) % colors.length;
470
+ };
471
+ const getConsistentRandomColorFromString = (str, colors = availableColorSchemes) => {
472
+ const index = djb2Hash(str, colors);
473
+ return colors[index];
474
+ };
475
+
461
476
  const useResizeWidth = ({
462
477
  stationaryEdge = "left",
463
478
  minWidthPx = 0,
@@ -14327,7 +14342,7 @@
14327
14342
  if (!ramda.is(Number, inputValue) && defaultToZeroIfEmpty) {
14328
14343
  handleInputChange(clamp(min, max, 0));
14329
14344
  }
14330
- }, [valueProp == null ? void 0 : valueProp.input]);
14345
+ }, [valueProp == null ? void 0 : valueProp.input, defaultToZeroIfEmpty]);
14331
14346
  return /* @__PURE__ */ React.createElement(react.InputGroup, null, /* @__PURE__ */ React.createElement(
14332
14347
  FormattedNumberInput,
14333
14348
  __spreadValues$1({
@@ -15304,6 +15319,7 @@
15304
15319
  exports.clamp = clamp;
15305
15320
  exports.createDebounceFunctionInstance = createDebounceFunctionInstance;
15306
15321
  exports.getChildrenWithProps = getChildrenWithProps;
15322
+ exports.getConsistentRandomColorFromString = getConsistentRandomColorFromString;
15307
15323
  exports.getContrastColor = getContrastColor;
15308
15324
  exports.getFieldError = getFieldError;
15309
15325
  exports.getInitials = getInitials;