@veltra/desktop 1.13.1 → 1.13.2

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.
Files changed (40) hide show
  1. package/dist/components/form/style2.css +9 -32
  2. package/dist/components/palette/palette.js +1 -0
  3. package/dist/components/palette/palette.js.map +1 -1
  4. package/package.json +1 -1
  5. package/src/components/ai-button/__test__/ai-button.test.ts +2 -0
  6. package/src/components/batch-edit/__test__/batch-edit.test.ts +2 -0
  7. package/src/components/button/__test__/button.test.ts +2 -0
  8. package/src/components/cascade/__test__/cascade.test.ts +2 -0
  9. package/src/components/collapse/__test__/collapse.test.ts +2 -0
  10. package/src/components/condition-editor/__test__/condition-editor.test.ts +2 -0
  11. package/src/components/contextmenu/__test__/contextmenu.test.ts +2 -0
  12. package/src/components/date-picker/__test__/date-picker.test.ts +2 -0
  13. package/src/components/date-range-picker/__test__/date-range-picker.test.ts +2 -0
  14. package/src/components/drawer/__test__/drawer.test.ts +2 -0
  15. package/src/components/empty/__test__/empty.test.ts +2 -0
  16. package/src/components/expression-editor/__test__/expression-editor.test.ts +2 -0
  17. package/src/components/file-viewer/__test__/file-viewer.test.ts +2 -0
  18. package/src/components/form/__test__/form.test.ts +2 -0
  19. package/src/components/form/style.scss +11 -46
  20. package/src/components/form-item/__test__/form-item.test.ts +2 -0
  21. package/src/components/image-cropper/__test__/draw-crop.test.ts +2 -0
  22. package/src/components/image-cropper/__test__/image-cropper.test.ts +2 -0
  23. package/src/components/image-cropper/__test__/use-transform.test.ts +2 -0
  24. package/src/components/image-previewer/__test__/image-previewer.test.ts +2 -0
  25. package/src/components/input/__test__/input.test.ts +2 -0
  26. package/src/components/kanban/__test__/kanban.test.ts +2 -0
  27. package/src/components/message-confirm/__test__/message-confirm.test.ts +2 -0
  28. package/src/components/multi-select/__test__/multi-select.test.ts +2 -0
  29. package/src/components/multi-tree-select/__test__/multi-tree-select.test.ts +2 -0
  30. package/src/components/number-input/__test__/number-input.test.ts +2 -0
  31. package/src/components/number-range-input/__test__/number-range-input.test.ts +2 -0
  32. package/src/components/palette/__test__/palette.test.ts +49 -0
  33. package/src/components/palette/palette.vue +5 -0
  34. package/src/components/password-input/__test__/password-input.test.ts +2 -0
  35. package/src/components/radio-group/__test__/radio-group.test.ts +2 -0
  36. package/src/components/rich-text-editor/__test__/image-node.test.ts +2 -0
  37. package/src/components/segment/__test__/segment.test.ts +2 -0
  38. package/src/components/select/__test__/select.test.ts +2 -0
  39. package/src/components/table-editor/__test__/table-editor.test.ts +2 -0
  40. package/src/components/tree-select/__test__/tree-select.test.ts +2 -0
@@ -31,46 +31,23 @@
31
31
  border-radius: var(--u-radius-default);
32
32
  }
33
33
  .u-form__data-before {
34
+ flex-basis: 100%;
35
+ min-width: 0;
34
36
  display: flex;
35
37
  align-items: center;
36
38
  gap: 4px;
37
- flex-wrap: wrap;
38
- margin-top: 4px;
39
- padding: 2px 8px;
40
- border-left: 2px solid var(--u-color-info);
41
- background-color: var(--u-color-info-a-8);
42
- border-radius: 2px;
43
- width: fit-content;
44
- max-width: 100%;
39
+ margin-top: 2px;
40
+ color: var(--u-text-color-second);
45
41
  line-height: 1.4;
46
42
  font-size: var(--u-font-size-assist-default);
47
43
  }
