@ljweb/layout-antdv-v4 0.1.0-beta.0 → 0.1.0-beta.1

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/README.md CHANGED
@@ -56,7 +56,7 @@ yarn release:beta
56
56
 
57
57
  `aTable` 现在返回内部 `ExtTable` 实例,已标记废弃;消费方应使用公开的 `refresh`、`clearSelected`。
58
58
  旧 Vue 2 JSX 指令、Form API 与事件模型仍须由消费方升级,不属于导入路径兼容层。
59
- `ColorInput` 支持 `v-model:value`、透明度和预置色;旧 `colorPickerProps` 已废弃,改用显式属性。
59
+ `ColorInput` 点击色块即打开可操作的色盘。`v-model:value` 和 `change` 均使用字符串,手输 HEX、RGB、RGBA、HSL 时保留原样。色盘生成 RGB 或 RGBA,启用 `disableAlpha` 时生成 HEX。组件支持预设色、`disabled` 与 `disableFields`;旧 `colorPickerProps` 已废弃,改用显式属性。
60
60
 
61
61
  本包 `ConfigProvider` 支持 `Theme.Light/Dark/RealLight`、`primaryColor`、设备与国际化配置,并兼容 antdv4 原生主题 token。
62
62
  `ExtUpload` 必须由消费方传入 `getUploadUrl` 签名地址函数,不再内置业务接口;展示枚举可通过 `formatMappings` 或对应格式化组件的 `mapping` 覆盖。
package/dist/style.css CHANGED
@@ -417,6 +417,49 @@
417
417
  gap: 8px;
418
418
  width: 220px;
419
419
  }
420
+ .ant-color-input-palette, .ops-color-input-palette, .kbr-color-input-palette {
421
+ position: relative;
422
+ width: 100%;
423
+ aspect-ratio: 4 / 3;
424
+ border-radius: 4px;
425
+ background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent);
426
+ cursor: crosshair;
427
+ touch-action: none;
428
+ }
429
+ .ant-color-input-palette-marker, .ops-color-input-palette-marker, .kbr-color-input-palette-marker {
430
+ position: absolute;
431
+ width: 12px;
432
+ height: 12px;
433
+ transform: translate(-50%, -50%);
434
+ border: 2px solid #fff;
435
+ border-radius: 50%;
436
+ box-shadow: 0 0 2px #000;
437
+ pointer-events: none;
438
+ }
439
+ .ant-color-input-hue, .ops-color-input-hue, .kbr-color-input-hue {
440
+ width: 100%;
441
+ height: 12px;
442
+ margin: 0;
443
+ appearance: none;
444
+ border-radius: 4px;
445
+ background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
446
+ cursor: pointer;
447
+ }
448
+ .ant-color-input-hue::-webkit-slider-thumb, .ops-color-input-hue::-webkit-slider-thumb, .kbr-color-input-hue::-webkit-slider-thumb {
449
+ appearance: none;
450
+ width: 10px;
451
+ height: 14px;
452
+ border: 1px solid #595959;
453
+ border-radius: 3px;
454
+ background: #fff;
455
+ }
456
+ .ant-color-input-hue::-moz-range-thumb, .ops-color-input-hue::-moz-range-thumb, .kbr-color-input-hue::-moz-range-thumb {
457
+ width: 10px;
458
+ height: 14px;
459
+ border: 1px solid #595959;
460
+ border-radius: 3px;
461
+ background: #fff;
462
+ }
420
463
  .ant-color-input-alpha, .ops-color-input-alpha, .kbr-color-input-alpha {
421
464
  display: flex;
422
465
  align-items: center;
@@ -8688,6 +8731,49 @@ a.info--text:focus,
8688
8731
  gap: 8px;
8689
8732
  width: 220px;
8690
8733
  }
8734
+ .ant-color-input-palette, .ops-color-input-palette, .kbr-color-input-palette {
8735
+ position: relative;
8736
+ width: 100%;
8737
+ aspect-ratio: 4 / 3;
8738
+ border-radius: 4px;
8739
+ background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent);
8740
+ cursor: crosshair;
8741
+ touch-action: none;
8742
+ }
8743
+ .ant-color-input-palette-marker, .ops-color-input-palette-marker, .kbr-color-input-palette-marker {
8744
+ position: absolute;
8745
+ width: 12px;
8746
+ height: 12px;
8747
+ transform: translate(-50%, -50%);
8748
+ border: 2px solid #fff;
8749
+ border-radius: 50%;
8750
+ box-shadow: 0 0 2px #000;
8751
+ pointer-events: none;
8752
+ }
8753
+ .ant-color-input-hue, .ops-color-input-hue, .kbr-color-input-hue {
8754
+ width: 100%;
8755
+ height: 12px;
8756
+ margin: 0;
8757
+ appearance: none;
8758
+ border-radius: 4px;
8759
+ background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
8760
+ cursor: pointer;
8761
+ }
8762
+ .ant-color-input-hue::-webkit-slider-thumb, .ops-color-input-hue::-webkit-slider-thumb, .kbr-color-input-hue::-webkit-slider-thumb {
8763
+ appearance: none;
8764
+ width: 10px;
8765
+ height: 14px;
8766
+ border: 1px solid #595959;
8767
+ border-radius: 3px;
8768
+ background: #fff;
8769
+ }
8770
+ .ant-color-input-hue::-moz-range-thumb, .ops-color-input-hue::-moz-range-thumb, .kbr-color-input-hue::-moz-range-thumb {
8771
+ width: 10px;
8772
+ height: 14px;
8773
+ border: 1px solid #595959;
8774
+ border-radius: 3px;
8775
+ background: #fff;
8776
+ }
8691
8777
  .ant-color-input-alpha, .ops-color-input-alpha, .kbr-color-input-alpha {
8692
8778
  display: flex;
8693
8779
  align-items: center;
@@ -417,6 +417,49 @@
417
417
  gap: 8px;
418
418
  width: 220px;
419
419
  }
420
+ .ant-color-input-palette, .ops-color-input-palette, .kbr-color-input-palette {
421
+ position: relative;
422
+ width: 100%;
423
+ aspect-ratio: 4 / 3;
424
+ border-radius: 4px;
425
+ background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent);
426
+ cursor: crosshair;
427
+ touch-action: none;
428
+ }
429
+ .ant-color-input-palette-marker, .ops-color-input-palette-marker, .kbr-color-input-palette-marker {
430
+ position: absolute;
431
+ width: 12px;
432
+ height: 12px;
433
+ transform: translate(-50%, -50%);
434
+ border: 2px solid #fff;
435
+ border-radius: 50%;
436
+ box-shadow: 0 0 2px #000;
437
+ pointer-events: none;
438
+ }
439
+ .ant-color-input-hue, .ops-color-input-hue, .kbr-color-input-hue {
440
+ width: 100%;
441
+ height: 12px;
442
+ margin: 0;
443
+ appearance: none;
444
+ border-radius: 4px;
445
+ background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
446
+ cursor: pointer;
447
+ }
448
+ .ant-color-input-hue::-webkit-slider-thumb, .ops-color-input-hue::-webkit-slider-thumb, .kbr-color-input-hue::-webkit-slider-thumb {
449
+ appearance: none;
450
+ width: 10px;
451
+ height: 14px;
452
+ border: 1px solid #595959;
453
+ border-radius: 3px;
454
+ background: #fff;
455
+ }
456
+ .ant-color-input-hue::-moz-range-thumb, .ops-color-input-hue::-moz-range-thumb, .kbr-color-input-hue::-moz-range-thumb {
457
+ width: 10px;
458
+ height: 14px;
459
+ border: 1px solid #595959;
460
+ border-radius: 3px;
461
+ background: #fff;
462
+ }
420
463
  .ant-color-input-alpha, .ops-color-input-alpha, .kbr-color-input-alpha {
421
464
  display: flex;
422
465
  align-items: center;
@@ -8688,6 +8731,49 @@ a.info--text:focus,
8688
8731
  gap: 8px;
8689
8732
  width: 220px;
8690
8733
  }
