@veltra/desktop 1.6.5 → 1.6.6

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.
@@ -35,6 +35,7 @@ function createChip(segment, opts) {
35
35
  chip.appendChild(close);
36
36
  chip.addEventListener("mousedown", (e) => {
37
37
  e.preventDefault();
38
+ e.stopPropagation();
38
39
  if (isCloseTarget(e.target)) opts.onRemove(chip);
39
40
  else opts.onReselect(chip);
40
41
  });
@@ -1 +1 @@
1
- {"version":3,"file":"chip.js","names":[],"sources":["../../../../src/components/expression-editor/core/chip.ts"],"sourcesContent":["import type { BEM } from '@veltra/utils'\n\nimport type { Segment } from './model'\n\nexport interface ChipDeps {\n cls: BEM<'expression-editor'>\n}\n\nexport interface ChipFactoryOptions extends ChipDeps {\n /**\n * 当用户点击 chip 主体(不是 ×)时回调,由调用方决定如何打开重选面板。\n * 收到的 chipEl 当前在 DOM 中的位置即为重选锚点。\n */\n onReselect: (chipEl: HTMLElement) => void\n /** 当用户点击 × 时回调,调用方应将该 chip 从模型 / DOM 中移除。 */\n onRemove: (chipEl: HTMLElement) => void\n}\n\nconst CHIP_DATA_SEG = 'var'\nconst CHIP_VALUE_ATTR = 'data-value'\nconst CHIP_TYPE_ATTR = 'data-var-type'\nconst CHIP_CLOSE_ATTR = 'data-chip-close'\n\n/** 判断一个 DOM 节点是否为 chip 元素(var 段渲染体) */\nexport function isChipElement(node: Node | null): node is HTMLElement {\n return (\n !!node &&\n node.nodeType === 1 &&\n (node as HTMLElement).getAttribute('data-seg') === CHIP_DATA_SEG\n )\n}\n\n/** 判断点击目标是否落在 × 删除区。 */\nfunction isCloseTarget(target: EventTarget | null): boolean {\n if (!(target instanceof Element)) return false\n return !!target.closest(`[${CHIP_CLOSE_ATTR}]`)\n}\n\n/** 从给定 segment 创建一个 chip 元素(var 段渲染体)。 */\nexport function createChip(\n segment: Extract<Segment, { kind: 'var' }>,\n opts: ChipFactoryOptions\n): HTMLElement {\n const { cls } = opts\n\n const chip = document.createElement('span')\n chip.setAttribute('data-seg', CHIP_DATA_SEG)\n chip.setAttribute(CHIP_VALUE_ATTR, segment.value)\n if (segment.type) chip.setAttribute(CHIP_TYPE_ATTR, segment.type)\n chip.setAttribute('contenteditable', 'false')\n chip.className = cls.e('chip')\n chip.title = segment.label\n\n const label = document.createElement('span')\n label.className = cls.e('chip-label')\n label.textContent = segment.type ? `${segment.label} (${segment.type})` : segment.label\n\n const close = document.createElement('span')\n close.className = cls.e('chip-close')\n close.setAttribute(CHIP_CLOSE_ATTR, 'true')\n close.setAttribute('aria-label', '删除')\n close.setAttribute('role', 'button')\n close.textContent = '×'\n\n chip.appendChild(label)\n chip.appendChild(close)\n\n chip.addEventListener('mousedown', (e) => {\n e.preventDefault()\n if (isCloseTarget(e.target)) {\n opts.onRemove(chip)\n } else {\n opts.onReselect(chip)\n }\n })\n\n return chip\n}\n\n/** 读取 chip 元素绑定的变量 value。 */\nexport function readChipValue(el: HTMLElement): string {\n return el.getAttribute(CHIP_VALUE_ATTR) ?? ''\n}\n\n/** 读取 chip 元素绑定的可选 type。 */\nexport function readChipType(el: HTMLElement): string | undefined {\n return el.getAttribute(CHIP_TYPE_ATTR) ?? undefined\n}\n\n/** 在 chip 上设置 / 取消选中(焦点)样式。 */\nexport function setChipFocused(el: HTMLElement, focused: boolean): void {\n el.classList.toggle('is-focused', focused)\n}\n\n/** 测试支持:暴露用于 DOM 选择器的属性常量。 */\nexport const ChipAttrs = {\n seg: 'data-seg',\n value: CHIP_VALUE_ATTR,\n type: CHIP_TYPE_ATTR,\n close: CHIP_CLOSE_ATTR\n} as const\n"],"mappings":";AAkBA,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;;AAGxB,SAAgB,cAAc,MAAwC;CACpE,OACE,CAAC,CAAC,QACF,KAAK,aAAa,KACjB,KAAqB,aAAa,UAAU,MAAM;AAEvD;;AAGA,SAAS,cAAc,QAAqC;CAC1D,IAAI,EAAE,kBAAkB,UAAU,OAAO;CACzC,OAAO,CAAC,CAAC,OAAO,QAAQ,IAAI,gBAAgB,EAAE;AAChD;;AAGA,SAAgB,WACd,SACA,MACa;CACb,MAAM,EAAE,QAAQ;CAEhB,MAAM,OAAO,SAAS,cAAc,MAAM;CAC1C,KAAK,aAAa,YAAY,aAAa;CAC3C,KAAK,aAAa,iBAAiB,QAAQ,KAAK;CAChD,IAAI,QAAQ,MAAM,KAAK,aAAa,gBAAgB,QAAQ,IAAI;CAChE,KAAK,aAAa,mBAAmB,OAAO;CAC5C,KAAK,YAAY,IAAI,EAAE,MAAM;CAC7B,KAAK,QAAQ,QAAQ;CAErB,MAAM,QAAQ,SAAS,cAAc,MAAM;CAC3C,MAAM,YAAY,IAAI,EAAE,YAAY;CACpC,MAAM,cAAc,QAAQ,OAAO,GAAG,QAAQ,MAAM,IAAI,QAAQ,KAAK,KAAK,QAAQ;CAElF,MAAM,QAAQ,SAAS,cAAc,MAAM;CAC3C,MAAM,YAAY,IAAI,EAAE,YAAY;CACpC,MAAM,aAAa,iBAAiB,MAAM;CAC1C,MAAM,aAAa,cAAc,IAAI;CACrC,MAAM,aAAa,QAAQ,QAAQ;CACnC,MAAM,cAAc;CAEpB,KAAK,YAAY,KAAK;CACtB,KAAK,YAAY,KAAK;CAEtB,KAAK,iBAAiB,cAAc,MAAM;EACxC,EAAE,eAAe;EACjB,IAAI,cAAc,EAAE,MAAM,GACxB,KAAK,SAAS,IAAI;OAElB,KAAK,WAAW,IAAI;CAExB,CAAC;CAED,OAAO;AACT;;AAGA,SAAgB,cAAc,IAAyB;CACrD,OAAO,GAAG,aAAa,eAAe,KAAK;AAC7C;;AAGA,SAAgB,aAAa,IAAqC;CAChE,OAAO,GAAG,aAAa,cAAc,KAAK,KAAA;AAC5C"}
1
+ {"version":3,"file":"chip.js","names":[],"sources":["../../../../src/components/expression-editor/core/chip.ts"],"sourcesContent":["import type { BEM } from '@veltra/utils'\n\nimport type { Segment } from './model'\n\nexport interface ChipDeps {\n cls: BEM<'expression-editor'>\n}\n\nexport interface ChipFactoryOptions extends ChipDeps {\n /**\n * 当用户点击 chip 主体(不是 ×)时回调,由调用方决定如何打开重选面板。\n * 收到的 chipEl 当前在 DOM 中的位置即为重选锚点。\n */\n onReselect: (chipEl: HTMLElement) => void\n /** 当用户点击 × 时回调,调用方应将该 chip 从模型 / DOM 中移除。 */\n onRemove: (chipEl: HTMLElement) => void\n}\n\nconst CHIP_DATA_SEG = 'var'\nconst CHIP_VALUE_ATTR = 'data-value'\nconst CHIP_TYPE_ATTR = 'data-var-type'\nconst CHIP_CLOSE_ATTR = 'data-chip-close'\n\n/** 判断一个 DOM 节点是否为 chip 元素(var 段渲染体) */\nexport function isChipElement(node: Node | null): node is HTMLElement {\n return (\n !!node &&\n node.nodeType === 1 &&\n (node as HTMLElement).getAttribute('data-seg') === CHIP_DATA_SEG\n )\n}\n\n/** 判断点击目标是否落在 × 删除区。 */\nfunction isCloseTarget(target: EventTarget | null): boolean {\n if (!(target instanceof Element)) return false\n return !!target.closest(`[${CHIP_CLOSE_ATTR}]`)\n}\n\n/** 从给定 segment 创建一个 chip 元素(var 段渲染体)。 */\nexport function createChip(\n segment: Extract<Segment, { kind: 'var' }>,\n opts: ChipFactoryOptions\n): HTMLElement {\n const { cls } = opts\n\n const chip = document.createElement('span')\n chip.setAttribute('data-seg', CHIP_DATA_SEG)\n chip.setAttribute(CHIP_VALUE_ATTR, segment.value)\n if (segment.type) chip.setAttribute(CHIP_TYPE_ATTR, segment.type)\n chip.setAttribute('contenteditable', 'false')\n chip.className = cls.e('chip')\n chip.title = segment.label\n\n const label = document.createElement('span')\n label.className = cls.e('chip-label')\n label.textContent = segment.type ? `${segment.label} (${segment.type})` : segment.label\n\n const close = document.createElement('span')\n close.className = cls.e('chip-close')\n close.setAttribute(CHIP_CLOSE_ATTR, 'true')\n close.setAttribute('aria-label', '删除')\n close.setAttribute('role', 'button')\n close.textContent = '×'\n\n chip.appendChild(label)\n chip.appendChild(close)\n\n chip.addEventListener('mousedown', (e) => {\n e.preventDefault()\n // 阻止冒泡:避免宿主弹框(如 dialog)的 mousedown 层级提升逻辑把 chip 打开的重选面板盖住\n e.stopPropagation()\n if (isCloseTarget(e.target)) {\n opts.onRemove(chip)\n } else {\n opts.onReselect(chip)\n }\n })\n\n return chip\n}\n\n/** 读取 chip 元素绑定的变量 value。 */\nexport function readChipValue(el: HTMLElement): string {\n return el.getAttribute(CHIP_VALUE_ATTR) ?? ''\n}\n\n/** 读取 chip 元素绑定的可选 type。 */\nexport function readChipType(el: HTMLElement): string | undefined {\n return el.getAttribute(CHIP_TYPE_ATTR) ?? undefined\n}\n\n/** 在 chip 上设置 / 取消选中(焦点)样式。 */\nexport function setChipFocused(el: HTMLElement, focused: boolean): void {\n el.classList.toggle('is-focused', focused)\n}\n\n/** 测试支持:暴露用于 DOM 选择器的属性常量。 */\nexport const ChipAttrs = {\n seg: 'data-seg',\n value: CHIP_VALUE_ATTR,\n type: CHIP_TYPE_ATTR,\n close: CHIP_CLOSE_ATTR\n} as const\n"],"mappings":";AAkBA,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;;AAGxB,SAAgB,cAAc,MAAwC;CACpE,OACE,CAAC,CAAC,QACF,KAAK,aAAa,KACjB,KAAqB,aAAa,UAAU,MAAM;AAEvD;;AAGA,SAAS,cAAc,QAAqC;CAC1D,IAAI,EAAE,kBAAkB,UAAU,OAAO;CACzC,OAAO,CAAC,CAAC,OAAO,QAAQ,IAAI,gBAAgB,EAAE;AAChD;;AAGA,SAAgB,WACd,SACA,MACa;CACb,MAAM,EAAE,QAAQ;CAEhB,MAAM,OAAO,SAAS,cAAc,MAAM;CAC1C,KAAK,aAAa,YAAY,aAAa;CAC3C,KAAK,aAAa,iBAAiB,QAAQ,KAAK;CAChD,IAAI,QAAQ,MAAM,KAAK,aAAa,gBAAgB,QAAQ,IAAI;CAChE,KAAK,aAAa,mBAAmB,OAAO;CAC5C,KAAK,YAAY,IAAI,EAAE,MAAM;CAC7B,KAAK,QAAQ,QAAQ;CAErB,MAAM,QAAQ,SAAS,cAAc,MAAM;CAC3C,MAAM,YAAY,IAAI,EAAE,YAAY;CACpC,MAAM,cAAc,QAAQ,OAAO,GAAG,QAAQ,MAAM,IAAI,QAAQ,KAAK,KAAK,QAAQ;CAElF,MAAM,QAAQ,SAAS,cAAc,MAAM;CAC3C,MAAM,YAAY,IAAI,EAAE,YAAY;CACpC,MAAM,aAAa,iBAAiB,MAAM;CAC1C,MAAM,aAAa,cAAc,IAAI;CACrC,MAAM,aAAa,QAAQ,QAAQ;CACnC,MAAM,cAAc;CAEpB,KAAK,YAAY,KAAK;CACtB,KAAK,YAAY,KAAK;CAEtB,KAAK,iBAAiB,cAAc,MAAM;EACxC,EAAE,eAAe;EAEjB,EAAE,gBAAgB;EAClB,IAAI,cAAc,EAAE,MAAM,GACxB,KAAK,SAAS,IAAI;OAElB,KAAK,WAAW,IAAI;CAExB,CAAC;CAED,OAAO;AACT;;AAGA,SAAgB,cAAc,IAAyB;CACrD,OAAO,GAAG,aAAa,eAAe,KAAK;AAC7C;;AAGA,SAAgB,aAAa,IAAqC;CAChE,OAAO,GAAG,aAAa,cAAc,KAAK,KAAA;AAC5C"}
@@ -575,7 +575,7 @@
575
575
  min-height: 100%;
576
576
  padding: clamp(22px, 3vw, 44px);
577
577
  }
