@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,1008 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
|
+
MpColorPicker: () => MpColorPicker
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
|
|
38
|
+
// src/color-picker.tsx
|
|
39
|
+
var import_vue10 = require("vue");
|
|
40
|
+
var import_vue11 = require("vue");
|
|
41
|
+
var import_pixel3_text2 = require("@mekari/pixel3-text");
|
|
42
|
+
var import_pixel3_popover = require("@mekari/pixel3-popover");
|
|
43
|
+
var import_pixel3_input2 = require("@mekari/pixel3-input");
|
|
44
|
+
var import_pixel3_icon2 = require("@mekari/pixel3-icon");
|
|
45
|
+
var import_pixel3_divider = require("@mekari/pixel3-divider");
|
|
46
|
+
var import_css6 = require("@mekari/pixel3-styled-system/css");
|
|
47
|
+
|
|
48
|
+
// src/modules/color-picker.props.ts
|
|
49
|
+
var PRESET_DEFAULT = ["#3B82F6", "#14B8A6", "#8B5CF6", "#F59E0B", "#EF4444", "#71717A", "#84CC16", "#EC4899", "#232933", "#60A5FA", "#2DD4BF", "#A78BFA", "#FBBF24", "#F87171", "#A1A1AA", "#A3E635", "#F472B6", "#FFFFFF"];
|
|
50
|
+
var colorPickerProps = {
|
|
51
|
+
id: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: ""
|
|
54
|
+
},
|
|
55
|
+
title: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: "Pick a color"
|
|
58
|
+
},
|
|
59
|
+
value: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: "#3B82F6"
|
|
62
|
+
},
|
|
63
|
+
placeholder: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: "3B82F6"
|
|
66
|
+
},
|
|
67
|
+
variant: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: "advance"
|
|
70
|
+
},
|
|
71
|
+
placement: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: "bottom"
|
|
74
|
+
},
|
|
75
|
+
preset: {
|
|
76
|
+
type: Array,
|
|
77
|
+
default() {
|
|
78
|
+
return PRESET_DEFAULT;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
isShowPopover: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false
|
|
84
|
+
},
|
|
85
|
+
isShowSaturation: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: true
|
|
88
|
+
},
|
|
89
|
+
isShowHue: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: true
|
|
92
|
+
},
|
|
93
|
+
isShowInput: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: true
|
|
96
|
+
},
|
|
97
|
+
isShowPreset: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: true
|
|
100
|
+
},
|
|
101
|
+
isInvalid: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: false
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/modules/color-picker.hooks.ts
|
|
108
|
+
var import_vue = require("vue");
|
|
109
|
+
var import_tinycolor2 = __toESM(require("tinycolor2"));
|
|
110
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
111
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
112
|
+
var import_css = require("@mekari/pixel3-styled-system/css");
|
|
113
|
+
var import_tokens = require("@mekari/pixel3-styled-system/tokens");
|
|
114
|
+
function useColorPicker(props, emit) {
|
|
115
|
+
const {
|
|
116
|
+
id,
|
|
117
|
+
value,
|
|
118
|
+
placeholder,
|
|
119
|
+
variant,
|
|
120
|
+
placement,
|
|
121
|
+
isShowPopover,
|
|
122
|
+
isInvalid
|
|
123
|
+
} = (0, import_vue.toRefs)(props);
|
|
124
|
+
const val = (0, import_vue.ref)(_colorChange(value.value));
|
|
125
|
+
const colorInput = (0, import_vue.ref)("");
|
|
126
|
+
const isPopoverOpen = (0, import_vue.ref)(false);
|
|
127
|
+
const getId = id.value || (0, import_pixel3_utils.getUniqueId)("", "color-picker").value;
|
|
128
|
+
const colors = (0, import_vue.computed)({
|
|
129
|
+
get() {
|
|
130
|
+
return val.value;
|
|
131
|
+
},
|
|
132
|
+
set(newVal) {
|
|
133
|
+
val.value = newVal;
|
|
134
|
+
emit("change", newVal);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const hex = (0, import_vue.computed)(() => {
|
|
138
|
+
const hex2 = colors.value.hex;
|
|
139
|
+
return hex2.replace("#", "");
|
|
140
|
+
});
|
|
141
|
+
const borderColor = (0, import_vue.computed)(() => {
|
|
142
|
+
if (isInvalid.value) {
|
|
143
|
+
return "red.400";
|
|
144
|
+
}
|
|
145
|
+
if (!isInvalid.value && isFocused.value) {
|
|
146
|
+
return "blue.400";
|
|
147
|
+
}
|
|
148
|
+
return "gray.100";
|
|
149
|
+
});
|
|
150
|
+
const isFocused = (0, import_vue.computed)(() => {
|
|
151
|
+
return isPopoverOpen.value;
|
|
152
|
+
});
|
|
153
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
154
|
+
return {
|
|
155
|
+
"data-pixel-component": "MpColorPicker",
|
|
156
|
+
id: getId,
|
|
157
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().root,
|
|
158
|
+
style: {
|
|
159
|
+
width: variant.value === "advance" ? "280px" : "72px"
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
const popoverAttrs = (0, import_vue.computed)(() => {
|
|
164
|
+
return {
|
|
165
|
+
id: `popover-${getId}`,
|
|
166
|
+
placement: placement.value,
|
|
167
|
+
defaultIsOpen: isShowPopover.value,
|
|
168
|
+
initialFocusRef: `#input-${getId}`,
|
|
169
|
+
onOpen: handleOpenPopover,
|
|
170
|
+
onClose: handleClosePopover
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
const popoverTriggerAttrs = (0, import_vue.computed)(() => {
|
|
174
|
+
return {
|
|
175
|
+
tabindex: "0",
|
|
176
|
+
class: (0, import_css.cx)((0, import_css.css)({
|
|
177
|
+
boxShadow: isPopoverOpen.value && !isInvalid.value ? "outline" : "none",
|
|
178
|
+
_hover: {
|
|
179
|
+
borderColor: isPopoverOpen.value && !isInvalid.value ? "blue.500 !important" : "gray.400 !important"
|
|
180
|
+
}
|
|
181
|
+
}), (0, import_recipes.colorPickerSlotRecipe)().popoverTrigger),
|
|
182
|
+
style: {
|
|
183
|
+
borderColor: (0, import_tokens.token)(`colors.${borderColor.value}`)
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
const boxColorAttrs = (0, import_vue.computed)(() => {
|
|
188
|
+
return {
|
|
189
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().boxColor,
|
|
190
|
+
style: {
|
|
191
|
+
background: colors.value.hex
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
const inputTriggerAttrs = (0, import_vue.computed)(() => {
|
|
196
|
+
return {
|
|
197
|
+
id: `input-${getId}`,
|
|
198
|
+
type: "text",
|
|
199
|
+
autocomplete: "off",
|
|
200
|
+
variant: "unstyled",
|
|
201
|
+
maxlength: "6",
|
|
202
|
+
value: colorInput.value,
|
|
203
|
+
placeholder: placeholder.value,
|
|
204
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().inputTrigger,
|
|
205
|
+
onInput: handleInputTrigger
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
const iconDropDownAttrs = (0, import_vue.computed)(() => {
|
|
209
|
+
return {
|
|
210
|
+
name: "chevrons-down",
|
|
211
|
+
size: "sm",
|
|
212
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().iconDropdown
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
const popoverContentAttrs = (0, import_vue.computed)(() => {
|
|
216
|
+
return {
|
|
217
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().popoverContent,
|
|
218
|
+
style: {
|
|
219
|
+
width: variant.value === "advance" ? "280px" : "188px"
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
const wrapperAdvanceAttrs = (0, import_vue.computed)(() => {
|
|
224
|
+
return {
|
|
225
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperAdvance
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
const wrapperBasicAttrs = (0, import_vue.computed)(() => {
|
|
229
|
+
return {
|
|
230
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperBasic
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
const wrapperSaturationAttrs = (0, import_vue.computed)(() => {
|
|
234
|
+
return {
|
|
235
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperSaturation
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
const saturationAttrs = (0, import_vue.computed)(() => {
|
|
239
|
+
return {
|
|
240
|
+
value: colors.value,
|
|
241
|
+
onChange: childChange
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
const wrapperHueAttrs = (0, import_vue.computed)(() => {
|
|
245
|
+
return {
|
|
246
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperHue
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
const hueAttrs = (0, import_vue.computed)(() => {
|
|
250
|
+
return {
|
|
251
|
+
value: colors.value,
|
|
252
|
+
onChange: childChange
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
const wrapperInputAttrs = (0, import_vue.computed)(() => {
|
|
256
|
+
return {
|
|
257
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperInput
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
const inputHexAttrs = (0, import_vue.computed)(() => {
|
|
261
|
+
return {
|
|
262
|
+
label: "hex",
|
|
263
|
+
width: "88px",
|
|
264
|
+
value: hex.value,
|
|
265
|
+
onChange: inputChange
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
const inputFullAttrs = (0, import_vue.computed)(() => {
|
|
269
|
+
return {
|
|
270
|
+
label: "hex",
|
|
271
|
+
width: "full",
|
|
272
|
+
value: hex.value,
|
|
273
|
+
onChange: inputChange
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
const inputRedAttrs = (0, import_vue.computed)(() => {
|
|
277
|
+
return {
|
|
278
|
+
label: "r",
|
|
279
|
+
width: "48px",
|
|
280
|
+
value: colors.value.rgba.r,
|
|
281
|
+
onChange: inputChange
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
const inputGreenAttrs = (0, import_vue.computed)(() => {
|
|
285
|
+
return {
|
|
286
|
+
label: "g",
|
|
287
|
+
width: "48px",
|
|
288
|
+
value: colors.value.rgba.g,
|
|
289
|
+
onChange: inputChange
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
const inputBlueAttrs = (0, import_vue.computed)(() => {
|
|
293
|
+
return {
|
|
294
|
+
label: "b",
|
|
295
|
+
width: "48px",
|
|
296
|
+
value: colors.value.rgba.b,
|
|
297
|
+
onChange: inputChange
|
|
298
|
+
};
|
|
299
|
+
});
|
|
300
|
+
const boxPresetAttrs = (0, import_vue.computed)(() => {
|
|
301
|
+
return {
|
|
302
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().boxPreset
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
const wrapperPresetAttrs = (0, import_vue.computed)(() => {
|
|
306
|
+
return {
|
|
307
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperPreset
|
|
308
|
+
};
|
|
309
|
+
});
|
|
310
|
+
const wrapperBasicPresetAttrs = (0, import_vue.computed)(() => {
|
|
311
|
+
return {
|
|
312
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperBasicPreset
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
const presetBoxAttrs = /* @__PURE__ */ __name((item) => {
|
|
316
|
+
return {
|
|
317
|
+
value: item,
|
|
318
|
+
isActive: item.toLowerCase() === colors.value.hex.toLowerCase(),
|
|
319
|
+
onClick: childChange
|
|
320
|
+
};
|
|
321
|
+
}, "presetBoxAttrs");
|
|
322
|
+
function isValidHex(hex2) {
|
|
323
|
+
return (0, import_tinycolor2.default)(hex2).isValid();
|
|
324
|
+
}
|
|
325
|
+
__name(isValidHex, "isValidHex");
|
|
326
|
+
function childChange(data) {
|
|
327
|
+
colorChange(data);
|
|
328
|
+
}
|
|
329
|
+
__name(childChange, "childChange");
|
|
330
|
+
function colorChange(data, oldHue) {
|
|
331
|
+
colors.value = _colorChange(data, oldHue);
|
|
332
|
+
}
|
|
333
|
+
__name(colorChange, "colorChange");
|
|
334
|
+
function _colorChange(data, oldHue) {
|
|
335
|
+
let color;
|
|
336
|
+
if (data && data.hsl) {
|
|
337
|
+
color = (0, import_tinycolor2.default)(data.hsl);
|
|
338
|
+
} else if (data && data.hex && data.hex.length > 0) {
|
|
339
|
+
color = (0, import_tinycolor2.default)(data.hex);
|
|
340
|
+
} else if (data && data.hsv) {
|
|
341
|
+
color = (0, import_tinycolor2.default)(data.hsv);
|
|
342
|
+
} else if (data && data.rgba) {
|
|
343
|
+
color = (0, import_tinycolor2.default)(data.rgba);
|
|
344
|
+
} else if (data && data.rgb) {
|
|
345
|
+
color = (0, import_tinycolor2.default)(data.rgb);
|
|
346
|
+
} else {
|
|
347
|
+
color = (0, import_tinycolor2.default)(data);
|
|
348
|
+
}
|
|
349
|
+
const hsl = color.toHsl();
|
|
350
|
+
const hsv = color.toHsv();
|
|
351
|
+
if (hsl.s === 0) {
|
|
352
|
+
hsv.h = hsl.h = data.h || data.hsl && data.hsl.h || oldHue || 0;
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
hsl,
|
|
356
|
+
hex: color.toHexString().toUpperCase(),
|
|
357
|
+
hex8: color.toHex8String().toUpperCase(),
|
|
358
|
+
rgba: color.toRgb(),
|
|
359
|
+
hsv,
|
|
360
|
+
oldHue: data.h || oldHue || hsl.h,
|
|
361
|
+
source: data.source
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
__name(_colorChange, "_colorChange");
|
|
365
|
+
function inputChange(data) {
|
|
366
|
+
if (!data) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (data.hex) {
|
|
370
|
+
isValidHex(data.hex) && colorChange({
|
|
371
|
+
hex: data.hex,
|
|
372
|
+
source: "hex"
|
|
373
|
+
});
|
|
374
|
+
} else if (data.r || data.g || data.b || data.a) {
|
|
375
|
+
colorChange({
|
|
376
|
+
r: data.r || colors.value.rgba.r,
|
|
377
|
+
g: data.g || colors.value.rgba.g,
|
|
378
|
+
b: data.b || colors.value.rgba.b,
|
|
379
|
+
a: data.a || colors.value.rgba.a,
|
|
380
|
+
source: "rgba"
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
__name(inputChange, "inputChange");
|
|
385
|
+
function handleInputTrigger(e) {
|
|
386
|
+
const target = e.target;
|
|
387
|
+
const value2 = target.value;
|
|
388
|
+
const data = {
|
|
389
|
+
hex: "",
|
|
390
|
+
"#": ""
|
|
391
|
+
};
|
|
392
|
+
data["hex"] = value2;
|
|
393
|
+
if (data.hex === void 0 && data["#"] === void 0) {
|
|
394
|
+
inputChange(data);
|
|
395
|
+
} else if (value2.length > 5) {
|
|
396
|
+
inputChange(data);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
__name(handleInputTrigger, "handleInputTrigger");
|
|
400
|
+
function handleOpenPopover() {
|
|
401
|
+
isPopoverOpen.value = true;
|
|
402
|
+
colorInput.value = hex.value;
|
|
403
|
+
}
|
|
404
|
+
__name(handleOpenPopover, "handleOpenPopover");
|
|
405
|
+
function handleClosePopover() {
|
|
406
|
+
isPopoverOpen.value = false;
|
|
407
|
+
colorInput.value = hex.value;
|
|
408
|
+
}
|
|
409
|
+
__name(handleClosePopover, "handleClosePopover");
|
|
410
|
+
(0, import_vue.watch)(() => value.value, (newValue, oldValue) => {
|
|
411
|
+
if (newValue !== oldValue) {
|
|
412
|
+
val.value = _colorChange(newValue);
|
|
413
|
+
colorInput.value = hex.value;
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
(0, import_vue.onMounted)(() => {
|
|
417
|
+
colorInput.value = hex.value;
|
|
418
|
+
});
|
|
419
|
+
return {
|
|
420
|
+
rootAttrs,
|
|
421
|
+
popoverAttrs,
|
|
422
|
+
popoverTriggerAttrs,
|
|
423
|
+
boxColorAttrs,
|
|
424
|
+
inputTriggerAttrs,
|
|
425
|
+
iconDropDownAttrs,
|
|
426
|
+
popoverContentAttrs,
|
|
427
|
+
wrapperAdvanceAttrs,
|
|
428
|
+
wrapperBasicAttrs,
|
|
429
|
+
wrapperSaturationAttrs,
|
|
430
|
+
saturationAttrs,
|
|
431
|
+
wrapperHueAttrs,
|
|
432
|
+
hueAttrs,
|
|
433
|
+
wrapperInputAttrs,
|
|
434
|
+
inputHexAttrs,
|
|
435
|
+
inputRedAttrs,
|
|
436
|
+
inputGreenAttrs,
|
|
437
|
+
inputBlueAttrs,
|
|
438
|
+
inputFullAttrs,
|
|
439
|
+
boxPresetAttrs,
|
|
440
|
+
wrapperPresetAttrs,
|
|
441
|
+
wrapperBasicPresetAttrs,
|
|
442
|
+
presetBoxAttrs
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
__name(useColorPicker, "useColorPicker");
|
|
446
|
+
|
|
447
|
+
// src/saturation.tsx
|
|
448
|
+
var import_vue2 = require("vue");
|
|
449
|
+
var import_vue3 = require("vue");
|
|
450
|
+
var import_clamp = __toESM(require("clamp"));
|
|
451
|
+
var import_lodash = __toESM(require("lodash.throttle"));
|
|
452
|
+
var import_css2 = require("@mekari/pixel3-styled-system/css");
|
|
453
|
+
var MpColorSaturation = (0, import_vue3.defineComponent)({
|
|
454
|
+
name: "MpColorSaturation",
|
|
455
|
+
props: {
|
|
456
|
+
value: {
|
|
457
|
+
type: Object
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
emits: ["change"],
|
|
461
|
+
setup(props, {
|
|
462
|
+
emit
|
|
463
|
+
}) {
|
|
464
|
+
const containerNode = (0, import_vue3.ref)();
|
|
465
|
+
const colors = (0, import_vue3.computed)(() => {
|
|
466
|
+
return props.value;
|
|
467
|
+
});
|
|
468
|
+
const bgColor = (0, import_vue3.computed)(() => {
|
|
469
|
+
var _a;
|
|
470
|
+
return `hsl(${(_a = colors.value) == null ? void 0 : _a.hsv.h}, 100%, 50%)`;
|
|
471
|
+
});
|
|
472
|
+
const pointerTop = (0, import_vue3.computed)(() => {
|
|
473
|
+
var _a;
|
|
474
|
+
return -(((_a = colors.value) == null ? void 0 : _a.hsv.v) * 100) + 1 + 100 + "%";
|
|
475
|
+
});
|
|
476
|
+
const pointerLeft = (0, import_vue3.computed)(() => {
|
|
477
|
+
var _a;
|
|
478
|
+
return ((_a = colors.value) == null ? void 0 : _a.hsv.s) * 100 + "%";
|
|
479
|
+
});
|
|
480
|
+
const handleThrottle = (0, import_lodash.default)((fn, data) => {
|
|
481
|
+
fn(data);
|
|
482
|
+
}, 20, {
|
|
483
|
+
leading: true,
|
|
484
|
+
trailing: false
|
|
485
|
+
});
|
|
486
|
+
function handleChange(e, skip) {
|
|
487
|
+
var _a, _b;
|
|
488
|
+
!skip && e.preventDefault();
|
|
489
|
+
const container = containerNode.value;
|
|
490
|
+
if (!container) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const containerWidth = container.clientWidth;
|
|
494
|
+
const containerHeight = container.clientHeight;
|
|
495
|
+
const xOffset = container.getBoundingClientRect().left + window.scrollX;
|
|
496
|
+
const yOffset = container.getBoundingClientRect().top + window.scrollY;
|
|
497
|
+
const pageX = e.pageX || (e.touches ? e.touches[0].pageX : 0);
|
|
498
|
+
const pageY = e.pageY || (e.touches ? e.touches[0].pageY : 0);
|
|
499
|
+
const left = (0, import_clamp.default)(pageX - xOffset, 0, containerWidth);
|
|
500
|
+
const top = (0, import_clamp.default)(pageY - yOffset, 0, containerHeight);
|
|
501
|
+
const saturation = left / containerWidth;
|
|
502
|
+
const bright = (0, import_clamp.default)(-(top / containerHeight) + 1, 0, 1);
|
|
503
|
+
handleThrottle(onChange, {
|
|
504
|
+
h: (_a = colors.value) == null ? void 0 : _a.hsv.h,
|
|
505
|
+
s: saturation,
|
|
506
|
+
v: bright,
|
|
507
|
+
a: (_b = colors.value) == null ? void 0 : _b.hsv.a,
|
|
508
|
+
source: "hsva"
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
__name(handleChange, "handleChange");
|
|
512
|
+
function onChange(param) {
|
|
513
|
+
emit("change", param);
|
|
514
|
+
}
|
|
515
|
+
__name(onChange, "onChange");
|
|
516
|
+
function handleMouseDown() {
|
|
517
|
+
window.addEventListener("mousemove", handleChange);
|
|
518
|
+
window.addEventListener("mouseup", handleChange);
|
|
519
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
520
|
+
}
|
|
521
|
+
__name(handleMouseDown, "handleMouseDown");
|
|
522
|
+
function handleMouseUp() {
|
|
523
|
+
unbindEventListeners();
|
|
524
|
+
}
|
|
525
|
+
__name(handleMouseUp, "handleMouseUp");
|
|
526
|
+
function unbindEventListeners() {
|
|
527
|
+
window.removeEventListener("mousemove", handleChange);
|
|
528
|
+
window.removeEventListener("mouseup", handleChange);
|
|
529
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
530
|
+
}
|
|
531
|
+
__name(unbindEventListeners, "unbindEventListeners");
|
|
532
|
+
return () => {
|
|
533
|
+
return (0, import_vue2.createVNode)("div", {
|
|
534
|
+
"ref": containerNode,
|
|
535
|
+
"data-pixel-component": "MpColorPickerSaturation",
|
|
536
|
+
"id": "saturation-container",
|
|
537
|
+
"class": (0, import_css2.css)({
|
|
538
|
+
cursor: "pointer",
|
|
539
|
+
position: "absolute",
|
|
540
|
+
top: "0",
|
|
541
|
+
right: "0",
|
|
542
|
+
bottom: "0",
|
|
543
|
+
left: "0"
|
|
544
|
+
}),
|
|
545
|
+
"style": {
|
|
546
|
+
background: bgColor.value
|
|
547
|
+
},
|
|
548
|
+
"onMousedown": handleMouseDown,
|
|
549
|
+
"onTouchmove": handleChange,
|
|
550
|
+
"onTouchstart": handleChange
|
|
551
|
+
}, [(0, import_vue2.createVNode)("div", {
|
|
552
|
+
"id": "saturation-white",
|
|
553
|
+
"class": (0, import_css2.css)({
|
|
554
|
+
position: "absolute",
|
|
555
|
+
top: "0",
|
|
556
|
+
right: "0",
|
|
557
|
+
bottom: "0",
|
|
558
|
+
left: "0",
|
|
559
|
+
background: "linear-gradient(to right, #fff, rgba(255,255,255,0))"
|
|
560
|
+
})
|
|
561
|
+
}, null), (0, import_vue2.createVNode)("div", {
|
|
562
|
+
"id": "saturation-black",
|
|
563
|
+
"class": (0, import_css2.css)({
|
|
564
|
+
position: "absolute",
|
|
565
|
+
top: "0",
|
|
566
|
+
right: "0",
|
|
567
|
+
bottom: "0",
|
|
568
|
+
left: "0",
|
|
569
|
+
background: "linear-gradient(to top, #000, rgba(0,0,0,0))"
|
|
570
|
+
})
|
|
571
|
+
}, null), (0, import_vue2.createVNode)("div", {
|
|
572
|
+
"id": "saturation-pointer",
|
|
573
|
+
"class": (0, import_css2.css)({
|
|
574
|
+
cursor: "pointer",
|
|
575
|
+
position: "absolute"
|
|
576
|
+
}),
|
|
577
|
+
"style": {
|
|
578
|
+
top: pointerTop.value,
|
|
579
|
+
left: pointerLeft.value
|
|
580
|
+
}
|
|
581
|
+
}, [(0, import_vue2.createVNode)("div", {
|
|
582
|
+
"id": "saturation-circle",
|
|
583
|
+
"class": (0, import_css2.css)({
|
|
584
|
+
cursor: "pointer",
|
|
585
|
+
width: "6px",
|
|
586
|
+
height: "6px",
|
|
587
|
+
boxShadow: "0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0,0,0,.3), 0 0 1px 2px rgba(0,0,0,.4)",
|
|
588
|
+
borderRadius: "50%",
|
|
589
|
+
transform: "translate(-2px, -2px)"
|
|
590
|
+
})
|
|
591
|
+
}, null)])]);
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
// src/hue.tsx
|
|
597
|
+
var import_vue4 = require("vue");
|
|
598
|
+
var import_vue5 = require("vue");
|
|
599
|
+
var import_css3 = require("@mekari/pixel3-styled-system/css");
|
|
600
|
+
var MpColorHue = (0, import_vue5.defineComponent)({
|
|
601
|
+
name: "MpColorHue",
|
|
602
|
+
props: {
|
|
603
|
+
value: {
|
|
604
|
+
type: Object
|
|
605
|
+
},
|
|
606
|
+
direction: {
|
|
607
|
+
type: String,
|
|
608
|
+
default: "horizontal"
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
emits: ["change"],
|
|
612
|
+
setup(props, {
|
|
613
|
+
emit
|
|
614
|
+
}) {
|
|
615
|
+
const oldHue = (0, import_vue5.ref)(0);
|
|
616
|
+
const pullDirection = (0, import_vue5.ref)("");
|
|
617
|
+
const containerNode = (0, import_vue5.ref)();
|
|
618
|
+
(0, import_vue5.watch)(() => props.value, (oldValue, newValue) => {
|
|
619
|
+
if (oldValue !== newValue) {
|
|
620
|
+
handlePullDirection();
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
const colors = (0, import_vue5.computed)(() => {
|
|
624
|
+
return props.value;
|
|
625
|
+
});
|
|
626
|
+
const pointerTop = (0, import_vue5.computed)(() => {
|
|
627
|
+
var _a;
|
|
628
|
+
const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
|
|
629
|
+
if (props.direction === "vertical") {
|
|
630
|
+
if (h === 0 && pullDirection.value === "right")
|
|
631
|
+
return 0;
|
|
632
|
+
return -(h * 100 / 360) + 100 + "%";
|
|
633
|
+
} else {
|
|
634
|
+
return 0;
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
const pointerLeft = (0, import_vue5.computed)(() => {
|
|
638
|
+
var _a;
|
|
639
|
+
const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
|
|
640
|
+
if (props.direction === "vertical") {
|
|
641
|
+
return 0;
|
|
642
|
+
} else {
|
|
643
|
+
if (h === 0 && pullDirection.value === "right")
|
|
644
|
+
return "100%";
|
|
645
|
+
return h * 100 / 360 + "%";
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
function handlePullDirection() {
|
|
649
|
+
var _a;
|
|
650
|
+
const h = (_a = props.value) == null ? void 0 : _a.hsl.h;
|
|
651
|
+
if (h !== 0 && h - oldHue.value > 0)
|
|
652
|
+
pullDirection.value = "right";
|
|
653
|
+
if (h !== 0 && h - oldHue.value < 0)
|
|
654
|
+
pullDirection.value = "left";
|
|
655
|
+
oldHue.value = h;
|
|
656
|
+
}
|
|
657
|
+
__name(handlePullDirection, "handlePullDirection");
|
|
658
|
+
function handleChange(e, skip) {
|
|
659
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
660
|
+
!skip && e.preventDefault();
|
|
661
|
+
const container = containerNode.value;
|
|
662
|
+
if (!container) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const containerWidth = container.clientWidth;
|
|
666
|
+
const containerHeight = container.clientHeight;
|
|
667
|
+
const xOffset = container.getBoundingClientRect().left + window.scrollX;
|
|
668
|
+
const yOffset = container.getBoundingClientRect().top + window.scrollY;
|
|
669
|
+
const pageX = e.pageX || (e.touches ? e.touches[0].pageX : 0);
|
|
670
|
+
const pageY = e.pageY || (e.touches ? e.touches[0].pageY : 0);
|
|
671
|
+
const left = pageX - xOffset;
|
|
672
|
+
const top = pageY - yOffset;
|
|
673
|
+
let h;
|
|
674
|
+
let percent;
|
|
675
|
+
if (props.direction === "vertical") {
|
|
676
|
+
if (top < 0) {
|
|
677
|
+
h = 360;
|
|
678
|
+
} else if (top > containerHeight) {
|
|
679
|
+
h = 0;
|
|
680
|
+
} else {
|
|
681
|
+
percent = -(top * 100 / containerHeight) + 100;
|
|
682
|
+
h = 360 * percent / 100;
|
|
683
|
+
}
|
|
684
|
+
if (((_a = colors.value) == null ? void 0 : _a.hsl.h) !== h) {
|
|
685
|
+
emit("change", {
|
|
686
|
+
h,
|
|
687
|
+
s: (_b = colors.value) == null ? void 0 : _b.hsl.s,
|
|
688
|
+
l: (_c = colors.value) == null ? void 0 : _c.hsl.l,
|
|
689
|
+
a: (_d = colors.value) == null ? void 0 : _d.hsl.a,
|
|
690
|
+
source: "hsl"
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
} else {
|
|
694
|
+
if (left < 0) {
|
|
695
|
+
h = 0;
|
|
696
|
+
} else if (left > containerWidth) {
|
|
697
|
+
h = 360;
|
|
698
|
+
} else {
|
|
699
|
+
percent = left * 100 / containerWidth;
|
|
700
|
+
h = 360 * percent / 100;
|
|
701
|
+
}
|
|
702
|
+
if (((_e = colors.value) == null ? void 0 : _e.hsl.h) !== h) {
|
|
703
|
+
emit("change", {
|
|
704
|
+
h,
|
|
705
|
+
s: (_f = colors.value) == null ? void 0 : _f.hsl.s,
|
|
706
|
+
l: (_g = colors.value) == null ? void 0 : _g.hsl.l,
|
|
707
|
+
a: (_h = colors.value) == null ? void 0 : _h.hsl.a,
|
|
708
|
+
source: "hsl"
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
__name(handleChange, "handleChange");
|
|
714
|
+
function handleMouseDown(e) {
|
|
715
|
+
handleChange(e, true);
|
|
716
|
+
window.addEventListener("mousemove", handleChange);
|
|
717
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
718
|
+
}
|
|
719
|
+
__name(handleMouseDown, "handleMouseDown");
|
|
720
|
+
function handleMouseUp() {
|
|
721
|
+
unbindEventListeners();
|
|
722
|
+
}
|
|
723
|
+
__name(handleMouseUp, "handleMouseUp");
|
|
724
|
+
function unbindEventListeners() {
|
|
725
|
+
window.removeEventListener("mousemove", handleChange);
|
|
726
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
727
|
+
}
|
|
728
|
+
__name(unbindEventListeners, "unbindEventListeners");
|
|
729
|
+
return () => {
|
|
730
|
+
var _a;
|
|
731
|
+
return (0, import_vue4.createVNode)("div", {
|
|
732
|
+
"data-pixel-component": "MpColorPickerHue",
|
|
733
|
+
"class": (0, import_css3.css)({
|
|
734
|
+
position: "absolute",
|
|
735
|
+
top: "0",
|
|
736
|
+
right: "0",
|
|
737
|
+
bottom: "0",
|
|
738
|
+
left: "0",
|
|
739
|
+
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%)"
|
|
740
|
+
})
|
|
741
|
+
}, [(0, import_vue4.createVNode)("div", {
|
|
742
|
+
"ref": containerNode,
|
|
743
|
+
"id": "hue-container",
|
|
744
|
+
"role": "slider",
|
|
745
|
+
"aria-valuenow": (_a = colors.value) == null ? void 0 : _a.hsl.h,
|
|
746
|
+
"aria-valuemin": "0",
|
|
747
|
+
"aria-valuemax": "360",
|
|
748
|
+
"class": (0, import_css3.css)({
|
|
749
|
+
cursor: "pointer",
|
|
750
|
+
margin: "0 2px",
|
|
751
|
+
position: "relative",
|
|
752
|
+
height: "100%"
|
|
753
|
+
}),
|
|
754
|
+
"onMousedown": handleMouseDown,
|
|
755
|
+
"onTouchmove": handleChange,
|
|
756
|
+
"onTouchstart": handleChange
|
|
757
|
+
}, [(0, import_vue4.createVNode)("div", {
|
|
758
|
+
"id": "hue-pointer",
|
|
759
|
+
"role": "presentation",
|
|
760
|
+
"class": (0, import_css3.css)({
|
|
761
|
+
position: "absolute",
|
|
762
|
+
zIndex: "2"
|
|
763
|
+
}),
|
|
764
|
+
"style": {
|
|
765
|
+
top: pointerTop.value,
|
|
766
|
+
left: pointerLeft.value
|
|
767
|
+
}
|
|
768
|
+
}, [(0, import_vue4.createVNode)("div", {
|
|
769
|
+
"id": "hue-picker",
|
|
770
|
+
"class": (0, import_css3.css)({
|
|
771
|
+
cursor: "pointer",
|
|
772
|
+
marginTop: "-2px",
|
|
773
|
+
width: "32px",
|
|
774
|
+
height: "32px",
|
|
775
|
+
transform: "translateX(-16px)",
|
|
776
|
+
borderRadius: "24px",
|
|
777
|
+
boxShadow: "0px 10px 15px -3px rgba(0, 0, 0, 0.10), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
778
|
+
background: "white"
|
|
779
|
+
})
|
|
780
|
+
}, null)])])]);
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
// src/input.tsx
|
|
786
|
+
var import_vue6 = require("vue");
|
|
787
|
+
var import_vue7 = require("vue");
|
|
788
|
+
var import_pixel3_text = require("@mekari/pixel3-text");
|
|
789
|
+
var import_pixel3_input = require("@mekari/pixel3-input");
|
|
790
|
+
var import_css4 = require("@mekari/pixel3-styled-system/css");
|
|
791
|
+
var MpColorInput = (0, import_vue7.defineComponent)({
|
|
792
|
+
name: "MpColorInput",
|
|
793
|
+
props: {
|
|
794
|
+
value: {
|
|
795
|
+
type: [String, Number],
|
|
796
|
+
default: ""
|
|
797
|
+
},
|
|
798
|
+
label: {
|
|
799
|
+
type: String,
|
|
800
|
+
default: "hex"
|
|
801
|
+
},
|
|
802
|
+
width: {
|
|
803
|
+
type: String
|
|
804
|
+
},
|
|
805
|
+
max: {
|
|
806
|
+
type: Number
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
emits: ["change"],
|
|
810
|
+
setup(props, {
|
|
811
|
+
emit
|
|
812
|
+
}) {
|
|
813
|
+
const val = (0, import_vue7.computed)({
|
|
814
|
+
get() {
|
|
815
|
+
return props.value;
|
|
816
|
+
},
|
|
817
|
+
set(v) {
|
|
818
|
+
if (!(props.max === void 0) && +v > props.max) {
|
|
819
|
+
return props.max;
|
|
820
|
+
} else {
|
|
821
|
+
return v;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
function handleInput(e) {
|
|
826
|
+
console.log("asdad", e);
|
|
827
|
+
const target = e.target;
|
|
828
|
+
const value = target.value;
|
|
829
|
+
const data = {};
|
|
830
|
+
data[props.label] = value;
|
|
831
|
+
if (data.hex === void 0 && data["#"] === void 0) {
|
|
832
|
+
emit("change", data);
|
|
833
|
+
} else if (value.length > 5) {
|
|
834
|
+
emit("change", data);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
__name(handleInput, "handleInput");
|
|
838
|
+
return () => {
|
|
839
|
+
return (0, import_vue6.createVNode)("div", {
|
|
840
|
+
"data-pixel-component": "MpColorPickerInput",
|
|
841
|
+
"class": (0, import_css4.css)({
|
|
842
|
+
display: "flex",
|
|
843
|
+
flexDirection: "column",
|
|
844
|
+
gap: "1"
|
|
845
|
+
})
|
|
846
|
+
}, [(0, import_vue6.createVNode)("div", null, [(0, import_vue6.createVNode)(import_pixel3_text.MpText, {
|
|
847
|
+
"size": "label-small",
|
|
848
|
+
"class": (0, import_css4.css)({
|
|
849
|
+
textTransform: "capitalize"
|
|
850
|
+
})
|
|
851
|
+
}, {
|
|
852
|
+
default: () => [props.label]
|
|
853
|
+
})]), (0, import_vue6.createVNode)(import_pixel3_input.MpInput, {
|
|
854
|
+
"value": val.value,
|
|
855
|
+
"size": "sm",
|
|
856
|
+
"maxlength": props.label === "hex" ? "7" : "3",
|
|
857
|
+
"style": {
|
|
858
|
+
width: props.width,
|
|
859
|
+
minWidth: props.width
|
|
860
|
+
},
|
|
861
|
+
"onInput": handleInput
|
|
862
|
+
}, null)]);
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
// src/preset.tsx
|
|
868
|
+
var import_vue8 = require("vue");
|
|
869
|
+
var import_vue9 = require("vue");
|
|
870
|
+
var import_tinycolor22 = __toESM(require("tinycolor2"));
|
|
871
|
+
var import_pixel3_icon = require("@mekari/pixel3-icon");
|
|
872
|
+
var import_css5 = require("@mekari/pixel3-styled-system/css");
|
|
873
|
+
var MpColorPreset = (0, import_vue9.defineComponent)({
|
|
874
|
+
name: "MpColorPreset",
|
|
875
|
+
props: {
|
|
876
|
+
value: {
|
|
877
|
+
type: String
|
|
878
|
+
},
|
|
879
|
+
isActive: {
|
|
880
|
+
type: Boolean,
|
|
881
|
+
default: false
|
|
882
|
+
}
|
|
883
|
+
},
|
|
884
|
+
emits: ["click"],
|
|
885
|
+
setup(props, {
|
|
886
|
+
emit
|
|
887
|
+
}) {
|
|
888
|
+
function handleClick() {
|
|
889
|
+
emit("click", props.value);
|
|
890
|
+
}
|
|
891
|
+
__name(handleClick, "handleClick");
|
|
892
|
+
return () => {
|
|
893
|
+
return (0, import_vue8.createVNode)("div", {
|
|
894
|
+
"data-pixel-component": "MpColorPickerPreset",
|
|
895
|
+
"class": (0, import_css5.css)({
|
|
896
|
+
display: "flex",
|
|
897
|
+
alignItems: "center",
|
|
898
|
+
justifyContent: "center",
|
|
899
|
+
position: "relative",
|
|
900
|
+
width: "6",
|
|
901
|
+
height: "6",
|
|
902
|
+
borderWidth: "1px",
|
|
903
|
+
borderColor: "gray.50",
|
|
904
|
+
borderRadius: "sm",
|
|
905
|
+
cursor: "pointer"
|
|
906
|
+
}),
|
|
907
|
+
"style": {
|
|
908
|
+
background: props.value
|
|
909
|
+
},
|
|
910
|
+
"onClick": handleClick
|
|
911
|
+
}, [props.isActive && (0, import_vue8.createVNode)(import_pixel3_icon.MpIcon, {
|
|
912
|
+
"name": "check",
|
|
913
|
+
"size": "sm",
|
|
914
|
+
"color": (0, import_tinycolor22.default)(props.value).isDark() ? "white" : "dark",
|
|
915
|
+
"style": {
|
|
916
|
+
position: "absolute"
|
|
917
|
+
}
|
|
918
|
+
}, null)]);
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
// src/color-picker.tsx
|
|
924
|
+
function _isSlot(s) {
|
|
925
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, import_vue10.isVNode)(s);
|
|
926
|
+
}
|
|
927
|
+
__name(_isSlot, "_isSlot");
|
|
928
|
+
var MpColorPicker = (0, import_vue11.defineComponent)({
|
|
929
|
+
name: "MpColorPicker",
|
|
930
|
+
props: colorPickerProps,
|
|
931
|
+
emits: ["change"],
|
|
932
|
+
setup(props, {
|
|
933
|
+
slots,
|
|
934
|
+
emit
|
|
935
|
+
}) {
|
|
936
|
+
const {
|
|
937
|
+
rootAttrs,
|
|
938
|
+
popoverAttrs,
|
|
939
|
+
popoverTriggerAttrs,
|
|
940
|
+
boxColorAttrs,
|
|
941
|
+
inputTriggerAttrs,
|
|
942
|
+
iconDropDownAttrs,
|
|
943
|
+
popoverContentAttrs,
|
|
944
|
+
wrapperAdvanceAttrs,
|
|
945
|
+
wrapperBasicAttrs,
|
|
946
|
+
wrapperSaturationAttrs,
|
|
947
|
+
saturationAttrs,
|
|
948
|
+
wrapperHueAttrs,
|
|
949
|
+
hueAttrs,
|
|
950
|
+
wrapperInputAttrs,
|
|
951
|
+
inputHexAttrs,
|
|
952
|
+
inputRedAttrs,
|
|
953
|
+
inputGreenAttrs,
|
|
954
|
+
inputBlueAttrs,
|
|
955
|
+
inputFullAttrs,
|
|
956
|
+
boxPresetAttrs,
|
|
957
|
+
wrapperBasicPresetAttrs,
|
|
958
|
+
wrapperPresetAttrs,
|
|
959
|
+
presetBoxAttrs
|
|
960
|
+
} = useColorPicker(props, emit);
|
|
961
|
+
return () => {
|
|
962
|
+
const children = slots.default && slots.default();
|
|
963
|
+
const {
|
|
964
|
+
variant,
|
|
965
|
+
title,
|
|
966
|
+
isShowSaturation,
|
|
967
|
+
isShowHue,
|
|
968
|
+
isShowInput,
|
|
969
|
+
isShowPreset
|
|
970
|
+
} = props;
|
|
971
|
+
return (0, import_vue10.createVNode)("div", rootAttrs.value, [(0, import_vue10.createVNode)(import_pixel3_popover.MpPopover, popoverAttrs.value, {
|
|
972
|
+
default: () => [(0, import_vue10.createVNode)(import_pixel3_popover.MpPopoverTrigger, null, {
|
|
973
|
+
default: () => [children ? (0, import_vue10.createVNode)("div", null, [children]) : (0, import_vue10.createVNode)("div", popoverTriggerAttrs.value, [(0, import_vue10.createVNode)("div", boxColorAttrs.value, null), variant === "advance" && (0, import_vue10.createVNode)(import_pixel3_text2.MpText, {
|
|
974
|
+
"color": "gray.400",
|
|
975
|
+
"style": "margin-top: 1px"
|
|
976
|
+
}, {
|
|
977
|
+
default: () => [(0, import_vue10.createTextVNode)("#")]
|
|
978
|
+
}), variant === "advance" && (0, import_vue10.createVNode)(import_pixel3_input2.MpInput, inputTriggerAttrs.value, null), (0, import_vue10.createVNode)(import_pixel3_icon2.MpIcon, iconDropDownAttrs.value, null)])]
|
|
979
|
+
}), (0, import_vue10.createVNode)(import_pixel3_popover.MpPopoverContent, popoverContentAttrs.value, {
|
|
980
|
+
default: () => [variant === "advance" && (0, import_vue10.createVNode)("div", wrapperAdvanceAttrs.value, [isShowSaturation && (0, import_vue10.createVNode)("div", wrapperSaturationAttrs.value, [(0, import_vue10.createVNode)(MpColorSaturation, saturationAttrs.value, null)]), isShowHue && (0, import_vue10.createVNode)("div", wrapperHueAttrs.value, [(0, import_vue10.createVNode)(MpColorHue, hueAttrs.value, null)]), isShowInput && (0, import_vue10.createVNode)("div", wrapperInputAttrs.value, [(0, import_vue10.createVNode)(MpColorInput, inputHexAttrs.value, null), (0, import_vue10.createVNode)(MpColorInput, inputRedAttrs.value, null), (0, import_vue10.createVNode)(MpColorInput, inputGreenAttrs.value, null), (0, import_vue10.createVNode)(MpColorInput, inputBlueAttrs.value, null)]), isShowPreset && (0, import_vue10.createVNode)(import_pixel3_divider.MpDivider, {
|
|
981
|
+
"class": (0, import_css6.css)({
|
|
982
|
+
marginTop: "0",
|
|
983
|
+
marginBottom: "0"
|
|
984
|
+
})
|
|
985
|
+
}, null), isShowPreset && (0, import_vue10.createVNode)("div", boxPresetAttrs.value, [(0, import_vue10.createVNode)("div", wrapperPresetAttrs.value, [(0, import_vue10.createVNode)(import_pixel3_text2.MpText, {
|
|
986
|
+
"size": "label-small",
|
|
987
|
+
"style": "width: 100%;"
|
|
988
|
+
}, {
|
|
989
|
+
default: () => [(0, import_vue10.createTextVNode)("Present")]
|
|
990
|
+
}), props.preset.map((item) => {
|
|
991
|
+
return (0, import_vue10.createVNode)(MpColorPreset, presetBoxAttrs(item), null);
|
|
992
|
+
})])])]), variant === "basic" && (0, import_vue10.createVNode)("div", wrapperBasicAttrs.value, [(0, import_vue10.createVNode)(import_pixel3_text2.MpText, {
|
|
993
|
+
"size": "body-small",
|
|
994
|
+
"color": "gray.600"
|
|
995
|
+
}, _isSlot(title) ? title : {
|
|
996
|
+
default: () => [title]
|
|
997
|
+
}), isShowPreset && (0, import_vue10.createVNode)("div", wrapperBasicPresetAttrs.value, [props.preset.map((item) => {
|
|
998
|
+
return (0, import_vue10.createVNode)(MpColorPreset, presetBoxAttrs(item), null);
|
|
999
|
+
})]), isShowInput && (0, import_vue10.createVNode)("div", wrapperInputAttrs.value, [(0, import_vue10.createVNode)(MpColorInput, inputFullAttrs.value, null)])])]
|
|
1000
|
+
})]
|
|
1001
|
+
})]);
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1006
|
+
0 && (module.exports = {
|
|
1007
|
+
MpColorPicker
|
|
1008
|
+
});
|