@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,206 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { ColorPickerProps, ColorPickerEmit, Placement } from './color-picker.props.js';
|
|
3
|
+
|
|
4
|
+
declare function useColorPicker(props: ColorPickerProps, emit: ColorPickerEmit): {
|
|
5
|
+
rootAttrs: vue.ComputedRef<{
|
|
6
|
+
'data-pixel-component': string;
|
|
7
|
+
id: string | undefined;
|
|
8
|
+
class: string;
|
|
9
|
+
style: {
|
|
10
|
+
width: string;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
popoverAttrs: vue.ComputedRef<{
|
|
14
|
+
id: string;
|
|
15
|
+
placement: Placement;
|
|
16
|
+
defaultIsOpen: boolean;
|
|
17
|
+
initialFocusRef: string;
|
|
18
|
+
onOpen: () => void;
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
}>;
|
|
21
|
+
popoverTriggerAttrs: vue.ComputedRef<{
|
|
22
|
+
tabindex: string;
|
|
23
|
+
class: string;
|
|
24
|
+
style: {
|
|
25
|
+
borderColor: string;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
boxColorAttrs: vue.ComputedRef<{
|
|
29
|
+
class: string;
|
|
30
|
+
style: {
|
|
31
|
+
background: string;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
inputTriggerAttrs: vue.ComputedRef<{
|
|
35
|
+
id: string;
|
|
36
|
+
type: string;
|
|
37
|
+
autocomplete: string;
|
|
38
|
+
variant: "unstyled";
|
|
39
|
+
maxlength: string;
|
|
40
|
+
value: string;
|
|
41
|
+
placeholder: string;
|
|
42
|
+
class: string;
|
|
43
|
+
onInput: (e: Event) => void;
|
|
44
|
+
}>;
|
|
45
|
+
iconDropDownAttrs: vue.ComputedRef<{
|
|
46
|
+
name: "chevrons-down";
|
|
47
|
+
size: "sm";
|
|
48
|
+
class: string;
|
|
49
|
+
}>;
|
|
50
|
+
popoverContentAttrs: vue.ComputedRef<{
|
|
51
|
+
class: string;
|
|
52
|
+
style: {
|
|
53
|
+
width: string;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
wrapperAdvanceAttrs: vue.ComputedRef<{
|
|
57
|
+
class: string;
|
|
58
|
+
}>;
|
|
59
|
+
wrapperBasicAttrs: vue.ComputedRef<{
|
|
60
|
+
class: string;
|
|
61
|
+
}>;
|
|
62
|
+
wrapperSaturationAttrs: vue.ComputedRef<{
|
|
63
|
+
class: string;
|
|
64
|
+
}>;
|
|
65
|
+
saturationAttrs: vue.ComputedRef<{
|
|
66
|
+
value: {
|
|
67
|
+
hsl: {
|
|
68
|
+
h: number;
|
|
69
|
+
s: number;
|
|
70
|
+
l: number;
|
|
71
|
+
a: number;
|
|
72
|
+
};
|
|
73
|
+
hex: string;
|
|
74
|
+
hex8: string;
|
|
75
|
+
rgba: {
|
|
76
|
+
r: number;
|
|
77
|
+
g: number;
|
|
78
|
+
b: number;
|
|
79
|
+
a: number;
|
|
80
|
+
};
|
|
81
|
+
hsv: {
|
|
82
|
+
a: number;
|
|
83
|
+
h: number;
|
|
84
|
+
s: number;
|
|
85
|
+
v: number;
|
|
86
|
+
};
|
|
87
|
+
oldHue: any;
|
|
88
|
+
source: any;
|
|
89
|
+
};
|
|
90
|
+
onChange: (data: any) => void;
|
|
91
|
+
}>;
|
|
92
|
+
wrapperHueAttrs: vue.ComputedRef<{
|
|
93
|
+
class: string;
|
|
94
|
+
}>;
|
|
95
|
+
hueAttrs: vue.ComputedRef<{
|
|
96
|
+
value: {
|
|
97
|
+
hsl: {
|
|
98
|
+
h: number;
|
|
99
|
+
s: number;
|
|
100
|
+
l: number;
|
|
101
|
+
a: number;
|
|
102
|
+
};
|
|
103
|
+
hex: string;
|
|
104
|
+
hex8: string;
|
|
105
|
+
rgba: {
|
|
106
|
+
r: number;
|
|
107
|
+
g: number;
|
|
108
|
+
b: number;
|
|
109
|
+
a: number;
|
|
110
|
+
};
|
|
111
|
+
hsv: {
|
|
112
|
+
a: number;
|
|
113
|
+
h: number;
|
|
114
|
+
s: number;
|
|
115
|
+
v: number;
|
|
116
|
+
};
|
|
117
|
+
oldHue: any;
|
|
118
|
+
source: any;
|
|
119
|
+
};
|
|
120
|
+
onChange: (data: any) => void;
|
|
121
|
+
}>;
|
|
122
|
+
wrapperInputAttrs: vue.ComputedRef<{
|
|
123
|
+
class: string;
|
|
124
|
+
}>;
|
|
125
|
+
inputHexAttrs: vue.ComputedRef<{
|
|
126
|
+
label: string;
|
|
127
|
+
width: string;
|
|
128
|
+
value: string;
|
|
129
|
+
onChange: (data: {
|
|
130
|
+
hex?: string | undefined;
|
|
131
|
+
'#'?: string | undefined;
|
|
132
|
+
r?: string | undefined;
|
|
133
|
+
g?: string | undefined;
|
|
134
|
+
b?: string | undefined;
|
|
135
|
+
a?: string | undefined;
|
|
136
|
+
}) => void;
|
|
137
|
+
}>;
|
|
138
|
+
inputRedAttrs: vue.ComputedRef<{
|
|
139
|
+
label: string;
|
|
140
|
+
width: string;
|
|
141
|
+
value: number;
|
|
142
|
+
onChange: (data: {
|
|
143
|
+
hex?: string | undefined;
|
|
144
|
+
'#'?: string | undefined;
|
|
145
|
+
r?: string | undefined;
|
|
146
|
+
g?: string | undefined;
|
|
147
|
+
b?: string | undefined;
|
|
148
|
+
a?: string | undefined;
|
|
149
|
+
}) => void;
|
|
150
|
+
}>;
|
|
151
|
+
inputGreenAttrs: vue.ComputedRef<{
|
|
152
|
+
label: string;
|
|
153
|
+
width: string;
|
|
154
|
+
value: number;
|
|
155
|
+
onChange: (data: {
|
|
156
|
+
hex?: string | undefined;
|
|
157
|
+
'#'?: string | undefined;
|
|
158
|
+
r?: string | undefined;
|
|
159
|
+
g?: string | undefined;
|
|
160
|
+
b?: string | undefined;
|
|
161
|
+
a?: string | undefined;
|
|
162
|
+
}) => void;
|
|
163
|
+
}>;
|
|
164
|
+
inputBlueAttrs: vue.ComputedRef<{
|
|
165
|
+
label: string;
|
|
166
|
+
width: string;
|
|
167
|
+
value: number;
|
|
168
|
+
onChange: (data: {
|
|
169
|
+
hex?: string | undefined;
|
|
170
|
+
'#'?: string | undefined;
|
|
171
|
+
r?: string | undefined;
|
|
172
|
+
g?: string | undefined;
|
|
173
|
+
b?: string | undefined;
|
|
174
|
+
a?: string | undefined;
|
|
175
|
+
}) => void;
|
|
176
|
+
}>;
|
|
177
|
+
inputFullAttrs: vue.ComputedRef<{
|
|
178
|
+
label: string;
|
|
179
|
+
width: string;
|
|
180
|
+
value: string;
|
|
181
|
+
onChange: (data: {
|
|
182
|
+
hex?: string | undefined;
|
|
183
|
+
'#'?: string | undefined;
|
|
184
|
+
r?: string | undefined;
|
|
185
|
+
g?: string | undefined;
|
|
186
|
+
b?: string | undefined;
|
|
187
|
+
a?: string | undefined;
|
|
188
|
+
}) => void;
|
|
189
|
+
}>;
|
|
190
|
+
boxPresetAttrs: vue.ComputedRef<{
|
|
191
|
+
class: string;
|
|
192
|
+
}>;
|
|
193
|
+
wrapperPresetAttrs: vue.ComputedRef<{
|
|
194
|
+
class: string;
|
|
195
|
+
}>;
|
|
196
|
+
wrapperBasicPresetAttrs: vue.ComputedRef<{
|
|
197
|
+
class: string;
|
|
198
|
+
}>;
|
|
199
|
+
presetBoxAttrs: (item: string) => {
|
|
200
|
+
value: string;
|
|
201
|
+
isActive: boolean;
|
|
202
|
+
onClick: (data: any) => void;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export { useColorPicker };
|
|
@@ -0,0 +1,378 @@
|
|
|
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/modules/color-picker.hooks.ts
|
|
32
|
+
var color_picker_hooks_exports = {};
|
|
33
|
+
__export(color_picker_hooks_exports, {
|
|
34
|
+
useColorPicker: () => useColorPicker
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(color_picker_hooks_exports);
|
|
37
|
+
var import_vue = require("vue");
|
|
38
|
+
var import_tinycolor2 = __toESM(require("tinycolor2"));
|
|
39
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
40
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
41
|
+
var import_css = require("@mekari/pixel3-styled-system/css");
|
|
42
|
+
var import_tokens = require("@mekari/pixel3-styled-system/tokens");
|
|
43
|
+
function useColorPicker(props, emit) {
|
|
44
|
+
const {
|
|
45
|
+
id,
|
|
46
|
+
value,
|
|
47
|
+
placeholder,
|
|
48
|
+
variant,
|
|
49
|
+
placement,
|
|
50
|
+
isShowPopover,
|
|
51
|
+
isInvalid
|
|
52
|
+
} = (0, import_vue.toRefs)(props);
|
|
53
|
+
const val = (0, import_vue.ref)(_colorChange(value.value));
|
|
54
|
+
const colorInput = (0, import_vue.ref)("");
|
|
55
|
+
const isPopoverOpen = (0, import_vue.ref)(false);
|
|
56
|
+
const getId = id.value || (0, import_pixel3_utils.getUniqueId)("", "color-picker").value;
|
|
57
|
+
const colors = (0, import_vue.computed)({
|
|
58
|
+
get() {
|
|
59
|
+
return val.value;
|
|
60
|
+
},
|
|
61
|
+
set(newVal) {
|
|
62
|
+
val.value = newVal;
|
|
63
|
+
emit("change", newVal);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const hex = (0, import_vue.computed)(() => {
|
|
67
|
+
const hex2 = colors.value.hex;
|
|
68
|
+
return hex2.replace("#", "");
|
|
69
|
+
});
|
|
70
|
+
const borderColor = (0, import_vue.computed)(() => {
|
|
71
|
+
if (isInvalid.value) {
|
|
72
|
+
return "red.400";
|
|
73
|
+
}
|
|
74
|
+
if (!isInvalid.value && isFocused.value) {
|
|
75
|
+
return "blue.400";
|
|
76
|
+
}
|
|
77
|
+
return "gray.100";
|
|
78
|
+
});
|
|
79
|
+
const isFocused = (0, import_vue.computed)(() => {
|
|
80
|
+
return isPopoverOpen.value;
|
|
81
|
+
});
|
|
82
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
83
|
+
return {
|
|
84
|
+
"data-pixel-component": "MpColorPicker",
|
|
85
|
+
id: getId,
|
|
86
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().root,
|
|
87
|
+
style: {
|
|
88
|
+
width: variant.value === "advance" ? "280px" : "72px"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
const popoverAttrs = (0, import_vue.computed)(() => {
|
|
93
|
+
return {
|
|
94
|
+
id: `popover-${getId}`,
|
|
95
|
+
placement: placement.value,
|
|
96
|
+
defaultIsOpen: isShowPopover.value,
|
|
97
|
+
initialFocusRef: `#input-${getId}`,
|
|
98
|
+
onOpen: handleOpenPopover,
|
|
99
|
+
onClose: handleClosePopover
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
const popoverTriggerAttrs = (0, import_vue.computed)(() => {
|
|
103
|
+
return {
|
|
104
|
+
tabindex: "0",
|
|
105
|
+
class: (0, import_css.cx)((0, import_css.css)({
|
|
106
|
+
boxShadow: isPopoverOpen.value && !isInvalid.value ? "outline" : "none",
|
|
107
|
+
_hover: {
|
|
108
|
+
borderColor: isPopoverOpen.value && !isInvalid.value ? "blue.500 !important" : "gray.400 !important"
|
|
109
|
+
}
|
|
110
|
+
}), (0, import_recipes.colorPickerSlotRecipe)().popoverTrigger),
|
|
111
|
+
style: {
|
|
112
|
+
borderColor: (0, import_tokens.token)(`colors.${borderColor.value}`)
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
const boxColorAttrs = (0, import_vue.computed)(() => {
|
|
117
|
+
return {
|
|
118
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().boxColor,
|
|
119
|
+
style: {
|
|
120
|
+
background: colors.value.hex
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
const inputTriggerAttrs = (0, import_vue.computed)(() => {
|
|
125
|
+
return {
|
|
126
|
+
id: `input-${getId}`,
|
|
127
|
+
type: "text",
|
|
128
|
+
autocomplete: "off",
|
|
129
|
+
variant: "unstyled",
|
|
130
|
+
maxlength: "6",
|
|
131
|
+
value: colorInput.value,
|
|
132
|
+
placeholder: placeholder.value,
|
|
133
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().inputTrigger,
|
|
134
|
+
onInput: handleInputTrigger
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
const iconDropDownAttrs = (0, import_vue.computed)(() => {
|
|
138
|
+
return {
|
|
139
|
+
name: "chevrons-down",
|
|
140
|
+
size: "sm",
|
|
141
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().iconDropdown
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
const popoverContentAttrs = (0, import_vue.computed)(() => {
|
|
145
|
+
return {
|
|
146
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().popoverContent,
|
|
147
|
+
style: {
|
|
148
|
+
width: variant.value === "advance" ? "280px" : "188px"
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
const wrapperAdvanceAttrs = (0, import_vue.computed)(() => {
|
|
153
|
+
return {
|
|
154
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperAdvance
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
const wrapperBasicAttrs = (0, import_vue.computed)(() => {
|
|
158
|
+
return {
|
|
159
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperBasic
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
const wrapperSaturationAttrs = (0, import_vue.computed)(() => {
|
|
163
|
+
return {
|
|
164
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperSaturation
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
const saturationAttrs = (0, import_vue.computed)(() => {
|
|
168
|
+
return {
|
|
169
|
+
value: colors.value,
|
|
170
|
+
onChange: childChange
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
const wrapperHueAttrs = (0, import_vue.computed)(() => {
|
|
174
|
+
return {
|
|
175
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperHue
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
const hueAttrs = (0, import_vue.computed)(() => {
|
|
179
|
+
return {
|
|
180
|
+
value: colors.value,
|
|
181
|
+
onChange: childChange
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
const wrapperInputAttrs = (0, import_vue.computed)(() => {
|
|
185
|
+
return {
|
|
186
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperInput
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
const inputHexAttrs = (0, import_vue.computed)(() => {
|
|
190
|
+
return {
|
|
191
|
+
label: "hex",
|
|
192
|
+
width: "88px",
|
|
193
|
+
value: hex.value,
|
|
194
|
+
onChange: inputChange
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
const inputFullAttrs = (0, import_vue.computed)(() => {
|
|
198
|
+
return {
|
|
199
|
+
label: "hex",
|
|
200
|
+
width: "full",
|
|
201
|
+
value: hex.value,
|
|
202
|
+
onChange: inputChange
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
const inputRedAttrs = (0, import_vue.computed)(() => {
|
|
206
|
+
return {
|
|
207
|
+
label: "r",
|
|
208
|
+
width: "48px",
|
|
209
|
+
value: colors.value.rgba.r,
|
|
210
|
+
onChange: inputChange
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
const inputGreenAttrs = (0, import_vue.computed)(() => {
|
|
214
|
+
return {
|
|
215
|
+
label: "g",
|
|
216
|
+
width: "48px",
|
|
217
|
+
value: colors.value.rgba.g,
|
|
218
|
+
onChange: inputChange
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
const inputBlueAttrs = (0, import_vue.computed)(() => {
|
|
222
|
+
return {
|
|
223
|
+
label: "b",
|
|
224
|
+
width: "48px",
|
|
225
|
+
value: colors.value.rgba.b,
|
|
226
|
+
onChange: inputChange
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
const boxPresetAttrs = (0, import_vue.computed)(() => {
|
|
230
|
+
return {
|
|
231
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().boxPreset
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
const wrapperPresetAttrs = (0, import_vue.computed)(() => {
|
|
235
|
+
return {
|
|
236
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperPreset
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
const wrapperBasicPresetAttrs = (0, import_vue.computed)(() => {
|
|
240
|
+
return {
|
|
241
|
+
class: (0, import_recipes.colorPickerSlotRecipe)().wrapperBasicPreset
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
const presetBoxAttrs = /* @__PURE__ */ __name((item) => {
|
|
245
|
+
return {
|
|
246
|
+
value: item,
|
|
247
|
+
isActive: item.toLowerCase() === colors.value.hex.toLowerCase(),
|
|
248
|
+
onClick: childChange
|
|
249
|
+
};
|
|
250
|
+
}, "presetBoxAttrs");
|
|
251
|
+
function isValidHex(hex2) {
|
|
252
|
+
return (0, import_tinycolor2.default)(hex2).isValid();
|
|
253
|
+
}
|
|
254
|
+
__name(isValidHex, "isValidHex");
|
|
255
|
+
function childChange(data) {
|
|
256
|
+
colorChange(data);
|
|
257
|
+
}
|
|
258
|
+
__name(childChange, "childChange");
|
|
259
|
+
function colorChange(data, oldHue) {
|
|
260
|
+
colors.value = _colorChange(data, oldHue);
|
|
261
|
+
}
|
|
262
|
+
__name(colorChange, "colorChange");
|
|
263
|
+
function _colorChange(data, oldHue) {
|
|
264
|
+
let color;
|
|
265
|
+
if (data && data.hsl) {
|
|
266
|
+
color = (0, import_tinycolor2.default)(data.hsl);
|
|
267
|
+
} else if (data && data.hex && data.hex.length > 0) {
|
|
268
|
+
color = (0, import_tinycolor2.default)(data.hex);
|
|
269
|
+
} else if (data && data.hsv) {
|
|
270
|
+
color = (0, import_tinycolor2.default)(data.hsv);
|
|
271
|
+
} else if (data && data.rgba) {
|
|
272
|
+
color = (0, import_tinycolor2.default)(data.rgba);
|
|
273
|
+
} else if (data && data.rgb) {
|
|
274
|
+
color = (0, import_tinycolor2.default)(data.rgb);
|
|
275
|
+
} else {
|
|
276
|
+
color = (0, import_tinycolor2.default)(data);
|
|
277
|
+
}
|
|
278
|
+
const hsl = color.toHsl();
|
|
279
|
+
const hsv = color.toHsv();
|
|
280
|
+
if (hsl.s === 0) {
|
|
281
|
+
hsv.h = hsl.h = data.h || data.hsl && data.hsl.h || oldHue || 0;
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
hsl,
|
|
285
|
+
hex: color.toHexString().toUpperCase(),
|
|
286
|
+
hex8: color.toHex8String().toUpperCase(),
|
|
287
|
+
rgba: color.toRgb(),
|
|
288
|
+
hsv,
|
|
289
|
+
oldHue: data.h || oldHue || hsl.h,
|
|
290
|
+
source: data.source
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
__name(_colorChange, "_colorChange");
|
|
294
|
+
function inputChange(data) {
|
|
295
|
+
if (!data) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (data.hex) {
|
|
299
|
+
isValidHex(data.hex) && colorChange({
|
|
300
|
+
hex: data.hex,
|
|
301
|
+
source: "hex"
|
|
302
|
+
});
|
|
303
|
+
} else if (data.r || data.g || data.b || data.a) {
|
|
304
|
+
colorChange({
|
|
305
|
+
r: data.r || colors.value.rgba.r,
|
|
306
|
+
g: data.g || colors.value.rgba.g,
|
|
307
|
+
b: data.b || colors.value.rgba.b,
|
|
308
|
+
a: data.a || colors.value.rgba.a,
|
|
309
|
+
source: "rgba"
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
__name(inputChange, "inputChange");
|
|
314
|
+
function handleInputTrigger(e) {
|
|
315
|
+
const target = e.target;
|
|
316
|
+
const value2 = target.value;
|
|
317
|
+
const data = {
|
|
318
|
+
hex: "",
|
|
319
|
+
"#": ""
|
|
320
|
+
};
|
|
321
|
+
data["hex"] = value2;
|
|
322
|
+
if (data.hex === void 0 && data["#"] === void 0) {
|
|
323
|
+
inputChange(data);
|
|
324
|
+
} else if (value2.length > 5) {
|
|
325
|
+
inputChange(data);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
__name(handleInputTrigger, "handleInputTrigger");
|
|
329
|
+
function handleOpenPopover() {
|
|
330
|
+
isPopoverOpen.value = true;
|
|
331
|
+
colorInput.value = hex.value;
|
|
332
|
+
}
|
|
333
|
+
__name(handleOpenPopover, "handleOpenPopover");
|
|
334
|
+
function handleClosePopover() {
|
|
335
|
+
isPopoverOpen.value = false;
|
|
336
|
+
colorInput.value = hex.value;
|
|
337
|
+
}
|
|
338
|
+
__name(handleClosePopover, "handleClosePopover");
|
|
339
|
+
(0, import_vue.watch)(() => value.value, (newValue, oldValue) => {
|
|
340
|
+
if (newValue !== oldValue) {
|
|
341
|
+
val.value = _colorChange(newValue);
|
|
342
|
+
colorInput.value = hex.value;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
(0, import_vue.onMounted)(() => {
|
|
346
|
+
colorInput.value = hex.value;
|
|
347
|
+
});
|
|
348
|
+
return {
|
|
349
|
+
rootAttrs,
|
|
350
|
+
popoverAttrs,
|
|
351
|
+
popoverTriggerAttrs,
|
|
352
|
+
boxColorAttrs,
|
|
353
|
+
inputTriggerAttrs,
|
|
354
|
+
iconDropDownAttrs,
|
|
355
|
+
popoverContentAttrs,
|
|
356
|
+
wrapperAdvanceAttrs,
|
|
357
|
+
wrapperBasicAttrs,
|
|
358
|
+
wrapperSaturationAttrs,
|
|
359
|
+
saturationAttrs,
|
|
360
|
+
wrapperHueAttrs,
|
|
361
|
+
hueAttrs,
|
|
362
|
+
wrapperInputAttrs,
|
|
363
|
+
inputHexAttrs,
|
|
364
|
+
inputRedAttrs,
|
|
365
|
+
inputGreenAttrs,
|
|
366
|
+
inputBlueAttrs,
|
|
367
|
+
inputFullAttrs,
|
|
368
|
+
boxPresetAttrs,
|
|
369
|
+
wrapperPresetAttrs,
|
|
370
|
+
wrapperBasicPresetAttrs,
|
|
371
|
+
presetBoxAttrs
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
__name(useColorPicker, "useColorPicker");
|
|
375
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
376
|
+
0 && (module.exports = {
|
|
377
|
+
useColorPicker
|
|
378
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare const colorPickerProps: {
|
|
4
|
+
id: {
|
|
5
|
+
type: PropType<string>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
title: {
|
|
9
|
+
type: PropType<string>;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
value: {
|
|
13
|
+
type: PropType<string>;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
placeholder: {
|
|
17
|
+
type: PropType<string>;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
variant: {
|
|
21
|
+
type: PropType<"advance" | "basic">;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
placement: {
|
|
25
|
+
type: PropType<Placement>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
preset: {
|
|
29
|
+
type: PropType<string[]>;
|
|
30
|
+
default(): string[];
|
|
31
|
+
};
|
|
32
|
+
isShowPopover: {
|
|
33
|
+
type: PropType<boolean>;
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
isShowSaturation: {
|
|
37
|
+
type: PropType<boolean>;
|
|
38
|
+
default: boolean;
|
|
39
|
+
};
|
|
40
|
+
isShowHue: {
|
|
41
|
+
type: PropType<boolean>;
|
|
42
|
+
default: boolean;
|
|
43
|
+
};
|
|
44
|
+
isShowInput: {
|
|
45
|
+
type: PropType<boolean>;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
isShowPreset: {
|
|
49
|
+
type: PropType<boolean>;
|
|
50
|
+
default: boolean;
|
|
51
|
+
};
|
|
52
|
+
isInvalid: {
|
|
53
|
+
type: PropType<boolean>;
|
|
54
|
+
default: boolean;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
declare const colorPickerEmit: readonly ["change"];
|
|
58
|
+
type ColorPickerProps = ExtractPropTypes<typeof colorPickerProps>;
|
|
59
|
+
type ColorPickerEmit = (event: (typeof colorPickerEmit)[number], value?: unknown, value2?: unknown) => void;
|
|
60
|
+
type Placement = 'top' | 'right' | 'bottom' | 'left' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end';
|
|
61
|
+
|
|
62
|
+
export { ColorPickerEmit, ColorPickerProps, Placement, colorPickerEmit, colorPickerProps };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare const colorPickerProps: {
|
|
4
|
+
id: {
|
|
5
|
+
type: PropType<string>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
title: {
|
|
9
|
+
type: PropType<string>;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
value: {
|
|
13
|
+
type: PropType<string>;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
placeholder: {
|
|
17
|
+
type: PropType<string>;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
variant: {
|
|
21
|
+
type: PropType<"advance" | "basic">;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
placement: {
|
|
25
|
+
type: PropType<Placement>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
preset: {
|
|
29
|
+
type: PropType<string[]>;
|
|
30
|
+
default(): string[];
|
|
31
|
+
};
|
|
32
|
+
isShowPopover: {
|
|
33
|
+
type: PropType<boolean>;
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
isShowSaturation: {
|
|
37
|
+
type: PropType<boolean>;
|
|
38
|
+
default: boolean;
|
|
39
|
+
};
|
|
40
|
+
isShowHue: {
|
|
41
|
+
type: PropType<boolean>;
|
|
42
|
+
default: boolean;
|
|
43
|
+
};
|
|
44
|
+
isShowInput: {
|
|
45
|
+
type: PropType<boolean>;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
isShowPreset: {
|
|
49
|
+
type: PropType<boolean>;
|
|
50
|
+
default: boolean;
|
|
51
|
+
};
|
|
52
|
+
isInvalid: {
|
|
53
|
+
type: PropType<boolean>;
|
|
54
|
+
default: boolean;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
declare const colorPickerEmit: readonly ["change"];
|
|
58
|
+
type ColorPickerProps = ExtractPropTypes<typeof colorPickerProps>;
|
|
59
|
+
type ColorPickerEmit = (event: (typeof colorPickerEmit)[number], value?: unknown, value2?: unknown) => void;
|
|
60
|
+
type Placement = 'top' | 'right' | 'bottom' | 'left' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end';
|
|
61
|
+
|
|
62
|
+
export { ColorPickerEmit, ColorPickerProps, Placement, colorPickerEmit, colorPickerProps };
|