48
- .u-form__data-before:has(.u-input), .u-form__data-before:has(.u-textarea), .u-form__data-before:has(.u-select), .u-form__data-before:has(.u-multi-select), .u-form__data-before:has(.u-multi-tree-select), .u-form__data-before:has(.u-auto-complete), .u-form__data-before:has(.u-cascade), .u-form__data-before:has(.u-date-picker), .u-form__data-before:has(.u-date-range-picker), .u-form__data-before:has(.u-number-input), .u-form__data-before:has(.u-tree-select) {
49
- width: 100%;
50
- }
51
- .u-form__data-before .u-form-item__content {
52
- background: transparent;
53
- padding: 0;
54
- }
55
- .u-form__data-before .u-input,
56
- .u-form__data-before .u-textarea,
57
- .u-form__data-before .u-select,
58
- .u-form__data-before .u-multi-select,
59
- .u-form__data-before .u-multi-tree-select,
60
- .u-form__data-before .u-auto-complete,
61
- .u-form__data-before .u-cascade,
62
- .u-form__data-before .u-date-picker,
63
- .u-form__data-before .u-date-range-picker {
64
- border: none;
65
- box-shadow: none;
66
- background: transparent;
67
- min-height: auto;
68
- height: auto;
69
- padding: 0;
44
+ .u-form__data-before .u-palette {
45
+ width: 14px;
46
+ height: 14px;
47
+ cursor: default;
70
48
  }
71
49
  .u-form__changed-tag {
50
+ flex-shrink: 0;
72
51
  color: var(--u-color-info);
73
- font-size: var(--u-font-size-assist-default);
74
52
  font-style: normal;
75
- flex-shrink: 0;
76
53
  }
@@ -64,6 +64,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
64
64
  skipColorUpdate = false;
65
65
  return;
66
66
  }
67
+ if (!isUserActive()) return;
67
68
  color.value = `#${RGB2HEX(RGB, alpha)}`;
68
69
  });
69
70
  const paletteSVRef = useTemplateRef("palette-sv");
