@mekari/pixel3-color-picker 0.1.1 → 0.1.2-dev.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.
Files changed (35) hide show
  1. package/dist/{chunk-L5BRB7ES.mjs → chunk-2ZZBAQKR.mjs} +5 -1
  2. package/dist/{chunk-DVRBDVR4.mjs → chunk-5CI43L4Q.mjs} +5 -1
  3. package/dist/{chunk-KHGAEPYZ.mjs → chunk-5VPWEGKC.mjs} +11 -25
  4. package/dist/chunk-62SESCIE.mjs +0 -0
  5. package/dist/{chunk-YPFR76KW.mjs → chunk-MILYTHNM.mjs} +0 -1
  6. package/dist/{chunk-6XOLIDD7.mjs → chunk-NT4KAY3K.mjs} +19 -10
  7. package/dist/color-picker.d.mts +16 -6
  8. package/dist/color-picker.d.ts +16 -6
  9. package/dist/color-picker.js +54 -52
  10. package/dist/color-picker.mjs +5 -5
  11. package/dist/hue.d.mts +4 -3
  12. package/dist/hue.d.ts +4 -3
  13. package/dist/index.d.mts +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +54 -52
  16. package/dist/index.mjs +6 -5
  17. package/dist/input.js +0 -1
  18. package/dist/input.mjs +1 -1
  19. package/dist/metafile-cjs.json +1 -1
  20. package/dist/metafile-esm.json +1 -1
  21. package/dist/modules/color-picker.hooks.d.mts +6 -3
  22. package/dist/modules/color-picker.hooks.d.ts +6 -3
  23. package/dist/modules/color-picker.hooks.js +11 -25
  24. package/dist/modules/color-picker.hooks.mjs +1 -1
  25. package/dist/modules/color-picker.props.d.mts +6 -1
  26. package/dist/modules/color-picker.props.d.ts +6 -1
  27. package/dist/modules/color-picker.props.js +5 -1
  28. package/dist/modules/color-picker.props.mjs +1 -1
  29. package/dist/modules/color-picker.types.d.mts +4 -0
  30. package/dist/modules/color-picker.types.d.ts +4 -0
  31. package/dist/modules/color-picker.types.js +18 -0
  32. package/dist/modules/color-picker.types.mjs +1 -0
  33. package/dist/preset.js +5 -1
  34. package/dist/preset.mjs +1 -1
  35. package/package.json +11 -10
@@ -23,7 +23,7 @@ var colorPickerProps = {
23
23
  },
24
24
  placement: {
25
25
  type: String,
26
- default: "bottom"
26
+ default: "bottom-start"
27
27
  },
