@cmstops/pro-compo 0.3.15 → 0.3.16

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.
@@ -10,23 +10,39 @@ const _sfc_main = defineComponent({
10
10
  __name: "component",
11
11
  props: {
12
12
  colorList: {},
13
- color: {}
13
+ color: {},
14
+ mode: {}
14
15
  },
15
16
  emits: ["change", "update:color"],
16
17
  setup(__props, { emit: __emit }) {
17
18
  const props = __props;
18
19
  const emit = __emit;
20
+ const _mode = props.mode || "rgb";
19
21
  const colorValue = computed({
20
22
  get() {
21
23
  return props.color;
22
24
  },
23
25
  set(value) {
24
- emit("update:color", value);
26
+ colorChange(value);
25
27
  }
26
28
  });
29
+ const colorRgb = (_color) => {
30
+ if (_color.includes("rgb")) {
31
+ return _color;
32
+ }
33
+ const red = parseInt(_color.slice(1, 3), 16);
34
+ const green = parseInt(_color.slice(3, 5), 16);
35
+ const blue = parseInt(_color.slice(5, 7), 16);
36
+ return `rgb(${red},${green},${blue})`;
37
+ };
27
38
  const colorChange = (_color) => {
28
39
  if (_color) {
29
- colorValue.value = _color.replace(/\s+/g, "");
40
+ if (_mode === "hex") {
41
+ colorValue.value = _color;
42
+ } else {
43
+ colorValue.value = colorRgb(_color.replace(/\s+/g, ""));
44
+ }
45
+ emit("update:color", colorValue.value);
30
46
  }
31
47
  };
32
48
  return (_ctx, _cache) => {
@@ -11,23 +11,39 @@ const _sfc_main = vue.defineComponent({
11
11
  __name: "component",
12
12
  props: {
13
13
  colorList: {},
14
- color: {}
14
+ color: {},
15
+ mode: {}
15
16
  },
16
17
  emits: ["change", "update:color"],
17
18
  setup(__props, { emit: __emit }) {
18
19
  const props = __props;
19
20
  const emit = __emit;
21
+ const _mode = props.mode || "rgb";
20
22
  const colorValue = vue.computed({
21
23
  get() {
22
24
  return props.color;
23
25
  },
24
26
  set(value) {
25
- emit("update:color", value);
27
+ colorChange(value);
26
28
  }
27
29
  });
30
+ const colorRgb = (_color) => {
31
+ if (_color.includes("rgb")) {
32
+ return _color;
33
+ }
34
+ const red = parseInt(_color.slice(1, 3), 16);
35
+ const green = parseInt(_color.slice(3, 5), 16);
36
+ const blue = parseInt(_color.slice(5, 7), 16);
37
+ return `rgb(${red},${green},${blue})`;
38
+ };
28
39
  const colorChange = (_color) => {
29
40
  if (_color) {
30
- colorValue.value = _color.replace(/\s+/g, "");
41
+ if (_mode === "hex") {
42
+ colorValue.value = _color;
43
+ } else {
44
+ colorValue.value = colorRgb(_color.replace(/\s+/g, ""));
45
+ }
46
+ emit("update:color", colorValue.value);
31
47
  }
32
48
  };
33
49
  return (_ctx, _cache) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmstops/pro-compo",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vue",