@mekari/pixel3-color-picker 0.0.1-dev.0

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 (43) hide show
  1. package/dist/chunk-36OXI4E3.mjs +347 -0
  2. package/dist/chunk-5FWKSVUW.mjs +89 -0
  3. package/dist/chunk-AEUPCATZ.mjs +156 -0
  4. package/dist/chunk-DVRBDVR4.mjs +63 -0
  5. package/dist/chunk-L5BRB7ES.mjs +64 -0
  6. package/dist/chunk-PULVLME3.mjs +196 -0
  7. package/dist/chunk-QZ7VFGWC.mjs +6 -0
  8. package/dist/chunk-YLUI3RMF.mjs +116 -0
  9. package/dist/color-picker.d.mts +129 -0
  10. package/dist/color-picker.d.ts +129 -0
  11. package/dist/color-picker.js +1006 -0
  12. package/dist/color-picker.mjs +13 -0
  13. package/dist/hue.d.mts +27 -0
  14. package/dist/hue.d.ts +27 -0
  15. package/dist/hue.js +217 -0
  16. package/dist/hue.mjs +7 -0
  17. package/dist/index.d.mts +4 -0
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.js +1008 -0
  20. package/dist/index.mjs +13 -0
  21. package/dist/input.d.mts +41 -0
  22. package/dist/input.d.ts +41 -0
  23. package/dist/input.js +110 -0
  24. package/dist/input.mjs +7 -0
  25. package/dist/metafile-cjs.json +1 -0
  26. package/dist/metafile-esm.json +1 -0
  27. package/dist/modules/color-picker.hooks.d.mts +206 -0
  28. package/dist/modules/color-picker.hooks.d.ts +206 -0
  29. package/dist/modules/color-picker.hooks.js +378 -0
  30. package/dist/modules/color-picker.hooks.mjs +7 -0
  31. package/dist/modules/color-picker.props.d.mts +62 -0
  32. package/dist/modules/color-picker.props.d.ts +62 -0
  33. package/dist/modules/color-picker.props.js +89 -0
  34. package/dist/modules/color-picker.props.mjs +9 -0
  35. package/dist/preset.d.mts +26 -0
  36. package/dist/preset.d.ts +26 -0
  37. package/dist/preset.js +94 -0
  38. package/dist/preset.mjs +7 -0
  39. package/dist/saturation.d.mts +16 -0
  40. package/dist/saturation.d.ts +16 -0
  41. package/dist/saturation.js +187 -0
  42. package/dist/saturation.mjs +7 -0
  43. package/package.json +53 -0