@@ -1 +1 @@
1
- {"version":3,"file":"palette.js","names":["_useModel","_openBlock","_createBlock","_unref","UTip","_normalizeClass","_withCtx","_createCommentVNode","_createVNode","PaletteSV","PaletteHue","PaletteAlpha","PaletteColorSwitch","_createElementVNode","_normalizeStyle"],"sources":["../../../src/components/palette/palette.vue"],"sourcesContent":["<template>\n <u-tip\n trigger=\"click\"\n :class=\"cls.e('panel')\"\n v-model:visible=\"visible\"\n :disabled=\"disabled || readonly\"\n >\n <span :class=\"className\" :style=\"{ backgroundColor: color }\"> </span>\n\n <template #content>\n <!-- 饱和度和亮度 -->\n <PaletteSV ref=\"palette-sv\" />\n\n <!-- 色相 -->\n <PaletteHue ref=\"palette-hue\" />\n\n <!-- 透明度 -->\n <PaletteAlpha ref=\"palette-alpha\" />\n\n <!-- 颜色切换 -->\n <PaletteColorSwitch v-model:color=\"color\" @clear=\"handleClear\" />\n </template>\n </u-tip>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFormFallbackProps, useUserAction } from '@veltra/compositions'\nimport { bem } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { computed, provide, shallowRef, useTemplateRef, watch } from 'vue'\n\nimport type { PaletteProps } from '../../types'\nimport { UTip } from '../tip'\nimport { HSV2RGB, RGB2HEX, HEX2RGBA, RGB2HSV } from './color-transform'\nimport { PaletteDIKey } from './di'\nimport PaletteAlpha from './palette-alpha.vue'\nimport PaletteColorSwitch from './palette-color-switch.vue'\nimport PaletteHue from './palette-hue.vue'\nimport PaletteSV from './palette-sv.vue'\nimport { useHSV } from './use-hsv'\n\ndefineOptions({ name: 'UPalette' })\n\nconst props = withDefaults(defineProps<PaletteProps>(), {\n disabled: undefined,\n readonly: undefined\n})\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props])\n\nconst cls = bem('palette')\n\nconst className = computed(() => {\n return [cls.b, cls.m(size.value), bem.is('no-color', !color.value)]\n})\n\nconst { HSV, alpha, ...rest } = useHSV()\n\nconst color = defineModel<string>()\nconst RGB = computed(() => HSV2RGB(HSV))\nconst { userAction, isUserActive } = useUserAction()\n\nconst visible = shallowRef(false)\n\n/** 清除时跳过一次内部状态到 color 的同步,防止 updateAlpha 把已清空的 color 覆盖回来 */\nlet skipColorUpdate = false\n\nconst handleClear = userAction(() => {\n if (alpha.value !== 1) {\n skipColorUpdate = true\n }\n color.value = ''\n rest.updateAlpha(1)\n visible.value = false\n})\n\nwatch([alpha, RGB], ([alpha, RGB]) => {\n if (skipColorUpdate) {\n skipColorUpdate = false\n return\n }\n color.value = `#${RGB2HEX(RGB, alpha)}`\n})\n\nconst paletteSVRef = useTemplateRef('palette-sv')\nconst paletteHueRef = useTemplateRef('palette-hue')\nconst paletteAlphaRef = useTemplateRef('palette-alpha')\n\nwatch(\n color,\n (color) => {\n if (!color) return\n if (isUserActive()) return\n\n const parsed = HEX2RGBA(color)\n // 无法解析的颜色(如非法字符)视为未绑定,跳过同步,避免把 NaN 写回 modelValue\n if (!parsed) return\n\n const { RGB, alpha } = parsed\n const hsv = RGB2HSV(RGB)\n rest.updateHue(hsv.h)\n rest.updateSV({ s: hsv.s, v: hsv.v })\n rest.updateAlpha(alpha)\n\n paletteSVRef.value?.init()\n paletteHueRef.value?.init()\n paletteAlphaRef.value?.init()\n },\n { immediate: true }\n)\n\nprovide(PaletteDIKey, { cls, HSV, RGB, alpha, userAction, isUserActive, ...rest })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAKd,MAAM,EAAE,cAAc,kBAAkB;EAExC,MAAM,EAAE,MAAM,UAAU,aAAa,qBAAqB,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;EAElF,MAAM,MAAM,IAAI,SAAS;EAEzB,MAAM,YAAY,eAAe;GAC/B,OAAO;IAAC,IAAI;IAAG,IAAI,EAAE,KAAK,KAAK;IAAG,IAAI,GAAG,YAAY,CAAC,MAAM,KAAK;GAAC;EACpE,CAAC;EAED,MAAM,EAAE,KAAK,OAAO,GAAG,SAAS,OAAO;EAEvC,MAAM,QAAQA,SAAmB,SAAA,YAAC;EAClC,MAAM,MAAM,eAAe,QAAQ,GAAG,CAAC;EACvC,MAAM,EAAE,YAAY,iBAAiB,cAAc;EAEnD,MAAM,UAAU,WAAW,KAAK;;EAGhC,IAAI,kBAAkB;EAEtB,MAAM,cAAc,iBAAiB;GACnC,IAAI,MAAM,UAAU,GAClB,kBAAkB;GAEpB,MAAM,QAAQ;GACd,KAAK,YAAY,CAAC;GAClB,QAAQ,QAAQ;EAClB,CAAC;EAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,SAAS;GACpC,IAAI,iBAAiB;IACnB,kBAAkB;IAClB;GACF;GACA,MAAM,QAAQ,IAAI,QAAQ,KAAK,KAAK;EACtC,CAAC;EAED,MAAM,eAAe,eAAe,YAAY;EAChD,MAAM,gBAAgB,eAAe,aAAa;EAClD,MAAM,kBAAkB,eAAe,eAAe;EAEtD,MACE,QACC,UAAU;GACT,IAAI,CAAC,OAAO;GACZ,IAAI,aAAa,GAAG;GA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","names":["_useModel","_openBlock","_createBlock","_unref","UTip","_normalizeClass","_withCtx","_createCommentVNode","_createVNode","PaletteSV","PaletteHue","PaletteAlpha","PaletteColorSwitch","_createElementVNode","_normalizeStyle"],"sources":["../../../src/components/palette/palette.vue"],"sourcesContent":["<template>\n <u-tip\n trigger=\"click\"\n :class=\"cls.e('panel')\"\n v-model:visible=\"visible\"\n :disabled=\"disabled || readonly\"\n >\n <span :class=\"className\" :style=\"{ backgroundColor: color }\"> </span>\n\n <template #content>\n <!-- 饱和度和亮度 -->\n <PaletteSV ref=\"palette-sv\" />\n\n <!-- 色相 -->\n <PaletteHue ref=\"palette-hue\" />\n\n <!-- 透明度 -->\n <PaletteAlpha ref=\"palette-alpha\" />\n\n <!-- 颜色切换 -->\n <PaletteColorSwitch v-model:color=\"color\" @clear=\"handleClear\" />\n </template>\n </u-tip>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFormFallbackProps, useUserAction } from '@veltra/compositions'\nimport { bem } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { computed, provide, shallowRef, useTemplateRef, watch } from 'vue'\n\nimport type { PaletteProps } from '../../types'\nimport { UTip } from '../tip'\nimport { HSV2RGB, RGB2HEX, HEX2RGBA, RGB2HSV } from './color-transform'\nimport { PaletteDIKey } from './di'\nimport PaletteAlpha from './palette-alpha.vue'\nimport PaletteColorSwitch from './palette-color-switch.vue'\nimport PaletteHue from './palette-hue.vue'\nimport PaletteSV from './palette-sv.vue'\nimport { useHSV } from './use-hsv'\n\ndefineOptions({ name: 'UPalette' })\n\nconst props = withDefaults(defineProps<PaletteProps>(), {\n disabled: undefined,\n readonly: undefined\n})\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props])\n\nconst cls = bem('palette')\n\nconst className = computed(() => {\n return [cls.b, cls.m(size.value), bem.is('no-color', !color.value)]\n})\n\nconst { HSV, alpha, ...rest } = useHSV()\n\nconst color = defineModel<string>()\nconst RGB = computed(() => HSV2RGB(HSV))\nconst { userAction, isUserActive } = useUserAction()\n\nconst visible = shallowRef(false)\n\n/** 清除时跳过一次内部状态到 color 的同步,防止 updateAlpha 把已清空的 color 覆盖回来 */\nlet skipColorUpdate = false\n\nconst handleClear = userAction(() => {\n if (alpha.value !== 1) {\n skipColorUpdate = true\n }\n color.value = ''\n rest.updateAlpha(1)\n visible.value = false\n})\n\nwatch([alpha, RGB], ([alpha, RGB]) => {\n if (skipColorUpdate) {\n skipColorUpdate = false\n return\n }\n\n // 仅用户操作(拖动取色/色相/透明度)驱动回写。初始化与外部回显也会走一遍\n // color → HSV 同步,不能把规范化后的值(如 #1890ff → #1890FF)写回 model\n if (!isUserActive()) return\n\n color.value = `#${RGB2HEX(RGB, alpha)}`\n})\n\nconst paletteSVRef = useTemplateRef('palette-sv')\nconst paletteHueRef = useTemplateRef('palette-hue')\nconst paletteAlphaRef = useTemplateRef('palette-alpha')\n\nwatch(\n color,\n (color) => {\n if (!color) return\n if (isUserActive()) return\n\n const parsed = HEX2RGBA(color)\n // 无法解析的颜色(如非法字符)视为未绑定,跳过同步,避免把 NaN 写回 modelValue\n if (!parsed) return\n\n const { RGB, alpha } = parsed\n const hsv = RGB2HSV(RGB)\n rest.updateHue(hsv.h)\n rest.updateSV({ s: hsv.s, v: hsv.v })\n rest.updateAlpha(alpha)\n\n paletteSVRef.value?.init()\n paletteHueRef.value?.init()\n paletteAlphaRef.value?.init()\n },\n { immediate: true }\n)\n\nprovide(PaletteDIKey, { cls, HSV, RGB, alpha, userAction, isUserActive, ...rest })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAKd,MAAM,EAAE,cAAc,kBAAkB;EAExC,MAAM,EAAE,MAAM,UAAU,aAAa,qBAAqB,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;EAElF,MAAM,MAAM,IAAI,SAAS;EAEzB,MAAM,YAAY,eAAe;GAC/B,OAAO;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AG;EAAK,CAAC;;GArH/E,OAAAC,UAAA,GAAAC,YAqBQC,MAAAC,WAAA,GAAA;IApBN,SAAQ;IACP,OAAKC,eAAEF,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA;IACL,SAAS,QAAA;IAAA,oBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,QAAO,QAAA;IACvB,UAAUA,MAAA,QAAA,KAAYA,MAAA,QAAA;;IAIZ,SAAOG,cACD;KAAfC,mBAAA,UAAA;KACAC,YAA8BC,aAAA,EAAnB,KAAI,aAAY,GAAA,MAAA,GAAA;KAE3BF,mBAAA,MAAA;KACAC,YAAgCE,aAAA,EAApB,KAAI,cAAa,GAAA,MAAA,GAAA;KAE7BH,mBAAA,OAAA;KACAC,YAAoCG,aAAA,EAAtB,KAAI,gBAAe,GAAA,MAAA,GAAA;KAEjCJ,mBAAA,QAAA;KACAC,YAAiEI,aAAA;MAArC,OAAO,MAAA;MAAA,kBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,MAAK,QAAA;MAAG,SAAOT,MAAA,WAAA;;;IAbpD,SAAAG,cAAqE,CAArEO,mBAAqE,QAAA;KAA9D,OAAKR,eAAE,UAAA,KAAS;KAAG,OAAKS,eAAA,EAAA,iBAAqB,MAAA,MAAK,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/desktop",
3
- "version": "1.13.1",
3
+ "version": "1.13.2",
4
4
  "homepage": "https://github.com/cabinet-fe/ultra-ui#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/cabinet-fe/ultra-ui/issues"
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { useConfig } from '@veltra/compositions'
2
4
  import type { AiProviderConfig } from '@veltra/utils'
3
5
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, reactive, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, defineComponent, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, defineComponent, h, inject, nextTick } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { date } from '@cat-kit/core'
2
4
  import { describe, expect, it } from 'vite-plus/test'
3
5
  import { createApp, h, nextTick, ref } from 'vue'
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { date } from '@cat-kit/core'
2
4
  import { describe, expect, it } from 'vite-plus/test'
3
5
  import { createApp, h, nextTick, ref } from 'vue'
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, defineComponent, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, defineComponent, h, nextTick, reactive, ref } from 'vue'
3
5
 
@@ -22,64 +22,29 @@
22
22
  }
