yc-pro-components 0.0.83 → 0.0.85

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 (91) hide show
  1. package/es/components/dialog-form/index.d.ts +4 -1
  2. package/es/components/dialog-form/src/index.vue.d.ts +4 -1
  3. package/es/components/display-item/index.d.ts +12 -3
  4. package/es/components/display-item/src/index.vue.d.ts +12 -3
  5. package/es/components/drawer-form/index.d.ts +4 -1
  6. package/es/components/drawer-form/src/index.vue.d.ts +4 -1
  7. package/es/components/form/index.d.ts +27 -2
  8. package/es/components/form/src/form-content.vue.d.ts +17 -2
  9. package/es/components/form/src/form-content.vue2.mjs +11 -2
  10. package/es/components/form/src/index.vue.d.ts +11 -2
  11. package/es/components/form/src/index.vue2.mjs +5 -2
  12. package/es/components/form/src/type.d.ts +5 -0
  13. package/es/components/form-item/index.d.ts +24 -1
  14. package/es/components/form-item/src/index.vue.d.ts +28 -5
  15. package/es/components/form-item/src/index.vue2.mjs +437 -303
  16. package/es/components/form-item/src/overflow-tooltip.d.ts +16 -0
  17. package/es/components/form-item/src/overflow-tooltip.mjs +67 -0
  18. package/es/components/page/index.d.ts +208 -25
  19. package/es/components/page/src/index.vue.d.ts +72 -9
  20. package/es/components/search/index.d.ts +95 -10
  21. package/es/components/search/src/index.vue.d.ts +31 -4
  22. package/es/components/search/src/index.vue2.mjs +3 -1
  23. package/es/components/search/src/type.d.ts +5 -0
  24. package/es/components/table/src/table-column.vue.d.ts +12 -3
  25. package/es/components/yc-plus-page/src/index.vue.d.ts +140 -17
  26. package/es/hooks/usePlusFormReset.d.ts +24 -6
  27. package/es/index.css +10 -10
  28. package/es/types/form.d.ts +5 -0
  29. package/es/version.d.ts +1 -1
  30. package/es/version.mjs +1 -1
  31. package/es/yc-components/version.d.ts +1 -1
  32. package/index.css +1 -1
  33. package/index.js +522 -309
  34. package/index.min.js +12 -12
  35. package/index.min.mjs +12 -12
  36. package/index.mjs +522 -309
  37. package/lib/components/dialog-form/index.d.ts +4 -1
  38. package/lib/components/dialog-form/src/index.vue.d.ts +4 -1
  39. package/lib/components/display-item/index.d.ts +12 -3
  40. package/lib/components/display-item/src/index.vue.d.ts +12 -3
  41. package/lib/components/drawer-form/index.d.ts +4 -1
  42. package/lib/components/drawer-form/src/index.vue.d.ts +4 -1
  43. package/lib/components/form/index.d.ts +27 -2
  44. package/lib/components/form/src/form-content.vue.d.ts +17 -2
  45. package/lib/components/form/src/form-content.vue2.js +11 -2
  46. package/lib/components/form/src/index.vue.d.ts +11 -2
  47. package/lib/components/form/src/index.vue2.js +5 -2
  48. package/lib/components/form/src/type.d.ts +5 -0
  49. package/lib/components/form-item/index.d.ts +24 -1
  50. package/lib/components/form-item/src/index.vue.d.ts +28 -5
  51. package/lib/components/form-item/src/index.vue2.js +436 -302
  52. package/lib/components/form-item/src/overflow-tooltip.d.ts +16 -0
  53. package/lib/components/form-item/src/overflow-tooltip.js +71 -0
  54. package/lib/components/page/index.d.ts +208 -25
  55. package/lib/components/page/src/index.vue.d.ts +72 -9
  56. package/lib/components/search/index.d.ts +95 -10
  57. package/lib/components/search/src/index.vue.d.ts +31 -4
  58. package/lib/components/search/src/index.vue2.js +3 -1
  59. package/lib/components/search/src/type.d.ts +5 -0
  60. package/lib/components/table/src/table-column.vue.d.ts +12 -3
  61. package/lib/components/yc-plus-page/src/index.vue.d.ts +140 -17
  62. package/lib/hooks/usePlusFormReset.d.ts +24 -6
  63. package/lib/index.css +9 -9
  64. package/lib/types/form.d.ts +5 -0
  65. package/lib/version.d.ts +1 -1
  66. package/lib/version.js +1 -1
  67. package/lib/yc-components/version.d.ts +1 -1
  68. package/locale/en.js +1 -1
  69. package/locale/en.min.js +1 -1
  70. package/locale/en.min.mjs +1 -1
  71. package/locale/en.mjs +1 -1
  72. package/locale/ja.js +1 -1
  73. package/locale/ja.min.js +1 -1
  74. package/locale/ja.min.mjs +1 -1
  75. package/locale/ja.mjs +1 -1
  76. package/locale/ko.js +1 -1
  77. package/locale/ko.min.js +1 -1
  78. package/locale/ko.min.mjs +1 -1
  79. package/locale/ko.mjs +1 -1
  80. package/locale/zh-cn.js +1 -1
  81. package/locale/zh-cn.min.js +1 -1
  82. package/locale/zh-cn.min.mjs +1 -1
  83. package/locale/zh-cn.mjs +1 -1
  84. package/locale/zh-tw.js +1 -1
  85. package/locale/zh-tw.min.js +1 -1
  86. package/locale/zh-tw.min.mjs +1 -1
  87. package/locale/zh-tw.mjs +1 -1
  88. package/package.json +1 -1
  89. package/theme-chalk/index.css +1 -1
  90. package/theme-chalk/plus-form-item.css +1 -1
  91. package/theme-chalk/src/form-item.scss +77 -0
