reanimated-color-picker 0.0.2 → 0.0.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.
|
@@ -126,8 +126,10 @@ export const COLOR_HSVA = colorStr => {
|
|
|
126
126
|
const isHsv = colorStr.startsWith('hsv');
|
|
127
127
|
const isHsva = colorStr.startsWith('hsva');
|
|
128
128
|
|
|
129
|
+
const regex = /\(([^)]+)/;
|
|
130
|
+
|
|
129
131
|
if (isRgb) {
|
|
130
|
-
const match = colorStr.match(
|
|
132
|
+
const match = colorStr.match(regex)?.[1];
|
|
131
133
|
if (!match) throw new Error('Invalid RGB value');
|
|
132
134
|
const colorValues = match.split(',');
|
|
133
135
|
if (colorValues.length !== 3) throw new Error('Invalid RGB value');
|
|
@@ -137,7 +139,7 @@ export const COLOR_HSVA = colorStr => {
|
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
if (isRgba) {
|
|
140
|
-
const match = colorStr.match(
|
|
142
|
+
const match = colorStr.match(regex)?.[1];
|
|
141
143
|
if (!match) throw new Error('Invalid RGBA value');
|
|
142
144
|
const colorValues = match.split(',');
|
|
143
145
|
if (colorValues.length !== 4) throw new Error('Invalid RGBA value');
|
|
@@ -151,7 +153,7 @@ export const COLOR_HSVA = colorStr => {
|
|
|
151
153
|
if (isNamedColor) return HEX_HSV(NamedColors[colorStr]);
|
|
152
154
|
|
|
153
155
|
if (isHsl) {
|
|
154
|
-
const match = colorStr.match(
|
|
156
|
+
const match = colorStr.match(regex)?.[1];
|
|
155
157
|
if (!match) throw new Error('Invalid HSL value');
|
|
156
158
|
const colorValues = match.split(',');
|
|
157
159
|
if (colorValues.length !== 3) throw new Error('Invalid HSL value');
|
|
@@ -161,7 +163,7 @@ export const COLOR_HSVA = colorStr => {
|
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
if (isHsla) {
|
|
164
|
-
const match = colorStr.match(
|
|
166
|
+
const match = colorStr.match(regex)?.[1];
|
|
165
167
|
if (!match) throw new Error('Invalid HSLA value');
|
|
166
168
|
const colorValues = match.split(',');
|
|
167
169
|
if (colorValues.length !== 4) throw new Error('Invalid HSLA value');
|
|
@@ -171,7 +173,7 @@ export const COLOR_HSVA = colorStr => {
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
if (isHsv) {
|
|
174
|
-
const match = colorStr.match(
|
|
176
|
+
const match = colorStr.match(regex)?.[1];
|
|
175
177
|
if (!match) throw new Error('Invalid HSV value');
|
|
176
178
|
const colorValues = match.split(',');
|
|
177
179
|
if (colorValues.length !== 3) throw new Error('Invalid HSV value');
|
|
@@ -181,7 +183,7 @@ export const COLOR_HSVA = colorStr => {
|
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
if (isHsva) {
|
|
184
|
-
const match = colorStr.match(
|
|
186
|
+
const match = colorStr.match(regex)?.[1];
|
|
185
187
|
if (!match) throw new Error('Invalid HSVA value');
|
|
186
188
|
const colorValues = match.split(',');
|
|
187
189
|
if (colorValues.length !== 4) throw new Error('Invalid HSVA value');
|