@aurouscia/au-color-picker 2.0.0 → 2.2.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Au
3
+ Copyright (c) 2024-2026 Au
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,103 +1,138 @@
1
- # au-color-picker
2
- vue3颜色选择控件,支持鼠标/手指的点击和拖动
3
-
4
- ![au-color-picker预览效果](https://gitee.com/au114514/au-color-picker/raw/main/public/preview.png)
5
-
6
- ## 用法
7
- ```shell
8
- npm i @aurouscia/au-color-picker
9
- ```
10
- ```ts
11
- //main.ts(必须导入样式)
12
- import '@aurouscia/au-color-picker/style.css'
13
-
14
- //xxx.vue
15
- import { AuColorPicker } from '@aurouscia/au-color-picker';
16
- import { AuColorPickerPresetsNested } from '@aurouscia/au-color-picker';
17
- ```
18
-
19
- ### 仅自定义
20
- ```vue
21
- <AuColorPicker
22
- v-model="'绑定颜色值'"
23
- :initial="'初始值(优先级低于v-model)'"
24
- @done="'面板关闭回调'"
25
- ></AuColorPicker>
26
- ```
27
-
28
- ### 预设+自定义
29
- ⚠️注意:“选中的预设”是与“自定义颜色”独立的两个状态
30
- 这使得模型的颜色可以依赖于系统全局配置(预设的颜色)
31
- ```ts
32
- const presets:NamedPreset[] = [
33
- {
34
- name: '水系', //名称不可重复
35
- colorHex: '#c3e5eb'
36
- },
37
- {
38
- name: '绿地',
39
- colorHex: '#ceeda4'
40
- },
41
- ]
42
- ```
43
- ```vue
44
- <AuColorPickerPresetsNested
45
- :presets="'预设列表'"
46
- v-model="'绑定颜色值'"
47
- :initial="'初始值(优先级低于v-model)'"
48
- v-model:model-value-selected-preset="'绑定预设name'"
49
- :initial-selected-preset="'初始选择预设(优先级低于v-model)'"
50
- @done="'面板关闭回调'"
51
- ></AuColorPickerPresetsNested>
52
- ```
53
-
54
- ### 覆盖当前值(旧版,新版直接赋值v-model
55
- ```ts
56
- const picker = ref<InstanceType<typeof AuColorPicker>>()
57
- const pickerNested = ref<InstanceType<typeof AuColorPickerPresetsNested>>()
58
- function enforceToDemo(){
59
- picker.value?.enforceTo('#ff00ff')
60
- pickerNested.value?.enforceCustomValueTo('#ff00ff')
61
- pickerNested.value?.enforcePresetTo('水系')
62
- }
63
- ```
64
-
65
- ### 组件属性定义
66
- ```ts
67
- //位置描述
68
- type Pos = 'left'|'right'|number
69
-
70
- //AuColorPicker的属性
71
- export interface PickerProps{
72
- initial?: string //初始值
73
- entryStyles?: CSSProperties //入口按钮的样式
74
- entryActiveStyles?: CSSProperties //入口按钮的样式(当面板展开)
75
- entryClassName?: string //入口按钮的类名
76
- pos?: Pos //面板位置描述
77
- panelBaseZIndex?:number //面板的zIndex基础值
78
- entryRespondDelay?:number //入口按钮点击后,面板展开的延迟(ms
79
- panelClickStopPropagation?:boolean //面板点击是否阻止冒泡
80
- showPackageName?:boolean //是否显示包名
81
- }
82
-
83
- //AuColorPickerPresetsNested的属性
84
- export interface PickerWithPresetsProps extends PickerProps{
85
- initialSelectedPreset?:string //初始选择预设名称(undefined即为自定义)
86
- presets?: NamedPreset[] //预设列表
87
- posInternal?: Pos //使用自定义时,自定义颜色选择器面板的位置描述
88
- }
89
-
90
- //预设列表项描述
91
- export interface NamedPreset{
92
- colorHex:string,
93
- name:string
94
- }
95
- ```
96
- ## 更新记录
97
- ### 1.0.0
98
- 修改了api
99
- ### 1.1.0
100
- 修复了旧浏览器上失效的问题(消除过新的context.reset函数)
101
-
102
- ## 许可证
1
+ # au-color-picker
2
+ vue3颜色选择控件,支持鼠标/手指的点击和拖动
3
+
4
+ ![au-color-picker预览效果](https://gitee.com/au114514/au-color-picker/raw/main/public/preview.png)
5
+
6
+ ## 用法
7
+ ```shell
8
+ npm i @aurouscia/au-color-picker
9
+ ```
10
+ ```ts
11
+ //main.ts(必须导入样式)
12
+ import '@aurouscia/au-color-picker/style.css'
13
+
14
+ //xxx.vue
15
+ import { AuColorPicker } from '@aurouscia/au-color-picker';
16
+ import { AuColorPickerPresetsNested } from '@aurouscia/au-color-picker';
17
+ ```
18
+
19
+ ### 仅自定义
20
+ ```vue
21
+ <AuColorPicker
22
+ v-model="'绑定颜色值'"
23
+ :initial="'初始值(优先级低于v-model)'"
24
+ @done="'面板关闭回调'"
25
+ ></AuColorPicker>
26
+ ```
27
+
28
+ ### 输入模式持久化
29
+ `AuColorPicker` 支持通过 `localStorage` 记住用户上次选择的输入模式(HEX / RGB / HSV)。
30
+
31
+ - **默认行为**:未指定 `color-mode-storage-key` 时,**不启用持久化**,每次打开默认 HEX 模式(向后兼容)。
32
+ - **启用持久化**:传入字符串指定 `localStorage` 键名,例如 `"acp-color-mode"`。
33
+ - **自定义键名**:适用于同一页面使用多个选择器时避免冲突。
34
+ - **禁用持久化**:传入 `false` 或空字符串可显式禁用(与不传效果相同)。
35
+ - **默认模式**:通过 `color-mode` 属性指定默认输入模式(`'rgb' | 'hsv' | 'hex'`)。当启用持久化且 `localStorage` 中已有值时,优先使用存储值;否则回退到 `color-mode`;未指定 `color-mode` 时回退到 `'hex'`。
36
+
37
+ ```vue
38
+ <!-- 默认:不启用持久化,默认 HEX -->
39
+ <AuColorPicker v-model="color" />
40
+
41
+ <!-- 不启用持久化,但默认 RGB -->
42
+ <AuColorPicker v-model="color" color-mode="rgb" />
43
+
44
+ <!-- 启用持久化(使用推荐键名) -->
45
+ <AuColorPicker v-model="color" color-mode-storage-key="acp-color-mode" />
46
+
47
+ <!-- 启用持久化 + 指定默认模式 -->
48
+ <AuColorPicker v-model="color" color-mode-storage-key="acp-color-mode" color-mode="hsv" />
49
+
50
+ <!-- 自定义键名 -->
51
+ <AuColorPicker v-model="color" color-mode-storage-key="my-app-color-mode" />
52
+
53
+ <!-- 显式禁用持久化(与不传效果相同) -->
54
+ <AuColorPicker v-model="color" :color-mode-storage-key="false" />
55
+ ```
56
+
57
+ ### 预设+自定义
58
+ ⚠️注意:“选中的预设”是与“自定义颜色”独立的两个状态
59
+ 这使得模型的颜色可以依赖于系统全局配置(预设的颜色)
60
+ ```ts
61
+ const presets:NamedPreset[] = [
62
+ {
63
+ name: '水系', //名称不可重复
64
+ colorHex: '#c3e5eb'
65
+ },
66
+ {
67
+ name: '绿地',
68
+ colorHex: '#ceeda4'
69
+ },
70
+ ]
71
+ ```
72
+ ```vue
73
+ <AuColorPickerPresetsNested
74
+ :presets="'预设列表'"
75
+ v-model="'绑定颜色值'"
76
+ :initial="'初始值(优先级低于v-model)'"
77
+ v-model:model-value-selected-preset="'绑定预设name'"
78
+ :initial-selected-preset="'初始选择预设(优先级低于v-model'"
79
+ @done="'面板关闭回调'"
80
+ ></AuColorPickerPresetsNested>
81
+ ```
82
+
83
+ ### 覆盖当前值(旧版,新版直接赋值v-model)
84
+ ```ts
85
+ const picker = ref<InstanceType<typeof AuColorPicker>>()
86
+ const pickerNested = ref<InstanceType<typeof AuColorPickerPresetsNested>>()
87
+ function enforceToDemo(){
88
+ picker.value?.enforceTo('#ff00ff')
89
+ pickerNested.value?.enforceCustomValueTo('#ff00ff')
90
+ pickerNested.value?.enforcePresetTo('水系')
91
+ }
92
+ ```
93
+
94
+ ### 组件属性定义
95
+ ```ts
96
+ //位置描述
97
+ type Pos = 'left'|'right'|number
98
+
99
+ //AuColorPicker的属性
100
+ export interface PickerProps{
101
+ initial?: string //初始值
102
+ entryStyles?: CSSProperties //入口按钮的样式
103
+ entryActiveStyles?: CSSProperties //入口按钮的样式(当面板展开)
104
+ entryClassName?: string //入口按钮的类名
105
+ pos?: Pos //面板位置描述
106
+ panelBaseZIndex?:number //面板的zIndex基础值
107
+ entryRespondDelay?:number //入口按钮点击后,面板展开的延迟(ms)
108
+ panelClickStopPropagation?:boolean //面板点击是否阻止冒泡
109
+ showPackageName?:boolean //是否显示包名
110
+ colorModeStorageKey?: string | false //输入模式持久化的 localStorage 键名,传 false 或空字符串可禁用
111
+ colorMode?: 'rgb' | 'hsv' | 'hex' //输入模式的默认值,storage 中无值时回退到此,默认 'hex'
112
+ }
113
+
114
+ //AuColorPickerPresetsNested的属性
115
+ export interface PickerWithPresetsProps extends PickerProps{
116
+ initialSelectedPreset?:string //初始选择预设名称(undefined即为自定义)
117
+ presets?: NamedPreset[] //预设列表
118
+ posInternal?: Pos //使用自定义时,自定义颜色选择器面板的位置描述
119
+ }
120
+
121
+ //预设列表项描述
122
+ export interface NamedPreset{
123
+ colorHex:string,
124
+ name:string
125
+ }
126
+ ```
127
+ ## 更新记录
128
+ ### 2.2.0
129
+ 新增 Tab 键输入框循环聚焦功能。面板打开时按 Tab 键可在输入框间循环切换,并自动选中已有值。
130
+ ### 2.1.0
131
+ 新增 `color-mode-storage-key` 和 `color-mode` 属性,支持通过 `localStorage` 持久化用户选择的输入模式(HEX / RGB / HSV)。默认不启用持久化,向后兼容。
132
+ ### 2.0.0
133
+ 将 vue 改为 peerDependency(正确做法)
134
+ ### 1.1.0
135
+ 修复了旧浏览器上失效的问题(消除过新的context.reset函数)
136
+
137
+ ## 许可证
103
138
  MIT
@@ -1 +1 @@
1
- .acpRingBody[data-v-2acdc0fb]{position:relative}canvas[data-v-2acdc0fb]{position:absolute;inset:0;width:100%;height:100%}[data-v-1feea9d7]{margin:0;padding:0}.acpSep[data-v-1feea9d7]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-1feea9d7]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-1feea9d7]{display:flex;justify-content:center;align-items:center;margin:8px;-webkit-user-select:none;user-select:none}.acpDoneBtn button[data-v-1feea9d7]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-1feea9d7]:hover{color:#000}.acpEntry[data-v-1feea9d7]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-1feea9d7]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-1feea9d7]{position:relative;width:fit-content}.acp label[data-v-1feea9d7]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-1feea9d7]{cursor:pointer}.acpPackageName[data-v-1feea9d7]{position:absolute;left:2px;bottom:3px;font-size:8px;color:#ccc;text-align:right;cursor:pointer;-webkit-user-select:none;user-select:none}.acpParams[data-v-1feea9d7]{display:flex;justify-content:space-between;align-items:center;padding:5px}.acpParams select[data-v-1feea9d7],.acpParams input[data-v-1feea9d7]{margin:0;padding:2px;display:block;font-size:16px;box-sizing:border-box;height:24px;line-height:24px}.acpParams select[data-v-1feea9d7]{-webkit-user-select:none;user-select:none}.acpParams input[data-v-1feea9d7]{text-align:center}.acpParams .acpSingleInput input[data-v-1feea9d7]{width:120px}.acpParams .acpTripleInputs[data-v-1feea9d7]{display:flex;justify-content:space-around}.acpParams .acpTripleInputs input[data-v-1feea9d7]{width:40px}[data-v-9fbc3723]{margin:0;padding:0}.acpSep[data-v-9fbc3723]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-9fbc3723]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-9fbc3723]{display:flex;justify-content:center;align-items:center;margin:8px;-webkit-user-select:none;user-select:none}.acpDoneBtn button[data-v-9fbc3723]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-9fbc3723]:hover{color:#000}.acpEntry[data-v-9fbc3723]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-9fbc3723]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-9fbc3723]{position:relative;width:fit-content}.acp label[data-v-9fbc3723]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-9fbc3723]{cursor:pointer}.acpNamedPresets[data-v-9fbc3723]{margin:5px;display:flex;flex-direction:column;gap:4px}.acpNamedPresets[data-v-9fbc3723]>*{display:flex;justify-content:flex-start;align-items:center;gap:5px}.acpNamedPresets>* .acpPresetName[data-v-9fbc3723]{color:#666}.acpNamedPresets>* .acpPresetName[data-v-9fbc3723]:hover{color:#000}
1
+ .acpRingBody[data-v-a0477470]{position:relative}canvas[data-v-a0477470]{position:absolute;inset:0;width:100%;height:100%}[data-v-0a352b8c]{margin:0;padding:0}.acpSep[data-v-0a352b8c]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-0a352b8c]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-0a352b8c]{display:flex;justify-content:center;align-items:center;margin:8px;-webkit-user-select:none;user-select:none}.acpDoneBtn button[data-v-0a352b8c]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-0a352b8c]:hover{color:#000}.acpEntry[data-v-0a352b8c]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-0a352b8c]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-0a352b8c]{position:relative;width:fit-content}.acp label[data-v-0a352b8c]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-0a352b8c]{cursor:pointer}.acpPackageName[data-v-0a352b8c]{position:absolute;left:2px;bottom:3px;font-size:8px;color:#ccc;text-align:right;cursor:pointer;-webkit-user-select:none;user-select:none}.acpParams[data-v-0a352b8c]{display:flex;justify-content:space-between;align-items:center;padding:5px}.acpParams select[data-v-0a352b8c],.acpParams input[data-v-0a352b8c]{margin:0;padding:2px;display:block;font-size:16px;box-sizing:border-box;height:24px;line-height:24px}.acpParams select[data-v-0a352b8c]{-webkit-user-select:none;user-select:none}.acpParams input[data-v-0a352b8c]{text-align:center}.acpParams .acpSingleInput input[data-v-0a352b8c]{width:120px}.acpParams .acpTripleInputs[data-v-0a352b8c]{display:flex;justify-content:space-around}.acpParams .acpTripleInputs input[data-v-0a352b8c]{width:40px}[data-v-9fbc3723]{margin:0;padding:0}.acpSep[data-v-9fbc3723]{height:2px;border-radius:100px;flex-grow:0;flex-shrink:0;background-color:#ddd}.acpPresetBody[data-v-9fbc3723]{width:25px;height:25px;border-radius:1000px;cursor:pointer}.acpDoneBtn[data-v-9fbc3723]{display:flex;justify-content:center;align-items:center;margin:8px;-webkit-user-select:none;user-select:none}.acpDoneBtn button[data-v-9fbc3723]{background:none;border:none;font-weight:700;color:gray;font-size:16px;cursor:pointer}.acpDoneBtn button[data-v-9fbc3723]:hover{color:#000}.acpEntry[data-v-9fbc3723]{width:30px;height:30px;cursor:pointer;border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff}.acpPanel[data-v-9fbc3723]{border-radius:5px;box-shadow:0 0 5px #000;background-color:#fff;margin-top:3px;position:absolute}.acp[data-v-9fbc3723]{position:relative;width:fit-content}.acp label[data-v-9fbc3723]{-webkit-user-select:none;user-select:none;white-space:nowrap;cursor:pointer}.acp input[type=radio][data-v-9fbc3723]{cursor:pointer}.acpNamedPresets[data-v-9fbc3723]{margin:5px;display:flex;flex-direction:column;gap:4px}.acpNamedPresets[data-v-9fbc3723]>*{display:flex;justify-content:flex-start;align-items:center;gap:5px}.acpNamedPresets>* .acpPresetName[data-v-9fbc3723]{color:#666}.acpNamedPresets>* .acpPresetName[data-v-9fbc3723]:hover{color:#000}
@@ -1,204 +1,204 @@
1
- import { defineComponent as ne, ref as I, onMounted as xe, onUnmounted as he, openBlock as T, createElementBlock as N, isRef as Pe, normalizeStyle as j, createElementVNode as d, computed as K, onBeforeMount as ce, watch as W, unref as h, normalizeClass as ke, createVNode as de, withDirectives as Q, vModelSelect as Ce, createCommentVNode as ee, vModelRadio as le, Fragment as Se, renderList as we, toDisplayString as Ie } from "vue";
2
- import M from "color-convert";
3
- function be(l, P) {
4
- const m = l.x - P.x, t = l.y - P.y;
5
- return m ** 2 + t ** 2;
1
+ import { defineComponent as ae, ref as S, onMounted as ke, onUnmounted as pe, openBlock as R, createElementBlock as b, isRef as Pe, normalizeStyle as X, createElementVNode as f, computed as J, watch as A, onBeforeMount as ge, useTemplateRef as q, nextTick as Se, unref as m, normalizeClass as Ie, createVNode as ye, withDirectives as oe, vModelSelect as Ce, createCommentVNode as le, vModelRadio as ue, Fragment as we, renderList as Re, toDisplayString as be } from "vue";
2
+ import V from "color-convert";
3
+ function Be(s, h) {
4
+ const v = s.x - h.x, o = s.y - h.y;
5
+ return v ** 2 + o ** 2;
6
6
  }
7
- function Be(l, P) {
8
- const m = l.x - P.x, t = l.y - P.y;
9
- return Math.atan2(t, m);
7
+ function Ve(s, h) {
8
+ const v = s.x - h.x, o = s.y - h.y;
9
+ return Math.atan2(o, v);
10
10
  }
11
- const B = 400, U = 400, J = 200, Ve = 200, se = 190, ae = 150, z = 200, ie = 16, re = 3, Re = /* @__PURE__ */ ne({
11
+ const w = 400, L = 400, ne = 200, Me = 200, ie = 190, ce = 150, W = 200, fe = 16, de = 3, Te = /* @__PURE__ */ ae({
12
12
  __name: "AuColorPickerRing",
13
13
  props: {
14
14
  initialHex: {}
15
15
  },
16
16
  emits: ["changed"],
17
- setup(l, { expose: P, emit: m }) {
18
- const t = I(), y = I();
19
- let u, c;
20
- const C = { x: 199, y: 199 }, A = (se + ae) / 2, E = se ** 2, L = ae ** 2, V = (B - z) / 2, D = V + z, k = I(0), S = I(100), w = I(100), R = l;
21
- let s;
22
- function a() {
23
- createImageBitmap(s).then((n) => {
24
- u.drawImage(n, 0, 0);
17
+ setup(s, { expose: h, emit: v }) {
18
+ const o = S(), p = S();
19
+ let i, c;
20
+ const x = { x: 199, y: 199 }, M = (ie + ce) / 2, T = ie ** 2, K = ce ** 2, I = (w - W) / 2, U = I + W, k = S(0), y = S(100), P = S(100), C = s;
21
+ let a;
22
+ function r() {
23
+ createImageBitmap(a).then((n) => {
24
+ i.drawImage(n, 0, 0);
25
25
  });
26
26
  }
27
- function v() {
28
- const n = t.value?.getContext("2d"), i = y.value?.getContext("2d");
29
- if (!n || !i)
27
+ function d() {
28
+ const n = o.value?.getContext("2d"), e = p.value?.getContext("2d");
29
+ if (!n || !e)
30
30
  throw Error("canvas context getting error");
31
- if (R.initialHex) {
32
- const r = M.hex.hsv(R.initialHex);
33
- k.value = r[0], S.value = r[1], w.value = r[2];
31
+ if (C.initialHex) {
32
+ const t = V.hex.hsv(C.initialHex);
33
+ k.value = t[0], y.value = t[1], P.value = t[2];
34
34
  }
35
- u = n, c = i, s = u.createImageData(B, U), H(), e(), G(), a();
35
+ i = n, c = e, a = i.createImageData(w, L), N(), D(), Y(), r();
36
36
  }
37
- function H() {
38
- for (let n = 0; n < B; n++)
39
- for (let i = 0; i < U; i++) {
40
- const r = { x: n, y: i };
41
- if (g(r)) {
42
- const p = r.y * B * 4 + r.x * 4, b = F(r), q = M.hsv.rgb([b, 100, 100]);
43
- s.data[p] = q[0], s.data[p + 1] = q[1], s.data[p + 2] = q[2], s.data[p + 3] = 255;
37
+ function N() {
38
+ for (let n = 0; n < w; n++)
39
+ for (let e = 0; e < L; e++) {
40
+ const t = { x: n, y: e };
41
+ if (Q(t)) {
42
+ const u = t.y * w * 4 + t.x * 4, l = _(t), g = V.hsv.rgb([l, 100, 100]);
43
+ a.data[u] = g[0], a.data[u + 1] = g[1], a.data[u + 2] = g[2], a.data[u + 3] = 255;
44
44
  }
45
45
  }
46
46
  }
47
- function F(n) {
48
- return 360 * ((Be(n, C) + Math.PI) / (2 * Math.PI));
47
+ function _(n) {
48
+ return 360 * ((Ve(n, x) + Math.PI) / (2 * Math.PI));
49
49
  }
50
- function g(n) {
51
- const i = be(C, n);
52
- return i > L && i < E;
50
+ function Q(n) {
51
+ const e = Be(x, n);
52
+ return e > K && e < T;
53
53
  }
54
- function e() {
55
- for (let n = 0; n < B; n++)
56
- for (let i = 0; i < U; i++) {
57
- const r = { x: n, y: i };
58
- if ($(r)) {
59
- const p = r.y * B * 4 + r.x * 4, { s: b, v: q } = o(r), _ = M.hsv.rgb([k.value, b, q]);
60
- s.data[p] = _[0], s.data[p + 1] = _[1], s.data[p + 2] = _[2], s.data[p + 3] = 255;
54
+ function D() {
55
+ for (let n = 0; n < w; n++)
56
+ for (let e = 0; e < L; e++) {
57
+ const t = { x: n, y: e };
58
+ if (z(t)) {
59
+ const u = t.y * w * 4 + t.x * 4, { s: l, v: g } = Z(t), F = V.hsv.rgb([k.value, l, g]);
60
+ a.data[u] = F[0], a.data[u + 1] = F[1], a.data[u + 2] = F[2], a.data[u + 3] = 255;
61
61
  }
62
62
  }
63
63
  }
64
- function o(n) {
65
- const i = n.x - V, r = n.y - V;
66
- let p = i / z, b = 1 - r / z;
67
- return p > 1 ? p = 1 : p < 0 && (p = 0), b > 1 ? b = 1 : b < 0 && (b = 0), { s: 100 * p, v: 100 * b };
64
+ function Z(n) {
65
+ const e = n.x - I, t = n.y - I;
66
+ let u = e / W, l = 1 - t / W;
67
+ return u > 1 ? u = 1 : u < 0 && (u = 0), l > 1 ? l = 1 : l < 0 && (l = 0), { s: 100 * u, v: 100 * l };
68
68
  }
69
- function $(n) {
70
- return !(n.x < V || n.x > D || n.y < V || n.y > D);
69
+ function z(n) {
70
+ return !(n.x < I || n.x > U || n.y < I || n.y > U);
71
71
  }
72
- let f = !1, x = "none", X = I(!1);
73
- function Y(n, i) {
74
- if (f || i && !X.value)
72
+ let O = !1, B = "none", H = S(!1);
73
+ function $(n, e) {
74
+ if (O || e && !H.value)
75
75
  return;
76
- f = !0;
77
- const r = pe(n);
78
- if (x === "none" && ($(r) ? x = "square" : g(r) && (x = "ring")), x === "ring" && (n.preventDefault(), k.value = F(r), e(), a()), x === "square") {
76
+ O = !0;
77
+ const t = ee(n);
78
+ if (B === "none" && (z(t) ? B = "square" : Q(t) && (B = "ring")), B === "ring" && (n.preventDefault(), k.value = _(t), D(), r()), B === "square") {
79
79
  n.preventDefault();
80
- const p = o(r);
81
- S.value = p.s, w.value = p.v;
80
+ const u = Z(t);
81
+ y.value = u.s, P.value = u.v;
82
82
  }
83
- x !== "none" && G(!0), f = !1;
83
+ B !== "none" && Y(!0), O = !1;
84
84
  }
85
- function Z() {
86
- x = "none", X.value = !1;
85
+ function E() {
86
+ B = "none", H.value = !1;
87
87
  }
88
- function pe(n) {
89
- let i, r;
90
- if (!t.value)
88
+ function ee(n) {
89
+ let e, t;
90
+ if (!o.value)
91
91
  return { x: -1, y: -1 };
92
92
  if ("touches" in n) {
93
- const p = t.value.getBoundingClientRect();
94
- i = n.touches[0].clientX - p.left, r = n.touches[0].clientY - p.top;
93
+ const u = o.value.getBoundingClientRect();
94
+ e = n.touches[0].clientX - u.left, t = n.touches[0].clientY - u.top;
95
95
  } else
96
- i = n.offsetX, r = n.offsetY;
97
- return i = i * B / J, r = r * B / J, { x: i, y: r };
96
+ e = n.offsetX, t = n.offsetY;
97
+ return e = e * w / ne, t = t * w / ne, { x: e, y: t };
98
98
  }
99
- function G(n) {
99
+ function Y(n) {
100
100
  if (n) {
101
- const ge = M.hsv.hex([k.value, S.value, w.value]);
102
- ye("changed", ge);
101
+ const xe = V.hsv.hex([k.value, y.value, P.value]);
102
+ G("changed", xe);
103
103
  }
104
- const i = (k.value / 360 * 2 + 1) * Math.PI, r = Math.cos(i) * A + B / 2, p = Math.sin(i) * A + U / 2, b = S.value / 100 * z + V, q = (1 - w.value / 100) * z + V;
105
- c.clearRect(0, 0, B, U), c.lineWidth = 4, c.strokeStyle = "black", c.fillStyle = "black", c.beginPath(), c.arc(r, p, ie - 2, 0, 2 * Math.PI), c.stroke(), c.beginPath(), c.arc(r, p, re, 0, 2 * Math.PI), c.fill();
106
- const _ = w.value > 50 ? "black" : "#ddd";
107
- c.strokeStyle = _, c.fillStyle = _, c.beginPath(), c.arc(b, q, ie - 2, 0, 2 * Math.PI), c.stroke(), c.beginPath(), c.arc(b, q, re, 0, 2 * Math.PI), c.fill();
104
+ const e = (k.value / 360 * 2 + 1) * Math.PI, t = Math.cos(e) * M + w / 2, u = Math.sin(e) * M + L / 2, l = y.value / 100 * W + I, g = (1 - P.value / 100) * W + I;
105
+ c.clearRect(0, 0, w, L), c.lineWidth = 4, c.strokeStyle = "black", c.fillStyle = "black", c.beginPath(), c.arc(t, u, fe - 2, 0, 2 * Math.PI), c.stroke(), c.beginPath(), c.arc(t, u, de, 0, 2 * Math.PI), c.fill();
106
+ const F = P.value > 50 ? "black" : "#ddd";
107
+ c.strokeStyle = F, c.fillStyle = F, c.beginPath(), c.arc(l, g, fe - 2, 0, 2 * Math.PI), c.stroke(), c.beginPath(), c.arc(l, g, de, 0, 2 * Math.PI), c.fill();
108
108
  }
109
- function me(n) {
110
- const i = M.hex.hsv(n);
111
- k.value = i[0], S.value = i[1], w.value = i[2], e(), a(), G();
109
+ function te(n) {
110
+ const e = V.hex.hsv(n);
111
+ k.value = e[0], y.value = e[1], P.value = e[2], D(), r(), Y();
112
112
  }
113
- const ye = m;
114
- return P({ enforceTo: me }), xe(() => {
115
- v(), window.addEventListener("touchend", Z), window.addEventListener("mouseup", Z);
116
- }), he(() => {
117
- window.removeEventListener("touchend", Z), window.removeEventListener("mouseup", Z);
118
- }), (n, i) => (T(), N("div", {
113
+ const G = v;
114
+ return h({ enforceTo: te }), ke(() => {
115
+ d(), window.addEventListener("touchend", E), window.addEventListener("mouseup", E);
116
+ }), pe(() => {
117
+ window.removeEventListener("touchend", E), window.removeEventListener("mouseup", E);
118
+ }), (n, e) => (R(), b("div", {
119
119
  class: "acpRingBody",
120
- style: j({ width: J + "px", height: Ve + "px" }),
121
- onTouchstart: Y,
122
- onTouchmove: Y,
123
- onTouchend: Z,
124
- onMousemove: i[0] || (i[0] = (r) => Y(r, !0)),
125
- onMousedown: i[1] || (i[1] = (r) => {
126
- Y(r), Pe(X) ? X.value = !0 : X = !0;
120
+ style: X({ width: ne + "px", height: Me + "px" }),
121
+ onTouchstart: $,
122
+ onTouchmove: $,
123
+ onTouchend: E,
124
+ onMousemove: e[0] || (e[0] = (t) => $(t, !0)),
125
+ onMousedown: e[1] || (e[1] = (t) => {
126
+ $(t), Pe(H) ? H.value = !0 : H = !0;
127
127
  })
128
128
  }, [
129
- d("canvas", {
130
- width: B,
131
- height: U,
129
+ f("canvas", {
130
+ width: w,
131
+ height: L,
132
132
  ref_key: "cvs",
133
- ref: t
133
+ ref: o
134
134
  }, null, 512),
135
- d("canvas", {
136
- width: B,
137
- height: U,
135
+ f("canvas", {
136
+ width: w,
137
+ height: L,
138
138
  ref_key: "cursorCvs",
139
- ref: y
139
+ ref: p
140
140
  }, null, 512)
141
141
  ], 36));
142
142
  }
143
- }), oe = (l, P) => {
144
- const m = l.__vccOpts || l;
145
- for (const [t, y] of P)
146
- m[t] = y;
147
- return m;
148
- }, Te = /* @__PURE__ */ oe(Re, [["__scopeId", "data-v-2acdc0fb"]]);
149
- function te(l) {
150
- return /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i.test(l);
143
+ }), re = (s, h) => {
144
+ const v = s.__vccOpts || s;
145
+ for (const [o, p] of h)
146
+ v[o] = p;
147
+ return v;
148
+ }, Ne = /* @__PURE__ */ re(Te, [["__scopeId", "data-v-a0477470"]]);
149
+ function se(s) {
150
+ return /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i.test(s);
151
151
  }
152
- function ve(l, P) {
153
- const m = I(!1), t = K(() => {
154
- let C = {};
155
- return m.value || (C.boxShadow = "none"), l.entryStyles && Object.assign(C, l.entryStyles), m.value && (C.transition = "0s", Object.assign(C, l.entryActiveStyles)), C.backgroundColor = P.value, C;
152
+ function me(s, h) {
153
+ const v = S(!1), o = J(() => {
154
+ let x = {};
155
+ return v.value || (x.boxShadow = "none"), s.entryStyles && Object.assign(x, s.entryStyles), v.value && (x.transition = "0s", Object.assign(x, s.entryActiveStyles)), x.backgroundColor = h.value, x;
156
156
  });
157
- function y() {
158
- m.value = !1;
157
+ function p() {
158
+ v.value = !1;
159
159
  }
160
- let u = 0;
160
+ let i = 0;
161
161
  function c() {
162
- if (l.entryRespondDelay && (window.clearTimeout(u), !m.value)) {
163
- u = window.setTimeout(() => {
164
- m.value = !0;
165
- }, l.entryRespondDelay);
162
+ if (s.entryRespondDelay && (window.clearTimeout(i), !v.value)) {
163
+ i = window.setTimeout(() => {
164
+ v.value = !0;
165
+ }, s.entryRespondDelay);
166
166
  return;
167
167
  }
168
- m.value = !m.value;
168
+ v.value = !v.value;
169
169
  }
170
- return { panelShow: m, closePanel: y, togglePanel: c, entryStylesActual: t };
170
+ return { panelShow: v, closePanel: p, togglePanel: c, entryStylesActual: o };
171
171
  }
172
- function ue() {
172
+ function ve() {
173
173
  window.alert("https://www.npmjs.com/package/@aurouscia/au-color-picker");
174
174
  }
175
- function O(l) {
176
- return l.startsWith("#") ? l.toUpperCase() : "#" + l.toUpperCase();
175
+ function j(s) {
176
+ return s.startsWith("#") ? s.toUpperCase() : "#" + s.toUpperCase();
177
177
  }
178
- function fe(l) {
178
+ function he(s) {
179
179
  return {
180
- panelStyles: K(() => {
181
- const m = l.panelBaseZIndex;
182
- let t, y;
183
- const u = l.pos;
184
- return typeof u == "number" ? t = u + "px" : u == "left" ? y = "0px" : t = "0px", {
185
- zIndex: (m || 0) + 100,
186
- left: t,
187
- right: y
180
+ panelStyles: J(() => {
181
+ const v = s.panelBaseZIndex;
182
+ let o, p;
183
+ const i = s.pos;
184
+ return typeof i == "number" ? o = i + "px" : i == "left" ? p = "0px" : o = "0px", {
185
+ zIndex: (v || 0) + 100,
186
+ left: o,
187
+ right: p
188
188
  };
189
189
  })
190
190
  };
191
191
  }
192
- const Ne = { class: "acp" }, De = { class: "acpRing" }, He = { class: "acpParams" }, Me = {
192
+ const De = { class: "acp" }, He = { class: "acpRing" }, Ee = { class: "acpParams" }, Ae = {
193
193
  key: 0,
194
194
  class: "acpSingleInput"
195
- }, Ae = ["value"], Ee = {
195
+ }, _e = ["value"], $e = {
196
196
  key: 1,
197
197
  class: "acpTripleInputs"
198
- }, $e = ["value"], qe = ["value"], Ue = ["value"], Le = {
198
+ }, qe = ["value"], Le = ["value"], Ke = ["value"], Ue = {
199
199
  key: 2,
200
200
  class: "acpTripleInputs"
201
- }, _e = ["value"], ze = ["value"], Oe = ["value"], We = { class: "acpDoneBtn" }, je = /* @__PURE__ */ ne({
201
+ }, ze = ["value"], Oe = ["value"], Fe = ["value"], We = { class: "acpDoneBtn" }, je = /* @__PURE__ */ ae({
202
202
  __name: "AuColorPicker",
203
203
  props: {
204
204
  modelValue: {},
@@ -210,163 +210,221 @@ const Ne = { class: "acp" }, De = { class: "acpRing" }, He = { class: "acpParams
210
210
  panelBaseZIndex: {},
211
211
  entryRespondDelay: {},
212
212
  panelClickStopPropagation: { type: Boolean },
213
- showPackageName: { type: Boolean }
213
+ showPackageName: { type: Boolean },
214
+ colorModeStorageKey: { type: [String, Boolean] },
215
+ colorMode: {}
214
216
  },
215
217
  emits: ["done", "update:modelValue"],
216
- setup(l, { expose: P, emit: m }) {
217
- const t = l, y = I(), u = I("#ff0000"), { panelShow: c, closePanel: C, togglePanel: A, entryStylesActual: E } = ve(t, u), { panelStyles: L } = fe(t);
218
- function V(g) {
219
- u.value = O(g), a();
218
+ setup(s, { expose: h, emit: v }) {
219
+ const o = s, p = S(), i = S("#ff0000"), { panelShow: c, closePanel: x, togglePanel: M, entryStylesActual: T } = me(o, i), { panelStyles: K } = he(o);
220
+ function I() {
221
+ return o.colorModeStorageKey === !1 || o.colorModeStorageKey === "" ? !1 : o.colorModeStorageKey || !1;
222
+ }
223
+ function U() {
224
+ const n = I();
225
+ if (!n) return null;
226
+ try {
227
+ const e = localStorage.getItem(n);
228
+ if (e === "rgb" || e === "hsv" || e === "hex")
229
+ return e;
230
+ } catch {
231
+ }
232
+ return null;
233
+ }
234
+ function k(n) {
235
+ const e = I();
236
+ if (e)
237
+ try {
238
+ localStorage.setItem(e, n);
239
+ } catch {
240
+ }
241
+ }
242
+ const y = S(U() || o.colorMode || "hex");
243
+ A(y, k);
244
+ function P(n) {
245
+ i.value = j(n), _();
220
246
  }
221
- const D = I("hex"), k = K(() => M.hex.rgb(u.value)), S = K(() => M.hex.hsv(u.value));
222
- function w(g) {
223
- const e = g.target;
247
+ const C = J(() => V.hex.rgb(i.value)), a = J(() => V.hex.hsv(i.value));
248
+ function r(n) {
249
+ const e = n.target;
224
250
  if ("value" in e) {
225
- const o = e.value;
226
- if (o && te(o)) {
227
- u.value = O(o), y.value?.enforceTo(u.value), a();
251
+ const t = e.value;
252
+ if (t && se(t)) {
253
+ i.value = j(t), p.value?.enforceTo(i.value), _();
228
254
  return;
229
255
  }
230
- e.value = u.value;
256
+ e.value = i.value;
231
257
  }
232
258
  }
233
- function R(g, e) {
234
- const o = g.target;
235
- if ("value" in o) {
236
- const $ = o.value;
237
- if ($) {
238
- let f = parseInt($);
239
- if (isNaN(f))
240
- o.value = "0";
259
+ function d(n, e) {
260
+ const t = n.target;
261
+ if ("value" in t) {
262
+ const u = t.value;
263
+ if (u) {
264
+ let l = parseInt(u);
265
+ if (isNaN(l))
266
+ t.value = "0";
241
267
  else {
242
- f > 255 ? f = 255 : f < 0 && (f = 0);
243
- const x = [...k.value];
244
- e == "r" ? x[0] = f : e == "g" ? x[1] = f : x[2] = f, u.value = O(M.rgb.hex(x)), y.value?.enforceTo(u.value), o.value = f.toString(), a();
268
+ l > 255 ? l = 255 : l < 0 && (l = 0);
269
+ const g = [...C.value];
270
+ e == "r" ? g[0] = l : e == "g" ? g[1] = l : g[2] = l, i.value = j(V.rgb.hex(g)), p.value?.enforceTo(i.value), t.value = l.toString(), _();
245
271
  return;
246
272
  }
247
273
  }
248
274
  }
249
275
  }
250
- function s(g, e) {
251
- const o = g.target;
252
- if ("value" in o) {
253
- const $ = o.value;
254
- if ($) {
255
- let f = parseInt($);
256
- if (isNaN(f))
257
- o.value = "0";
276
+ function N(n, e) {
277
+ const t = n.target;
278
+ if ("value" in t) {
279
+ const u = t.value;
280
+ if (u) {
281
+ let l = parseInt(u);
282
+ if (isNaN(l))
283
+ t.value = "0";
258
284
  else {
259
- e === "h" ? f > 359 && (f = 359) : f > 100 && (f = 100), f < 0 && (f = 0);
260
- const x = [...S.value];
261
- e == "h" ? x[0] = f : e == "s" ? x[1] = f : x[2] = f, u.value = O(M.hsv.hex(x)), o.value = f.toString(), y.value?.enforceTo(u.value), a();
285
+ e === "h" ? l > 359 && (l = 359) : l > 100 && (l = 100), l < 0 && (l = 0);
286
+ const g = [...a.value];
287
+ e == "h" ? g[0] = l : e == "s" ? g[1] = l : g[2] = l, i.value = j(V.hsv.hex(g)), t.value = l.toString(), p.value?.enforceTo(i.value), _();
262
288
  return;
263
289
  }
264
290
  }
265
291
  }
266
292
  }
267
- function a() {
268
- F("update:modelValue", u.value);
293
+ function _() {
294
+ Z("update:modelValue", i.value);
269
295
  }
270
- function v() {
271
- return u.value;
296
+ function Q() {
297
+ return i.value;
272
298
  }
273
- function H(g) {
274
- if (te(g)) {
275
- const e = O(g);
276
- u.value = e, y.value?.enforceTo(e);
299
+ function D(n) {
300
+ if (se(n)) {
301
+ const e = j(n);
302
+ i.value = e, p.value?.enforceTo(e);
277
303
  }
278
304
  }
279
- ce(() => {
280
- t.modelValue ? H(t.modelValue) : t.initial && H(t.initial);
305
+ ge(() => {
306
+ o.modelValue ? D(o.modelValue) : o.initial && D(o.initial);
281
307
  });
282
- const F = m;
283
- return P({ closePanel: C, getCurrentHex: v, enforceTo: H }), W(() => t.modelValue, (g) => {
284
- g && g !== u.value && H(g);
285
- }), W(c, (g) => {
286
- g === !1 && F("done");
287
- }), (g, e) => (T(), N("div", Ne, [
288
- d("div", {
289
- class: ke(l.entryClassName || "acpEntry"),
290
- style: j(h(E)),
308
+ const Z = v;
309
+ h({ closePanel: x, getCurrentHex: Q, enforceTo: D }), A(() => o.modelValue, (n) => {
310
+ n && n !== i.value && D(n);
311
+ }), A(c, (n) => {
312
+ n === !1 && Z("done");
313
+ });
314
+ const z = q("hexInputRef"), O = q("rgbInputRef0"), B = q("rgbInputRef1"), H = q("rgbInputRef2"), $ = q("hsvInputRef0"), E = q("hsvInputRef1"), ee = q("hsvInputRef2");
315
+ function Y() {
316
+ return y.value === "hex" ? z.value ? [z.value] : [] : y.value === "rgb" ? [O.value, B.value, H.value].filter(Boolean) : [$.value, E.value, ee.value].filter(Boolean);
317
+ }
318
+ function te() {
319
+ const n = Y();
320
+ if (n.length === 0) return;
321
+ const e = document.activeElement, t = n.findIndex((g) => g === e), u = t >= 0 ? (t + 1) % n.length : 0, l = n[u];
322
+ l && (l.focus(), l.select());
323
+ }
324
+ function G(n) {
325
+ n.key === "Tab" && (n.preventDefault(), te());
326
+ }
327
+ return A(c, async (n) => {
328
+ n === !0 ? (await Se(), window.addEventListener("keydown", G)) : window.removeEventListener("keydown", G);
329
+ }), pe(() => {
330
+ window.removeEventListener("keydown", G);
331
+ }), (n, e) => (R(), b("div", De, [
332
+ f("div", {
333
+ class: Ie(s.entryClassName || "acpEntry"),
334
+ style: X(m(T)),
291
335
  onClick: e[0] || (e[0] = //@ts-ignore
292
- (...o) => h(A) && h(A)(...o))
336
+ (...t) => m(M) && m(M)(...t))
293
337
  }, null, 6),
294
- h(c) ? (T(), N("div", {
338
+ m(c) ? (R(), b("div", {
295
339
  key: 0,
296
340
  class: "acpPanel",
297
- style: j(h(L)),
298
- onClick: e[10] || (e[10] = (o) => l.panelClickStopPropagation && o.stopPropagation())
341
+ style: X(m(K)),
342
+ onClick: e[10] || (e[10] = (t) => s.panelClickStopPropagation && t.stopPropagation())
299
343
  }, [
300
- d("div", De, [
301
- de(Te, {
344
+ f("div", He, [
345
+ ye(Ne, {
302
346
  ref_key: "ring",
303
- ref: y,
304
- "initial-hex": u.value,
305
- onChanged: V,
306
- "show-package-name": l.showPackageName
347
+ ref: p,
348
+ "initial-hex": i.value,
349
+ onChanged: P,
350
+ "show-package-name": s.showPackageName
307
351
  }, null, 8, ["initial-hex", "show-package-name"])
308
352
  ]),
309
- d("div", He, [
310
- Q(d("select", {
311
- "onUpdate:modelValue": e[1] || (e[1] = (o) => D.value = o)
353
+ f("div", Ee, [
354
+ oe(f("select", {
355
+ "onUpdate:modelValue": e[1] || (e[1] = (t) => y.value = t)
312
356
  }, [...e[11] || (e[11] = [
313
- d("option", { value: "hex" }, "HEX", -1),
314
- d("option", { value: "rgb" }, "RGB", -1),
315
- d("option", { value: "hsv" }, "HSV", -1)
357
+ f("option", { value: "hex" }, "HEX", -1),
358
+ f("option", { value: "rgb" }, "RGB", -1),
359
+ f("option", { value: "hsv" }, "HSV", -1)
316
360
  ])], 512), [
317
- [Ce, D.value]
361
+ [Ce, y.value]
318
362
  ]),
319
- D.value == "hex" ? (T(), N("div", Me, [
320
- d("input", {
321
- value: u.value,
322
- onBlur: w,
363
+ y.value == "hex" ? (R(), b("div", Ae, [
364
+ f("input", {
365
+ ref_key: "hexInputRef",
366
+ ref: z,
367
+ value: i.value,
368
+ onBlur: r,
323
369
  spellcheck: "false",
324
370
  maxlength: "7"
325
- }, null, 40, Ae)
326
- ])) : D.value == "rgb" ? (T(), N("div", Ee, [
327
- d("input", {
328
- value: k.value[0],
329
- onBlur: e[2] || (e[2] = (o) => R(o, "r"))
330
- }, null, 40, $e),
331
- d("input", {
332
- value: k.value[1],
333
- onBlur: e[3] || (e[3] = (o) => R(o, "g"))
371
+ }, null, 40, _e)
372
+ ])) : y.value == "rgb" ? (R(), b("div", $e, [
373
+ f("input", {
374
+ ref_key: "rgbInputRef0",
375
+ ref: O,
376
+ value: C.value[0],
377
+ onBlur: e[2] || (e[2] = (t) => d(t, "r"))
334
378
  }, null, 40, qe),
335
- d("input", {
336
- value: k.value[2],
337
- onBlur: e[4] || (e[4] = (o) => R(o, "b"))
338
- }, null, 40, Ue)
339
- ])) : (T(), N("div", Le, [
340
- d("input", {
341
- value: S.value[0],
342
- onBlur: e[5] || (e[5] = (o) => s(o, "h"))
343
- }, null, 40, _e),
344
- d("input", {
345
- value: S.value[1],
346
- onBlur: e[6] || (e[6] = (o) => s(o, "s"))
379
+ f("input", {
380
+ ref_key: "rgbInputRef1",
381
+ ref: B,
382
+ value: C.value[1],
383
+ onBlur: e[3] || (e[3] = (t) => d(t, "g"))
384
+ }, null, 40, Le),
385
+ f("input", {
386
+ ref_key: "rgbInputRef2",
387
+ ref: H,
388
+ value: C.value[2],
389
+ onBlur: e[4] || (e[4] = (t) => d(t, "b"))
390
+ }, null, 40, Ke)
391
+ ])) : (R(), b("div", Ue, [
392
+ f("input", {
393
+ ref_key: "hsvInputRef0",
394
+ ref: $,
395
+ value: a.value[0],
396
+ onBlur: e[5] || (e[5] = (t) => N(t, "h"))
347
397
  }, null, 40, ze),
348
- d("input", {
349
- value: S.value[2],
350
- onBlur: e[7] || (e[7] = (o) => s(o, "v"))
351
- }, null, 40, Oe)
398
+ f("input", {
399
+ ref_key: "hsvInputRef1",
400
+ ref: E,
401
+ value: a.value[1],
402
+ onBlur: e[6] || (e[6] = (t) => N(t, "s"))
403
+ }, null, 40, Oe),
404
+ f("input", {
405
+ ref_key: "hsvInputRef2",
406
+ ref: ee,
407
+ value: a.value[2],
408
+ onBlur: e[7] || (e[7] = (t) => N(t, "v"))
409
+ }, null, 40, Fe)
352
410
  ]))
353
411
  ]),
354
- d("div", We, [
355
- d("button", {
412
+ f("div", We, [
413
+ f("button", {
356
414
  onClick: e[8] || (e[8] = //@ts-ignore
357
- (...o) => h(C) && h(C)(...o))
415
+ (...t) => m(x) && m(x)(...t))
358
416
  }, "OK")
359
417
  ]),
360
- l.showPackageName ? (T(), N("div", {
418
+ s.showPackageName ? (R(), b("div", {
361
419
  key: 0,
362
420
  class: "acpPackageName",
363
421
  onClick: e[9] || (e[9] = //@ts-ignore
364
- (...o) => h(ue) && h(ue)(...o))
365
- }, " au-color-picker ")) : ee("", !0)
366
- ], 4)) : ee("", !0)
422
+ (...t) => m(ve) && m(ve)(...t))
423
+ }, " au-color-picker ")) : le("", !0)
424
+ ], 4)) : le("", !0)
367
425
  ]));
368
426
  }
369
- }), Fe = /* @__PURE__ */ oe(je, [["__scopeId", "data-v-1feea9d7"]]), Xe = { class: "acp" }, Ze = { class: "acpNamedPresets" }, Ke = ["for", "onClick"], Ye = ["id", "value"], Ge = { class: "acpPresetName" }, Je = { class: "acpDoneBtn" }, Qe = /* @__PURE__ */ ne({
427
+ }), Xe = /* @__PURE__ */ re(je, [["__scopeId", "data-v-0a352b8c"]]), Ze = { class: "acp" }, Ye = { class: "acpNamedPresets" }, Ge = ["for", "onClick"], Je = ["id", "value"], Qe = { class: "acpPresetName" }, et = { class: "acpDoneBtn" }, tt = /* @__PURE__ */ ae({
370
428
  __name: "AuColorPickerPresetsNested",
371
429
  props: {
372
430
  modelValueSelectedPreset: {},
@@ -382,114 +440,116 @@ const Ne = { class: "acp" }, De = { class: "acpRing" }, He = { class: "acpParams
382
440
  panelBaseZIndex: {},
383
441
  entryRespondDelay: {},
384
442
  panelClickStopPropagation: { type: Boolean },
385
- showPackageName: { type: Boolean }
443
+ showPackageName: { type: Boolean },
444
+ colorModeStorageKey: { type: [String, Boolean] },
445
+ colorMode: {}
386
446
  },
387
447
  emits: ["done", "update:modelValue", "update:modelValueSelectedPreset"],
388
- setup(l, { expose: P, emit: m }) {
389
- const t = l, y = I(), u = I(), c = I("#ff0000"), C = K(() => {
390
- let s = null;
391
- return y.value && (s = t.presets?.find((v) => v.name == y.value)?.colorHex), s || c.value;
392
- }), { panelShow: A, closePanel: E, togglePanel: L, entryStylesActual: V } = ve(t, C), { panelStyles: D } = fe(t);
393
- function k(s) {
394
- y.value = s?.name, S("update:modelValueSelectedPreset", s?.name);
448
+ setup(s, { expose: h, emit: v }) {
449
+ const o = s, p = S(), i = S(), c = S("#ff0000"), x = J(() => {
450
+ let a = null;
451
+ return p.value && (a = o.presets?.find((d) => d.name == p.value)?.colorHex), a || c.value;
452
+ }), { panelShow: M, closePanel: T, togglePanel: K, entryStylesActual: I } = me(o, x), { panelStyles: U } = he(o);
453
+ function k(a) {
454
+ p.value = a?.name, y("update:modelValueSelectedPreset", a?.name);
395
455
  }
396
- const S = m;
397
- W(c, (s) => {
398
- S("update:modelValue", s);
456
+ const y = v;
457
+ A(c, (a) => {
458
+ y("update:modelValue", a);
399
459
  });
400
- function w(s) {
401
- if (te(s)) {
402
- const a = O(s);
403
- c.value = a, u.value?.enforceTo(a);
460
+ function P(a) {
461
+ if (se(a)) {
462
+ const r = j(a);
463
+ c.value = r, i.value?.enforceTo(r);
404
464
  }
405
465
  }
406
- function R(s) {
407
- s || k(void 0);
408
- const a = t.presets?.find((v) => v.name === s);
409
- a && k(a);
466
+ function C(a) {
467
+ a || k(void 0);
468
+ const r = o.presets?.find((d) => d.name === a);
469
+ r && k(r);
410
470
  }
411
- return P({ closePanel: E, enforceCustomValueTo: w, enforcePresetTo: R }), W(A, (s) => {
412
- s === !1 && S("done");
413
- }), W(() => t.modelValue, (s) => {
414
- s && w(s);
415
- }), W(() => t.modelValueSelectedPreset, (s) => {
416
- R(s);
417
- }), ce(() => {
418
- t.modelValue ? w(t.modelValue) : t.initial && w(t.initial), t.modelValueSelectedPreset ? R(t.modelValueSelectedPreset) : t.initialSelectedPreset && R(t.initialSelectedPreset);
419
- }), (s, a) => (T(), N("div", Xe, [
420
- d("div", {
471
+ return h({ closePanel: T, enforceCustomValueTo: P, enforcePresetTo: C }), A(M, (a) => {
472
+ a === !1 && y("done");
473
+ }), A(() => o.modelValue, (a) => {
474
+ a && P(a);
475
+ }), A(() => o.modelValueSelectedPreset, (a) => {
476
+ C(a);
477
+ }), ge(() => {
478
+ o.modelValue ? P(o.modelValue) : o.initial && P(o.initial), o.modelValueSelectedPreset ? C(o.modelValueSelectedPreset) : o.initialSelectedPreset && C(o.initialSelectedPreset);
479
+ }), (a, r) => (R(), b("div", Ze, [
480
+ f("div", {
421
481
  class: "acpEntry",
422
- style: j(h(V)),
423
- onClick: a[0] || (a[0] = //@ts-ignore
424
- (...v) => h(L) && h(L)(...v))
482
+ style: X(m(I)),
483
+ onClick: r[0] || (r[0] = //@ts-ignore
484
+ (...d) => m(K) && m(K)(...d))
425
485
  }, null, 4),
426
- h(A) ? (T(), N("div", {
486
+ m(M) ? (R(), b("div", {
427
487
  key: 0,
428
488
  class: "acpPanel",
429
- style: j(h(D)),
430
- onClick: a[6] || (a[6] = (v) => l.panelClickStopPropagation && v.stopPropagation())
489
+ style: X(m(U)),
490
+ onClick: r[6] || (r[6] = (d) => s.panelClickStopPropagation && d.stopPropagation())
431
491
  }, [
432
- d("div", Ze, [
433
- d("label", {
492
+ f("div", Ye, [
493
+ f("label", {
434
494
  for: "acpColorPresetCustom",
435
- onClick: a[3] || (a[3] = (v) => k(void 0))
495
+ onClick: r[3] || (r[3] = (d) => k(void 0))
436
496
  }, [
437
- de(Fe, {
497
+ ye(Xe, {
438
498
  modelValue: c.value,
439
- "onUpdate:modelValue": a[1] || (a[1] = (v) => c.value = v),
440
- onDone: h(E),
499
+ "onUpdate:modelValue": r[1] || (r[1] = (d) => c.value = d),
500
+ onDone: m(T),
441
501
  "entry-class-name": "acpPresetBody",
442
502
  ref_key: "customPicker",
443
- ref: u,
444
- "show-package-name": l.showPackageName,
445
- pos: l.posInternal
503
+ ref: i,
504
+ "show-package-name": s.showPackageName,
505
+ pos: s.posInternal
446
506
  }, null, 8, ["modelValue", "onDone", "show-package-name", "pos"]),
447
- Q(d("input", {
507
+ oe(f("input", {
448
508
  name: "colorType",
449
509
  type: "radio",
450
510
  id: "acpColorPresetCustom",
451
511
  value: void 0,
452
- "onUpdate:modelValue": a[2] || (a[2] = (v) => y.value = v)
512
+ "onUpdate:modelValue": r[2] || (r[2] = (d) => p.value = d)
453
513
  }, null, 512), [
454
- [le, y.value]
514
+ [ue, p.value]
455
515
  ]),
456
- a[7] || (a[7] = d("div", { class: "acpPresetName" }, "自定义", -1))
516
+ r[7] || (r[7] = f("div", { class: "acpPresetName" }, "自定义", -1))
457
517
  ]),
458
- a[8] || (a[8] = d("div", { class: "acpSep" }, null, -1)),
459
- (T(!0), N(Se, null, we(l.presets, (v) => (T(), N("label", {
460
- for: `acpColorPreset${v.name}`,
461
- onClick: (H) => k(v),
462
- key: v.name
518
+ r[8] || (r[8] = f("div", { class: "acpSep" }, null, -1)),
519
+ (R(!0), b(we, null, Re(s.presets, (d) => (R(), b("label", {
520
+ for: `acpColorPreset${d.name}`,
521
+ onClick: (N) => k(d),
522
+ key: d.name
463
523
  }, [
464
- d("div", {
524
+ f("div", {
465
525
  class: "acpPresetBody",
466
- style: j({ backgroundColor: v.colorHex })
526
+ style: X({ backgroundColor: d.colorHex })
467
527
  }, null, 4),
468
- Q(d("input", {
528
+ oe(f("input", {
469
529
  name: "colorType",
470
530
  type: "radio",
471
- id: `acpColorPreset${v.name}`,
472
- value: v.name,
473
- "onUpdate:modelValue": a[4] || (a[4] = (H) => y.value = H)
474
- }, null, 8, Ye), [
475
- [le, y.value]
531
+ id: `acpColorPreset${d.name}`,
532
+ value: d.name,
533
+ "onUpdate:modelValue": r[4] || (r[4] = (N) => p.value = N)
534
+ }, null, 8, Je), [
535
+ [ue, p.value]
476
536
  ]),
477
- d("div", Ge, Ie(v.name), 1)
478
- ], 8, Ke))), 128)),
479
- a[9] || (a[9] = d("div", { class: "acpSep" }, null, -1))
537
+ f("div", Qe, be(d.name), 1)
538
+ ], 8, Ge))), 128)),
539
+ r[9] || (r[9] = f("div", { class: "acpSep" }, null, -1))
480
540
  ]),
481
- d("div", Je, [
482
- d("button", {
483
- onClick: a[5] || (a[5] = //@ts-ignore
484
- (...v) => h(E) && h(E)(...v))
541
+ f("div", et, [
542
+ f("button", {
543
+ onClick: r[5] || (r[5] = //@ts-ignore
544
+ (...d) => m(T) && m(T)(...d))
485
545
  }, "OK")
486
546
  ])
487
- ], 4)) : ee("", !0)
547
+ ], 4)) : le("", !0)
488
548
  ]));
489
549
  }
490
- }), nt = /* @__PURE__ */ oe(Qe, [["__scopeId", "data-v-9fbc3723"]]);
550
+ }), lt = /* @__PURE__ */ re(tt, [["__scopeId", "data-v-9fbc3723"]]);
491
551
  export {
492
- Fe as AuColorPicker,
493
- nt as AuColorPickerPresetsNested,
494
- Te as AuColorPickerRing
552
+ Xe as AuColorPicker,
553
+ lt as AuColorPickerPresetsNested,
554
+ Ne as AuColorPickerRing
495
555
  };
@@ -1,4 +1,4 @@
1
- import { HEX } from 'color-convert/conversions';
1
+ import { HEX } from 'color-convert';
2
2
  import { PickerProps } from './common/pickerProps';
3
3
  declare function getCurrentHex(): string;
4
4
  declare function enforceTo(newHexValue: string): void;
@@ -16,11 +16,11 @@ declare const _default: import('vue').DefineComponent<PickerProps, {
16
16
  ring: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
17
17
  initialHex?: string;
18
18
  }> & Readonly<{
19
- onChanged?: ((hex: HEX) => any) | undefined;
19
+ onChanged?: ((hex: string) => any) | undefined;
20
20
  }>, {
21
21
  enforceTo: (hex: HEX) => void;
22
22
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
23
- changed: (hex: HEX) => any;
23
+ changed: (hex: string) => any;
24
24
  }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
25
25
  cvs: HTMLCanvasElement;
26
26
  cursorCvs: HTMLCanvasElement;
@@ -34,9 +34,16 @@ declare const _default: import('vue').DefineComponent<PickerProps, {
34
34
  }, Readonly<{
35
35
  initialHex?: string;
36
36
  }> & Readonly<{
37
- onChanged?: ((hex: HEX) => any) | undefined;
37
+ onChanged?: ((hex: string) => any) | undefined;
38
38
  }>, {
39
39
  enforceTo: (hex: HEX) => void;
40
40
  }, {}, {}, {}, {}> | null;
41
+ hexInputRef: HTMLInputElement;
42
+ rgbInputRef0: HTMLInputElement;
43
+ rgbInputRef1: HTMLInputElement;
44
+ rgbInputRef2: HTMLInputElement;
45
+ hsvInputRef0: HTMLInputElement;
46
+ hsvInputRef1: HTMLInputElement;
47
+ hsvInputRef2: HTMLInputElement;
41
48
  }, HTMLDivElement>;
42
49
  export default _default;
@@ -28,11 +28,11 @@ declare const _default: import('vue').DefineComponent<PickerWithPresetsProps, {
28
28
  ring: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
29
29
  initialHex?: string;
30
30
  }> & Readonly<{
31
- onChanged?: ((hex: HEX) => any) | undefined;
31
+ onChanged?: ((hex: string) => any) | undefined;
32
32
  }>, {
33
- enforceTo: (hex: HEX) => void;
33
+ enforceTo: (hex: import('color-convert').HEX) => void;
34
34
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
35
- changed: (hex: HEX) => any;
35
+ changed: (hex: string) => any;
36
36
  }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
37
37
  cvs: HTMLCanvasElement;
38
38
  cursorCvs: HTMLCanvasElement;
@@ -46,10 +46,17 @@ declare const _default: import('vue').DefineComponent<PickerWithPresetsProps, {
46
46
  }, Readonly<{
47
47
  initialHex?: string;
48
48
  }> & Readonly<{
49
- onChanged?: ((hex: HEX) => any) | undefined;
49
+ onChanged?: ((hex: string) => any) | undefined;
50
50
  }>, {
51
- enforceTo: (hex: HEX) => void;
51
+ enforceTo: (hex: import('color-convert').HEX) => void;
52
52
  }, {}, {}, {}, {}> | null;
53
+ hexInputRef: HTMLInputElement;
54
+ rgbInputRef0: HTMLInputElement;
55
+ rgbInputRef1: HTMLInputElement;
56
+ rgbInputRef2: HTMLInputElement;
57
+ hsvInputRef0: HTMLInputElement;
58
+ hsvInputRef1: HTMLInputElement;
59
+ hsvInputRef2: HTMLInputElement;
53
60
  }, HTMLDivElement, import('vue').ComponentProvideOptions, {
54
61
  P: {};
55
62
  B: {};
@@ -1,4 +1,4 @@
1
- import { HEX } from 'color-convert/conversions';
1
+ import { HEX } from 'color-convert';
2
2
  type __VLS_Props = {
3
3
  initialHex?: string;
4
4
  };
@@ -6,9 +6,9 @@ declare function enforceTo(hex: HEX): void;
6
6
  declare const _default: import('vue').DefineComponent<__VLS_Props, {
7
7
  enforceTo: typeof enforceTo;
8
8
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
9
- changed: (hex: HEX) => any;
9
+ changed: (hex: string) => any;
10
10
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
11
- onChanged?: ((hex: HEX) => any) | undefined;
11
+ onChanged?: ((hex: string) => any) | undefined;
12
12
  }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
13
13
  cvs: HTMLCanvasElement;
14
14
  cursorCvs: HTMLCanvasElement;
@@ -11,6 +11,8 @@ export interface PickerProps {
11
11
  entryRespondDelay?: number;
12
12
  panelClickStopPropagation?: boolean;
13
13
  showPackageName?: boolean;
14
+ colorModeStorageKey?: string | false;
15
+ colorMode?: 'rgb' | 'hsv' | 'hex';
14
16
  }
15
17
  export interface PickerWithPresetsProps extends PickerProps {
16
18
  modelValueSelectedPreset?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurouscia/au-color-picker",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "author": {
5
5
  "name": "Au"
6
6
  },