@@ -0,0 +1,16 @@
1
+ export interface PlaceholderHit {
2
+ el: HTMLElement;
3
+ text: string;
4
+ }
5
+ export type TextMeasurer = (text: string, font: string) => number;
6
+ /** 用 canvas 测量文本宽度,避免读取 input 的 scrollWidth(占位符不参与布局) */
7
+ export declare const measureTextWidth: TextMeasurer;
8
+ export declare const isInputPlaceholderOverflow: (input: HTMLInputElement | HTMLTextAreaElement, measure?: TextMeasurer) => boolean;
9
+ /**
10
+ * 找到当前指针下被截断的占位符。
11
+ * 输入框用文本测量;下拉框的占位符是独立节点,用 scrollWidth 判断。
12
+ */
13
+ export declare const findPlaceholderOverflow: (root: HTMLElement, target: EventTarget | null, point?: {
14
+ x: number;
15
+ y: number;
16
+ }, measure?: TextMeasurer) => PlaceholderHit | null;
@@ -0,0 +1,67 @@
1
+ const FIELD_SELECTOR = [
2
+ ".el-input",
3
+ ".el-textarea",
4
+ ".el-select",
5
+ ".el-date-editor",
6
+ ".el-cascader",
7
+ ".el-autocomplete",
8
+ ".el-input-number",
9
+ ".el-tree-select",
10
+ ".plus-form-item-field"
11
+ ].join(",");
12
+ let measureCanvas = null;
13
+ const measureTextWidth = (text, font) => {
14
+ if (typeof document === "undefined") return 0;
15
+ measureCanvas = measureCanvas || document.createElement("canvas");
16
+ const context = measureCanvas.getContext("2d");
17
+ if (!context) return 0;
18
+ context.font = font;
19
+ return context.measureText(text).width;
20
+ };
21
+ const readFont = (style) => `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
22
+ const availableWidth = (input) => {
23
+ const style = getComputedStyle(input);
24
+ const padding = (Number.parseFloat(style.paddingLeft) || 0) + (Number.parseFloat(style.paddingRight) || 0);
25
+ return input.clientWidth - padding;
26
+ };
27
+ const isInputPlaceholderOverflow = (input, measure = measureTextWidth) => {
28
+ var _a;
29
+ const text = ((_a = input.placeholder) == null ? void 0 : _a.trim()) || "";
30
+ if (!text || input.value || input.clientWidth <= 0) return false;
31
+ return measure(text, readFont(getComputedStyle(input))) > availableWidth(input) + 1;
32
+ };
33
+ const hitFromInput = (input, measure) => {
34
+ if (!isInputPlaceholderOverflow(input, measure)) return null;
35
+ return { el: input, text: input.placeholder.trim() };
36
+ };
37
+ const containsPoint = (el, point) => {
38
+ const rect = el.getBoundingClientRect();
39
+ return point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom;
40
+ };
41
+ const findPlaceholderOverflow = (root, target, point, measure = measureTextWidth) => {
42
+ var _a;
43
+ if (!(target instanceof HTMLElement) || !root.contains(target)) return null;
44
+ const directInput = target.closest("input, textarea");
45
+ if (directInput instanceof HTMLInputElement || directInput instanceof HTMLTextAreaElement) {
46
+ if (!root.contains(directInput)) return null;
47
+ return hitFromInput(directInput, measure);
48
+ }
49
+ const field = target.closest(FIELD_SELECTOR);
50
+ if (!(field instanceof HTMLElement) || !root.contains(field)) return null;
51
+ const selectPlaceholder = field.querySelector(".el-select__placeholder.is-transparent");
52
+ if (selectPlaceholder instanceof HTMLElement) {
53
+ const text = ((_a = selectPlaceholder.textContent) == null ? void 0 : _a.trim()) || "";
54
+ if (text && selectPlaceholder.scrollWidth > selectPlaceholder.clientWidth + 1) {
55
+ return { el: selectPlaceholder, text };
56
+ }
57
+ return null;
58
+ }
59
+ if (!point) return null;
60
+ const inputs = Array.from(field.querySelectorAll("input, textarea"));
61
+ const hovered = inputs.find(
62
+ (input) => (input instanceof HTMLInputElement || input instanceof HTMLTextAreaElement) && input.clientWidth > 0 && containsPoint(input, point)
63
+ );
64
+ return hovered ? hitFromInput(hovered, measure) : null;
65
+ };
66
+
67
+ export { findPlaceholderOverflow, isInputPlaceholderOverflow, measureTextWidth };