windly-ui 1.0.2 → 1.0.4
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/{ui-library/dist → dist}/module.json +2 -2
- package/dist/module.mjs +33 -0
- package/dist/runtime/components/Accordion.d.vue.ts +39 -0
- package/dist/runtime/components/Accordion.vue +96 -0
- package/dist/runtime/components/Accordion.vue.d.ts +39 -0
- package/dist/runtime/components/Alert.d.vue.ts +83 -0
- package/dist/runtime/components/Alert.vue +78 -0
- package/dist/runtime/components/Alert.vue.d.ts +83 -0
- package/dist/runtime/components/Avatar.d.vue.ts +141 -0
- package/dist/runtime/components/Avatar.vue +72 -0
- package/dist/runtime/components/Avatar.vue.d.ts +141 -0
- package/dist/runtime/components/Badge.d.vue.ts +133 -0
- package/dist/runtime/components/Badge.vue +99 -0
- package/dist/runtime/components/Badge.vue.d.ts +133 -0
- package/dist/runtime/components/Breadcrumbs.d.vue.ts +83 -0
- package/dist/runtime/components/Breadcrumbs.vue +116 -0
- package/dist/runtime/components/Breadcrumbs.vue.d.ts +83 -0
- package/dist/runtime/components/Button.d.vue.ts +208 -0
- package/dist/runtime/components/Button.vue +126 -0
- package/dist/runtime/components/Button.vue.d.ts +208 -0
- package/dist/runtime/components/Card.d.vue.ts +83 -0
- package/dist/runtime/components/Card.vue +71 -0
- package/dist/runtime/components/Card.vue.d.ts +83 -0
- package/dist/runtime/components/Checkbox.d.vue.ts +190 -0
- package/dist/runtime/components/Checkbox.vue +125 -0
- package/dist/runtime/components/Checkbox.vue.d.ts +190 -0
- package/dist/runtime/components/CodeBlock.d.vue.ts +16 -0
- package/dist/runtime/components/CodeBlock.vue +75 -0
- package/dist/runtime/components/CodeBlock.vue.d.ts +16 -0
- package/dist/runtime/components/ColorPicker.d.vue.ts +91 -0
- package/dist/runtime/components/ColorPicker.vue +244 -0
- package/dist/runtime/components/ColorPicker.vue.d.ts +91 -0
- package/dist/runtime/components/Date.d.vue.ts +137 -0
- package/dist/runtime/components/Date.vue +201 -0
- package/dist/runtime/components/Date.vue.d.ts +137 -0
- package/dist/runtime/components/Dialog.d.vue.ts +63 -0
- package/dist/runtime/components/Dialog.vue +85 -0
- package/dist/runtime/components/Dialog.vue.d.ts +63 -0
- package/dist/runtime/components/Divider.d.vue.ts +51 -0
- package/dist/runtime/components/Divider.vue +52 -0
- package/dist/runtime/components/Divider.vue.d.ts +51 -0
- package/dist/runtime/components/Drawer.d.vue.ts +30 -0
- package/dist/runtime/components/Drawer.vue +43 -0
- package/dist/runtime/components/Drawer.vue.d.ts +30 -0
- package/dist/runtime/components/Dropdown.d.vue.ts +34 -0
- package/dist/runtime/components/Dropdown.vue +127 -0
- package/dist/runtime/components/Dropdown.vue.d.ts +34 -0
- package/dist/runtime/components/FileUploader.d.vue.ts +65 -0
- package/dist/runtime/components/FileUploader.vue +358 -0
- package/dist/runtime/components/FileUploader.vue.d.ts +65 -0
- package/dist/runtime/components/Icon.d.vue.ts +41 -0
- package/dist/runtime/components/Icon.vue +66 -0
- package/dist/runtime/components/Icon.vue.d.ts +41 -0
- package/dist/runtime/components/Image.d.vue.ts +77 -0
- package/dist/runtime/components/Image.vue +61 -0
- package/dist/runtime/components/Image.vue.d.ts +77 -0
- package/dist/runtime/components/Input.d.vue.ts +68 -0
- package/dist/runtime/components/Input.vue +241 -0
- package/dist/runtime/components/Input.vue.d.ts +68 -0
- package/dist/runtime/components/Radio.d.vue.ts +41 -0
- package/dist/runtime/components/Radio.vue +222 -0
- package/dist/runtime/components/Radio.vue.d.ts +41 -0
- package/dist/runtime/components/ScrollArea.d.vue.ts +79 -0
- package/dist/runtime/components/ScrollArea.vue +36 -0
- package/dist/runtime/components/ScrollArea.vue.d.ts +79 -0
- package/dist/runtime/components/Select.d.vue.ts +51 -0
- package/dist/runtime/components/Select.vue +271 -0
- package/dist/runtime/components/Select.vue.d.ts +51 -0
- package/dist/runtime/components/Stepper.d.vue.ts +46 -0
- package/dist/runtime/components/Stepper.vue +218 -0
- package/dist/runtime/components/Stepper.vue.d.ts +46 -0
- package/dist/runtime/components/TabPanel.d.vue.ts +17 -0
- package/dist/runtime/components/TabPanel.vue +21 -0
- package/dist/runtime/components/TabPanel.vue.d.ts +17 -0
- package/dist/runtime/components/Table.d.vue.ts +40 -0
- package/dist/runtime/components/Table.vue +92 -0
- package/dist/runtime/components/Table.vue.d.ts +40 -0
- package/dist/runtime/components/Tabs.d.vue.ts +20 -0
- package/dist/runtime/components/Tabs.vue +62 -0
- package/dist/runtime/components/Tabs.vue.d.ts +20 -0
- package/dist/runtime/components/Textarea.d.vue.ts +208 -0
- package/dist/runtime/components/Textarea.vue +185 -0
- package/dist/runtime/components/Textarea.vue.d.ts +208 -0
- package/dist/runtime/components/Toggle.d.vue.ts +36 -0
- package/dist/runtime/components/Toggle.vue +173 -0
- package/dist/runtime/components/Toggle.vue.d.ts +36 -0
- package/dist/runtime/components/Tooltip.d.vue.ts +63 -0
- package/dist/runtime/components/Tooltip.vue +144 -0
- package/dist/runtime/components/Tooltip.vue.d.ts +63 -0
- package/dist/runtime/components/uiProps.d.ts +38 -0
- package/dist/runtime/components/uiProps.js +11 -0
- package/dist/runtime/components/useUiClasses.d.ts +43 -0
- package/dist/runtime/components/useUiClasses.js +124 -0
- package/dist/runtime/composables/plugin.d.ts +2 -0
- package/dist/runtime/composables/plugin.js +3 -0
- package/dist/runtime/tailwind-color.d.ts +2 -0
- package/dist/runtime/tailwind-color.js +5859 -0
- package/package.json +12 -46
- package/LICENSE +0 -21
- package/README.md +0 -232
- package/ui-library/dist/module.mjs +0 -22
- /package/{ui-library/dist → dist}/module.d.mts +0 -0
- /package/{ui-library/dist → dist}/types.d.mts +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, useSlots, computed, isVNode } from "vue";
|
|
3
|
+
defineProps({
|
|
4
|
+
title: { type: String, required: false }
|
|
5
|
+
});
|
|
6
|
+
const activeTab = ref("example");
|
|
7
|
+
const slots = useSlots();
|
|
8
|
+
function stringifyProps(props) {
|
|
9
|
+
if (!props || typeof props !== "object") {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
return Object.entries(props).filter(([key]) => !key.startsWith("on")).map(([key, value]) => {
|
|
13
|
+
if (value === true) return key;
|
|
14
|
+
if (value === false || value == null) return "";
|
|
15
|
+
return `${key}="${String(value)}"`;
|
|
16
|
+
}).filter(Boolean).join(" ");
|
|
17
|
+
}
|
|
18
|
+
function renderVNode(vnode) {
|
|
19
|
+
if (typeof vnode.children === "string") {
|
|
20
|
+
return vnode.children;
|
|
21
|
+
}
|
|
22
|
+
if (vnode.type === /* @__PURE__ */ Symbol.for("v-fgt")) {
|
|
23
|
+
return vnode.children.map(renderVNode).join("");
|
|
24
|
+
}
|
|
25
|
+
if (typeof vnode.type === "object") {
|
|
26
|
+
const typeAny = vnode.type;
|
|
27
|
+
const name = typeAny.__name || typeAny.name || typeAny.displayName || "Component";
|
|
28
|
+
const props = stringifyProps(vnode.props);
|
|
29
|
+
return `<${name}${props ? " " + props : ""} />`;
|
|
30
|
+
}
|
|
31
|
+
if (typeof vnode.type === "string") {
|
|
32
|
+
const children = Array.isArray(vnode.children) ? vnode.children.map((child) => isVNode(child) ? renderVNode(child) : typeof child === "string" ? child : "").join("") : typeof vnode.children === "string" ? vnode.children : "";
|
|
33
|
+
return `<${vnode.type}>${children}</${vnode.type}>`;
|
|
34
|
+
}
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
const slotCode = computed(() => {
|
|
38
|
+
const vnodes = slots.default?.() || [];
|
|
39
|
+
return vnodes.map(renderVNode).join("");
|
|
40
|
+
});
|
|
41
|
+
const buttonIcon = ref("content_copy");
|
|
42
|
+
const copyCode = async () => {
|
|
43
|
+
await navigator.clipboard.writeText(slotCode.value);
|
|
44
|
+
buttonIcon.value = "check";
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
buttonIcon.value = "content_copy";
|
|
47
|
+
}, 2e3);
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<div class="border rounded-lg bg-white overflow-hidden">
|
|
53
|
+
<!-- Header -->
|
|
54
|
+
<div class="flex items-center justify-between px-4 py-2 border-b bg-gray-50">
|
|
55
|
+
<h3 v-if="title" class="font-medium text-gray-700">
|
|
56
|
+
{{ title }}
|
|
57
|
+
</h3>
|
|
58
|
+
|
|
59
|
+
<UIButton flat :icon="buttonIcon" size="sm" class="text-gray-600" @click="copyCode" />
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<!-- Tabs -->
|
|
63
|
+
<UITabs v-model="activeTab">
|
|
64
|
+
<UITabPanel name="example" label="Example">
|
|
65
|
+
<div class="p-4">
|
|
66
|
+
<slot />
|
|
67
|
+
</div>
|
|
68
|
+
</UITabPanel>
|
|
69
|
+
|
|
70
|
+
<UITabPanel name="code" label="Code">
|
|
71
|
+
<pre class="p-4 bg-gray-900 text-gray-100 text-sm overflow-x-auto"><code>{{ slotCode }}</code></pre>
|
|
72
|
+
</UITabPanel>
|
|
73
|
+
</UITabs>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
title?: string;
|
|
3
|
+
};
|
|
4
|
+
declare var __VLS_20: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_20) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
13
|
+
new (): {
|
|
14
|
+
$slots: S;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
modelValue: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
defaultValue: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: string;
|
|
9
|
+
};
|
|
10
|
+
showOpacity: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: boolean;
|
|
13
|
+
};
|
|
14
|
+
disabled: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
readonly: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
flat: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
square: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
bordered: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
borderRadius: {
|
|
35
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
39
|
+
"update:modelValue": (...args: any[]) => void;
|
|
40
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
41
|
+
modelValue: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
defaultValue: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
showOpacity: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
};
|
|
53
|
+
disabled: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
readonly: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
default: boolean;
|
|
60
|
+
};
|
|
61
|
+
flat: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
65
|
+
square: {
|
|
66
|
+
type: BooleanConstructor;
|
|
67
|
+
default: boolean;
|
|
68
|
+
};
|
|
69
|
+
bordered: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: boolean;
|
|
72
|
+
};
|
|
73
|
+
borderRadius: {
|
|
74
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
75
|
+
default: string;
|
|
76
|
+
};
|
|
77
|
+
}>> & Readonly<{
|
|
78
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
79
|
+
}>, {
|
|
80
|
+
modelValue: string;
|
|
81
|
+
disabled: boolean;
|
|
82
|
+
flat: boolean;
|
|
83
|
+
square: boolean;
|
|
84
|
+
bordered: boolean;
|
|
85
|
+
defaultValue: string;
|
|
86
|
+
showOpacity: boolean;
|
|
87
|
+
readonly: boolean;
|
|
88
|
+
borderRadius: string | number;
|
|
89
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
90
|
+
declare const _default: typeof __VLS_export;
|
|
91
|
+
export default _default;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, onMounted, watch } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
modelValue: { type: String, default: "" },
|
|
5
|
+
defaultValue: { type: String, default: "#ff0000" },
|
|
6
|
+
showOpacity: { type: Boolean, default: false },
|
|
7
|
+
disabled: { type: Boolean, default: false },
|
|
8
|
+
readonly: { type: Boolean, default: false },
|
|
9
|
+
flat: { type: Boolean, default: false },
|
|
10
|
+
square: { type: Boolean, default: false },
|
|
11
|
+
bordered: { type: Boolean, default: false },
|
|
12
|
+
borderRadius: { type: [String, Number], default: "12px" }
|
|
13
|
+
});
|
|
14
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
15
|
+
const hue = ref(0);
|
|
16
|
+
const opacity = ref(1);
|
|
17
|
+
const pickedColor = ref({ r: 255, g: 0, b: 0 });
|
|
18
|
+
const saturation = ref(100);
|
|
19
|
+
const lightness = ref(50);
|
|
20
|
+
const canvasRef = ref(null);
|
|
21
|
+
const clamp = (v, min, max) => Math.min(max, Math.max(min, v));
|
|
22
|
+
function rgbToHsl(r, g, b) {
|
|
23
|
+
r /= 255;
|
|
24
|
+
g /= 255;
|
|
25
|
+
b /= 255;
|
|
26
|
+
const max = Math.max(r, g, b);
|
|
27
|
+
const min = Math.min(r, g, b);
|
|
28
|
+
let h = 0, s = 0;
|
|
29
|
+
const l = (max + min) / 2;
|
|
30
|
+
if (max !== min) {
|
|
31
|
+
const d = max - min;
|
|
32
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
33
|
+
switch (max) {
|
|
34
|
+
case r:
|
|
35
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
36
|
+
break;
|
|
37
|
+
case g:
|
|
38
|
+
h = (b - r) / d + 2;
|
|
39
|
+
break;
|
|
40
|
+
case b:
|
|
41
|
+
h = (r - g) / d + 4;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
h /= 6;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
h: Math.round(h * 360),
|
|
48
|
+
s: Math.round(s * 100),
|
|
49
|
+
l: Math.round(l * 100)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function applyColor(color) {
|
|
53
|
+
if (color.startsWith("#")) {
|
|
54
|
+
const hex = color.replace("#", "");
|
|
55
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
56
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
57
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
58
|
+
pickedColor.value = { r, g, b };
|
|
59
|
+
const hsl = rgbToHsl(r, g, b);
|
|
60
|
+
hue.value = hsl.h;
|
|
61
|
+
saturation.value = hsl.s;
|
|
62
|
+
lightness.value = hsl.l;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function drawCanvas() {
|
|
66
|
+
const canvas = canvasRef.value;
|
|
67
|
+
if (!canvas) return;
|
|
68
|
+
const ctx = canvas.getContext("2d");
|
|
69
|
+
const w = canvas.width;
|
|
70
|
+
const h = canvas.height;
|
|
71
|
+
ctx.clearRect(0, 0, w, h);
|
|
72
|
+
ctx.fillStyle = `hsl(${hue.value}, 100%, 50%)`;
|
|
73
|
+
ctx.fillRect(0, 0, w, h);
|
|
74
|
+
const whiteGrad = ctx.createLinearGradient(0, 0, w, 0);
|
|
75
|
+
whiteGrad.addColorStop(0, "#fff");
|
|
76
|
+
whiteGrad.addColorStop(1, "transparent");
|
|
77
|
+
ctx.fillStyle = whiteGrad;
|
|
78
|
+
ctx.fillRect(0, 0, w, h);
|
|
79
|
+
const blackGrad = ctx.createLinearGradient(0, 0, 0, h);
|
|
80
|
+
blackGrad.addColorStop(0, "transparent");
|
|
81
|
+
blackGrad.addColorStop(1, "#000");
|
|
82
|
+
ctx.fillStyle = blackGrad;
|
|
83
|
+
ctx.fillRect(0, 0, w, h);
|
|
84
|
+
}
|
|
85
|
+
function sampleCanvasAt(sat, light) {
|
|
86
|
+
const canvas = canvasRef.value;
|
|
87
|
+
if (!canvas) return;
|
|
88
|
+
const ctx = canvas.getContext("2d");
|
|
89
|
+
if (!ctx) return;
|
|
90
|
+
const w = canvas.width;
|
|
91
|
+
const h = canvas.height;
|
|
92
|
+
const x = clamp(Math.floor(sat / 100 * w), 0, w - 1);
|
|
93
|
+
const y = clamp(Math.floor((100 - light) / 100 * h), 0, h - 1);
|
|
94
|
+
const pixel = ctx.getImageData(x, y, 1, 1).data;
|
|
95
|
+
pickedColor.value = {
|
|
96
|
+
r: pixel[0],
|
|
97
|
+
g: pixel[1],
|
|
98
|
+
b: pixel[2]
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function emitColor() {
|
|
102
|
+
const { r, g, b } = pickedColor.value;
|
|
103
|
+
if (props.showOpacity) {
|
|
104
|
+
emit("update:modelValue", `rgba(${r}, ${g}, ${b}, ${opacity.value})`);
|
|
105
|
+
} else {
|
|
106
|
+
emit("update:modelValue", `rgb(${r}, ${g}, ${b})`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function pickSquare(e) {
|
|
110
|
+
if (props.disabled || props.readonly) return;
|
|
111
|
+
const canvas = canvasRef.value;
|
|
112
|
+
if (!canvas) return;
|
|
113
|
+
const rect = canvas.getBoundingClientRect();
|
|
114
|
+
const x = clamp(e.clientX - rect.left, 0, rect.width);
|
|
115
|
+
const y = clamp(e.clientY - rect.top, 0, rect.height);
|
|
116
|
+
saturation.value = Math.round(x / rect.width * 100);
|
|
117
|
+
lightness.value = Math.round(100 - y / rect.height * 100);
|
|
118
|
+
sampleCanvasAt(saturation.value, lightness.value);
|
|
119
|
+
emitColor();
|
|
120
|
+
}
|
|
121
|
+
function pickHue(e) {
|
|
122
|
+
if (props.disabled || props.readonly) return;
|
|
123
|
+
const rect = e.target.getBoundingClientRect();
|
|
124
|
+
const y = clamp(e.clientY - rect.top, 0, rect.height);
|
|
125
|
+
hue.value = clamp(Math.round(y / rect.height * 360), 0, 359);
|
|
126
|
+
drawCanvas();
|
|
127
|
+
sampleCanvasAt(saturation.value, lightness.value);
|
|
128
|
+
emitColor();
|
|
129
|
+
}
|
|
130
|
+
const squareCursor = computed(() => ({
|
|
131
|
+
left: `${saturation.value}%`,
|
|
132
|
+
top: `${100 - lightness.value}%`
|
|
133
|
+
}));
|
|
134
|
+
const hueCursor = computed(() => ({
|
|
135
|
+
top: `${hue.value / 360 * 100}%`
|
|
136
|
+
}));
|
|
137
|
+
function toHex(v) {
|
|
138
|
+
return v.toString(16).padStart(2, "0");
|
|
139
|
+
}
|
|
140
|
+
const currentHex = computed(() => {
|
|
141
|
+
const { r, g, b } = pickedColor.value;
|
|
142
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
143
|
+
});
|
|
144
|
+
const displayHex = computed(() => {
|
|
145
|
+
if (!props.showOpacity) return currentHex.value;
|
|
146
|
+
const alpha = Math.round(opacity.value * 255).toString(16).padStart(2, "0");
|
|
147
|
+
return currentHex.value + alpha;
|
|
148
|
+
});
|
|
149
|
+
const displayColor = computed(() => {
|
|
150
|
+
const { r, g, b } = pickedColor.value;
|
|
151
|
+
return props.showOpacity ? `rgba(${r}, ${g}, ${b}, ${opacity.value})` : `rgb(${r}, ${g}, ${b})`;
|
|
152
|
+
});
|
|
153
|
+
function copy(text) {
|
|
154
|
+
navigator.clipboard.writeText(text).catch(() => {
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const containerClasses = computed(() => [
|
|
158
|
+
"p-4 w-fit space-y-4",
|
|
159
|
+
props.flat ? "" : "shadow-md bg-white",
|
|
160
|
+
props.bordered ? "border border-gray-300" : ""
|
|
161
|
+
]);
|
|
162
|
+
const containerStyle = computed(() => ({
|
|
163
|
+
borderRadius: props.square ? "0px" : typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius
|
|
164
|
+
}));
|
|
165
|
+
watch(
|
|
166
|
+
() => props.modelValue,
|
|
167
|
+
(val) => {
|
|
168
|
+
if (val) applyColor(val);
|
|
169
|
+
},
|
|
170
|
+
{ immediate: true }
|
|
171
|
+
);
|
|
172
|
+
onMounted(() => {
|
|
173
|
+
const initial = props.modelValue || props.defaultValue;
|
|
174
|
+
if (initial) applyColor(initial);
|
|
175
|
+
drawCanvas();
|
|
176
|
+
sampleCanvasAt(saturation.value, lightness.value);
|
|
177
|
+
});
|
|
178
|
+
</script>
|
|
179
|
+
|
|
180
|
+
<template>
|
|
181
|
+
<div :class="containerClasses" :style="containerStyle" class="p-4 w-fit bg-white rounded-lg space-y-4">
|
|
182
|
+
<div class="flex gap-3">
|
|
183
|
+
<div class="relative">
|
|
184
|
+
<canvas
|
|
185
|
+
ref="canvasRef"
|
|
186
|
+
width="192"
|
|
187
|
+
height="192"
|
|
188
|
+
class="w-48 h-48 rounded cursor-crosshair border"
|
|
189
|
+
@click="pickSquare"
|
|
190
|
+
/>
|
|
191
|
+
<div
|
|
192
|
+
class="absolute w-3 h-3 border-2 border-white rounded-full shadow -translate-x-1/2 -translate-y-1/2 pointer-events-none"
|
|
193
|
+
:style="squareCursor"
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div
|
|
198
|
+
class="relative w-6 h-48 rounded cursor-pointer"
|
|
199
|
+
style="background: linear-gradient(to bottom, red, yellow, lime, cyan, blue, magenta, red)"
|
|
200
|
+
@click="pickHue"
|
|
201
|
+
>
|
|
202
|
+
<div
|
|
203
|
+
class="absolute left-0 w-full h-1 bg-white shadow -translate-y-1/2 pointer-events-none"
|
|
204
|
+
:style="hueCursor"
|
|
205
|
+
/>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<input
|
|
210
|
+
v-if="showOpacity"
|
|
211
|
+
type="range"
|
|
212
|
+
min="0"
|
|
213
|
+
max="1"
|
|
214
|
+
step="0.01"
|
|
215
|
+
v-model="opacity"
|
|
216
|
+
@input="emitColor"
|
|
217
|
+
class="w-full"
|
|
218
|
+
/>
|
|
219
|
+
|
|
220
|
+
<div
|
|
221
|
+
class="h-12 rounded border"
|
|
222
|
+
:style="{ background: displayColor }"
|
|
223
|
+
/>
|
|
224
|
+
|
|
225
|
+
<div class="text-sm space-y-2">
|
|
226
|
+
|
|
227
|
+
<div class="flex justify-between items-center">
|
|
228
|
+
<span>{{ displayHex }}</span>
|
|
229
|
+
<button @click="copy(displayHex)">Copy</button>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<div class="flex justify-between items-center">
|
|
233
|
+
<span>{{ displayColor }}</span>
|
|
234
|
+
<button @click="copy(displayColor)">Copy</button>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
</div>
|
|
240
|
+
</template>
|
|
241
|
+
|
|
242
|
+
<style scoped>
|
|
243
|
+
button{border:1px solid #ccc;border-radius:4px;font-size:12px;padding:2px 6px}
|
|
244
|
+
</style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
modelValue: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
defaultValue: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: string;
|
|
9
|
+
};
|
|
10
|
+
showOpacity: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: boolean;
|
|
13
|
+
};
|
|
14
|
+
disabled: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
readonly: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
flat: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
square: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
bordered: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
borderRadius: {
|
|
35
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
39
|
+
"update:modelValue": (...args: any[]) => void;
|
|
40
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
41
|
+
modelValue: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
defaultValue: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
showOpacity: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
};
|
|
53
|
+
disabled: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
readonly: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
default: boolean;
|
|
60
|
+
};
|
|
61
|
+
flat: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
65
|
+
square: {
|
|
66
|
+
type: BooleanConstructor;
|
|
67
|
+
default: boolean;
|
|
68
|
+
};
|
|
69
|
+
bordered: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: boolean;
|
|
72
|
+
};
|
|
73
|
+
borderRadius: {
|
|
74
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
75
|
+
default: string;
|
|
76
|
+
};
|
|
77
|
+
}>> & Readonly<{
|
|
78
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
79
|
+
}>, {
|
|
80
|
+
modelValue: string;
|
|
81
|
+
disabled: boolean;
|
|
82
|
+
flat: boolean;
|
|
83
|
+
square: boolean;
|
|
84
|
+
bordered: boolean;
|
|
85
|
+
defaultValue: string;
|
|
86
|
+
showOpacity: boolean;
|
|
87
|
+
readonly: boolean;
|
|
88
|
+
borderRadius: string | number;
|
|
89
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
90
|
+
declare const _default: typeof __VLS_export;
|
|
91
|
+
export default _default;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
modelValue: {
|
|
3
|
+
type: (StringConstructor | ArrayConstructor)[];
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
multiDate: BooleanConstructor;
|
|
7
|
+
rangeDate: BooleanConstructor;
|
|
8
|
+
disabledDates: {
|
|
9
|
+
type: () => string[];
|
|
10
|
+
default: () => never[];
|
|
11
|
+
};
|
|
12
|
+
format: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
showHeader: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
default: boolean;
|
|
19
|
+
};
|
|
20
|
+
backgroundColor: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
bordered: {
|
|
25
|
+
type: BooleanConstructor;
|
|
26
|
+
default: boolean;
|
|
27
|
+
};
|
|
28
|
+
borderRadius: {
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
default: string;
|
|
31
|
+
acceptedValues: string[];
|
|
32
|
+
};
|
|
33
|
+
flat: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
color: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
textColor: {
|
|
42
|
+
readonly type: StringConstructor;
|
|
43
|
+
readonly default: "";
|
|
44
|
+
};
|
|
45
|
+
contentClass: {
|
|
46
|
+
readonly type: StringConstructor;
|
|
47
|
+
readonly default: "";
|
|
48
|
+
};
|
|
49
|
+
contentStyle: {
|
|
50
|
+
readonly type: StringConstructor;
|
|
51
|
+
readonly default: "";
|
|
52
|
+
};
|
|
53
|
+
disable: {
|
|
54
|
+
readonly type: BooleanConstructor;
|
|
55
|
+
readonly default: false;
|
|
56
|
+
};
|
|
57
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
58
|
+
"update:modelValue": (...args: any[]) => void;
|
|
59
|
+
change: (...args: any[]) => void;
|
|
60
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
61
|
+
modelValue: {
|
|
62
|
+
type: (StringConstructor | ArrayConstructor)[];
|
|
63
|
+
default: string;
|
|
64
|
+
};
|
|
65
|
+
multiDate: BooleanConstructor;
|
|
66
|
+
rangeDate: BooleanConstructor;
|
|
67
|
+
disabledDates: {
|
|
68
|
+
type: () => string[];
|
|
69
|
+
default: () => never[];
|
|
70
|
+
};
|
|
71
|
+
format: {
|
|
72
|
+
type: StringConstructor;
|
|
73
|
+
default: string;
|
|
74
|
+
};
|
|
75
|
+
showHeader: {
|
|
76
|
+
type: BooleanConstructor;
|
|
77
|
+
default: boolean;
|
|
78
|
+
};
|
|
79
|
+
backgroundColor: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
bordered: {
|
|
84
|
+
type: BooleanConstructor;
|
|
85
|
+
default: boolean;
|
|
86
|
+
};
|
|
87
|
+
borderRadius: {
|
|
88
|
+
type: StringConstructor;
|
|
89
|
+
default: string;
|
|
90
|
+
acceptedValues: string[];
|
|
91
|
+
};
|
|
92
|
+
flat: {
|
|
93
|
+
type: BooleanConstructor;
|
|
94
|
+
default: boolean;
|
|
95
|
+
};
|
|
96
|
+
color: {
|
|
97
|
+
type: StringConstructor;
|
|
98
|
+
default: string;
|
|
99
|
+
};
|
|
100
|
+
textColor: {
|
|
101
|
+
readonly type: StringConstructor;
|
|
102
|
+
readonly default: "";
|
|
103
|
+
};
|
|
104
|
+
contentClass: {
|
|
105
|
+
readonly type: StringConstructor;
|
|
106
|
+
readonly default: "";
|
|
107
|
+
};
|
|
108
|
+
contentStyle: {
|
|
109
|
+
readonly type: StringConstructor;
|
|
110
|
+
readonly default: "";
|
|
111
|
+
};
|
|
112
|
+
disable: {
|
|
113
|
+
readonly type: BooleanConstructor;
|
|
114
|
+
readonly default: false;
|
|
115
|
+
};
|
|
116
|
+
}>> & Readonly<{
|
|
117
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
118
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
119
|
+
}>, {
|
|
120
|
+
modelValue: string | unknown[];
|
|
121
|
+
contentClass: string;
|
|
122
|
+
contentStyle: string;
|
|
123
|
+
textColor: string;
|
|
124
|
+
disable: boolean;
|
|
125
|
+
color: string;
|
|
126
|
+
backgroundColor: string;
|
|
127
|
+
flat: boolean;
|
|
128
|
+
bordered: boolean;
|
|
129
|
+
borderRadius: string;
|
|
130
|
+
multiDate: boolean;
|
|
131
|
+
rangeDate: boolean;
|
|
132
|
+
disabledDates: string[];
|
|
133
|
+
format: string;
|
|
134
|
+
showHeader: boolean;
|
|
135
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
136
|
+
declare const _default: typeof __VLS_export;
|
|
137
|
+
export default _default;
|