8734
+ .ant-color-input-palette, .ops-color-input-palette, .kbr-color-input-palette {
8735
+ position: relative;
8736
+ width: 100%;
8737
+ aspect-ratio: 4 / 3;
8738
+ border-radius: 4px;
8739
+ background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent);
8740
+ cursor: crosshair;
8741
+ touch-action: none;
8742
+ }
8743
+ .ant-color-input-palette-marker, .ops-color-input-palette-marker, .kbr-color-input-palette-marker {
8744
+ position: absolute;
8745
+ width: 12px;
8746
+ height: 12px;
8747
+ transform: translate(-50%, -50%);
8748
+ border: 2px solid #fff;
8749
+ border-radius: 50%;
8750
+ box-shadow: 0 0 2px #000;
8751
+ pointer-events: none;
8752
+ }
8753
+ .ant-color-input-hue, .ops-color-input-hue, .kbr-color-input-hue {
8754
+ width: 100%;
8755
+ height: 12px;
8756
+ margin: 0;
8757
+ appearance: none;
8758
+ border-radius: 4px;
8759
+ background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
8760
+ cursor: pointer;
8761
+ }
8762
+ .ant-color-input-hue::-webkit-slider-thumb, .ops-color-input-hue::-webkit-slider-thumb, .kbr-color-input-hue::-webkit-slider-thumb {
8763
+ appearance: none;
8764
+ width: 10px;
8765
+ height: 14px;
8766
+ border: 1px solid #595959;
8767
+ border-radius: 3px;
8768
+ background: #fff;
8769
+ }
8770
+ .ant-color-input-hue::-moz-range-thumb, .ops-color-input-hue::-moz-range-thumb, .kbr-color-input-hue::-moz-range-thumb {
8771
+ width: 10px;
8772
+ height: 14px;
8773
+ border: 1px solid #595959;
8774
+ border-radius: 3px;
8775
+ background: #fff;
8776
+ }
8691
8777
  .ant-color-input-alpha, .ops-color-input-alpha, .kbr-color-input-alpha {
8692
8778
  display: flex;
8693
8779
  align-items: center;
@@ -1,12 +1,22 @@
1
- import { defineComponent, ref, computed, h } from "vue";
1
+ import { defineComponent, ref, computed, shallowRef, watch, h } from "vue";
2
2
  import { Input, Popover } from "ant-design-vue";
3
3
  import { useConfigContextInject } from "ant-design-vue/es/config-provider/context";
4
- import { colorPickerValue, colorWithAlpha, colorAlpha } from "./helpers.js";
4
+ import { useInjectDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
5
+ import tinycolor from "tinycolor2";
6
+ import { colorWithAlpha } from "./helpers.js";
7
+ const paletteKeys = {
8
+ ArrowLeft: [-0.01, 0],
9
+ ArrowRight: [0.01, 0],
10
+ ArrowDown: [0, -0.01],
11
+ ArrowUp: [0, 0.01]
12
+ };
13
+ const clampUnit = (value) => Math.max(0, Math.min(1, value));
5
14
  const ColorInput = defineComponent({
6
15
  name: "ColorInput",
7
16
  inheritAttrs: false,
8
17
  props: {
9
18
  value: String,
19
+ disabled: { type: Boolean, default: void 0 },
10
20
  disableAlpha: Boolean,
11
21
  disableFields: Boolean,
12
22
  presetColors: { type: Array, default: () => [] },
@@ -19,57 +29,115 @@ const ColorInput = defineComponent({
19
29
  const container = ref();
20
30
  const input = ref();
21
31
  const { getPrefixCls } = useConfigContextInject();
32
+ const contextDisabled = useInjectDisabled();
33
+ const disabled = computed(() => props.disabled ?? contextDisabled.value);
22
34
  const prefixCls = computed(() => getPrefixCls("color-input", props.prefixCls));
35
+ const hsv = computed(() => tinycolor(props.value || "#000000").toHsv());
36
+ const hue = shallowRef(hsv.value.h);
37
+ watch(hsv, ({ h: nextHue, s, v }) => {
38
+ if (s && v) hue.value = nextHue;
39
+ });
23
40
  const change = (value) => {
24
41
  emit("update:value", value);
25
42
  emit("change", value);
26
43
  };
27
- const selectColor = (value) => change(colorWithAlpha(value, colorAlpha(props.value), props.disableAlpha));
28
- const disabled = computed(() => !!attrs.disabled);
44
+ const selectColor = (s, v) => {
45
+ change(colorWithAlpha({ h: hue.value, s: clampUnit(s), v: clampUnit(v) }, hsv.value.a, props.disableAlpha));
46
+ };
47
+ const selectFromPointer = (event) => {
48
+ const { left, top, width, height } = event.currentTarget.getBoundingClientRect();
49
+ if (width && height) selectColor((event.clientX - left) / width, 1 - (event.clientY - top) / height);
50
+ };
29
51
  expose({ focus: () => input.value?.focus(), blur: () => input.value?.blur() });
30
- const renderPicker = () => h("div", { class: `${prefixCls.value}-picker` }, [
31
- h("input", {
32
- type: "color",
33
- "aria-label": "选择颜色",
34
- value: colorPickerValue(props.value),
35
- disabled: disabled.value,
36
- onInput: (event) => selectColor(event.target.value)
37
- }),
38
- !props.disableAlpha ? h("label", { class: `${prefixCls.value}-alpha` }, [
39
- "透明度",
52
+ const renderPicker = () => {
53
+ const { s, v, a } = hsv.value;
54
+ const pickerPrefix = prefixCls.value;
55
+ return h("div", { class: `${pickerPrefix}-picker` }, [
56
+ h(
57
+ "div",
58
+ {
59
+ class: `${pickerPrefix}-palette`,
60
+ role: "slider",
61
+ tabindex: disabled.value ? -1 : 0,
62
+ "aria-label": "饱和度和明度",
63
+ "aria-valuemin": 0,
64
+ "aria-valuemax": 100,
65
+ "aria-valuenow": Math.round(s * 100),
66
+ "aria-valuetext": `饱和度 ${Math.round(s * 100)}%,明度 ${Math.round(v * 100)}%`,
67
+ "aria-disabled": disabled.value,
68
+ style: { backgroundColor: `hsl(${hue.value}, 100%, 50%)` },
69
+ onPointerdown: (event) => {
70
+ if (disabled.value || event.button !== 0) return;
71
+ const palette = event.currentTarget;
72
+ palette.setPointerCapture?.(event.pointerId);
73
+ selectFromPointer(event);
74
+ },
75
+ onPointermove: (event) => {
76
+ if (!disabled.value && event.currentTarget.hasPointerCapture?.(event.pointerId)) {
77
+ selectFromPointer(event);
78
+ }
79
+ },
80
+ onKeydown: (event) => {
81
+ const delta = paletteKeys[event.key];
82
+ if (disabled.value || !delta) return;
83
+ event.preventDefault();
84
+ selectColor(s + delta[0], v + delta[1]);
85
+ }
86
+ },
87
+ h("span", {
88
+ class: `${pickerPrefix}-palette-marker`,
89
+ style: { left: `${s * 100}%`, top: `${(1 - v) * 100}%` }
90
+ })
91
+ ),
40
92
  h("input", {
93
+ class: `${pickerPrefix}-hue`,
41
94
  type: "range",
42
95
  min: 0,
43
- max: 1,
44
- step: 0.01,
45
- "aria-label": "透明度",
46
- value: colorAlpha(props.value),
96
+ max: 359,
97
+ "aria-label": "色相",
98
+ value: Math.round(hue.value) % 360,
47
99
  disabled: disabled.value,
48
- onInput: (event) => change(colorWithAlpha(props.value || "#000000", Number(event.target.value)))
49
- })
50
- ]) : null,
51
- !props.disableFields ? h("input", {
52
- "aria-label": "颜色值",
53
- value: props.value,
54
- disabled: disabled.value,
55
- onInput: (event) => change(event.target.value)
56
- }) : null,
57
- props.presetColors.length ? h(
58
- "div",
59
- { class: `${prefixCls.value}-presets` },
60
- props.presetColors.map(
61
- (color) => h("button", {
62
- key: color,
63
- type: "button",
64
- "aria-label": `选择 ${color}`,
65
- title: color,
100
+ onInput: (event) => {
101
+ hue.value = event.target.valueAsNumber;
102
+ selectColor(s, v);
103
+ }
104
+ }),
105
+ !props.disableAlpha ? h("label", { class: `${pickerPrefix}-alpha` }, [
106
+ "透明度",
107
+ h("input", {
108
+ type: "range",
109
+ min: 0,
110
+ max: 1,
111
+ step: 0.01,
112
+ "aria-label": "透明度",
113
+ value: a,
66
114
  disabled: disabled.value,
67
- style: { backgroundColor: color },
68
- onClick: () => change(props.disableAlpha ? colorWithAlpha(color, 1, true) : color)
115
+ onInput: (event) => change(colorWithAlpha(props.value || "#000000", event.target.valueAsNumber))
69
116
  })
70
- )
71
- ) : null
72
- ]);
117
+ ]) : null,
118
+ !props.disableFields ? h("input", {
119
+ "aria-label": "颜色值",
120
+ value: props.value,
121
+ disabled: disabled.value,
122
+ onInput: (event) => change(event.target.value)
123
+ }) : null,
124
+ props.presetColors.length ? h(
125
+ "div",
126
+ { class: `${pickerPrefix}-presets` },
127
+ props.presetColors.map(
128
+ (color) => h("button", {
129
+ key: color,
130
+ type: "button",
131
+ "aria-label": `选择 ${color}`,
132
+ title: color,
133
+ disabled: disabled.value,
134
+ style: { backgroundColor: color },
135
+ onClick: () => change(props.disableAlpha ? colorWithAlpha(color, 1, true) : color)
136
+ })
137
+ )
138
+ ) : null
139
+ ]);
140
+ };
73
141
  return () => h("div", { ref: container, class: prefixCls.value }, [
74
142
  h(
75
143
  Input,
@@ -77,6 +145,7 @@ const ColorInput = defineComponent({
77
145
  ...attrs,
78
146
  ref: input,
79
147
  value: props.value,
148
+ disabled: disabled.value,
80
149
  onChange: (event) => change(event.target.value)
81
150
  },
82
151
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ColorInput.js","sources":["../../../src/components/color-input/ColorInput.ts"],"sourcesContent":["import { computed, defineComponent, h, ref } from 'vue';\nimport { Input, Popover } from 'ant-design-vue';\nimport { useConfigContextInject } from 'ant-design-vue/es/config-provider/context';\nimport { colorAlpha, colorPickerValue, colorWithAlpha } from './helpers';\nimport type { PropType } from 'vue';\nimport type { PopoverProps } from 'ant-design-vue';\n\nexport interface ColorInputProps {\n value?: string;\n disableAlpha?: boolean;\n disableFields?: boolean;\n presetColors?: string[];\n popupProps?: Partial<PopoverProps>;\n prefixCls?: string;\n /** @deprecated 使用 disableAlpha、disableFields、presetColors 配置色盘。 */\n colorPickerProps?: Record<string, unknown>;\n}\n\nexport default defineComponent({\n name: 'ColorInput',\n inheritAttrs: false,\n props: {\n value: String,\n disableAlpha: Boolean,\n disableFields: Boolean,\n presetColors: { type: Array as PropType<string[]>, default: () => [] },\n popupProps: Object as PropType<Partial<PopoverProps>>,\n colorPickerProps: Object as PropType<Record<string, unknown>>,\n prefixCls: String,\n },\n emits: ['change', 'update:value'],\n setup(props, { attrs, emit, slots, expose }) {\n const container = ref<HTMLElement>();\n const input = ref<any>();\n const { getPrefixCls } = useConfigContextInject();\n const prefixCls = computed(() => getPrefixCls('color-input', props.prefixCls));\n const change = (value: string) => {\n emit('update:value', value);\n emit('change', value);\n };\n const selectColor = (value: string) => change(colorWithAlpha(value, colorAlpha(props.value), props.disableAlpha));\n const disabled = computed(() => !!attrs.disabled);\n expose({ focus: () => input.value?.focus(), blur: () => input.value?.blur() });\n\n const renderPicker = () =>\n h('div', { class: `${prefixCls.value}-picker` }, [\n h('input', {\n type: 'color',\n 'aria-label': '选择颜色',\n value: colorPickerValue(props.value),\n disabled: disabled.value,\n onInput: (event: Event) => selectColor((event.target as HTMLInputElement).value),\n }),\n !props.disableAlpha\n ? h('label', { class: `${prefixCls.value}-alpha` }, [\n '透明度',\n h('input', {\n type: 'range',\n min: 0,\n max: 1,\n step: 0.01,\n 'aria-label': '透明度',\n value: colorAlpha(props.value),\n disabled: disabled.value,\n onInput: (event: Event) =>\n change(colorWithAlpha(props.value || '#000000', Number((event.target as HTMLInputElement).value))),\n }),\n ])\n : null,\n !props.disableFields\n ? h('input', {\n 'aria-label': '颜色值',\n value: props.value,\n disabled: disabled.value,\n onInput: (event: Event) => change((event.target as HTMLInputElement).value),\n })\n : null,\n props.presetColors.length\n ? h(\n 'div',\n { class: `${prefixCls.value}-presets` },\n props.presetColors.map((color) =>\n h('button', {\n key: color,\n type: 'button',\n 'aria-label': `选择 ${color}`,\n title: color,\n disabled: disabled.value,\n style: { backgroundColor: color },\n onClick: () => change(props.disableAlpha ? colorWithAlpha(color, 1, true) : color),\n }),\n ),\n )\n : null,\n ]);\n\n return () =>\n h('div', { ref: container, class: prefixCls.value }, [\n h(\n Input,\n {\n ...attrs,\n ref: input,\n value: props.value,\n onChange: (event: Event) => change((event.target as HTMLInputElement).value),\n },\n {\n ...slots,\n prefix: () =>\n h(\n Popover,\n {\n ...props.popupProps,\n trigger: 'click',\n ...(disabled.value ? { open: false } : {}),\n getPopupContainer: () => container.value || document.body,\n },\n {\n content: renderPicker,\n default: () =>\n h('button', {\n type: 'button',\n class: `${prefixCls.value}-color-tips`,\n 'aria-label': '打开颜色选择器',\n disabled: disabled.value,\n style: { backgroundColor: props.value },\n }),\n },\n ),\n },\n ),\n ]);\n },\n});\n"],"names":[],"mappings":";;;;AAkBA,MAAA,aAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,OAAO;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,IACd,eAAe;AAAA,IACf,cAAc,EAAE,MAAM,OAA6B,SAAS,MAAM,CAAA,EAAC;AAAA,IACnE,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,WAAW;AAAA,EAAA;AAAA,EAEb,OAAO,CAAC,UAAU,cAAc;AAAA,EAChC,MAAM,OAAO,EAAE,OAAO,MAAM,OAAO,UAAU;AAC3C,UAAM,YAAY,IAAA;AAClB,UAAM,QAAQ,IAAA;AACd,UAAM,EAAE,aAAA,IAAiB,uBAAA;AACzB,UAAM,YAAY,SAAS,MAAM,aAAa,eAAe,MAAM,SAAS,CAAC;AAC7E,UAAM,SAAS,CAAC,UAAkB;AAChC,WAAK,gBAAgB,KAAK;AAC1B,WAAK,UAAU,KAAK;AAAA,IACtB;AACA,UAAM,cAAc,CAAC,UAAkB,OAAO,eAAe,OAAO,WAAW,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC;AAChH,UAAM,WAAW,SAAS,MAAM,CAAC,CAAC,MAAM,QAAQ;AAChD,WAAO,EAAE,OAAO,MAAM,MAAM,OAAO,SAAS,MAAM,MAA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IAAI,IAAI,KAAK;AAAA,UAAA,CAClF;AAAA,QAAA;AAAA,MACH,IAEF;AAAA,IAAA,CACL;AAEH,WAAO,MACL,EAAE,OAAO,EAAE,KAAK,WAAW,OAAO,UAAU,SAAS;AAAA,MACnD;AAAA,QACE;AAAA,QACA;AAAA,UACE,GAAG;AAAA,UACH,KAAK;AAAA,UACL,OAAO,MAAM;AAAA,UACb,UAAU,CAAC,UAAiB,OAAQ,MAAM,OAA4B,KAAK;AAAA,QAAA;AAAA,QAE7E;AAAA,UACE,GAAG;AAAA,UACH,QAAQ,MACN;AAAA,YACE;AAAA,YACA;AAAA,cACE,GAAG,MAAM;AAAA,cACT,SAAS;AAAA,cACT,GAAI,SAAS,QAAQ,EAAE,MAAM,MAAA,IAAU,CAAA;AAAA,cACvC,mBAAmB,MAAM,UAAU,SAAS,SAAS;AAAA,YAAA;AAAA,YAEvD;AAAA,cACE,SAAS;AAAA,cACT,SAAS,MACP,EAAE,UAAU;AAAA,gBACV,MAAM;AAAA,gBACN,OAAO,GAAG,UAAU,KAAK;AAAA,gBACzB,cAAc;AAAA,gBACd,UAAU,SAAS;AAAA,gBACnB,OAAO,EAAE,iBAAiB,MAAM,MAAA;AAAA,cAAM,CACvC;AAAA,YAAA;AAAA,UACL;AAAA,QACF;AAAA,MACJ;AAAA,IACF,CACD;AAAA,EACL;AACF,CAAC;"}
1
+ {"version":3,"file":"ColorInput.js","sources":["../../../src/components/color-input/ColorInput.ts"],"sourcesContent":["import { computed, defineComponent, h, ref, shallowRef, watch } from 'vue';\nimport { Input, Popover } from 'ant-design-vue';\nimport { useConfigContextInject } from 'ant-design-vue/es/config-provider/context';\nimport { useInjectDisabled } from 'ant-design-vue/es/config-provider/DisabledContext';\nimport tinycolor from 'tinycolor2';\nimport { colorWithAlpha } from './helpers';\nimport type { PropType } from 'vue';\nimport type { PopoverProps } from 'ant-design-vue';\n\nconst paletteKeys: Partial<Record<string, [number, number]>> = {\n ArrowLeft: [-0.01, 0],\n ArrowRight: [0.01, 0],\n ArrowDown: [0, -0.01],\n ArrowUp: [0, 0.01],\n};\n\nconst clampUnit = (value: number) => Math.max(0, Math.min(1, value));\n\nexport interface ColorInputProps {\n value?: string;\n disabled?: boolean;\n disableAlpha?: boolean;\n disableFields?: boolean;\n presetColors?: string[];\n popupProps?: Partial<PopoverProps>;\n prefixCls?: string;\n /** @deprecated 使用 disableAlpha、disableFields、presetColors 配置色盘。 */\n colorPickerProps?: Record<string, unknown>;\n}\n\nexport default defineComponent({\n name: 'ColorInput',\n inheritAttrs: false,\n props: {\n value: String,\n disabled: { type: Boolean, default: undefined },\n disableAlpha: Boolean,\n disableFields: Boolean,\n presetColors: { type: Array as PropType<string[]>, default: () => [] },\n popupProps: Object as PropType<Partial<PopoverProps>>,\n colorPickerProps: Object as PropType<Record<string, unknown>>,\n prefixCls: String,\n },\n emits: ['change', 'update:value'],\n setup(props, { attrs, emit, slots, expose }) {\n const container = ref<HTMLElement>();\n const input = ref<any>();\n const { getPrefixCls } = useConfigContextInject();\n const contextDisabled = useInjectDisabled();\n const disabled = computed(() => props.disabled ?? contextDisabled.value);\n const prefixCls = computed(() => getPrefixCls('color-input', props.prefixCls));\n const hsv = computed(() => tinycolor(props.value || '#000000').toHsv());\n const hue = shallowRef(hsv.value.h);\n watch(hsv, ({ h: nextHue, s, v }) => {\n // 黑色和灰色没有可还原的色相,保留用户在滑条上选中的色相。\n if (s && v) hue.value = nextHue;\n });\n\n const change = (value: string) => {\n emit('update:value', value);\n emit('change', value);\n };\n const selectColor = (s: number, v: number) => {\n change(colorWithAlpha({ h: hue.value, s: clampUnit(s), v: clampUnit(v) }, hsv.value.a, props.disableAlpha));\n };\n const selectFromPointer = (event: PointerEvent) => {\n const { left, top, width, height } = (event.currentTarget as HTMLElement).getBoundingClientRect();\n if (width && height) selectColor((event.clientX - left) / width, 1 - (event.clientY - top) / height);\n };\n expose({ focus: () => input.value?.focus(), blur: () => input.value?.blur() });\n\n const renderPicker = () => {\n const { s, v, a } = hsv.value;\n const pickerPrefix = prefixCls.value;\n return h('div', { class: `${pickerPrefix}-picker` }, [\n h(\n 'div',\n {\n class: `${pickerPrefix}-palette`,\n role: 'slider',\n tabindex: disabled.value ? -1 : 0,\n 'aria-label': '饱和度和明度',\n 'aria-valuemin': 0,\n 'aria-valuemax': 100,\n 'aria-valuenow': Math.round(s * 100),\n 'aria-valuetext': `饱和度 ${Math.round(s * 100)}%,明度 ${Math.round(v * 100)}%`,\n 'aria-disabled': disabled.value,\n style: { backgroundColor: `hsl(${hue.value}, 100%, 50%)` },\n onPointerdown: (event: PointerEvent) => {\n if (disabled.value || event.button !== 0) return;\n const palette = event.currentTarget as HTMLElement;\n palette.setPointerCapture?.(event.pointerId);\n selectFromPointer(event);\n },\n onPointermove: (event: PointerEvent) => {\n if (!disabled.value && (event.currentTarget as HTMLElement).hasPointerCapture?.(event.pointerId)) {\n selectFromPointer(event);\n }\n },\n onKeydown: (event: KeyboardEvent) => {\n const delta = paletteKeys[event.key];\n if (disabled.value || !delta) return;\n event.preventDefault();\n selectColor(s + delta[0], v + delta[1]);\n },\n },\n h('span', {\n class: `${pickerPrefix}-palette-marker`,\n style: { left: `${s * 100}%`, top: `${(1 - v) * 100}%` },\n }),\n ),\n h('input', {\n class: `${pickerPrefix}-hue`,\n type: 'range',\n min: 0,\n max: 359,\n 'aria-label': '色相',\n value: Math.round(hue.value) % 360,\n disabled: disabled.value,\n onInput: (event: Event) => {\n hue.value = (event.target as HTMLInputElement).valueAsNumber;\n selectColor(s, v);\n },\n }),\n !props.disableAlpha\n ? h('label', { class: `${pickerPrefix}-alpha` }, [\n '透明度',\n h('input', {\n type: 'range',\n min: 0,\n max: 1,\n step: 0.01,\n 'aria-label': '透明度',\n value: a,\n disabled: disabled.value,\n onInput: (event: Event) =>\n change(colorWithAlpha(props.value || '#000000', (event.target as HTMLInputElement).valueAsNumber)),\n }),\n ])\n : null,\n !props.disableFields\n ? h('input', {\n 'aria-label': '颜色值',\n value: props.value,\n disabled: disabled.value,\n onInput: (event: Event) => change((event.target as HTMLInputElement).value),\n })\n : null,\n props.presetColors.length\n ? h(\n 'div',\n { class: `${pickerPrefix}-presets` },\n props.presetColors.map((color) =>\n h('button', {\n key: color,\n type: 'button',\n 'aria-label': `选择 ${color}`,\n title: color,\n disabled: disabled.value,\n style: { backgroundColor: color },\n onClick: () => change(props.disableAlpha ? colorWithAlpha(color, 1, true) : color),\n }),\n ),\n )\n : null,\n ]);\n };\n\n return () =>\n h('div', { ref: container, class: prefixCls.value }, [\n h(\n Input,\n {\n ...attrs,\n ref: input,\n value: props.value,\n disabled: disabled.value,\n onChange: (event: Event) => change((event.target as HTMLInputElement).value),\n },\n {\n ...slots,\n prefix: () =>\n h(\n Popover,\n {\n ...props.popupProps,\n trigger: 'click',\n ...(disabled.value ? { open: false } : {}),\n getPopupContainer: () => container.value || document.body,\n },\n {\n content: renderPicker,\n default: () =>\n h('button', {\n type: 'button',\n class: `${prefixCls.value}-color-tips`,\n 'aria-label': '打开颜色选择器',\n disabled: disabled.value,\n style: { backgroundColor: props.value },\n }),\n },\n ),\n },\n ),\n ]);\n },\n});\n"],"names":[],"mappings":";;;;;;AASA,MAAM,cAAyD;AAAA,EAC7D,WAAW,CAAC,OAAO,CAAC;AAAA,EACpB,YAAY,CAAC,MAAM,CAAC;AAAA,EACpB,WAAW,CAAC,GAAG,KAAK;AAAA,EACpB,SAAS,CAAC,GAAG,IAAI;AACnB;AAEA,MAAM,YAAY,CAAC,UAAkB,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAcnE,MAAA,aAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,OAAO;AAAA,IACL,OAAO;AAAA,IACP,UAAU,EAAE,MAAM,SAAS,SAAS,OAAA;AAAA,IACpC,cAAc;AAAA,IACd,eAAe;AAAA,IACf,cAAc,EAAE,MAAM,OAA6B,SAAS,MAAM,CAAA,EAAC;AAAA,IACnE,YAAY;AAAA,IACZ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,OAAO,EAAE,KAAK,WAAW,OAAO,UAAU,SAAS;AAAA,MACnD;AAAA,QACE;AAAA,QACA;AAAA,UACE,GAAG;AAAA,UACH,KAAK;AAAA,UACL,OAAO,MAAM;AAAA,UACb,UAAU,SAAS;AAAA,UACnB,UAAU,CAAC,UAAiB,OAAQ,MAAM,OAA4B,KAAK;AAAA,QAAA;AAAA,QAE7E;AAAA,UACE,GAAG;AAAA,UACH,QAAQ,MACN;AAAA,YACE;AAAA,YACA;AAAA,cACE,GAAG,MAAM;AAAA,cACT,SAAS;AAAA,cACT,GAAI,SAAS,QAAQ,EAAE,MAAM,MAAA,IAAU,CAAA;AAAA,cACvC,mBAAmB,MAAM,UAAU,SAAS,SAAS;AAAA,YAAA;AAAA,YAEvD;AAAA,cACE,SAAS;AAAA,cACT,SAAS,MACP,EAAE,UAAU;AAAA,gBACV,MAAM;AAAA,gBACN,OAAO,GAAG,UAAU,KAAK;AAAA,gBACzB,cAAc;AAAA,gBACd,UAAU,SAAS;AAAA,gBACnB,OAAO,EAAE,iBAAiB,MAAM,MAAA;AAAA,cAAM,CACvC;AAAA,YAAA;AAAA,UACL;AAAA,QACF;AAAA,MACJ;AAAA,IACF,CACD;AAAA,EACL;AACF,CAAC;"}
@@ -3,9 +3,8 @@ function colorPickerValue(value) {
3
3
  return tinycolor(value || "#000000").toHexString();
4
4
  }
5
5
  function colorWithAlpha(value, alpha, disableAlpha = false) {
6
- const color = tinycolor(value);
7
- if (disableAlpha) return color.toHexString();
8
- return color.setAlpha(Math.max(0, Math.min(1, alpha))).toRgbString();
6
+ if (disableAlpha) return colorPickerValue(value);
7
+ return tinycolor(value).setAlpha(Math.max(0, Math.min(1, alpha))).toRgbString();
9
8
  }
10
9
  function colorAlpha(value) {
11
10
  return tinycolor(value || "#000000").getAlpha();
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../src/components/color-input/helpers.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\n\nexport function colorPickerValue(value?: string) {\n return tinycolor(value || '#000000').toHexString();\n}\n\nexport function colorWithAlpha(value: string, alpha: number, disableAlpha = false) {\n const color = tinycolor(value);\n if (disableAlpha) return color.toHexString();\n return color.setAlpha(Math.max(0, Math.min(1, alpha))).toRgbString();\n}\n\nexport function colorAlpha(value?: string) {\n return tinycolor(value || '#000000').getAlpha();\n}\n"],"names":[],"mappings":";AAEO,SAAS,iBAAiB,OAAgB;AAC/C,SAAO,UAAU,SAAS,SAAS,EAAE,YAAA;AACvC;AAEO,SAAS,eAAe,OAAe,OAAe,eAAe,OAAO;AACjF,QAAM,QAAQ,UAAU,KAAK;AAC7B,MAAI,aAAc,QAAO,MAAM,YAAA;AAC/B,SAAO,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,YAAA;AACzD;AAEO,SAAS,WAAW,OAAgB;AACzC,SAAO,UAAU,SAAS,SAAS,EAAE,SAAA;AACvC;"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/components/color-input/helpers.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\n\ntype ColorValue = string | { h: number; s: number; v: number };\n\nexport function colorPickerValue(value?: ColorValue) {\n return tinycolor(value || '#000000').toHexString();\n}\n\nexport function colorWithAlpha(value: ColorValue, alpha: number, disableAlpha = false) {\n if (disableAlpha) return colorPickerValue(value);\n return tinycolor(value)\n .setAlpha(Math.max(0, Math.min(1, alpha)))\n .toRgbString();\n}\n\nexport function colorAlpha(value?: string) {\n return tinycolor(value || '#000000').getAlpha();\n}\n"],"names":[],"mappings":";AAIO,SAAS,iBAAiB,OAAoB;AACnD,SAAO,UAAU,SAAS,SAAS,EAAE,YAAA;AACvC;AAEO,SAAS,eAAe,OAAmB,OAAe,eAAe,OAAO;AACrF,MAAI,aAAc,QAAO,iBAAiB,KAAK;AAC/C,SAAO,UAAU,KAAK,EACnB,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,CAAC,EACxC,YAAA;AACL;AAEO,SAAS,WAAW,OAAgB;AACzC,SAAO,UAAU,SAAS,SAAS,EAAE,SAAA;AACvC;"}
@@ -417,6 +417,49 @@
417
417
  gap: 8px;
418
418
  width: 220px;
419
419
  }
420
+ .ant-color-input-palette, .ops-color-input-palette, .kbr-color-input-palette {
421
+ position: relative;
422
+ width: 100%;
423
+ aspect-ratio: 4 / 3;
424
+ border-radius: 4px;
425
+ background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent);
426
+ cursor: crosshair;
427
+ touch-action: none;
428
+ }
429
+ .ant-color-input-palette-marker, .ops-color-input-palette-marker, .kbr-color-input-palette-marker {
430
+ position: absolute;
431
+ width: 12px;
432
+ height: 12px;
433
+ transform: translate(-50%, -50%);
434
+ border: 2px solid #fff;
435
+ border-radius: 50%;
436
+ box-shadow: 0 0 2px #000;
437
+ pointer-events: none;
438
+ }
439
+ .ant-color-input-hue, .ops-color-input-hue, .kbr-color-input-hue {
440
+ width: 100%;
441
+ height: 12px;
442
+ margin: 0;
443
+ appearance: none;
444
+ border-radius: 4px;
445
+ background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
446
+ cursor: pointer;
447
+ }
448
+ .ant-color-input-hue::-webkit-slider-thumb, .ops-color-input-hue::-webkit-slider-thumb, .kbr-color-input-hue::-webkit-slider-thumb {
449
+ appearance: none;
450
+ width: 10px;
451
+ height: 14px;
452
+ border: 1px solid #595959;
453
+ border-radius: 3px;
454
+ background: #fff;
455
+ }
456
+ .ant-color-input-hue::-moz-range-thumb, .ops-color-input-hue::-moz-range-thumb, .kbr-color-input-hue::-moz-range-thumb {
457
+ width: 10px;
458
+ height: 14px;
459
+ border: 1px solid #595959;
460
+ border-radius: 3px;
461
+ background: #fff;
462
+ }
420
463
  .ant-color-input-alpha, .ops-color-input-alpha, .kbr-color-input-alpha {
421
464
  display: flex;
422
465
  align-items: center;
@@ -8688,6 +8731,49 @@ a.info--text:focus,
8688
8731
  gap: 8px;
8689
8732
  width: 220px;
8690
8733
  }
8734
+ .ant-color-input-palette, .ops-color-input-palette, .kbr-color-input-palette {
8735
+ position: relative;
8736
+ width: 100%;
8737
+ aspect-ratio: 4 / 3;
8738
+ border-radius: 4px;
8739
+ background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent);
8740
+ cursor: crosshair;
8741
+ touch-action: none;
8742
+ }
8743
+ .ant-color-input-palette-marker, .ops-color-input-palette-marker, .kbr-color-input-palette-marker {
8744
+ position: absolute;
8745
+ width: 12px;
8746
+ height: 12px;
8747
+ transform: translate(-50%, -50%);
8748
+ border: 2px solid #fff;
8749
+ border-radius: 50%;
8750
+ box-shadow: 0 0 2px #000;
8751
+ pointer-events: none;
8752
+ }
8753
+ .ant-color-input-hue, .ops-color-input-hue, .kbr-color-input-hue {
8754
+ width: 100%;
8755
+ height: 12px;
8756
+ margin: 0;
8757
+ appearance: none;
8758
+ border-radius: 4px;
8759
+ background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
8760
+ cursor: pointer;
8761
+ }
8762
+ .ant-color-input-hue::-webkit-slider-thumb, .ops-color-input-hue::-webkit-slider-thumb, .kbr-color-input-hue::-webkit-slider-thumb {
8763
+ appearance: none;
8764
+ width: 10px;
8765
+ height: 14px;
8766
+ border: 1px solid #595959;
8767
+ border-radius: 3px;
8768
+ background: #fff;
8769
+ }
8770
+ .ant-color-input-hue::-moz-range-thumb, .ops-color-input-hue::-moz-range-thumb, .kbr-color-input-hue::-moz-range-thumb {
8771
+ width: 10px;
8772
+ height: 14px;
8773
+ border: 1px solid #595959;
8774
+ border-radius: 3px;
8775
+ background: #fff;
8776
+ }
8691
8777
  .ant-color-input-alpha, .ops-color-input-alpha, .kbr-color-input-alpha {
8692
8778
  display: flex;
8693
8779
  align-items: center;
@@ -3,12 +3,24 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const vue = require("vue");
4
4
  const antDesignVue = require("ant-design-vue");
5
5
  const context = require("ant-design-vue/lib/config-provider/context");
6
+ const DisabledContext = require("ant-design-vue/lib/config-provider/DisabledContext");
7
+ const tinycolor = require("tinycolor2");
6
8
  const components_colorInput_helpers = require("./helpers.js");
9
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
10
+ const tinycolor__default = /* @__PURE__ */ _interopDefault(tinycolor);
11
+ const paletteKeys = {
12
+ ArrowLeft: [-0.01, 0],
13
+ ArrowRight: [0.01, 0],
14
+ ArrowDown: [0, -0.01],
15
+ ArrowUp: [0, 0.01]
16
+ };
17
+ const clampUnit = (value) => Math.max(0, Math.min(1, value));
7
18
  const ColorInput = vue.defineComponent({
8
19
  name: "ColorInput",
9
20
  inheritAttrs: false,
10
21
  props: {
11
22
  value: String,
23
+ disabled: { type: Boolean, default: void 0 },
12
24
  disableAlpha: Boolean,
13
25
  disableFields: Boolean,
14
26
  presetColors: { type: Array, default: () => [] },
@@ -21,57 +33,115 @@ const ColorInput = vue.defineComponent({
21
33
  const container = vue.ref();
22
34
  const input = vue.ref();
23
35
  const { getPrefixCls } = context.useConfigContextInject();
36
+ const contextDisabled = DisabledContext.useInjectDisabled();
37
+ const disabled = vue.computed(() => props.disabled ?? contextDisabled.value);
24
38
  const prefixCls = vue.computed(() => getPrefixCls("color-input", props.prefixCls));
39
+ const hsv = vue.computed(() => tinycolor__default.default(props.value || "#000000").toHsv());
40
+ const hue = vue.shallowRef(hsv.value.h);
41
+ vue.watch(hsv, ({ h: nextHue, s, v }) => {
42
+ if (s && v) hue.value = nextHue;
43
+ });
25
44
  const change = (value) => {
26
45
  emit("update:value", value);
27
46
  emit("change", value);
28
47
  };
29
- const selectColor = (value) => change(components_colorInput_helpers.colorWithAlpha(value, components_colorInput_helpers.colorAlpha(props.value), props.disableAlpha));
30
- const disabled = vue.computed(() => !!attrs.disabled);
48
+ const selectColor = (s, v) => {
49
+ change(components_colorInput_helpers.colorWithAlpha({ h: hue.value, s: clampUnit(s), v: clampUnit(v) }, hsv.value.a, props.disableAlpha));
50
+ };
51
+ const selectFromPointer = (event) => {
52
+ const { left, top, width, height } = event.currentTarget.getBoundingClientRect();
53
+ if (width && height) selectColor((event.clientX - left) / width, 1 - (event.clientY - top) / height);
54
+ };
31
55
  expose({ focus: () => input.value?.focus(), blur: () => input.value?.blur() });
32
- const renderPicker = () => vue.h("div", { class: `${prefixCls.value}-picker` }, [
33
- vue.h("input", {
34
- type: "color",
35
- "aria-label": "选择颜色",
36
- value: components_colorInput_helpers.colorPickerValue(props.value),
37
- disabled: disabled.value,
38
- onInput: (event) => selectColor(event.target.value)
39
- }),
40
- !props.disableAlpha ? vue.h("label", { class: `${prefixCls.value}-alpha` }, [
41
- "透明度",
56
+ const renderPicker = () => {
57
+ const { s, v, a } = hsv.value;
58
+ const pickerPrefix = prefixCls.value;
59
+ return vue.h("div", { class: `${pickerPrefix}-picker` }, [
60
+ vue.h(
61
+ "div",
62
+ {
63
+ class: `${pickerPrefix}-palette`,
64
+ role: "slider",
65
+ tabindex: disabled.value ? -1 : 0,
66
+ "aria-label": "饱和度和明度",
67
+ "aria-valuemin": 0,
68
+ "aria-valuemax": 100,
69
+ "aria-valuenow": Math.round(s * 100),
70
+ "aria-valuetext": `饱和度 ${Math.round(s * 100)}%,明度 ${Math.round(v * 100)}%`,
71
+ "aria-disabled": disabled.value,
72
+ style: { backgroundColor: `hsl(${hue.value}, 100%, 50%)` },
73
+ onPointerdown: (event) => {
74
+ if (disabled.value || event.button !== 0) return;
75
+ const palette = event.currentTarget;
76
+ palette.setPointerCapture?.(event.pointerId);
77
+ selectFromPointer(event);
78
+ },
79
+ onPointermove: (event) => {
80
+ if (!disabled.value && event.currentTarget.hasPointerCapture?.(event.pointerId)) {
81
+ selectFromPointer(event);
82
+ }
83
+ },
84
+ onKeydown: (event) => {
85
+ const delta = paletteKeys[event.key];
86
+ if (disabled.value || !delta) return;
87
+ event.preventDefault();
88
+ selectColor(s + delta[0], v + delta[1]);
89
+ }
90
+ },
91
+ vue.h("span", {
92
+ class: `${pickerPrefix}-palette-marker`,
93
+ style: { left: `${s * 100}%`, top: `${(1 - v) * 100}%` }
94
+ })
95
+ ),
42
96
  vue.h("input", {
97
+ class: `${pickerPrefix}-hue`,
43
98
  type: "range",
44
99
  min: 0,
45
- max: 1,
46
- step: 0.01,
47
- "aria-label": "透明度",
48
- value: components_colorInput_helpers.colorAlpha(props.value),
100
+ max: 359,
101
+ "aria-label": "色相",
102
+ value: Math.round(hue.value) % 360,
49
103
  disabled: disabled.value,
50
- onInput: (event) => change(components_colorInput_helpers.colorWithAlpha(props.value || "#000000", Number(event.target.value)))
51
- })
52
- ]) : null,
53
- !props.disableFields ? vue.h("input", {
54
- "aria-label": "颜色值",
55
- value: props.value,
56
- disabled: disabled.value,
57
- onInput: (event) => change(event.target.value)
58
- }) : null,
59
- props.presetColors.length ? vue.h(
60
- "div",
61
- { class: `${prefixCls.value}-presets` },
62
- props.presetColors.map(
63
- (color) => vue.h("button", {
64
- key: color,
65
- type: "button",
66
- "aria-label": `选择 ${color}`,
67
- title: color,
104
+ onInput: (event) => {
105
+ hue.value = event.target.valueAsNumber;
106
+ selectColor(s, v);
107
+ }
108
+ }),
109
+ !props.disableAlpha ? vue.h("label", { class: `${pickerPrefix}-alpha` }, [
110
+ "透明度",
111
+ vue.h("input", {
112
+ type: "range",
113
+ min: 0,
114
+ max: 1,
115
+ step: 0.01,
116
+ "aria-label": "透明度",
117
+ value: a,
68
118
  disabled: disabled.value,
69
- style: { backgroundColor: color },
70
- onClick: () => change(props.disableAlpha ? components_colorInput_helpers.colorWithAlpha(color, 1, true) : color)
119
+ onInput: (event) => change(components_colorInput_helpers.colorWithAlpha(props.value || "#000000", event.target.valueAsNumber))
71
120
  })
72
- )
73
- ) : null
74
- ]);
121
+ ]) : null,
122
+ !props.disableFields ? vue.h("input", {
123
+ "aria-label": "颜色值",
124
+ value: props.value,
125
+ disabled: disabled.value,
126
+ onInput: (event) => change(event.target.value)
127
+ }) : null,
128
+ props.presetColors.length ? vue.h(
129
+ "div",
130
+ { class: `${pickerPrefix}-presets` },
131
+ props.presetColors.map(
132
+ (color) => vue.h("button", {
133
+ key: color,
134
+ type: "button",
135
+ "aria-label": `选择 ${color}`,
136
+ title: color,
137
+ disabled: disabled.value,
138
+ style: { backgroundColor: color },
139
+ onClick: () => change(props.disableAlpha ? components_colorInput_helpers.colorWithAlpha(color, 1, true) : color)
140
+ })
141
+ )
142
+ ) : null
143
+ ]);
144
+ };
75
145
  return () => vue.h("div", { ref: container, class: prefixCls.value }, [
76
146
  vue.h(
77
147
  antDesignVue.Input,
@@ -79,6 +149,7 @@ const ColorInput = vue.defineComponent({
79
149
  ...attrs,
80
150
  ref: input,
81
151
  value: props.value,
152
+ disabled: disabled.value,
82
153
  onChange: (event) => change(event.target.value)
83
154
  },
84
155
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ColorInput.js","sources":["../../../src/components/color-input/ColorInput.ts"],"sourcesContent":["import { computed, defineComponent, h, ref } from 'vue';\nimport { Input, Popover } from 'ant-design-vue';\nimport { useConfigContextInject } from 'ant-design-vue/es/config-provider/context';\nimport { colorAlpha, colorPickerValue, colorWithAlpha } from './helpers';\nimport type { PropType } from 'vue';\nimport type { PopoverProps } from 'ant-design-vue';\n\nexport interface ColorInputProps {\n value?: string;\n disableAlpha?: boolean;\n disableFields?: boolean;\n presetColors?: string[];\n popupProps?: Partial<PopoverProps>;\n prefixCls?: string;\n /** @deprecated 使用 disableAlpha、disableFields、presetColors 配置色盘。 */\n colorPickerProps?: Record<string, unknown>;\n}\n\nexport default defineComponent({\n name: 'ColorInput',\n inheritAttrs: false,\n props: {\n value: String,\n disableAlpha: Boolean,\n disableFields: Boolean,\n presetColors: { type: Array as PropType<string[]>, default: () => [] },\n popupProps: Object as PropType<Partial<PopoverProps>>,\n colorPickerProps: Object as PropType<Record<string, unknown>>,\n prefixCls: String,\n },\n emits: ['change', 'update:value'],\n setup(props, { attrs, emit, slots, expose }) {\n const container = ref<HTMLElement>();\n const input = ref<any>();\n const { getPrefixCls } = useConfigContextInject();\n const prefixCls = computed(() => getPrefixCls('color-input', props.prefixCls));\n const change = (value: string) => {\n emit('update:value', value);\n emit('change', value);\n };\n const selectColor = (value: string) => change(colorWithAlpha(value, colorAlpha(props.value), props.disableAlpha));\n const disabled = computed(() => !!attrs.disabled);\n expose({ focus: () => input.value?.focus(), blur: () => input.value?.blur() });\n\n const renderPicker = () =>\n h('div', { class: `${prefixCls.value}-picker` }, [\n h('input', {\n type: 'color',\n 'aria-label': '选择颜色',\n value: colorPickerValue(props.value),\n disabled: disabled.value,\n onInput: (event: Event) => selectColor((event.target as HTMLInputElement).value),\n }),\n !props.disableAlpha\n ? h('label', { class: `${prefixCls.value}-alpha` }, [\n '透明度',\n h('input', {\n type: 'range',\n min: 0,\n max: 1,\n step: 0.01,\n 'aria-label': '透明度',\n value: colorAlpha(props.value),\n disabled: disabled.value,\n onInput: (event: Event) =>\n change(colorWithAlpha(props.value || '#000000', Number((event.target as HTMLInputElement).value))),\n }),\n ])\n : null,\n !props.disableFields\n ? h('input', {\n 'aria-label': '颜色值',\n value: props.value,\n disabled: disabled.value,\n onInput: (event: Event) => change((event.target as HTMLInputElement).value),\n })\n : null,\n props.presetColors.length\n ? h(\n 'div',\n { class: `${prefixCls.value}-presets` },\n props.presetColors.map((color) =>\n h('button', {\n key: color,\n type: 'button',\n 'aria-label': `选择 ${color}`,\n title: color,\n disabled: disabled.value,\n style: { backgroundColor: color },\n onClick: () => change(props.disableAlpha ? colorWithAlpha(color, 1, true) : color),\n }),\n ),\n )\n : null,\n ]);\n\n return () =>\n h('div', { ref: container, class: prefixCls.value }, [\n h(\n Input,\n {\n ...attrs,\n ref: input,\n value: props.value,\n onChange: (event: Event) => change((event.target as HTMLInputElement).value),\n },\n {\n ...slots,\n prefix: () =>\n h(\n Popover,\n {\n ...props.popupProps,\n trigger: 'click',\n ...(disabled.value ? { open: false } : {}),\n getPopupContainer: () => container.value || document.body,\n },\n {\n content: renderPicker,\n default: () =>\n h('button', {\n type: 'button',\n class: `${prefixCls.value}-color-tips`,\n 'aria-label': '打开颜色选择器',\n disabled: disabled.value,\n style: { backgroundColor: props.value },\n }),\n },\n ),\n },\n ),\n ]);\n },\n});\n"],"names":["defineComponent","ref","useConfigContextInject","computed","colorWithAlpha","colorAlpha","h","colorPickerValue","Input","Popover"],"mappings":";;;;;;AAkBA,MAAA,aAAeA,oBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,OAAO;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,IACd,eAAe;AAAA,IACf,cAAc,EAAE,MAAM,OAA6B,SAAS,MAAM,CAAA,EAAC;AAAA,IACnE,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,WAAW;AAAA,EAAA;AAAA,EAEb,OAAO,CAAC,UAAU,cAAc;AAAA,EAChC,MAAM,OAAO,EAAE,OAAO,MAAM,OAAO,UAAU;AAC3C,UAAM,YAAYC,IAAAA,IAAA;AAClB,UAAM,QAAQA,IAAAA,IAAA;AACd,UAAM,EAAE,aAAA,IAAiBC,+BAAA;AACzB,UAAM,YAAYC,IAAAA,SAAS,MAAM,aAAa,eAAe,MAAM,SAAS,CAAC;AAC7E,UAAM,SAAS,CAAC,UAAkB;AAChC,WAAK,gBAAgB,KAAK;AAC1B,WAAK,UAAU,KAAK;AAAA,IACtB;AACA,UAAM,cAAc,CAAC,UAAkB,OAAOC,8BAAAA,eAAe,OAAOC,8BAAAA,WAAW,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC;AAChH,UAAM,WAAWF,IAAAA,SAAS,MAAM,CAAC,CAAC,MAAM,QAAQ;AAChD,WAAO,EAAE,OAAO,MAAM,MAAM,OAAO,SAAS,MAAM,MAAM,MAAM,OAAO,KAAA,GAAQ;AAE7E,UAAM,eAAe,MACnBG,MAAE,OAAO,EAAE,OAAO,GAAG,UAAU,KAAK,aAAa;AAAA,MAC/CA,IAAAA,EAAE,SAAS;AAAA,QACT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MACH,IAEF;AAAA,IAAA,CACL;AAEH,WAAO,MACLE,IAAAA,EAAE,OAAO,EAAE,KAAK,WAAW,OAAO,UAAU,SAAS;AAAA,MACnDA,IAAAA;AAAAA,QACEE,aAAAA;AAAAA,QACA;AAAA,UACE,GAAG;AAAA,UACH,KAAK;AAAA,UACL,OAAO,MAAM;AAAA,UACb,UAAU,CAAC,UAAiB,OAAQ,MAAM,OAA4B,KAAK;AAAA,QAAA;AAAA,QAE7E;AAAA,UACE,GAAG;AAAA,UACH,QAAQ,MACNF,IAAAA;AAAAA,YACEG,aAAAA;AAAAA,YACA;AAAA,cACE,GAAG,MAAM;AAAA,cACT,SAAS;AAAA,cACT,GAAI,SAAS,QAAQ,EAAE,MAAM,MAAA,IAAU,CAAA;AAAA,cACvC,mBAAmB,MAAM,UAAU,SAAS,SAAS;AAAA,YAAA;AAAA,YAEvD;AAAA,cACE,SAAS;AAAA,cACT,SAAS,MACPH,IAAAA,EAAE,UAAU;AAAA,gBACV,MAAM;AAAA,gBACN,OAAO,GAAG,UAAU,KAAK;AAAA,gBACzB,cAAc;AAAA,gBACd,UAAU,SAAS;AAAA,gBACnB,OAAO,EAAE,iBAAiB,MAAM,MAAA;AAAA,cAAM,CACvC;AAAA,YAAA;AAAA,UACL;AAAA,QACF;AAAA,MACJ;AAAA,IACF,CACD;AAAA,EACL;AACF,CAAC;;"}
1
+ {"version":3,"file":"ColorInput.js","sources":["../../../src/components/color-input/ColorInput.ts"],"sourcesContent":["import { computed, defineComponent, h, ref, shallowRef, watch } from 'vue';\nimport { Input, Popover } from 'ant-design-vue';\nimport { useConfigContextInject } from 'ant-design-vue/es/config-provider/context';\nimport { useInjectDisabled } from 'ant-design-vue/es/config-provider/DisabledContext';\nimport tinycolor from 'tinycolor2';\nimport { colorWithAlpha } from './helpers';\nimport type { PropType } from 'vue';\nimport type { PopoverProps } from 'ant-design-vue';\n\nconst paletteKeys: Partial<Record<string, [number, number]>> = {\n ArrowLeft: [-0.01, 0],\n ArrowRight: [0.01, 0],\n ArrowDown: [0, -0.01],\n ArrowUp: [0, 0.01],\n};\n\nconst clampUnit = (value: number) => Math.max(0, Math.min(1, value));\n\nexport interface ColorInputProps {\n value?: string;\n disabled?: boolean;\n disableAlpha?: boolean;\n disableFields?: boolean;\n presetColors?: string[];\n popupProps?: Partial<PopoverProps>;\n prefixCls?: string;\n /** @deprecated 使用 disableAlpha、disableFields、presetColors 配置色盘。 */\n colorPickerProps?: Record<string, unknown>;\n}\n\nexport default defineComponent({\n name: 'ColorInput',\n inheritAttrs: false,\n props: {\n value: String,\n disabled: { type: Boolean, default: undefined },\n disableAlpha: Boolean,\n disableFields: Boolean,\n presetColors: { type: Array as PropType<string[]>, default: () => [] },\n popupProps: Object as PropType<Partial<PopoverProps>>,\n colorPickerProps: Object as PropType<Record<string, unknown>>,\n prefixCls: String,\n },\n emits: ['change', 'update:value'],\n setup(props, { attrs, emit, slots, expose }) {\n const container = ref<HTMLElement>();\n const input = ref<any>();\n const { getPrefixCls } = useConfigContextInject();\n const contextDisabled = useInjectDisabled();\n const disabled = computed(() => props.disabled ?? contextDisabled.value);\n const prefixCls = computed(() => getPrefixCls('color-input', props.prefixCls));\n const hsv = computed(() => tinycolor(props.value || '#000000').toHsv());\n const hue = shallowRef(hsv.value.h);\n watch(hsv, ({ h: nextHue, s, v }) => {\n // 黑色和灰色没有可还原的色相,保留用户在滑条上选中的色相。\n if (s && v) hue.value = nextHue;\n });\n\n const change = (value: string) => {\n emit('update:value', value);\n emit('change', value);\n };\n const selectColor = (s: number, v: number) => {\n change(colorWithAlpha({ h: hue.value, s: clampUnit(s), v: clampUnit(v) }, hsv.value.a, props.disableAlpha));\n };\n const selectFromPointer = (event: PointerEvent) => {\n const { left, top, width, height } = (event.currentTarget as HTMLElement).getBoundingClientRect();\n if (width && height) selectColor((event.clientX - left) / width, 1 - (event.clientY - top) / height);\n };\n expose({ focus: () => input.value?.focus(), blur: () => input.value?.blur() });\n\n const renderPicker = () => {\n const { s, v, a } = hsv.value;\n const pickerPrefix = prefixCls.value;\n return h('div', { class: `${pickerPrefix}-picker` }, [\n h(\n 'div',\n {\n class: `${pickerPrefix}-palette`,\n role: 'slider',\n tabindex: disabled.value ? -1 : 0,\n 'aria-label': '饱和度和明度',\n 'aria-valuemin': 0,\n 'aria-valuemax': 100,\n 'aria-valuenow': Math.round(s * 100),\n 'aria-valuetext': `饱和度 ${Math.round(s * 100)}%,明度 ${Math.round(v * 100)}%`,\n 'aria-disabled': disabled.value,\n style: { backgroundColor: `hsl(${hue.value}, 100%, 50%)` },\n onPointerdown: (event: PointerEvent) => {\n if (disabled.value || event.button !== 0) return;\n const palette = event.currentTarget as HTMLElement;\n palette.setPointerCapture?.(event.pointerId);\n selectFromPointer(event);\n },\n onPointermove: (event: PointerEvent) => {\n if (!disabled.value && (event.currentTarget as HTMLElement).hasPointerCapture?.(event.pointerId)) {\n selectFromPointer(event);\n }\n },\n onKeydown: (event: KeyboardEvent) => {\n const delta = paletteKeys[event.key];\n if (disabled.value || !delta) return;\n event.preventDefault();\n selectColor(s + delta[0], v + delta[1]);\n },\n },\n h('span', {\n class: `${pickerPrefix}-palette-marker`,\n style: { left: `${s * 100}%`, top: `${(1 - v) * 100}%` },\n }),\n ),\n h('input', {\n class: `${pickerPrefix}-hue`,\n type: 'range',\n min: 0,\n max: 359,\n 'aria-label': '色相',\n value: Math.round(hue.value) % 360,\n disabled: disabled.value,\n onInput: (event: Event) => {\n hue.value = (event.target as HTMLInputElement).valueAsNumber;\n selectColor(s, v);\n },\n }),\n !props.disableAlpha\n ? h('label', { class: `${pickerPrefix}-alpha` }, [\n '透明度',\n h('input', {\n type: 'range',\n min: 0,\n max: 1,\n step: 0.01,\n 'aria-label': '透明度',\n value: a,\n disabled: disabled.value,\n onInput: (event: Event) =>\n change(colorWithAlpha(props.value || '#000000', (event.target as HTMLInputElement).valueAsNumber)),\n }),\n ])\n : null,\n !props.disableFields\n ? h('input', {\n 'aria-label': '颜色值',\n value: props.value,\n disabled: disabled.value,\n onInput: (event: Event) => change((event.target as HTMLInputElement).value),\n })\n : null,\n props.presetColors.length\n ? h(\n 'div',\n { class: `${pickerPrefix}-presets` },\n props.presetColors.map((color) =>\n h('button', {\n key: color,\n type: 'button',\n 'aria-label': `选择 ${color}`,\n title: color,\n disabled: disabled.value,\n style: { backgroundColor: color },\n onClick: () => change(props.disableAlpha ? colorWithAlpha(color, 1, true) : color),\n }),\n ),\n )\n : null,\n ]);\n };\n\n return () =>\n h('div', { ref: container, class: prefixCls.value }, [\n h(\n Input,\n {\n ...attrs,\n ref: input,\n value: props.value,\n disabled: disabled.value,\n onChange: (event: Event) => change((event.target as HTMLInputElement).value),\n },\n {\n ...slots,\n prefix: () =>\n h(\n Popover,\n {\n ...props.popupProps,\n trigger: 'click',\n ...(disabled.value ? { open: false } : {}),\n getPopupContainer: () => container.value || document.body,\n },\n {\n content: renderPicker,\n default: () =>\n h('button', {\n type: 'button',\n class: `${prefixCls.value}-color-tips`,\n 'aria-label': '打开颜色选择器',\n disabled: disabled.value,\n style: { backgroundColor: props.value },\n }),\n },\n ),\n },\n ),\n ]);\n },\n});\n"],"names":["defineComponent","ref","useConfigContextInject","useInjectDisabled","computed","tinycolor","shallowRef","watch","colorWithAlpha","h","Input","Popover"],"mappings":";;;;;;;;;;AASA,MAAM,cAAyD;AAAA,EAC7D,WAAW,CAAC,OAAO,CAAC;AAAA,EACpB,YAAY,CAAC,MAAM,CAAC;AAAA,EACpB,WAAW,CAAC,GAAG,KAAK;AAAA,EACpB,SAAS,CAAC,GAAG,IAAI;AACnB;AAEA,MAAM,YAAY,CAAC,UAAkB,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAcnE,MAAA,aAAeA,oBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,OAAO;AAAA,IACL,OAAO;AAAA,IACP,UAAU,EAAE,MAAM,SAAS,SAAS,OAAA;AAAA,IACpC,cAAc;AAAA,IACd,eAAe;AAA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AA,cACzB,OAAO;AAAA,cACP,UAAU,SAAS;AAAA,cACnB,OAAO,EAAE,iBAAiB,MAAA;AAAA,cAC1B,SAAS,MAAM,OAAO,MAAM,eAAeD,8BAAAA,eAAe,OAAO,GAAG,IAAI,IAAI,KAAK;AAAA,YAAA,CAClF;AAAA,UAAA;AAAA,QACH,IAEF;AAAA,MAAA,CACL;AAAA,IACH;AAEA,WAAO,MACLC,IAAAA,EAAE,OAAO,EAAE,KAAK,WAAW,OAAO,UAAU,SAAS;AAAA,MACnDA,IAAAA;AAAAA,QACEC,aAAAA;AAAAA,QACA;AAAA,UACE,GAAG;AAAA,UACH,KAAK;AAAA,UACL,OAAO,MAAM;AAAA,UACb,UAAU,SAAS;AAAA,UACnB,UAAU,CAAC,UAAiB,OAAQ,MAAM,OAA4B,KAAK;AAAA,QAAA;AAAA,QAE7E;AAAA,UACE,GAAG;AAAA,UACH,QAAQ,MACND,IAAAA;AAAAA,YACEE,aAAAA;AAAAA,YACA;AAAA,cACE,GAAG,MAAM;AAAA,cACT,SAAS;AAAA,cACT,GAAI,SAAS,QAAQ,EAAE,MAAM,MAAA,IAAU,CAAA;AAAA,cACvC,mBAAmB,MAAM,UAAU,SAAS,SAAS;AAAA,YAAA;AAAA,YAEvD;AAAA,cACE,SAAS;AAAA,cACT,SAAS,MACPF,IAAAA,EAAE,UAAU;AAAA,gBACV,MAAM;AAAA,gBACN,OAAO,GAAG,UAAU,KAAK;AAAA,gBACzB,cAAc;AAAA,gBACd,UAAU,SAAS;AAAA,gBACnB,OAAO,EAAE,iBAAiB,MAAM,MAAA;AAAA,cAAM,CACvC;AAAA,YAAA;AAAA,UACL;AAAA,QACF;AAAA,MACJ;AAAA,IACF,CACD;AAAA,EACL;AACF,CAAC;;"}
@@ -7,9 +7,8 @@ function colorPickerValue(value) {
7
7
  return tinycolor__default.default(value || "#000000").toHexString();
8
8
  }
9
9
  function colorWithAlpha(value, alpha, disableAlpha = false) {
10
- const color = tinycolor__default.default(value);
11
- if (disableAlpha) return color.toHexString();
12
- return color.setAlpha(Math.max(0, Math.min(1, alpha))).toRgbString();
10
+ if (disableAlpha) return colorPickerValue(value);
11
+ return tinycolor__default.default(value).setAlpha(Math.max(0, Math.min(1, alpha))).toRgbString();
13
12
  }
14
13
  function colorAlpha(value) {
15
14
  return tinycolor__default.default(value || "#000000").getAlpha();
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../src/components/color-input/helpers.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\n\nexport function colorPickerValue(value?: string) {\n return tinycolor(value || '#000000').toHexString();\n}\n\nexport function colorWithAlpha(value: string, alpha: number, disableAlpha = false) {\n const color = tinycolor(value);\n if (disableAlpha) return color.toHexString();\n return color.setAlpha(Math.max(0, Math.min(1, alpha))).toRgbString();\n}\n\nexport function colorAlpha(value?: string) {\n return tinycolor(value || '#000000').getAlpha();\n}\n"],"names":["tinycolor"],"mappings":";;;;;AAEO,SAAS,iBAAiB,OAAgB;AAC/C,SAAOA,2BAAU,SAAS,SAAS,EAAE,YAAA;AACvC;AAEO,SAAS,eAAe,OAAe,OAAe,eAAe,OAAO;AACjF,QAAM,QAAQA,mBAAAA,QAAU,KAAK;AAC7B,MAAI,aAAc,QAAO,MAAM,YAAA;AAC/B,SAAO,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,YAAA;AACzD;AAEO,SAAS,WAAW,OAAgB;AACzC,SAAOA,2BAAU,SAAS,SAAS,EAAE,SAAA;AACvC;;;;"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/components/color-input/helpers.ts"],"sourcesContent":["import tinycolor from 'tinycolor2';\n\ntype ColorValue = string | { h: number; s: number; v: number };\n\nexport function colorPickerValue(value?: ColorValue) {\n return tinycolor(value || '#000000').toHexString();\n}\n\nexport function colorWithAlpha(value: ColorValue, alpha: number, disableAlpha = false) {\n if (disableAlpha) return colorPickerValue(value);\n return tinycolor(value)\n .setAlpha(Math.max(0, Math.min(1, alpha)))\n .toRgbString();\n}\n\nexport function colorAlpha(value?: string) {\n return tinycolor(value || '#000000').getAlpha();\n}\n"],"names":["tinycolor"],"mappings":";;;;;AAIO,SAAS,iBAAiB,OAAoB;AACnD,SAAOA,2BAAU,SAAS,SAAS,EAAE,YAAA;AACvC;AAEO,SAAS,eAAe,OAAmB,OAAe,eAAe,OAAO;AACrF,MAAI,aAAc,QAAO,iBAAiB,KAAK;AAC/C,SAAOA,mBAAAA,QAAU,KAAK,EACnB,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,CAAC,EACxC,YAAA;AACL;AAEO,SAAS,WAAW,OAAgB;AACzC,SAAOA,2BAAU,SAAS,SAAS,EAAE,SAAA;AACvC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ljweb/layout-antdv-v4",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0-beta.1",
4
4
  "description": "Vue 3 与 Ant Design Vue 4 公共布局和业务组件",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -15,6 +15,54 @@
15
15
  width: 220px;
16
16
  }
17
17
 
18
+ &-palette {
19
+ position: relative;
20
+ width: 100%;
21
+ aspect-ratio: 4 / 3;
22
+ border-radius: 4px;
23
+ background-image: linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent);
24
+ cursor: crosshair;
25
+ touch-action: none;
26
+ }
27
+
28
+ &-palette-marker {
29
+ position: absolute;
30
+ width: 12px;
31
+ height: 12px;
32
+ transform: translate(-50%, -50%);
33
+ border: 2px solid #fff;
34
+ border-radius: 50%;
35
+ box-shadow: 0 0 2px #000;
36
+ pointer-events: none;
37
+ }
38
+
39
+ &-hue {
40
+ width: 100%;
41
+ height: 12px;
42
+ margin: 0;
43
+ appearance: none;
44
+ border-radius: 4px;
45
+ background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
46
+ cursor: pointer;
47
+
48
+ .hue-thumb() {
49
+ width: 10px;
50
+ height: 14px;
51
+ border: 1px solid #595959;
52
+ border-radius: 3px;
53
+ background: #fff;
54
+ }
55
+
56
+ &::-webkit-slider-thumb {
57
+ appearance: none;
58
+ .hue-thumb();
59
+ }
60
+
61
+ &::-moz-range-thumb {
62
+ .hue-thumb();
63
+ }
64
+ }
65
+
18
66
  &-alpha {
19
67
  display: flex;
20
68
  align-items: center;
@@ -2,6 +2,7 @@ import type { PropType } from 'vue';
2
2
  import type { PopoverProps } from 'ant-design-vue';
3
3
  export interface ColorInputProps {
4
4
  value?: string;
5
+ disabled?: boolean;
5
6
  disableAlpha?: boolean;
6
7
  disableFields?: boolean;
7
8
  presetColors?: string[];
@@ -12,6 +13,10 @@ export interface ColorInputProps {
12
13
  }
13
14
  declare const _default: import("vue").DefineComponent<{
14
15
  value: StringConstructor;
16
+ disabled: {
17
+ type: BooleanConstructor;
18
+ default: undefined;
19
+ };
15
20
  disableAlpha: BooleanConstructor;
16
21
  disableFields: BooleanConstructor;
17
22
  presetColors: {
@@ -93,6 +98,10 @@ declare const _default: import("vue").DefineComponent<{
93
98
  [key: string]: any;
94
99
  }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:value")[], "change" | "update:value", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
95
100
  value: StringConstructor;
101
+ disabled: {
102
+ type: BooleanConstructor;
103
+ default: undefined;
104
+ };
96
105
  disableAlpha: BooleanConstructor;
97
106
  disableFields: BooleanConstructor;
98
107
  presetColors: {
@@ -174,6 +183,7 @@ declare const _default: import("vue").DefineComponent<{
174
183
  onChange?: ((...args: any[]) => any) | undefined;
175
184
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
176
185
  }, {
186
+ disabled: boolean;
177
187
  disableAlpha: boolean;
178
188
  disableFields: boolean;
179
189
  presetColors: string[];
@@ -1,3 +1,9 @@
1
- export declare function colorPickerValue(value?: string): string;
2
- export declare function colorWithAlpha(value: string, alpha: number, disableAlpha?: boolean): string;
1
+ type ColorValue = string | {
2
+ h: number;
3
+ s: number;
4
+ v: number;
5
+ };
6
+ export declare function colorPickerValue(value?: ColorValue): string;
7
+ export declare function colorWithAlpha(value: ColorValue, alpha: number, disableAlpha?: boolean): string;
3
8
  export declare function colorAlpha(value?: string): number;
9
+ export {};