@teammodlr/ui-kit 2.1.69 → 2.1.70

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.70",
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: 1 };
202
+ }
184
203
  return HSVToRGBA(hueSlider.value * 3.6, brightness.value, saturation.value, opacitySlider.value / 100);
185
204
  });
186
205
 
@@ -193,6 +212,10 @@ export default defineComponent({
193
212
  };
194
213
 
195
214
  const setInputs = () => {
215
+ if (hexInput.value === "inherit") {
216
+ return;
217
+ }
218
+
196
219
  hexInput.value = RGBAToHex(finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
197
220
  rInput.value = finalColor.value.r.toString();
198
221
  gInput.value = finalColor.value.g.toString();
@@ -217,12 +240,24 @@ export default defineComponent({
217
240
  }
218
241
 
219
242
  const updateFromHex = () => {
220
- let color = hexToRGB(hexInput.value, finalColor.value.r, finalColor.value.g, finalColor.value.b, finalColor.value.a);
243
+ if (hexInput.value === "inherit") {
244
+ return;
245
+ }
246
+ const color = hexToRGB(hexInput.value);
221
247
  updateFromHSV(RGBToHSV(color.r, color.g, color.b), color.a);
222
248
  if (modelModifiers.lazy) {
223
249
  emitModelValue();
224
250
  }
225
- }
251
+ };
252
+
253
+ const toggleInherit = () => {
254
+ if (props.modelValue === "inherit") {
255
+ hexInput.value = "#FFFFFF";
256
+ } else {
257
+ hexInput.value = "inherit";
258
+ }
259
+ emitModelValue();
260
+ };
226
261
 
227
262
  const updateFromRGB = () => {
228
263
  let red = parseInt(rInput.value);
@@ -274,7 +309,7 @@ export default defineComponent({
274
309
  watch(() => props.modelValue, () => {
275
310
  let val = props.modelValue;
276
311
  if (!val || val.trim() === "") {
277
- val = props.defaultColor ?? "#FFFFFF"
312
+ val = props.defaultColor ?? "#FFFFFF";
278
313
  }
279
314
  hexInput.value = val;
280
315
  updateFromHex();
@@ -299,9 +334,13 @@ export default defineComponent({
299
334
  isOpen.value = false;
300
335
  });
301
336
 
337
+
302
338
  watch(() => eyeDropColor.value, () => {
303
- hexInput.value = eyeDropColor.value;
304
- updateFromHex();
339
+ if (eyeDropColor.value) {
340
+ hexInput.value = eyeDropColor.value;
341
+ emit('update:modelValue', eyeDropColor.value);
342
+ updateFromHex();
343
+ }
305
344
  });
306
345
 
307
346
  const openEyeDropper = () => {
@@ -350,7 +389,8 @@ export default defineComponent({
350
389
  canPickColor,
351
390
  openEyeDropper,
352
391
  scale,
353
- onSliderChangeComplete
392
+ onSliderChangeComplete,
393
+ toggleInherit
354
394
  };
355
395
  }
356
396
  })