@northlight/ui 2.31.2 → 2.32.0
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/es/northlight.d.ts +3 -1
- package/dist/es/northlight.js +17 -2
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +16 -0
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +3 -3
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/umd/northlight.cjs
CHANGED
|
@@ -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,
|
|
@@ -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;
|