578
- .u-file-viewer__docx-body :deep(.u-file-viewer__docx-doc) {
578
+ .u-file-viewer__docx-doc {
579
579
  margin: 0 auto;
580
580
  color: #222;
581
581
  background: #fff;
@@ -584,7 +584,7 @@
584
584
  .u-file-viewer.is-modal .u-file-viewer__docx-body {
585
585
  padding: clamp(24px, 4vw, 64px);
586
586
  }
587
- .u-file-viewer.is-modal .u-file-viewer__docx-body :deep(.u-file-viewer__docx-doc) {
587
+ .u-file-viewer.is-modal .u-file-viewer__docx-doc {
588
588
  box-shadow: 0 38px 110px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
589
589
  }
590
590
  .u-file-viewer__sheet {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/desktop",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
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"
@@ -80,12 +80,12 @@
80
80
  "peerDependencies": {
81
81
  "@cat-kit/core": ">=1.1.8",
82
82
  "@cat-kit/fe": ">=1.1.8",
83
- "@veltra/compositions": "^1.6.5",
84
- "@veltra/directives": "^1.6.5",
83
+ "@veltra/compositions": "^1.6.6",
84
+ "@veltra/directives": "^1.6.6",
85
85
  "@veltra/icons": "^1.5.0",
86
- "@veltra/sheet-core": "^2.4.0",
87
- "@veltra/styles": "^1.6.5",
88
- "@veltra/utils": "^1.6.5",
86
+ "@veltra/sheet-core": "^2.5.0",
87
+ "@veltra/styles": "^1.6.6",
88
+ "@veltra/utils": "^1.6.6",
89
89
  "vue": ">=3.5.41"
90
90
  },
91
91
  "peerDependenciesMeta": {
@@ -67,6 +67,8 @@ export function createChip(
67
67
 
68
68
  chip.addEventListener('mousedown', (e) => {
69
69
  e.preventDefault()
70
+ // 阻止冒泡:避免宿主弹框(如 dialog)的 mousedown 层级提升逻辑把 chip 打开的重选面板盖住
71
+ e.stopPropagation()
70
72
  if (isCloseTarget(e.target)) {
71
73
  opts.onRemove(chip)
72
74
  } else {
@@ -695,23 +695,23 @@
695
695
  @include m.e(docx-body) {
696
696
  min-height: 100%;
697
697
  padding: clamp(22px, 3vw, 44px);
698
+ }
698
699
 
699
- :deep(.u-file-viewer__docx-doc) {
700
- margin: 0 auto;
701
- color: #222;
702
- background: #fff;
703
- box-shadow: var(--u-file-viewer-page-shadow);
704
- }
700
+ @include m.e(docx-doc) {
701
+ margin: 0 auto;
702
+ color: #222;
703
+ background: #fff;
704
+ box-shadow: var(--u-file-viewer-page-shadow);
705
705
  }
706
706
 
707
707
  &.is-modal &__docx-body {
708
708
  padding: clamp(24px, 4vw, 64px);
709
+ }
709
710
 
710
- :deep(.u-file-viewer__docx-doc) {
711
- box-shadow:
712
- 0 38px 110px rgba(0, 0, 0, 0.5),
713
- 0 0 0 1px rgba(255, 255, 255, 0.04);
714
- }
711
+ &.is-modal &__docx-doc {
712
+ box-shadow:
713
+ 0 38px 110px rgba(0, 0, 0, 0.5),
714
+ 0 0 0 1px rgba(255, 255, 255, 0.04);
715
715
  }
716
716
 
717
717
  @include m.e(sheet) {