@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.
- package/dist/chunk-36OXI4E3.mjs +347 -0
- package/dist/chunk-5FWKSVUW.mjs +89 -0
- package/dist/chunk-AEUPCATZ.mjs +156 -0
- package/dist/chunk-DVRBDVR4.mjs +63 -0
- package/dist/chunk-L5BRB7ES.mjs +64 -0
- package/dist/chunk-PULVLME3.mjs +196 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/chunk-YLUI3RMF.mjs +116 -0
- package/dist/color-picker.d.mts +129 -0
- package/dist/color-picker.d.ts +129 -0
- package/dist/color-picker.js +1006 -0
- package/dist/color-picker.mjs +13 -0
- package/dist/hue.d.mts +27 -0
- package/dist/hue.d.ts +27 -0
- package/dist/hue.js +217 -0
- package/dist/hue.mjs +7 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1008 -0
- package/dist/index.mjs +13 -0
- package/dist/input.d.mts +41 -0
- package/dist/input.d.ts +41 -0
- package/dist/input.js +110 -0
- package/dist/input.mjs +7 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modules/color-picker.hooks.d.mts +206 -0
- package/dist/modules/color-picker.hooks.d.ts +206 -0
- package/dist/modules/color-picker.hooks.js +378 -0
- package/dist/modules/color-picker.hooks.mjs +7 -0
- package/dist/modules/color-picker.props.d.mts +62 -0
- package/dist/modules/color-picker.props.d.ts +62 -0
- package/dist/modules/color-picker.props.js +89 -0
- package/dist/modules/color-picker.props.mjs +9 -0
- package/dist/preset.d.mts +26 -0
- package/dist/preset.d.ts +26 -0
- package/dist/preset.js +94 -0
- package/dist/preset.mjs +7 -0
- package/dist/saturation.d.mts +16 -0
- package/dist/saturation.d.ts +16 -0
- package/dist/saturation.js +187 -0
- package/dist/saturation.mjs +7 -0
- package/package.json +53 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MpColorPicker
|
|
3
|
+
} from "./chunk-YLUI3RMF.mjs";
|
|
4
|
+
import "./chunk-PULVLME3.mjs";
|
|
5
|
+
import "./chunk-5FWKSVUW.mjs";
|
|
6
|
+
import "./chunk-DVRBDVR4.mjs";
|
|
7
|
+
import "./chunk-AEUPCATZ.mjs";
|
|
8
|
+
import "./chunk-36OXI4E3.mjs";
|
|
9
|
+
import "./chunk-L5BRB7ES.mjs";
|
|
10
|
+
import "./chunk-QZ7VFGWC.mjs";
|
|
11
|
+
export {
|
|
12
|
+
MpColorPicker
|
|
13
|
+
};
|
package/dist/hue.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare const MpColorHue: vue.DefineComponent<{
|
|
6
|
+
value: {
|
|
7
|
+
type: ObjectConstructor;
|
|
8
|
+
};
|
|
9
|
+
direction: {
|
|
10
|
+
type: PropType<"horizontal" | "vertical">;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "change"[], "change", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
14
|
+
value: {
|
|
15
|
+
type: ObjectConstructor;
|
|
16
|
+
};
|
|
17
|
+
direction: {
|
|
18
|
+
type: PropType<"horizontal" | "vertical">;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>> & {
|
|
22
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
direction: "horizontal" | "vertical";
|
|
25
|
+
}, {}>;
|
|
26
|
+
|
|
27
|
+
export { MpColorHue };
|
package/dist/hue.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare const MpColorHue: vue.DefineComponent<{
|
|
6
|
+
value: {
|
|
7
|
+
type: ObjectConstructor;
|
|
8
|
+
};
|
|
9
|
+
direction: {
|
|
10
|
+
type: PropType<"horizontal" | "vertical">;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "change"[], "change", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
14
|
+
value: {
|
|
15
|
+
type: ObjectConstructor;
|
|
16
|
+
};
|
|
17
|
+
direction: {
|
|
18
|
+
type: PropType<"horizontal" | "vertical">;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>> & {
|
|
22
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
direction: "horizontal" | "vertical";
|
|
25
|
+
}, {}>;
|
|
26
|
+
|
|
27
|
+
export { MpColorHue };
|
package/dist/hue.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/hue.tsx
|
|
22
|
+
var hue_exports = {};
|
|
23
|
+
__export(hue_exports, {
|
|
24
|
+
MpColorHue: () => MpColorHue
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(hue_exports);
|
|
27
|
+
var import_vue = require("vue");
|
|
28
|
+
var import_vue2 = require("vue");
|
|
29
|
+
var import_css = require("@mekari/pixel3-styled-system/css");
|
|
30
|
+
var MpColorHue = (0, import_vue2.defineComponent)({
|
|
31
|
+
name: "MpColorHue",
|
|
32
|
+
props: {
|
|
33
|
+
value: {
|
|
34
|
+
type: Object
|
|
35
|
+
},
|
|
36
|
+
direction: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: "horizontal"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
emits: ["change"],
|
|
42
|
+
setup(props, {
|
|
43
|
+
emit
|
|
44
|
+
}) {
|
|
45
|
+
const oldHue = (0, import_vue2.ref)(0);
|
|
46
|
+
const pullDirection = (0, import_vue2.ref)("");
|
|
47
|
+
const containerNode = (0, import_vue2.ref)();
|
|
48
|
+
(0, import_vue2.watch)(() => props.value, (oldValue, newValue) => {
|
|
49
|
+
if (oldValue !== newValue) {
|
|
50
|
+
handlePullDirection();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const colors = (0, import_vue2.computed)(() => {
|
|
54
|
+
return props.value;
|
|
55
|
+
});
|
|
56
|
+
const pointerTop = (0, import_vue2.computed)(() => {
|
|
57
|
+
var _a;
|
|
58
|
+
const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
|
|
59
|
+
if (props.direction === "vertical") {
|
|
60
|
+
if (h === 0 && pullDirection.value === "right")
|
|
61
|
+
return 0;
|
|
62
|
+
return -(h * 100 / 360) + 100 + "%";
|
|
63
|
+
} else {
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const pointerLeft = (0, import_vue2.computed)(() => {
|
|
68
|
+
var _a;
|
|
69
|
+
const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
|
|
70
|
+
if (props.direction === "vertical") {
|
|
71
|
+
return 0;
|
|
72
|
+
} else {
|
|
73
|
+
if (h === 0 && pullDirection.value === "right")
|
|
74
|
+
return "100%";
|
|
75
|
+
return h * 100 / 360 + "%";
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
function handlePullDirection() {
|
|
79
|
+
var _a;
|
|
80
|
+
const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
|
|
81
|
+
if (h !== 0 && h - oldHue.value > 0)
|
|
82
|
+
pullDirection.value = "right";
|
|
83
|
+
if (h !== 0 && h - oldHue.value < 0)
|
|
84
|
+
pullDirection.value = "left";
|
|
85
|
+
oldHue.value = h;
|
|
86
|
+
}
|
|
87
|
+
__name(handlePullDirection, "handlePullDirection");
|
|
88
|
+
function handleChange(e, skip) {
|
|
89
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
90
|
+
!skip && e.preventDefault();
|
|
91
|
+
const container = containerNode.value;
|
|
92
|
+
if (!container) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const containerWidth = container.clientWidth;
|
|
96
|
+
const containerHeight = container.clientHeight;
|
|
97
|
+
const xOffset = container.getBoundingClientRect().left + window.scrollX;
|
|
98
|
+
const yOffset = container.getBoundingClientRect().top + window.scrollY;
|
|
99
|
+
const pageX = e.pageX || (e.touches ? e.touches[0].pageX : 0);
|
|
100
|
+
const pageY = e.pageY || (e.touches ? e.touches[0].pageY : 0);
|
|
101
|
+
const left = pageX - xOffset;
|
|
102
|
+
const top = pageY - yOffset;
|
|
103
|
+
let h;
|
|
104
|
+
let percent;
|
|
105
|
+
if (props.direction === "vertical") {
|
|
106
|
+
if (top < 0) {
|
|
107
|
+
h = 360;
|
|
108
|
+
} else if (top > containerHeight) {
|
|
109
|
+
h = 0;
|
|
110
|
+
} else {
|
|
111
|
+
percent = -(top * 100 / containerHeight) + 100;
|
|
112
|
+
h = 360 * percent / 100;
|
|
113
|
+
}
|
|
114
|
+
if (((_a = colors.value) == null ? void 0 : _a.hsl.h) !== h) {
|
|
115
|
+
emit("change", {
|
|
116
|
+
h,
|
|
117
|
+
s: (_b = colors.value) == null ? void 0 : _b.hsl.s,
|
|
118
|
+
l: (_c = colors.value) == null ? void 0 : _c.hsl.l,
|
|
119
|
+
a: (_d = colors.value) == null ? void 0 : _d.hsl.a,
|
|
120
|
+
source: "hsl"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
if (left < 0) {
|
|
125
|
+
h = 0;
|
|
126
|
+
} else if (left > containerWidth) {
|
|
127
|
+
h = 360;
|
|
128
|
+
} else {
|
|
129
|
+
percent = left * 100 / containerWidth;
|
|
130
|
+
h = 360 * percent / 100;
|
|
131
|
+
}
|
|
132
|
+
if (((_e = colors.value) == null ? void 0 : _e.hsl.h) !== h) {
|
|
133
|
+
emit("change", {
|
|
134
|
+
h,
|
|
135
|
+
s: (_f = colors.value) == null ? void 0 : _f.hsl.s,
|
|
136
|
+
l: (_g = colors.value) == null ? void 0 : _g.hsl.l,
|
|
137
|
+
a: (_h = colors.value) == null ? void 0 : _h.hsl.a,
|
|
138
|
+
source: "hsl"
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
__name(handleChange, "handleChange");
|
|
144
|
+
function handleMouseDown(e) {
|
|
145
|
+
handleChange(e, true);
|
|
146
|
+
window.addEventListener("mousemove", handleChange);
|
|
147
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
148
|
+
}
|
|
149
|
+
__name(handleMouseDown, "handleMouseDown");
|
|
150
|
+
function handleMouseUp() {
|
|
151
|
+
unbindEventListeners();
|
|
152
|
+
}
|
|
153
|
+
__name(handleMouseUp, "handleMouseUp");
|
|
154
|
+
function unbindEventListeners() {
|
|
155
|
+
window.removeEventListener("mousemove", handleChange);
|
|
156
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
157
|
+
}
|
|
158
|
+
__name(unbindEventListeners, "unbindEventListeners");
|
|
159
|
+
return () => {
|
|
160
|
+
var _a;
|
|
161
|
+
return (0, import_vue.createVNode)("div", {
|
|
162
|
+
"data-pixel-component": "MpColorPickerHue",
|
|
163
|
+
"class": (0, import_css.css)({
|
|
164
|
+
position: "absolute",
|
|
165
|
+
top: "0",
|
|
166
|
+
right: "0",
|
|
167
|
+
bottom: "0",
|
|
168
|
+
left: "0",
|
|
169
|
+
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%)"
|
|
170
|
+
})
|
|
171
|
+
}, [(0, import_vue.createVNode)("div", {
|
|
172
|
+
"ref": containerNode,
|
|
173
|
+
"id": "hue-container",
|
|
174
|
+
"role": "slider",
|
|
175
|
+
"aria-valuenow": (_a = colors.value) == null ? void 0 : _a.hsl.h,
|
|
176
|
+
"aria-valuemin": "0",
|
|
177
|
+
"aria-valuemax": "360",
|
|
178
|
+
"class": (0, import_css.css)({
|
|
179
|
+
cursor: "pointer",
|
|
180
|
+
margin: "0 2px",
|
|
181
|
+
position: "relative",
|
|
182
|
+
height: "100%"
|
|
183
|
+
}),
|
|
184
|
+
"onMousedown": handleMouseDown,
|
|
185
|
+
"onTouchmove": handleChange,
|
|
186
|
+
"onTouchstart": handleChange
|
|
187
|
+
}, [(0, import_vue.createVNode)("div", {
|
|
188
|
+
"id": "hue-pointer",
|
|
189
|
+
"role": "presentation",
|
|
190
|
+
"class": (0, import_css.css)({
|
|
191
|
+
position: "absolute",
|
|
192
|
+
zIndex: "2"
|
|
193
|
+
}),
|
|
194
|
+
"style": {
|
|
195
|
+
top: pointerTop.value,
|
|
196
|
+
left: pointerLeft.value
|
|
197
|
+
}
|
|
198
|
+
}, [(0, import_vue.createVNode)("div", {
|
|
199
|
+
"id": "hue-picker",
|
|
200
|
+
"class": (0, import_css.css)({
|
|
201
|
+
cursor: "pointer",
|
|
202
|
+
marginTop: "-2px",
|
|
203
|
+
width: "32px",
|
|
204
|
+
height: "32px",
|
|
205
|
+
transform: "translateX(-16px)",
|
|
206
|
+
borderRadius: "24px",
|
|
207
|
+
boxShadow: "0px 10px 15px -3px rgba(0, 0, 0, 0.10), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
208
|
+
background: "white"
|
|
209
|
+
})
|
|
210
|
+
}, null)])])]);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
+
0 && (module.exports = {
|
|
216
|
+
MpColorHue
|
|
217
|
+
});
|
package/dist/hue.mjs
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED