@colisweb/rescript-toolkit 5.43.4 → 5.44.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "5.43.4",
3
+ "version": "5.44.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -22,6 +22,7 @@ let make = (
22
22
  ~onChange: option<ReactEvent.Form.t => unit>=?,
23
23
  ~onChangeText: option<string => unit>=?,
24
24
  ~allowWhiteSpace=false,
25
+ ~onPaste=?,
25
26
  ~isInvalid: option<bool>=?,
26
27
  ~className: string="",
27
28
  ~style: option<ReactDOM.style>=?,
@@ -41,6 +42,7 @@ let make = (
41
42
  ?style
42
43
  ?name
43
44
  ?value
45
+ ?onPaste
44
46
  ?defaultValue
45
47
  ?type_
46
48
  ?disabled
@@ -47,3 +47,49 @@ let decodeEnumFromString = (type enum, str: string, enum: module(Enum with type
47
47
  | Error(_) => None
48
48
  }
49
49
  }
50
+
51
+ %%private(
52
+ let hashString = %raw(`function hashString(str) {
53
+ let hash = 5381;
54
+ for (let i = 0; i < str.length; i++) {
55
+ hash = ((hash << 5) + hash) + str.charCodeAt(i); // hash * 33 + c
56
+ }
57
+ return hash >>> 0; // assurer un entier positif
58
+ }`)
59
+
60
+ let hsvToRgb = %raw(`function hsvToRgb(h, s, v) {
61
+ const c = v * s;
62
+ const hPrime = h / 60;
63
+ const x = c * (1 - Math.abs((hPrime % 2) - 1));
64
+ let r1, g1, b1;
65
+
66
+ if (hPrime < 1) {
67
+ r1 = c; g1 = x; b1 = 0;
68
+ } else if (hPrime < 2) {
69
+ r1 = x; g1 = c; b1 = 0;
70
+ } else if (hPrime < 3) {
71
+ r1 = 0; g1 = c; b1 = x;
72
+ } else if (hPrime < 4) {
73
+ r1 = 0; g1 = x; b1 = c;
74
+ } else if (hPrime < 5) {
75
+ r1 = x; g1 = 0; b1 = c;
76
+ } else {
77
+ r1 = c; g1 = 0; b1 = x;
78
+ }
79
+
80
+ const m = v - c;
81
+ const r = Math.round((r1 + m) * 255).toString(16).padStart(2, '0');
82
+ const g = Math.round((g1 + m) * 255).toString(16).padStart(2, '0');
83
+ const b = Math.round((b1 + m) * 255).toString(16).padStart(2, '0');
84
+
85
+ return [r, g, b];
86
+ }`)
87
+ )
88
+
89
+ let makeRgbColor = id => {
90
+ let hash = hashString(id)
91
+ let hue = mod(hash * 997, 360)
92
+ let (r, g, b) = hsvToRgb(hue, 0.6, 0.85)
93
+
94
+ "#" ++ r ++ g ++ b
95
+ }