23
23
  }
24
24
 
25
+ // 变更前:值条内换行的次级说明文字。只读副本控件渲染纯文本,无需剥盒
25
26
  @include m.e(data-before) {
27
+ flex-basis: 100%;
28
+ min-width: 0;
26
29
  display: flex;
27
30
  align-items: center;
28
31
  gap: 4px;
29
- flex-wrap: wrap;
30
- margin-top: 4px;
31
- padding: 2px 8px;
32
- border-left: 2px solid fn.use-var(color, info);
33
- background-color: fn.color-a(color, 8, info);
34
- border-radius: 2px;
35
- width: fit-content;
36
- max-width: 100%;
32
+ margin-top: 2px;
33
+ color: fn.use-var(text-color, second);
37
34
  line-height: 1.4;
38
35
  font-size: fn.use-var(font-size, assist, default);
39
36
 
40
- // 文本类控件保持全宽,便于展示较长内容
41
- &:has(#{fn.bem(input)}),
42
- &:has(#{fn.bem(textarea)}),
43
- &:has(#{fn.bem(select)}),
44
- &:has(#{fn.bem(multi-select)}),
45
- &:has(#{fn.bem(multi-tree-select)}),
46
- &:has(#{fn.bem(auto-complete)}),
47
- &:has(#{fn.bem(cascade)}),
48
- &:has(#{fn.bem(date-picker)}),
49
- &:has(#{fn.bem(date-range-picker)}),
50
- &:has(#{fn.bem(number-input)}),
51
- &:has(#{fn.bem(tree-select)}) {
52
- width: 100%;
53
- }
54
-
55
- // 让内部只读控件更像辅助说明,减少「第二个输入框」感
56
- @include m.bem(form-item, content) {
57
- background: transparent;
58
- padding: 0;
59
- }
60
-
61
- #{fn.bem(input)},
62
- #{fn.bem(textarea)},
63
- #{fn.bem(select)},
64
- #{fn.bem(multi-select)},
65
- #{fn.bem(multi-tree-select)},
66
- #{fn.bem(auto-complete)},
67
- #{fn.bem(cascade)},
68
- #{fn.bem(date-picker)},
69
- #{fn.bem(date-range-picker)} {
70
- border: none;
71
- box-shadow: none;
72
- background: transparent;
73
- min-height: auto;
74
- height: auto;
75
- padding: 0;
37
+ // 色板无只读文本态,副本缩到文字高度,避免 32px 大色块撑高说明行
38
+ #{fn.bem(palette)} {
39
+ width: 14px;
40
+ height: 14px;
41
+ cursor: default;
76
42
  }
77
43
  }
78
44
 
79
45
  @include m.e(changed-tag) {
46
+ flex-shrink: 0;
80
47
  color: fn.use-var(color, info);
81
- font-size: fn.use-var(font-size, assist, default);
82
48
  font-style: normal;
83
- flex-shrink: 0;
84
49
  }
85
50
  }
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, reactive, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
2
4
 
3
5
  import { cropToResult, drawCropToCanvas } from '../draw-crop'
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref, shallowRef } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, shallowRef } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { zIndex } from '@veltra/utils'
2
4
  import { afterEach, describe, expect, it } from 'vite-plus/test'
3
5
  import { nextTick } from 'vue'
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref, type Ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref, type Ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -99,4 +101,51 @@ describe('UPalette', () => {
99
101
  unmount()
100
102
  }
101
103
  })
104
+
105
+ it('初始化与外部回显不回写 model,保持原始值', async () => {
106
+ const { model, setModel, unmount } = mountPalette('#1890ff')
107
+
108
+ try {
109
+ await nextTick()
110
+ await nextTick()
111
+ // 挂载时 color → HSV 同步会触发回写 watch,不能把规范化后的 #1890FF 写回
112
+ expect(model.value).toBe('#1890ff')
113
+
114
+ setModel('#00ff00')
115
+ await nextTick()
116
+ await nextTick()
117
+ expect(model.value).toBe('#00ff00')
118
+ } finally {
119
+ await unmount()
120
+ }
121
+ })
122
+
123
+ it('用户拖动 SV 面板仍回写 model', async () => {
124
+ const { host, model, unmount } = mountPalette('#1890ff')
125
+
126
+ // happy-dom 未实现 MouseEvent.x/y(浏览器里是 clientX 的别名),use-drag 依赖它们
127
+ function dragEvent(type: string, x: number, y: number, bubbles = false) {
128
+ const ev = new MouseEvent(type, { bubbles, button: 0, clientX: x, clientY: y })
129
+ Object.defineProperty(ev, 'x', { value: x })
130
+ Object.defineProperty(ev, 'y', { value: y })
131
+ return ev
132
+ }
133
+
134
+ try {
135
+ await openPanel(host)
136
+
137
+ const sv = document.body.querySelector<HTMLElement>('.u-palette__sv')
138
+ expect(sv).not.toBeNull()
139
+ sv!.dispatchEvent(dragEvent('mousedown', 100, 100, true))
140
+ document.dispatchEvent(dragEvent('mousemove', 60, 60))
141
+ document.dispatchEvent(dragEvent('mouseup', 60, 60))
142
+
143
+ await nextTick()
144
+ await nextTick()
145
+ // 拖到左上角:s = 0、v = 1 → 白色;用户动作驱动的回写不受影响
146
+ expect(model.value).toBe('#FFFFFF')
147
+ } finally {
148
+ await unmount()
149
+ }
150
+ })
102
151
  })
@@ -81,6 +81,11 @@ watch([alpha, RGB], ([alpha, RGB]) => {
81
81
  skipColorUpdate = false
82
82
  return
83
83
  }
84
+
85
+ // 仅用户操作(拖动取色/色相/透明度)驱动回写。初始化与外部回显也会走一遍
86
+ // color → HSV 同步,不能把规范化后的值(如 #1890ff → #1890FF)写回 model
87
+ if (!isUserActive()) return
88
+
84
89
  color.value = `#${RGB2HEX(RGB, alpha)}`
85
90
  })
86
91
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { createEditor, type LexicalEditor } from 'lexical'
2
4
  import { afterAll, beforeAll, describe, expect, it } from 'vite-plus/test'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref, type Ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, shallowRef, ref, type Ref } from 'vue'
3
5
 
@@ -1,3 +1,5 @@
1
+ // @vitest-environment happy-dom
2
+
1
3
  import { describe, expect, it } from 'vite-plus/test'
2
4
  import { createApp, h, nextTick, ref, type Ref } from 'vue'
3
5