28
28
  preset: {
29
29
  type: Array,
@@ -51,6 +51,10 @@ var colorPickerProps = {
51
51
  type: Boolean,
52
52
  default: true
53
53
  },
54
+ isDisabled: {
55
+ type: Boolean,
56
+ default: false
57
+ },
54
58
  isInvalid: {
55
59
  type: Boolean,
56
60
  default: false
@@ -7,6 +7,7 @@ import { createVNode as _createVNode } from "vue";
7
7
  import { defineComponent } from "vue";
8
8
  import tinycolor from "tinycolor2";
9
9
  import { MpIcon } from "@mekari/pixel3-icon";
10
+ import { usePixelTheme } from "@mekari/pixel3-utils";
10
11
  import { css } from "@mekari/pixel3-styled-system/css";
11
12
  var MpColorPreset = defineComponent({
12
13
  name: "MpColorPreset",
@@ -23,6 +24,9 @@ var MpColorPreset = defineComponent({
23
24
  setup(props, {
24
25
  emit
25
26
  }) {
27
+ const {
28
+ isNextTheme
29
+ } = usePixelTheme();
26
30
  function handleClick() {
27
31
  emit("click", props.value);
28
32
  }
@@ -38,7 +42,7 @@ var MpColorPreset = defineComponent({
38
42
  width: "6",
39
43
  height: "6",
40
44
  borderWidth: "1px",
41
- borderColor: "gray.50",
45
+ borderColor: isNextTheme.value ? "border.default" : "gray.50",
42
46
  borderRadius: "sm",
43
47
  cursor: "pointer"
44
48
  }),
@@ -7,8 +7,6 @@ import { computed, watch, ref, toRefs, onMounted } from "vue";
7
7
  import tinycolor from "tinycolor2";
8
8
  import { getUniqueId } from "@mekari/pixel3-utils";
9
9
  import { colorPickerSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
10
- import { css, cx } from "@mekari/pixel3-styled-system/css";
11
- import { token } from "@mekari/pixel3-styled-system/tokens";
12
10
  function useColorPicker(props, emit) {
13
11
  const {
14
12
  id,
@@ -17,6 +15,7 @@ function useColorPicker(props, emit) {
17
15
  variant,
18
16
  placement,
19
17
  isShowPopover,
18
+ isDisabled,
20
19
  isInvalid
21
20
  } = toRefs(props);
22
21
  const val = ref(_colorChange(value.value));
@@ -33,20 +32,7 @@ function useColorPicker(props, emit) {
33
32
  }
34
33
  });
35
34
  const hex = computed(() => {
36
- const hex2 = colors.value.hex;
37
- return hex2.replace("#", "");
38
- });
39
- const borderColor = computed(() => {
40
- if (isInvalid.value) {
41
- return "red.400";
42
- }
43
- if (!isInvalid.value && isFocused.value) {
44
- return "blue.400";
45
- }
46
- return "gray.100";
47
- });
48
- const isFocused = computed(() => {
49
- return isPopoverOpen.value;
35
+ return colors.value.hex.replace("#", "");
50
36
  });
51
37
  const rootAttrs = computed(() => {
52
38
  return {
@@ -61,22 +47,18 @@ function useColorPicker(props, emit) {
61
47
  placement: placement.value,
62
48
  defaultIsOpen: isShowPopover.value,
63
49
  initialFocusRef: `#input-${getId}`,
50
+ isManual: isDisabled.value,
51
+ // hack way to disabled Popover
64
52
  onOpen: handleOpenPopover,
65
53
  onClose: handleClosePopover
66
54
  };
67
55
  });
68
56
  const popoverTriggerAttrs = computed(() => {
69
57
  return {
58
+ "data-invalid": isInvalid.value || void 0,
59
+ "data-disabled": isDisabled.value || void 0,
70
60
  tabindex: "0",
71
- class: cx(css({
72
- boxShadow: isPopoverOpen.value && !isInvalid.value ? "outline" : "none",
73
- _hover: {
74
- borderColor: isPopoverOpen.value && !isInvalid.value ? "blue.500 !important" : "gray.400 !important"
75
- }
76
- }), colorPickerSlotRecipe().popoverTrigger),
77
- style: {
78
- borderColor: token(`colors.${borderColor.value}`)
79
- }
61
+ class: colorPickerSlotRecipe().popoverTrigger
80
62
  };
81
63
  });
82
64
  const boxColorAttrs = computed(() => {
@@ -96,6 +78,8 @@ function useColorPicker(props, emit) {
96
78
  maxlength: "6",
97
79
  value: colorInput.value,
98
80
  placeholder: placeholder.value,
81
+ isDisabled: isDisabled.value,
82
+ isInvalid: isInvalid.value,
99
83
  class: colorPickerSlotRecipe().inputTrigger,
100
84
  onInput: handleInputTrigger
101
85
  };
@@ -293,6 +277,8 @@ function useColorPicker(props, emit) {
293
277
  }
294
278
  __name(handleInputTrigger, "handleInputTrigger");
295
279
  function handleOpenPopover() {
280
+ if (isDisabled.value)
281
+ return;
296
282
  isPopoverOpen.value = true;
297
283
  colorInput.value = hex.value;
298
284
  }
File without changes
@@ -43,7 +43,6 @@ var MpColorInput = defineComponent({
43
43
  }
44
44
  });
45
45
  function handleInput(e) {
46
- console.log("asdad", e);
47
46
  const target = e.target;
48
47
  const value = target.value;
49
48
  const data = {};
@@ -3,19 +3,19 @@ import {
3
3
  } from "./chunk-PULVLME3.mjs";
4
4
  import {
5
5
  MpColorInput
6
- } from "./chunk-YPFR76KW.mjs";
6
+ } from "./chunk-MILYTHNM.mjs";
7
7
  import {
8
8
  MpColorPreset
9
- } from "./chunk-DVRBDVR4.mjs";
9
+ } from "./chunk-5CI43L4Q.mjs";
10
10
  import {
11
11
  MpColorSaturation
12
12
  } from "./chunk-AEUPCATZ.mjs";
13
13
  import {
14
14
  useColorPicker
15
- } from "./chunk-KHGAEPYZ.mjs";
15
+ } from "./chunk-5VPWEGKC.mjs";
16
16
  import {
17
17
  colorPickerProps
18
- } from "./chunk-L5BRB7ES.mjs";
18
+ } from "./chunk-2ZZBAQKR.mjs";
19
19
  import {
20
20
  __name
21
21
  } from "./chunk-QZ7VFGWC.mjs";
@@ -28,6 +28,7 @@ import { MpPopover, MpPopoverTrigger, MpPopoverContent } from "@mekari/pixel3-po
28
28
  import { MpInput } from "@mekari/pixel3-input";
29
29
  import { MpIcon } from "@mekari/pixel3-icon";
30
30
  import { MpDivider } from "@mekari/pixel3-divider";
31
+ import { usePixelTheme } from "@mekari/pixel3-utils";
31
32
  import { css } from "@mekari/pixel3-styled-system/css";
32
33
  function _isSlot(s) {
33
34
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !_isVNode(s);
@@ -41,6 +42,9 @@ var MpColorPicker = defineComponent({
41
42
  slots,
42
43
  emit
43
44
  }) {
45
+ const {
46
+ isNextTheme
47
+ } = usePixelTheme();
44
48
  const {
45
49
  rootAttrs,
46
50
  popoverAttrs,
@@ -69,6 +73,7 @@ var MpColorPicker = defineComponent({
69
73
  return () => {
70
74
  const children = slots.default && slots.default();
71
75
  const {
76
+ id,
72
77
  variant,
73
78
  title,
74
79
  isShowSaturation,
@@ -79,28 +84,32 @@ var MpColorPicker = defineComponent({
79
84
  return _createVNode("div", rootAttrs.value, [_createVNode(MpPopover, popoverAttrs.value, {
80
85
  default: () => [_createVNode(MpPopoverTrigger, null, {
81
86
  default: () => [children ? _createVNode("div", null, [children]) : _createVNode("div", popoverTriggerAttrs.value, [_createVNode("div", boxColorAttrs.value, null), variant === "advance" && _createVNode(MpText, {
82
- "color": "gray.400",
83
- "style": "margin-top: 1px"
87
+ "color": isNextTheme.value ? "text.disabled" : "gray.400",
88
+ "class": css({
89
+ marginTop: "1px"
90
+ })
84
91
  }, {
85
92
  default: () => [_createTextVNode("#")]
86
93
  }), variant === "advance" && _createVNode(MpInput, inputTriggerAttrs.value, null), _createVNode(MpIcon, iconDropDownAttrs.value, null)])]
87
94
  }), _createVNode(MpPopoverContent, popoverContentAttrs.value, {
88
95
  default: () => [variant === "advance" && _createVNode("div", wrapperAdvanceAttrs.value, [isShowSaturation && _createVNode("div", wrapperSaturationAttrs.value, [_createVNode(MpColorSaturation, saturationAttrs.value, null)]), isShowHue && _createVNode("div", wrapperHueAttrs.value, [_createVNode(MpColorHue, hueAttrs.value, null)]), isShowInput && _createVNode("div", wrapperInputAttrs.value, [_createVNode(MpColorInput, inputHexAttrs.value, null), _createVNode(MpColorInput, inputRedAttrs.value, null), _createVNode(MpColorInput, inputGreenAttrs.value, null), _createVNode(MpColorInput, inputBlueAttrs.value, null)]), isShowPreset && _createVNode(MpDivider, {
89
- "id": "divider-color-picker",
96
+ "id": `${id}-divider`,
90
97
  "class": css({
91
98
  marginTop: "0",
92
99
  marginBottom: "0"
93
100
  })
94
101
  }, null), isShowPreset && _createVNode("div", boxPresetAttrs.value, [_createVNode("div", wrapperPresetAttrs.value, [_createVNode(MpText, {
95
102
  "size": "label-small",
96
- "style": "width: 100%;"
103
+ "class": css({
104
+ width: "full"
105
+ })
97
106
  }, {
98
- default: () => [_createTextVNode("Present")]
107
+ default: () => [_createTextVNode("Preset")]
99
108
  }), props.preset.map((item) => {
100
109
  return _createVNode(MpColorPreset, presetBoxAttrs(item), null);
101
110
  })])])]), variant === "basic" && _createVNode("div", wrapperBasicAttrs.value, [_createVNode(MpText, {
102
111
  "size": "body-small",
103
- "color": "gray.600"
112
+ "color": isNextTheme.value ? "text.secondary" : "gray.600"
104
113
  }, _isSlot(title) ? title : {
105
114
  default: () => [title]
106
115
  }), isShowPreset && _createVNode("div", wrapperBasicPresetAttrs.value, [props.preset.map((item) => {
@@ -1,5 +1,6 @@
1
1
  import * as vue_jsx_runtime from 'vue/jsx-runtime';
2
2
  import { Placement } from './modules/color-picker.props.mjs';
3
+ import { ColorPickerVariant } from './modules/color-picker.types.mjs';
3
4
  import * as vue from 'vue';
4
5
 
5
6
  declare const MpColorPicker: vue.DefineComponent<{
@@ -20,7 +21,7 @@ declare const MpColorPicker: vue.DefineComponent<{
20
21
  default: string;
21
22
  };
22
23
  variant: {
23
- type: vue.PropType<"advance" | "basic">;
24
+ type: vue.PropType<ColorPickerVariant>;
24
25
  default: string;
25
26
  };
26
27
  placement: {
@@ -51,6 +52,10 @@ declare const MpColorPicker: vue.DefineComponent<{
51
52
  type: vue.PropType<boolean>;
52
53
  default: boolean;
53
54
  };
55
+ isDisabled: {
56
+ type: vue.PropType<boolean>;
57
+ default: boolean;
58
+ };
54
59
  isInvalid: {
55
60
  type: vue.PropType<boolean>;
56
61
  default: boolean;
@@ -73,7 +78,7 @@ declare const MpColorPicker: vue.DefineComponent<{
73
78
  default: string;
74
79
  };
75
80
  variant: {
76
- type: vue.PropType<"advance" | "basic">;
81
+ type: vue.PropType<ColorPickerVariant>;
77
82
  default: string;
78
83
  };
79
84
  placement: {
@@ -104,6 +109,10 @@ declare const MpColorPicker: vue.DefineComponent<{
104
109
  type: vue.PropType<boolean>;
105
110
  default: boolean;
106
111
  };
112
+ isDisabled: {
113
+ type: vue.PropType<boolean>;
114
+ default: boolean;
115
+ };
107
116
  isInvalid: {
108
117
  type: vue.PropType<boolean>;
109
118
  default: boolean;
@@ -111,19 +120,20 @@ declare const MpColorPicker: vue.DefineComponent<{
111
120
  }>> & {
112
121
  onChange?: ((...args: any[]) => any) | undefined;
113
122
  }, {
114
- value: string;
115
- title: string;
116
123
  id: string;
124
+ title: string;
125
+ value: string;
117
126
  placeholder: string;
127
+ variant: ColorPickerVariant;
118
128
  placement: Placement;
119
- variant: "advance" | "basic";
120
- isInvalid: boolean;
121
129
  preset: string[];
122
130
  isShowPopover: boolean;
123
131
  isShowSaturation: boolean;
124
132
  isShowHue: boolean;
125
133
  isShowInput: boolean;
126
134
  isShowPreset: boolean;
135
+ isDisabled: boolean;
136
+ isInvalid: boolean;
127
137
  }, {}>;
128
138
 
129
139
  export { MpColorPicker };
@@ -1,5 +1,6 @@
1
1
  import * as vue_jsx_runtime from 'vue/jsx-runtime';
2
2
  import { Placement } from './modules/color-picker.props.js';
3
+ import { ColorPickerVariant } from './modules/color-picker.types.js';
3
4
  import * as vue from 'vue';
4
5
 
5
6
  declare const MpColorPicker: vue.DefineComponent<{
@@ -20,7 +21,7 @@ declare const MpColorPicker: vue.DefineComponent<{
20
21
  default: string;
21
22
  };
22
23
  variant: {
23
- type: vue.PropType<"advance" | "basic">;
24
+ type: vue.PropType<ColorPickerVariant>;
24
25
  default: string;
25
26
  };
26
27
  placement: {
@@ -51,6 +52,10 @@ declare const MpColorPicker: vue.DefineComponent<{
51
52
  type: vue.PropType<boolean>;
52
53
  default: boolean;
53
54
  };
55
+ isDisabled: {
56
+ type: vue.PropType<boolean>;
57
+ default: boolean;
58
+ };
54
59
  isInvalid: {
55
60
  type: vue.PropType<boolean>;
56
61
  default: boolean;
@@ -73,7 +78,7 @@ declare const MpColorPicker: vue.DefineComponent<{
73
78
  default: string;
74
79
  };
75
80
  variant: {
76
- type: vue.PropType<"advance" | "basic">;
81
+ type: vue.PropType<ColorPickerVariant>;
77
82
  default: string;
78
83
  };
79
84
  placement: {
@@ -104,6 +109,10 @@ declare const MpColorPicker: vue.DefineComponent<{
104
109
  type: vue.PropType<boolean>;
105
110
  default: boolean;
106
111
  };
112
+ isDisabled: {
113
+ type: vue.PropType<boolean>;
114
+ default: boolean;
115
+ };
107
116
  isInvalid: {
108
117
  type: vue.PropType<boolean>;
109
118
  default: boolean;
@@ -111,19 +120,20 @@ declare const MpColorPicker: vue.DefineComponent<{
111
120
  }>> & {
112
121
  onChange?: ((...args: any[]) => any) | undefined;
113
122
  }, {
114
- value: string;
115
- title: string;
116
123
  id: string;
124
+ title: string;
125
+ value: string;
117
126
  placeholder: string;
127
+ variant: ColorPickerVariant;
118
128
  placement: Placement;
119
- variant: "advance" | "basic";
120
- isInvalid: boolean;
121
129
  preset: string[];
122
130
  isShowPopover: boolean;
123
131
  isShowSaturation: boolean;
124
132
  isShowHue: boolean;
125
133
  isShowInput: boolean;
126
134
  isShowPreset: boolean;
135
+ isDisabled: boolean;
136
+ isInvalid: boolean;
127
137
  }, {}>;
128
138
 
129
139
  export { MpColorPicker };