@teammodlr/ui-kit 2.1.69 → 2.1.71

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": "@teammodlr/ui-kit",
3
- "version": "2.1.69",
3
+ "version": "2.1.71",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -4,9 +4,15 @@
4
4
  <slot :r="finalColor.r" :g="finalColor.g" :b="finalColor.b" :a="finalColor.a" :hex="hexInput"
5
5
  :transparent="style.transparent">
6
6
  <div>
7
- <div :class="style.referenceColor"
8
- :style="{ backgroundColor: `rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, ${finalColor.a})` }">
9
- </div>
7
+ <template v-if="modelValue === 'inherit'">
8
+ <div :style="{ border: '1px dashed #999', padding: '8px', textAlign: 'center' }">Inherit</div>
9
+ </template>
10
+ <template v-else>
11
+ <!-- Regular color display -->
12
+ <div :class="style.referenceColor"
13
+ :style="{ backgroundColor: `rgba(${finalColor.r}, ${finalColor.g}, ${finalColor.b}, ${finalColor.a})` }">
14
+ </div>
15
+ </template>
10
16
  </div>
11
17
  </slot>
12
18
  </div>
@@ -24,9 +30,8 @@
24
30
 
25
31
  <div :class="style.colorActions">
26
32
  <template v-if="canPickColor">
27
- <button role="button" :disabled="!canPickColor" :class="style.eyeDrop"
28
- @click="openEyeDropper">
29
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
33
+ <MButton icon :disabled="!canPickColor" :class="style.eyeDrop" @click="openEyeDropper">
34
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none"
30
35
  xmlns="http://www.w3.org/2000/svg">
31
36
  <path
32
37
  d="M20.3847 2.87868C19.2132 1.70711 17.3137 1.70711 16.1421 2.87868L14.0202 5.00052L13.313 4.29332C12.9225 3.9028 12.2894 3.9028 11.8988 4.29332C11.5083 4.68385 11.5083 5.31701 11.8988 5.70754L17.5557 11.3644C17.9462 11.7549 18.5794 11.7549 18.9699 11.3644C19.3604 10.9739 19.3604 10.3407 18.9699 9.95018L18.2629 9.24316L20.3847 7.12132C21.5563 5.94975 21.5563 4.05025 20.3847 2.87868Z"
@@ -35,7 +40,7 @@
35
40
  d="M11.9297 7.09116L4.1515 14.8693C3.22786 15.793 3.03239 17.169 3.5651 18.2842L1.99994 19.8493L3.41415 21.2635L4.97931 19.6984C6.09444 20.2311 7.4705 20.0356 8.39414 19.112L16.1723 11.3338L11.9297 7.09116ZM13.3439 11.3338L11.9297 9.91959L5.56571 16.2835C5.17518 16.6741 5.17518 17.3072 5.56571 17.6978C5.95623 18.0883 6.5894 18.0883 6.97992 17.6978L13.3439 11.3338Z"
36
41
  fill="currentColor" />
37
42
  </svg>
38
- </button>
43
+ </MButton>
39
44
  </template>
40
45
  <template v-else>
41
46
  <div :class="style.preview">
@@ -81,6 +86,17 @@
81
86
  </svg>
82
87
 
83
88
  </MButton>
89
+ <MButton icon @click.prevent="toggleInherit">
90
+ <svg style="width: 18px; height: 18px;" xmlns="http://www.w3.org/2000/svg" width="24"
91
+ height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
92
+ stroke-linecap="round" stroke-linejoin="round">
93
+ <path d="M21 6H3" />
94
+ <path d="M7 12H3" />
95
+ <path d="M7 18H3" />
96
+ <path d="M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14" />
97
+ <path d="M11 10v4h4" />
98
+ </svg>
99
+ </MButton>
84
100
  </div>
85
101
  </div>
86
102
  </transition>
@@ -181,6 +197,9 @@ export default defineComponent({
181
197
  })
182
198
 