@@ -0,0 +1,196 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-QZ7VFGWC.mjs";
4
+
5
+ // src/hue.tsx
6
+ import { createVNode as _createVNode } from "vue";
7
+ import { defineComponent, ref, computed, watch } from "vue";
8
+ import { css } from "@mekari/pixel3-styled-system/css";
9
+ var MpColorHue = defineComponent({
10
+ name: "MpColorHue",
11
+ props: {
12
+ value: {
13
+ type: Object
14
+ },
15
+ direction: {
16
+ type: String,
17
+ default: "horizontal"
18
+ }
19
+ },
20
+ emits: ["change"],
21
+ setup(props, {
22
+ emit
23
+ }) {
24
+ const oldHue = ref(0);
25
+ const pullDirection = ref("");
26
+ const containerNode = ref();
27
+ watch(() => props.value, (oldValue, newValue) => {
28
+ if (oldValue !== newValue) {
29
+ handlePullDirection();
30
+ }
31
+ });
32
+ const colors = computed(() => {
33
+ return props.value;
34
+ });
35
+ const pointerTop = computed(() => {
36
+ var _a;
37
+ const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
38
+ if (props.direction === "vertical") {
39
+ if (h === 0 && pullDirection.value === "right")
40
+ return 0;
41
+ return -(h * 100 / 360) + 100 + "%";
42
+ } else {
43
+ return 0;
44
+ }
45
+ });
46
+ const pointerLeft = computed(() => {
47
+ var _a;
48
+ const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
49
+ if (props.direction === "vertical") {
50
+ return 0;
51
+ } else {
52
+ if (h === 0 && pullDirection.value === "right")
53
+ return "100%";
54
+ return h * 100 / 360 + "%";
55
+ }
56
+ });
57
+ function handlePullDirection() {
58
+ var _a;
59
+ const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
60
+ if (h !== 0 && h - oldHue.value > 0)
61
+ pullDirection.value = "right";
62
+ if (h !== 0 && h - oldHue.value < 0)
63
+ pullDirection.value = "left";
64
+ oldHue.value = h;
65
+ }
66
+ __name(handlePullDirection, "handlePullDirection");
67
+ function handleChange(e, skip) {
68
+ var _a, _b, _c, _d, _e, _f, _g, _h;
69
+ !skip && e.preventDefault();
70
+ const container = containerNode.value;
71
+ if (!container) {
72
+ return;
73
+ }
74
+ const containerWidth = container.clientWidth;
75
+ const containerHeight = container.clientHeight;
76
+ const xOffset = container.getBoundingClientRect().left + window.scrollX;
77
+ const yOffset = container.getBoundingClientRect().top + window.scrollY;
78
+ const pageX = e.pageX || (e.touches ? e.touches[0].pageX : 0);
79
+ const pageY = e.pageY || (e.touches ? e.touches[0].pageY : 0);
80
+ const left = pageX - xOffset;
81
+ const top = pageY - yOffset;
82
+ let h;
83
+ let percent;
84
+ if (props.direction === "vertical") {
85
+ if (top < 0) {
86
+ h = 360;
87
+ } else if (top > containerHeight) {
88
+ h = 0;
89
+ } else {
90
+ percent = -(top * 100 / containerHeight) + 100;
91
+ h = 360 * percent / 100;
92
+ }
93
+ if (((_a = colors.value) == null ? void 0 : _a.hsl.h) !== h) {
94
+ emit("change", {
95
+ h,
96
+ s: (_b = colors.value) == null ? void 0 : _b.hsl.s,
97
+ l: (_c = colors.value) == null ? void 0 : _c.hsl.l,
98
+ a: (_d = colors.value) == null ? void 0 : _d.hsl.a,
99
+ source: "hsl"
100
+ });
101
+ }
102
+ } else {
103
+ if (left < 0) {
104
+ h = 0;
105
+ } else if (left > containerWidth) {
106
+ h = 360;
107
+ } else {
108
+ percent = left * 100 / containerWidth;
109
+ h = 360 * percent / 100;
110
+ }
111
+ if (((_e = colors.value) == null ? void 0 : _e.hsl.h) !== h) {
112
+ emit("change", {
113
+ h,
114
+ s: (_f = colors.value) == null ? void 0 : _f.hsl.s,
115
+ l: (_g = colors.value) == null ? void 0 : _g.hsl.l,
116
+ a: (_h = colors.value) == null ? void 0 : _h.hsl.a,
117
+ source: "hsl"
118
+ });
119
+ }
120
+ }
121
+ }
122
+ __name(handleChange, "handleChange");
123
+ function handleMouseDown(e) {
124
+ handleChange(e, true);
125
+ window.addEventListener("mousemove", handleChange);
126
+ window.addEventListener("mouseup", handleMouseUp);
127
+ }
128
+ __name(handleMouseDown, "handleMouseDown");
129
+ function handleMouseUp() {
130
+ unbindEventListeners();
131
+ }
132
+ __name(handleMouseUp, "handleMouseUp");
133
+ function unbindEventListeners() {
134
+ window.removeEventListener("mousemove", handleChange);
135
+ window.removeEventListener("mouseup", handleMouseUp);
136
+ }
137
+ __name(unbindEventListeners, "unbindEventListeners");
138
+ return () => {
139
+ var _a;
140
+ return _createVNode("div", {
141
+ "data-pixel-component": "MpColorPickerHue",
142
+ "class": css({
143
+ position: "absolute",
144
+ top: "0",
145
+ right: "0",
146
+ bottom: "0",
147
+ left: "0",
148
+ background: props.direction === "horizontal" ? "linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)" : "linear-gradient(to top, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)"
149
+ })
150
+ }, [_createVNode("div", {
151
+ "ref": containerNode,
152
+ "id": "hue-container",
153
+ "role": "slider",
154
+ "aria-valuenow": (_a = colors.value) == null ? void 0 : _a.hsl.h,
155
+ "aria-valuemin": "0",
156
+ "aria-valuemax": "360",
157
+ "class": css({
158
+ cursor: "pointer",
159
+ margin: "0 2px",
160
+ position: "relative",
161
+ height: "100%"
162
+ }),
163
+ "onMousedown": handleMouseDown,
164
+ "onTouchmove": handleChange,
165
+ "onTouchstart": handleChange
166
+ }, [_createVNode("div", {
167
+ "id": "hue-pointer",
168
+ "role": "presentation",
169
+ "class": css({
170
+ position: "absolute",
171
+ zIndex: "2"
172
+ }),
173
+ "style": {
174
+ top: pointerTop.value,
175
+ left: pointerLeft.value
176
+ }
177
+ }, [_createVNode("div", {
178
+ "id": "hue-picker",
179
+ "class": css({
180
+ cursor: "pointer",
181
+ marginTop: "-2px",
182
+ width: "32px",
183
+ height: "32px",
184
+ transform: "translateX(-16px)",
185
+ borderRadius: "24px",
186
+ boxShadow: "0px 10px 15px -3px rgba(0, 0, 0, 0.10), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",
187
+ background: "white"
188
+ })
189
+ }, null)])])]);
190
+ };
191
+ }
192
+ });
193
+
194
+ export {
195
+ MpColorHue
196
+ };
@@ -0,0 +1,6 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ export {
5
+ __name
6
+ };
@@ -0,0 +1,116 @@
1
+ import {
2
+ MpColorHue
3
+ } from "./chunk-PULVLME3.mjs";
4
+ import {
5
+ MpColorInput
6
+ } from "./chunk-5FWKSVUW.mjs";
7
+ import {
8
+ MpColorPreset
9
+ } from "./chunk-DVRBDVR4.mjs";
10
+ import {
11
+ MpColorSaturation
12
+ } from "./chunk-AEUPCATZ.mjs";
13
+ import {
14
+ useColorPicker
15
+ } from "./chunk-36OXI4E3.mjs";
16
+ import {
17
+ colorPickerProps
18
+ } from "./chunk-L5BRB7ES.mjs";
19
+ import {
20
+ __name
21
+ } from "./chunk-QZ7VFGWC.mjs";
22
+
23
+ // src/color-picker.tsx
24
+ import { isVNode as _isVNode, createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
25
+ import { defineComponent } from "vue";
26
+ import { MpText } from "@mekari/pixel3-text";
27
+ import { MpPopover, MpPopoverTrigger, MpPopoverContent } from "@mekari/pixel3-popover";
28
+ import { MpInput } from "@mekari/pixel3-input";
29
+ import { MpIcon } from "@mekari/pixel3-icon";
30
+ import { MpDivider } from "@mekari/pixel3-divider";
31
+ import { css } from "@mekari/pixel3-styled-system/css";
32
+ function _isSlot(s) {
33
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !_isVNode(s);
34
+ }
35
+ __name(_isSlot, "_isSlot");
36
+ var MpColorPicker = defineComponent({
37
+ name: "MpColorPicker",
38
+ props: colorPickerProps,
39
+ emits: ["change"],
40
+ setup(props, {
41
+ slots,
42
+ emit
43
+ }) {
44
+ const {
45
+ rootAttrs,
46
+ popoverAttrs,
47
+ popoverTriggerAttrs,
48
+ boxColorAttrs,
49
+ inputTriggerAttrs,
50
+ iconDropDownAttrs,
51
+ popoverContentAttrs,
52
+ wrapperAdvanceAttrs,
53
+ wrapperBasicAttrs,
54
+ wrapperSaturationAttrs,
55
+ saturationAttrs,
56
+ wrapperHueAttrs,
57
+ hueAttrs,
58
+ wrapperInputAttrs,
59
+ inputHexAttrs,
60
+ inputRedAttrs,
61
+ inputGreenAttrs,
62
+ inputBlueAttrs,
63
+ inputFullAttrs,
64
+ boxPresetAttrs,
65
+ wrapperBasicPresetAttrs,
66
+ wrapperPresetAttrs,
67
+ presetBoxAttrs
68
+ } = useColorPicker(props, emit);
69
+ return () => {
70
+ const children = slots.default && slots.default();
71
+ const {
72
+ variant,
73
+ title,
74
+ isShowSaturation,
75
+ isShowHue,
76
+ isShowInput,
77
+ isShowPreset
78
+ } = props;
79
+ return _createVNode("div", rootAttrs.value, [_createVNode(MpPopover, popoverAttrs.value, {
80
+ default: () => [_createVNode(MpPopoverTrigger, null, {
81
+ 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"
84
+ }, {
85
+ default: () => [_createTextVNode("#")]
86
+ }), variant === "advance" && _createVNode(MpInput, inputTriggerAttrs.value, null), _createVNode(MpIcon, iconDropDownAttrs.value, null)])]
87
+ }), _createVNode(MpPopoverContent, popoverContentAttrs.value, {
88
+ 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
+ "class": css({
90
+ marginTop: "0",
91
+ marginBottom: "0"
92
+ })
93
+ }, null), isShowPreset && _createVNode("div", boxPresetAttrs.value, [_createVNode("div", wrapperPresetAttrs.value, [_createVNode(MpText, {
94
+ "size": "label-small",
95
+ "style": "width: 100%;"
96
+ }, {
97
+ default: () => [_createTextVNode("Present")]
98
+ }), props.preset.map((item) => {
99
+ return _createVNode(MpColorPreset, presetBoxAttrs(item), null);
100
+ })])])]), variant === "basic" && _createVNode("div", wrapperBasicAttrs.value, [_createVNode(MpText, {
101
+ "size": "body-small",
102
+ "color": "gray.600"
103
+ }, _isSlot(title) ? title : {
104
+ default: () => [title]
105
+ }), isShowPreset && _createVNode("div", wrapperBasicPresetAttrs.value, [props.preset.map((item) => {
106
+ return _createVNode(MpColorPreset, presetBoxAttrs(item), null);
107
+ })]), isShowInput && _createVNode("div", wrapperInputAttrs.value, [_createVNode(MpColorInput, inputFullAttrs.value, null)])])]
108
+ })]
109
+ })]);
110
+ };
111
+ }
112
+ });
113
+
114
+ export {
115
+ MpColorPicker
116
+ };
@@ -0,0 +1,129 @@
1
+ import * as vue_jsx_runtime from 'vue/jsx-runtime';
2
+ import { Placement } from './modules/color-picker.props.mjs';
3
+ import * as vue from 'vue';
4
+
5
+ declare const MpColorPicker: vue.DefineComponent<{
6
+ id: {
7
+ type: vue.PropType<string>;
8
+ default: string;
9
+ };
10
+ title: {
11
+ type: vue.PropType<string>;
12
+ default: string;
13
+ };
14
+ value: {
15
+ type: vue.PropType<string>;
16
+ default: string;
17
+ };
18
+ placeholder: {
19
+ type: vue.PropType<string>;
20
+ default: string;
21
+ };
22
+ variant: {
23
+ type: vue.PropType<"advance" | "basic">;
24
+ default: string;
25
+ };
26
+ placement: {
27
+ type: vue.PropType<Placement>;
28
+ default: string;
29
+ };
30
+ preset: {
31
+ type: vue.PropType<string[]>;
32
+ default(): string[];
33
+ };
34
+ isShowPopover: {
35
+ type: vue.PropType<boolean>;
36
+ default: boolean;
37
+ };
38
+ isShowSaturation: {
39
+ type: vue.PropType<boolean>;
40
+ default: boolean;
41
+ };
42
+ isShowHue: {
43
+ type: vue.PropType<boolean>;
44
+ default: boolean;
45
+ };
46
+ isShowInput: {
47
+ type: vue.PropType<boolean>;
48
+ default: boolean;
49
+ };
50
+ isShowPreset: {
51
+ type: vue.PropType<boolean>;
52
+ default: boolean;
53
+ };
54
+ isInvalid: {
55
+ type: vue.PropType<boolean>;
56
+ default: boolean;
57
+ };
58
+ }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "change"[], "change", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
59
+ id: {
60
+ type: vue.PropType<string>;
61
+ default: string;
62
+ };
63
+ title: {
64
+ type: vue.PropType<string>;
65
+ default: string;
66
+ };
67
+ value: {
68
+ type: vue.PropType<string>;
69
+ default: string;
70
+ };
71
+ placeholder: {
72
+ type: vue.PropType<string>;
73
+ default: string;
74
+ };
75
+ variant: {
76
+ type: vue.PropType<"advance" | "basic">;
77
+ default: string;
78
+ };
79
+ placement: {
80
+ type: vue.PropType<Placement>;
81
+ default: string;
82
+ };
83
+ preset: {
84
+ type: vue.PropType<string[]>;
85
+ default(): string[];
86
+ };
87
+ isShowPopover: {
88
+ type: vue.PropType<boolean>;
89
+ default: boolean;
90
+ };
91
+ isShowSaturation: {
92
+ type: vue.PropType<boolean>;
93
+ default: boolean;
94
+ };
95
+ isShowHue: {
96
+ type: vue.PropType<boolean>;
97
+ default: boolean;
98
+ };
99
+ isShowInput: {
100
+ type: vue.PropType<boolean>;
101
+ default: boolean;
102
+ };
103
+ isShowPreset: {
104
+ type: vue.PropType<boolean>;
105
+ default: boolean;
106
+ };
107
+ isInvalid: {
108
+ type: vue.PropType<boolean>;
109
+ default: boolean;
110
+ };
111
+ }>> & {
112
+ onChange?: ((...args: any[]) => any) | undefined;
113
+ }, {
114
+ id: string;
115
+ title: string;
116
+ value: string;
117
+ placeholder: string;
118
+ variant: "advance" | "basic";
119
+ placement: Placement;
120
+ preset: string[];
121
+ isShowPopover: boolean;
122
+ isShowSaturation: boolean;
123
+ isShowHue: boolean;
124
+ isShowInput: boolean;
125
+ isShowPreset: boolean;
126
+ isInvalid: boolean;
127
+ }, {}>;
128
+
129
+ export { MpColorPicker };
@@ -0,0 +1,129 @@
1
+ import * as vue_jsx_runtime from 'vue/jsx-runtime';
2
+ import { Placement } from './modules/color-picker.props.js';
3
+ import * as vue from 'vue';
4
+
5
+ declare const MpColorPicker: vue.DefineComponent<{
6
+ id: {
7
+ type: vue.PropType<string>;
8
+ default: string;
9
+ };
10
+ title: {
11
+ type: vue.PropType<string>;
12
+ default: string;
13
+ };
14
+ value: {
15
+ type: vue.PropType<string>;
16
+ default: string;
17
+ };
18
+ placeholder: {
19
+ type: vue.PropType<string>;
20
+ default: string;
21
+ };
22
+ variant: {
23
+ type: vue.PropType<"advance" | "basic">;
24
+ default: string;
25
+ };
26
+ placement: {
27
+ type: vue.PropType<Placement>;
28
+ default: string;
29
+ };
30
+ preset: {
31
+ type: vue.PropType<string[]>;
32
+ default(): string[];
33
+ };
34
+ isShowPopover: {
35
+ type: vue.PropType<boolean>;
36
+ default: boolean;
37
+ };
38
+ isShowSaturation: {
39
+ type: vue.PropType<boolean>;
40
+ default: boolean;
41
+ };
42
+ isShowHue: {
43
+ type: vue.PropType<boolean>;
44
+ default: boolean;
45
+ };
46
+ isShowInput: {
47
+ type: vue.PropType<boolean>;
48
+ default: boolean;
49
+ };
50
+ isShowPreset: {
51
+ type: vue.PropType<boolean>;
52
+ default: boolean;
53
+ };
54
+ isInvalid: {
55
+ type: vue.PropType<boolean>;
56
+ default: boolean;
57
+ };
58
+ }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "change"[], "change", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
59
+ id: {
60
+ type: vue.PropType<string>;
61
+ default: string;
62
+ };
63
+ title: {
64
+ type: vue.PropType<string>;
65
+ default: string;
66
+ };
67
+ value: {
68
+ type: vue.PropType<string>;
69
+ default: string;
70
+ };
71
+ placeholder: {
72
+ type: vue.PropType<string>;
73
+ default: string;
74
+ };
75
+ variant: {
76
+ type: vue.PropType<"advance" | "basic">;
77
+ default: string;
78
+ };
79
+ placement: {
80
+ type: vue.PropType<Placement>;
81
+ default: string;
82
+ };
83
+ preset: {
84
+ type: vue.PropType<string[]>;
85
+ default(): string[];
86
+ };
87
+ isShowPopover: {
88
+ type: vue.PropType<boolean>;
89
+ default: boolean;
90
+ };
91
+ isShowSaturation: {
92
+ type: vue.PropType<boolean>;
93
+ default: boolean;
94
+ };
95
+ isShowHue: {
96
+ type: vue.PropType<boolean>;
97
+ default: boolean;
98
+ };
99
+ isShowInput: {
100
+ type: vue.PropType<boolean>;
101
+ default: boolean;
102
+ };
103
+ isShowPreset: {
104
+ type: vue.PropType<boolean>;
105
+ default: boolean;
106
+ };
107
+ isInvalid: {
108
+ type: vue.PropType<boolean>;
109
+ default: boolean;
110
+ };
111
+ }>> & {
112
+ onChange?: ((...args: any[]) => any) | undefined;
113
+ }, {
114
+ id: string;
115
+ title: string;
116
+ value: string;
117
+ placeholder: string;
118
+ variant: "advance" | "basic";
119
+ placement: Placement;
120
+ preset: string[];
121
+ isShowPopover: boolean;
122
+ isShowSaturation: boolean;
123
+ isShowHue: boolean;
124
+ isShowInput: boolean;
125
+ isShowPreset: boolean;
126
+ isInvalid: boolean;
127
+ }, {}>;
128
+
129
+ export { MpColorPicker };