183
199
  const finalColor = computed(() => {
200
+ if (hexInput.value === "inherit") {
201
+ return { r: 0, g: 0, b: 0, a: 0 };
202
+ }
184
203
  return HSVToRGBA(hueSlider.value * 3.6, brightness.value, saturation.value, opacitySlider.value / 100);
185
204
  });
186
205
 
@@ -193,7 +212,9 @@ export default defineComponent({
193
212
  };
194
213
 
195
214
  const setInputs = () => {
196
- hexInput.value = RGBAToHex(finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
215
+ if (hexInput.value !== 'inherit') {
216
+ hexInput.value = RGBAToHex(finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
217
+ }
197
218
  rInput.value = finalColor.value.r.toString();
198
219
  gInput.value = finalColor.value.g.toString();
199
220
  bInput.value = finalColor.value.b.toString();
@@ -217,12 +238,31 @@ export default defineComponent({
217
238
  }
218
239
 
219
240
  const updateFromHex = () => {
220
- let color = hexToRGB(hexInput.value, finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
241
+ if (hexInput.value === 'inherit') {
242
+ if (modelModifiers.lazy) {
243
+ emitModelValue();
244
+ }
245
+ return;
246
+ }
247
+ const color = hexToRGB(hexInput.value);
248
+ if (color.a === 0) {
249
+ color.a = 1;
250
+ opacitySlider.value = 100;
251
+ }
221
252
  updateFromHSV(RGBToHSV(color.r, color.g, color.b), color.a);
222
253
  if (modelModifiers.lazy) {
223
254
  emitModelValue();
224
255
  }
225
- }
256
+ };
257
+
258
+ const toggleInherit = () => {
259
+ if (props.modelValue === "inherit") {
260
+ hexInput.value = "#FFFFFF";
261
+ } else {
262
+ hexInput.value = "inherit";
263
+ }
264
+ emitModelValue();
265
+ };
226
266
 
227
267
  const updateFromRGB = () => {
228
268
  let red = parseInt(rInput.value);
@@ -246,7 +286,11 @@ export default defineComponent({
246
286
  }
247
287
 
248
288
  updateFromHSV(RGBToHSV(red, green, blue), alpha);
249
- if (modelModifiers.lazy) {
289
+
290
+ if (hexInput.value === 'inherit') {
291
+ hexInput.value = RGBAToHex(red, green, blue, alpha);
292
+ emitModelValue();
293
+ } else if (modelModifiers.lazy) {
250
294
  emitModelValue();
251
295
  }
252
296
  };
@@ -274,7 +318,7 @@ export default defineComponent({
274
318
  watch(() => props.modelValue, () => {
275
319
  let val = props.modelValue;
276
320
  if (!val || val.trim() === "") {
277
- val = props.defaultColor ?? "#FFFFFF"
321
+ val = props.defaultColor ?? "#FFFFFF";
278
322
  }
279
323
  hexInput.value = val;
280
324
  updateFromHex();
@@ -286,6 +330,10 @@ export default defineComponent({
286
330
  };
287
331
 
288
332
  const handleMouseDown = () => {
333
+ if (hexInput.value === 'inherit') {
334
+ hexInput.value = RGBAToHex(finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
335
+ emitModelValue();
336
+ }
289
337
  dragging.value = true;
290
338
  setThumbPosition();
291
339
  };
@@ -299,9 +347,13 @@ export default defineComponent({
299
347
  isOpen.value = false;
300
348
  });
301
349
 
350
+
302
351
  watch(() => eyeDropColor.value, () => {
303
- hexInput.value = eyeDropColor.value;
304
- updateFromHex();
352
+ if (eyeDropColor.value) {
353
+ hexInput.value = eyeDropColor.value;
354
+ emitModelValue();
355
+ updateFromHex();
356
+ }
305
357
  });
306
358
 
307
359
  const openEyeDropper = () => {
@@ -350,7 +402,8 @@ export default defineComponent({
350
402
  canPickColor,
351
403
  openEyeDropper,
352
404
  scale,
353
- onSliderChangeComplete
405
+ onSliderChangeComplete,
406
+ toggleInherit
354
407
  };
355
408
  }
356
409
  })