@sdata/web-vue 2.2.1 → 2.3.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.
Files changed (83) hide show
  1. package/es/_components/picker/input-range.vue.d.ts +2 -2
  2. package/es/_utils/date.d.ts +10 -9
  3. package/es/_utils/date.js +23 -7
  4. package/es/anchor/anchor.vue.d.ts +52 -2
  5. package/es/anchor/anchor.vue_vue_type_script_setup_true_lang.js +75 -15
  6. package/es/anchor/index.d.ts +75 -0
  7. package/es/button/button.vue.d.ts +16 -3
  8. package/es/button/button.vue_vue_type_script_setup_true_lang.js +39 -9
  9. package/es/button/index.d.ts +19 -0
  10. package/es/button/interface.d.ts +1 -0
  11. package/es/config-provider/config-provider.vue.d.ts +9 -0
  12. package/es/config-provider/config-provider.vue_vue_type_script_setup_true_lang.js +10 -1
  13. package/es/config-provider/context.d.ts +1 -0
  14. package/es/config-provider/index.d.ts +15 -0
  15. package/es/copy/copy.vue_vue_type_script_setup_true_lang.js +1 -0
  16. package/es/date-picker/hooks/use-cell-class-name.d.ts +1 -0
  17. package/es/date-picker/hooks/use-cell-class-name.js +3 -2
  18. package/es/date-picker/hooks/use-header-value.d.ts +2 -0
  19. package/es/date-picker/hooks/use-header-value.js +23 -19
  20. package/es/date-picker/hooks/use-picker-state.d.ts +2 -0
  21. package/es/date-picker/hooks/use-picker-state.js +3 -3
  22. package/es/date-picker/hooks/use-range-header-value.d.ts +2 -0
  23. package/es/date-picker/hooks/use-range-header-value.js +5 -1
  24. package/es/date-picker/hooks/use-range-picker-state.d.ts +2 -0
  25. package/es/date-picker/hooks/use-range-picker-state.js +3 -3
  26. package/es/date-picker/hooks/use-value-format.d.ts +5 -3
  27. package/es/date-picker/hooks/use-value-format.js +10 -8
  28. package/es/date-picker/index.d.ts +1361 -0
  29. package/es/date-picker/interface.d.ts +7 -0
  30. package/es/date-picker/panels/body.vue.d.ts +24 -6
  31. package/es/date-picker/panels/body.vue_vue_type_script_setup_true_lang.js +13 -12
  32. package/es/date-picker/panels/date/index.vue.d.ts +26 -8
  33. package/es/date-picker/panels/date/index.vue_vue_type_script_setup_true_lang.js +18 -9
  34. package/es/date-picker/panels/header.vue_vue_type_script_setup_true_lang.js +13 -20
  35. package/es/date-picker/panels/month/index.vue.d.ts +13 -8
  36. package/es/date-picker/panels/month/index.vue_vue_type_script_setup_true_lang.js +6 -6
  37. package/es/date-picker/panels/quarter/index.vue.d.ts +13 -8
  38. package/es/date-picker/panels/quarter/index.vue_vue_type_script_setup_true_lang.js +6 -6
  39. package/es/date-picker/panels/shortcuts.vue_vue_type_script_setup_true_lang.js +2 -6
  40. package/es/date-picker/panels/week/index.vue.d.ts +13 -1
  41. package/es/date-picker/panels/week/index.vue_vue_type_script_setup_true_lang.js +5 -2
  42. package/es/date-picker/panels/year/index.vue.d.ts +13 -8
  43. package/es/date-picker/panels/year/index.vue_vue_type_script_setup_true_lang.js +25 -15
  44. package/es/date-picker/picker-panel.vue.d.ts +56 -14
  45. package/es/date-picker/picker-panel.vue_vue_type_script_setup_true_lang.js +36 -19
  46. package/es/date-picker/picker.vue.d.ts +949 -1
  47. package/es/date-picker/picker.vue_vue_type_script_setup_true_lang.js +91 -29
  48. package/es/date-picker/range-picker-panel.vue.d.ts +77 -15
  49. package/es/date-picker/range-picker-panel.vue_vue_type_script_setup_true_lang.js +52 -28
  50. package/es/date-picker/range-picker.vue.d.ts +1345 -1
  51. package/es/date-picker/range-picker.vue_vue_type_script_setup_true_lang.js +114 -34
  52. package/es/image/preview-toolbar.vue.d.ts +2 -3
  53. package/es/image/preview-toolbar.vue_vue_type_script_setup_true_lang.js +2 -3
  54. package/es/locale/interface.d.ts +2 -0
  55. package/es/locale/lang/ar-eg.js +46 -0
  56. package/es/locale/lang/de-de.js +46 -0
  57. package/es/locale/lang/es-es.js +46 -0
  58. package/es/locale/lang/fr-fr.js +46 -0
  59. package/es/locale/lang/id-id.js +46 -0
  60. package/es/locale/lang/it-it.js +46 -0
  61. package/es/locale/lang/km-kh.js +46 -0
  62. package/es/locale/lang/ko-kr.js +46 -0
  63. package/es/locale/lang/ms-my.js +46 -0
  64. package/es/locale/lang/pt-pt.js +46 -0
  65. package/es/locale/lang/th-th.js +46 -0
  66. package/es/locale/lang/vi-vn.js +46 -0
  67. package/es/mention/mention.js +2 -0
  68. package/es/menu/sub-menu-pop.vue_vue_type_script_setup_true_lang.js +3 -4
  69. package/es/modal/index.d.ts +7 -5
  70. package/es/modal/index.js +47 -11
  71. package/es/modal/interface.d.ts +5 -0
  72. package/es/textarea/textarea.vue_vue_type_script_setup_true_lang.js +2 -2
  73. package/es/tree/base-node.vue_vue_type_script_setup_true_lang.js +6 -21
  74. package/es/tree/node-switcher.vue.d.ts +0 -11
  75. package/es/tree/node-switcher.vue_vue_type_script_lang.js +1 -5
  76. package/es/trigger/trigger.js +2 -1
  77. package/es/verification-code/verification-code.js +17 -7
  78. package/json/vetur-attributes.json +53 -0
  79. package/json/vetur-tags.json +14 -0
  80. package/json/web-types.json +113 -1
  81. package/package.json +1 -1
  82. package/es/_components/render-function.d.ts +0 -14
  83. package/es/_components/render-function.js +0 -14
@@ -38,7 +38,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
38
38
  default: () => never[];
39
39
  };
40
40
  inputValue: {
41
- type: PropType<string[]>;
41
+ type: PropType<(string | undefined)[]>;
42
42
  };
43
43
  value: {
44
44
  type: PropType<(Dayjs | undefined)[]>;
@@ -85,7 +85,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
85
85
  default: () => never[];
86
86
  };
87
87
  inputValue: {
88
- type: PropType<string[]>;
88
+ type: PropType<(string | undefined)[]>;
89
89
  };
90
90
  value: {
91
91
  type: PropType<(Dayjs | undefined)[]>;
@@ -9,17 +9,18 @@ export declare const methods: {
9
9
  set(time: Dayjs, unit: UnitType, value: number): originDayjs.Dayjs;
10
10
  isSameWeek(date1: Dayjs, date2: Dayjs, weekStart: number): boolean;
11
11
  };
12
- export declare function getNow(): originDayjs.Dayjs;
13
- export declare function getSortedDayjsArray(values: Dayjs[]): originDayjs.Dayjs[];
12
+ export declare function getNow(utcOffset?: number, timezone?: string): originDayjs.Dayjs;
13
+ export declare function toLocal(date: Dayjs, utcOffset?: number, timezone?: string): Dayjs;
14
+ export declare function getSortedDayjsArray(values: Dayjs[], _fixedTime?: boolean): originDayjs.Dayjs[];
14
15
  export declare function isValueChange(prevValue: Dayjs | (Dayjs | undefined)[] | undefined, currentValue: Dayjs | (Dayjs | undefined)[] | undefined): boolean;
15
16
  type DateValue = Date | string | number;
16
- export declare function getDayjsValue(time: DateValue, format: string): Dayjs;
17
- export declare function getDayjsValue(time: DateValue | undefined, format: string): Dayjs | undefined;
18
- export declare function getDayjsValue(time: DateValue[], format: string): Dayjs[];
19
- export declare function getDayjsValue(time: DateValue[] | undefined, format: string): Dayjs[] | undefined;
20
- export declare function getDayjsValue(time: (DateValue | undefined)[], format: string): (Dayjs | undefined)[];
21
- export declare function getDayjsValue(time: (DateValue | undefined)[] | undefined, format: string): (Dayjs | undefined)[] | undefined;
22
- export declare function getDayjsValue(time: DateValue | (DateValue | undefined)[] | undefined, format: string): Dayjs | (Dayjs | undefined)[] | undefined;
17
+ export declare function getDayjsValue(time: DateValue, format: string, utcOffset?: number, timezone?: string): Dayjs;
18
+ export declare function getDayjsValue(time: DateValue | undefined, format: string, utcOffset?: number, timezone?: string): Dayjs | undefined;
19
+ export declare function getDayjsValue(time: DateValue[], format: string, utcOffset?: number, timezone?: string): Dayjs[];
20
+ export declare function getDayjsValue(time: DateValue[] | undefined, format: string, utcOffset?: number, timezone?: string): Dayjs[] | undefined;
21
+ export declare function getDayjsValue(time: (DateValue | undefined)[], format: string, utcOffset?: number, timezone?: string): (Dayjs | undefined)[];
22
+ export declare function getDayjsValue(time: (DateValue | undefined)[] | undefined, format: string, utcOffset?: number, timezone?: string): (Dayjs | undefined)[] | undefined;
23
+ export declare function getDayjsValue(time: DateValue | (DateValue | undefined)[] | undefined, format: string, utcOffset?: number, timezone?: string): Dayjs | (Dayjs | undefined)[] | undefined;
23
24
  export declare function getDateValue(value: Dayjs): Date;
24
25
  export declare function getDateValue(value: Dayjs | undefined): Date | undefined;
25
26
  export declare function getDateValue(value: Dayjs[]): Date[];
package/es/_utils/date.js CHANGED
@@ -6,6 +6,8 @@ import AdvancedFormat from "dayjs/plugin/advancedFormat";
6
6
  import customParseFormat from "dayjs/plugin/customParseFormat";
7
7
  import isBetween from "dayjs/plugin/isBetween";
8
8
  import QuarterOfYear from "dayjs/plugin/quarterOfYear";
9
+ import timezone from "dayjs/plugin/timezone";
10
+ import utc from "dayjs/plugin/utc";
9
11
  import weekOfYear from "dayjs/plugin/weekOfYear";
10
12
  import weekYear from "dayjs/plugin/weekYear";
11
13
  //#region components/_utils/date.ts
@@ -53,6 +55,8 @@ dayjs.extend(weekOfYear);
53
55
  dayjs.extend(AdvancedFormat);
54
56
  dayjs.extend(weekYear);
55
57
  dayjs.extend(QuarterOfYear);
58
+ dayjs.extend(utc);
59
+ dayjs.extend(timezone);
56
60
  var dayjs$1 = dayjs;
57
61
  var DAYJS_LOCALE_MAP = {
58
62
  "ar-eg": "ar",
@@ -111,10 +115,18 @@ var methods = {
111
115
  return getWeek(date1) === getWeek(date2);
112
116
  }
113
117
  };
114
- function getNow() {
115
- return dayjs$1();
118
+ function getNow(utcOffset, timezone) {
119
+ const now = dayjs$1();
120
+ if (utcOffset !== void 0) return now.utcOffset(utcOffset);
121
+ if (timezone) return now.tz(timezone);
122
+ return now;
116
123
  }
117
- function getSortedDayjsArray(values) {
124
+ function toLocal(date, utcOffset, timezone) {
125
+ if (utcOffset !== void 0) return date.utcOffset(utcOffset);
126
+ if (timezone) return date.tz(timezone);
127
+ return date;
128
+ }
129
+ function getSortedDayjsArray(values, _fixedTime) {
118
130
  return [...values].sort((a, b) => a.valueOf() - b.valueOf());
119
131
  }
120
132
  function isValueChange(prevValue, currentValue) {
@@ -128,7 +140,7 @@ function isValueChange(prevValue, currentValue) {
128
140
  if (!isArray(currentValue) && !isArray(prevValue)) return isDifference(currentValue, prevValue);
129
141
  return true;
130
142
  }
131
- function getDayjsValue(time, format) {
143
+ function getDayjsValue(time, format, utcOffset, timezone) {
132
144
  const parseQuarterToMonth = (value) => {
133
145
  const reg = /(Q1)|(Q2)|(Q3)|(Q4)/;
134
146
  const quarter = {
@@ -148,8 +160,12 @@ function getDayjsValue(time, format) {
148
160
  }
149
161
  return dayjs$1(value);
150
162
  };
151
- if (isArray(time)) return time.map(formatValue);
152
- return formatValue(time);
163
+ if (isArray(time)) return time.map((t) => {
164
+ const parsed = formatValue(t);
165
+ return parsed ? toLocal(parsed, utcOffset, timezone) : parsed;
166
+ });
167
+ const parsed = formatValue(time);
168
+ return parsed ? toLocal(parsed, utcOffset, timezone) : parsed;
153
169
  }
154
170
  function getDateValue(value) {
155
171
  const formatValue = (t) => t ? t.toDate() : void 0;
@@ -178,4 +194,4 @@ function _initializeDateLocale() {
178
194
  return _initializeDateLocale.apply(this, arguments);
179
195
  }
180
196
  //#endregion
181
- export { dayjs$1 as dayjs, getDateValue, getDayjsValue, getNow, getSortedDayjsArray, initializeDateLocale, isValueChange, methods };
197
+ export { dayjs$1 as dayjs, getDateValue, getDayjsValue, getNow, getSortedDayjsArray, initializeDateLocale, isValueChange, methods, toLocal };
@@ -1,8 +1,11 @@
1
+ import type { CSSProperties } from 'vue';
1
2
  import { PropType } from 'vue';
2
3
  import { type BoundaryPosition } from './utils';
3
- declare var __VLS_1: {};
4
+ declare const DIRECTIONS: readonly ["vertical", "horizontal"];
5
+ type Direction = (typeof DIRECTIONS)[number];
6
+ declare var __VLS_8: {};
4
7
  type __VLS_Slots = {} & {
5
- default?: (props: typeof __VLS_1) => any;
8
+ default?: (props: typeof __VLS_8) => any;
6
9
  };
7
10
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
11
  boundary: {
@@ -14,6 +17,28 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
14
17
  type: BooleanConstructor;
15
18
  default: boolean;
16
19
  };
20
+ affix: {
21
+ type: BooleanConstructor;
22
+ default: boolean;
23
+ };
24
+ affixStyle: {
25
+ type: PropType<CSSProperties>;
26
+ };
27
+ offsetTop: {
28
+ type: NumberConstructor;
29
+ default: number;
30
+ };
31
+ offsetBottom: {
32
+ type: NumberConstructor;
33
+ };
34
+ direction: {
35
+ type: PropType<Direction>;
36
+ default: string;
37
+ validator: (value: any) => boolean;
38
+ };
39
+ targetOffset: {
40
+ type: NumberConstructor;
41
+ };
17
42
  scrollContainer: {
18
43
  type: PropType<string | HTMLElement | Window>;
19
44
  };
@@ -38,6 +63,28 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
38
63
  type: BooleanConstructor;
39
64
  default: boolean;
40
65
  };
66
+ affix: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
70
+ affixStyle: {
71
+ type: PropType<CSSProperties>;
72
+ };
73
+ offsetTop: {
74
+ type: NumberConstructor;
75
+ default: number;
76
+ };
77
+ offsetBottom: {
78
+ type: NumberConstructor;
79
+ };
80
+ direction: {
81
+ type: PropType<Direction>;
82
+ default: string;
83
+ validator: (value: any) => boolean;
84
+ };
85
+ targetOffset: {
86
+ type: NumberConstructor;
87
+ };
41
88
  scrollContainer: {
42
89
  type: PropType<string | HTMLElement | Window>;
43
90
  };
@@ -53,9 +100,12 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
53
100
  onChange?: ((_hash: string) => any) | undefined;
54
101
  onSelect?: ((_hash: string | undefined, _preHash: string) => any) | undefined;
55
102
  }>, {
103
+ direction: "horizontal" | "vertical";
56
104
  smooth: boolean;
105
+ offsetTop: number;
57
106
  boundary: number | "center" | "end" | "start" | "nearest";
58
107
  lineLess: boolean;
108
+ affix: boolean;
59
109
  changeHash: boolean;
60
110
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
61
111
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -5,7 +5,7 @@ import { getElement, off, on } from "../_utils/dom.js";
5
5
  import { throttleByRaf } from "../_utils/throttle-by-raf.js";
6
6
  import { anchorInjectionKey } from "./context.js";
7
7
  import { BOUNDARY_POSITIONS, slide } from "./utils.js";
8
- import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, nextTick, normalizeClass, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderSlot, unref, watch } from "vue";
8
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, nextTick, normalizeClass, normalizeProps, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderSlot, resolveDynamicComponent, unref, watch, withCtx } from "vue";
9
9
  import { compute } from "compute-scroll-into-view";
10
10
  //#region components/anchor/anchor.vue?vue&type=script&setup=true&lang.ts
11
11
  var anchor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "Anchor" }), {}, {
@@ -32,6 +32,47 @@ var anchor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
32
32
  default: false
33
33
  },
34
34
  /**
35
+ * @zh 是否固定
36
+ * @en Whether to wrap anchor within Affix
37
+ */
38
+ affix: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ /**
43
+ * @zh 设置 Affix 组件的样式
44
+ * @en The style to be applied to Affix
45
+ */
46
+ affixStyle: { type: Object },
47
+ /**
48
+ * @zh 距离窗口顶部的偏移量
49
+ * @en Offset from the top of the viewport
50
+ */
51
+ offsetTop: {
52
+ type: Number,
53
+ default: 0
54
+ },
55
+ /**
56
+ * @zh 距离窗口底部的偏移量
57
+ * @en Offset from the bottom of the viewport
58
+ */
59
+ offsetBottom: { type: Number },
60
+ /**
61
+ * @zh 锚点方向
62
+ * @en Direction
63
+ * @values 'vertical', 'horizontal'
64
+ */
65
+ direction: {
66
+ type: String,
67
+ default: "vertical",
68
+ validator: (value) => ["vertical", "horizontal"].includes(value)
69
+ },
70
+ /**
71
+ * @zh 锚点区域边界相对于滚动容器顶部的偏移量。未设置时,默认值为滚动容器高度的一半
72
+ * @en The offset of the baseline relative to the top of the container. The value is half of the height of the scrolling container if not specified
73
+ */
74
+ targetOffset: { type: Number },
75
+ /**
35
76
  * @zh 滚动容器
36
77
  * @en Scroll container
37
78
  */
@@ -82,7 +123,8 @@ var anchor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
82
123
  };
83
124
  const scrollIntoView = (hash) => {
84
125
  try {
85
- const element = getElement(hash);
126
+ var _getElement;
127
+ const element = (_getElement = getElement(hash, containerEle.value)) !== null && _getElement !== void 0 ? _getElement : getElement(hash);
86
128
  if (!element) return;
87
129
  let block;
88
130
  let diff = 0;
@@ -123,12 +165,14 @@ var anchor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
123
165
  if (!scrollContainerEle.value || !containerEle.value) return;
124
166
  const boundary = isNumber(props.boundary) ? props.boundary : 0;
125
167
  const containerRect = containerEle.value.getBoundingClientRect();
168
+ const targetOffset = isNumber(props.targetOffset) ? props.targetOffset : containerRect.height / 2;
126
169
  for (const hash of Object.keys(links)) {
127
- const element = getElement(hash);
170
+ var _getElement2;
171
+ const element = (_getElement2 = getElement(hash, containerEle.value)) !== null && _getElement2 !== void 0 ? _getElement2 : getElement(hash);
128
172
  if (element) {
129
173
  const { top } = element.getBoundingClientRect();
130
174
  const offsetTop = isWindow(scrollContainerEle.value) ? top - boundary : top - containerRect.top - boundary;
131
- if (offsetTop >= 0 && offsetTop <= containerRect.height / 2) return element;
175
+ if (offsetTop >= 0 && offsetTop <= targetOffset) return element;
132
176
  }
133
177
  }
134
178
  };
@@ -169,18 +213,34 @@ var anchor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
169
213
  removeLink,
170
214
  handleClick
171
215
  }));
172
- const cls = computed(() => [prefixCls, { [`${prefixCls}-line-less`]: props.lineLess }]);
216
+ const cls = computed(() => [prefixCls, {
217
+ [`${prefixCls}-line-less`]: props.lineLess,
218
+ [`${prefixCls}-horizontal`]: props.direction === "horizontal"
219
+ }]);
220
+ const wrapperComponent = computed(() => props.affix ? "Affix" : "div");
221
+ const wrapperProps = computed(() => {
222
+ if (!props.affix) return {};
223
+ return {
224
+ offsetTop: props.offsetTop,
225
+ offsetBottom: props.offsetBottom,
226
+ target: props.scrollContainer,
227
+ style: props.affixStyle
228
+ };
229
+ });
173
230
  return (_ctx, _cache) => {
174
- return openBlock(), createElementBlock("div", {
175
- ref_key: "anchorRef",
176
- ref: anchorRef,
177
- class: normalizeClass(cls.value)
178
- }, [!__props.lineLess ? (openBlock(), createElementBlock("div", {
179
- key: 0,
180
- ref_key: "lineSliderRef",
181
- ref: lineSliderRef,
182
- class: normalizeClass(`${unref(prefixCls)}-line-slider`)
183
- }, null, 2)) : createCommentVNode("", true), createElementVNode("ul", { class: normalizeClass(`${unref(prefixCls)}-list`) }, [renderSlot(_ctx.$slots, "default")], 2)], 2);
231
+ return openBlock(), createBlock(resolveDynamicComponent(wrapperComponent.value), normalizeProps(guardReactiveProps(wrapperProps.value)), {
232
+ default: withCtx(() => [createElementVNode("div", {
233
+ ref_key: "anchorRef",
234
+ ref: anchorRef,
235
+ class: normalizeClass(cls.value)
236
+ }, [!__props.lineLess ? (openBlock(), createElementBlock("div", {
237
+ key: 0,
238
+ ref_key: "lineSliderRef",
239
+ ref: lineSliderRef,
240
+ class: normalizeClass(`${unref(prefixCls)}-line-slider`)
241
+ }, null, 2)) : createCommentVNode("", true), createElementVNode("ul", { class: normalizeClass(`${unref(prefixCls)}-list`) }, [renderSlot(_ctx.$slots, "default")], 2)], 2)]),
242
+ _: 3
243
+ }, 16);
184
244
  };
185
245
  }
186
246
  }));
@@ -13,6 +13,28 @@ declare const Anchor: {
13
13
  type: BooleanConstructor;
14
14
  default: boolean;
15
15
  };
16
+ affix: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
20
+ affixStyle: {
21
+ type: import("vue").PropType<import("vue").CSSProperties>;
22
+ };
23
+ offsetTop: {
24
+ type: NumberConstructor;
25
+ default: number;
26
+ };
27
+ offsetBottom: {
28
+ type: NumberConstructor;
29
+ };
30
+ direction: {
31
+ type: import("vue").PropType<"horizontal" | "vertical">;
32
+ default: string;
33
+ validator: (value: any) => boolean;
34
+ };
35
+ targetOffset: {
36
+ type: NumberConstructor;
37
+ };
16
38
  scrollContainer: {
17
39
  type: import("vue").PropType<string | HTMLElement | Window>;
18
40
  };
@@ -31,9 +53,12 @@ declare const Anchor: {
31
53
  change: (_hash: string) => any;
32
54
  select: (_hash: string | undefined, _preHash: string) => any;
33
55
  }, import("vue").PublicProps, {
56
+ direction: "horizontal" | "vertical";
34
57
  smooth: boolean;
58
+ offsetTop: number;
35
59
  boundary: number | "center" | "end" | "start" | "nearest";
36
60
  lineLess: boolean;
61
+ affix: boolean;
37
62
  changeHash: boolean;
38
63
  }, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
39
64
  P: {};
@@ -52,6 +77,28 @@ declare const Anchor: {
52
77
  type: BooleanConstructor;
53
78
  default: boolean;
54
79
  };
80
+ affix: {
81
+ type: BooleanConstructor;
82
+ default: boolean;
83
+ };
84
+ affixStyle: {
85
+ type: import("vue").PropType<import("vue").CSSProperties>;
86
+ };
87
+ offsetTop: {
88
+ type: NumberConstructor;
89
+ default: number;
90
+ };
91
+ offsetBottom: {
92
+ type: NumberConstructor;
93
+ };
94
+ direction: {
95
+ type: import("vue").PropType<"horizontal" | "vertical">;
96
+ default: string;
97
+ validator: (value: any) => boolean;
98
+ };
99
+ targetOffset: {
100
+ type: NumberConstructor;
101
+ };
55
102
  scrollContainer: {
56
103
  type: import("vue").PropType<string | HTMLElement | Window>;
57
104
  };
@@ -67,9 +114,12 @@ declare const Anchor: {
67
114
  onChange?: ((_hash: string) => any) | undefined;
68
115
  onSelect?: ((_hash: string | undefined, _preHash: string) => any) | undefined;
69
116
  }>, {}, {}, {}, {}, {
117
+ direction: "horizontal" | "vertical";
70
118
  smooth: boolean;
119
+ offsetTop: number;
71
120
  boundary: number | "center" | "end" | "start" | "nearest";
72
121
  lineLess: boolean;
122
+ affix: boolean;
73
123
  changeHash: boolean;
74
124
  }>;
75
125
  __isFragment?: never;
@@ -85,6 +135,28 @@ declare const Anchor: {
85
135
  type: BooleanConstructor;
86
136
  default: boolean;
87
137
  };
138
+ affix: {
139
+ type: BooleanConstructor;
140
+ default: boolean;
141
+ };
142
+ affixStyle: {
143
+ type: import("vue").PropType<import("vue").CSSProperties>;
144
+ };
145
+ offsetTop: {
146
+ type: NumberConstructor;
147
+ default: number;
148
+ };
149
+ offsetBottom: {
150
+ type: NumberConstructor;
151
+ };
152
+ direction: {
153
+ type: import("vue").PropType<"horizontal" | "vertical">;
154
+ default: string;
155
+ validator: (value: any) => boolean;
156
+ };
157
+ targetOffset: {
158
+ type: NumberConstructor;
159
+ };
88
160
  scrollContainer: {
89
161
  type: import("vue").PropType<string | HTMLElement | Window>;
90
162
  };
@@ -103,9 +175,12 @@ declare const Anchor: {
103
175
  change: (_hash: string) => any;
104
176
  select: (_hash: string | undefined, _preHash: string) => any;
105
177
  }, string, {
178
+ direction: "horizontal" | "vertical";
106
179
  smooth: boolean;
180
+ offsetTop: number;
107
181
  boundary: number | "center" | "end" | "start" | "nearest";
108
182
  lineLess: boolean;
183
+ affix: boolean;
109
184
  changeHash: boolean;
110
185
  }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
111
186
  $slots: {
@@ -1,15 +1,19 @@
1
1
  import type { PropType } from 'vue';
2
2
  import { Status, Size, BorderShape } from '../_utils/constant';
3
3
  import { ButtonTypes } from './constants';
4
- declare var __VLS_6: {}, __VLS_8: {}, __VLS_15: {}, __VLS_17: {};
4
+ declare var __VLS_6: {}, __VLS_8: {}, __VLS_10: {}, __VLS_17: {}, __VLS_19: {}, __VLS_21: {};
5
5
  type __VLS_Slots = {} & {
6
6
  icon?: (props: typeof __VLS_6) => any;
7
7
  } & {
8
8
  default?: (props: typeof __VLS_8) => any;
9
9
  } & {
10
- icon?: (props: typeof __VLS_15) => any;
10
+ default?: (props: typeof __VLS_10) => any;
11
11
  } & {
12
- default?: (props: typeof __VLS_17) => any;
12
+ icon?: (props: typeof __VLS_17) => any;
13
+ } & {
14
+ default?: (props: typeof __VLS_19) => any;
15
+ } & {
16
+ default?: (props: typeof __VLS_21) => any;
13
17
  };
14
18
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
15
19
  type: {
@@ -32,6 +36,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
32
36
  type: BooleanConstructor;
33
37
  default: boolean;
34
38
  };
39
+ loadingFixedWidth: {
40
+ type: BooleanConstructor;
41
+ default: boolean;
42
+ };
35
43
  disabled: {
36
44
  type: BooleanConstructor;
37
45
  };
@@ -67,6 +75,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
67
75
  type: BooleanConstructor;
68
76
  default: boolean;
69
77
  };
78
+ loadingFixedWidth: {
79
+ type: BooleanConstructor;
80
+ default: boolean;
81
+ };
70
82
  disabled: {
71
83
  type: BooleanConstructor;
72
84
  };
@@ -86,6 +98,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
86
98
  disabled: boolean;
87
99
  loading: boolean;
88
100
  long: boolean;
101
+ loadingFixedWidth: boolean;
89
102
  htmlType: "reset" | "submit" | "button";
90
103
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
91
104
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,18 +1,21 @@
1
1
  import { useFormItem } from "../_hooks/use-form-item.js";
2
+ import { configProviderInjectionKey } from "../config-provider/context.js";
2
3
  import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/objectSpread2.js";
3
4
  import { getPrefixCls } from "../_utils/global-config.js";
4
5
  import { isString } from "../_utils/is.js";
5
6
  import IconLoading from "../icon/icon-loading/index.js";
6
7
  import { useSize } from "../_hooks/use-size.js";
7
8
  import { buttonGroupInjectionKey } from "./context.js";
8
- import { computed, createBlock, createCommentVNode, createElementBlock, defineComponent, inject, normalizeClass, openBlock, renderSlot, toRefs, unref } from "vue";
9
+ import { computed, createBlock, createCommentVNode, createElementBlock, defineComponent, inject, normalizeClass, onMounted, onUpdated, openBlock, ref, renderSlot, toRefs, unref } from "vue";
9
10
  //#region components/button/button.vue?vue&type=script&setup=true&lang.ts
10
11
  var _hoisted_1 = ["href"];
11
- var _hoisted_2 = [
12
+ var _hoisted_2 = { key: 2 };
13
+ var _hoisted_3 = [
12
14
  "type",
13
15
  "disabled",
14
16
  "autofocus"
15
17
  ];
18
+ var _hoisted_4 = { key: 2 };
16
19
  var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "Button" }), {}, {
17
20
  __name: "button",
18
21
  props: {
@@ -58,6 +61,14 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
58
61
  default: false
59
62
  },
60
63
  /**
64
+ * @zh 当 loading 的时候,不改变按钮的宽度。
65
+ * @en The width of the button remains unchanged on loading.
66
+ */
67
+ loadingFixedWidth: {
68
+ type: Boolean,
69
+ default: false
70
+ },
71
+ /**
61
72
  * @zh 按钮是否禁用
62
73
  * @en Whether the button is disabled
63
74
  * @defaultValue false
@@ -87,10 +98,7 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
87
98
  },
88
99
  emits: ["click"],
89
100
  setup(__props, { emit: __emit }) {
90
- /**
91
- * @todo 添加loadingFixedWidth
92
- * @todo 添加twoChineseChars
93
- */
101
+ const regexTwoCNChar = /^[一-龥]{2}$/;
94
102
  const props = __props;
95
103
  const emit = __emit;
96
104
  /**
@@ -100,7 +108,9 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
100
108
  */
101
109
  const { size, disabled } = toRefs(props);
102
110
  const prefixCls = getPrefixCls("btn");
111
+ const configContext = inject(configProviderInjectionKey, void 0);
103
112
  const groupContext = inject(buttonGroupInjectionKey, void 0);
113
+ const autoInsertSpaceInButton = computed(() => Boolean(configContext === null || configContext === void 0 ? void 0 : configContext.autoInsertSpaceInButton));
104
114
  const { mergedSize: _mergedSize, mergedDisabled } = useFormItem({
105
115
  size: computed(() => {
106
116
  var _size$value;
@@ -109,6 +119,20 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
109
119
  disabled: computed(() => Boolean(disabled.value || (groupContext === null || groupContext === void 0 ? void 0 : groupContext.disabled)))
110
120
  });
111
121
  const { mergedSize } = useSize(_mergedSize);
122
+ const buttonRef = ref();
123
+ const isTwoCNChar = ref(false);
124
+ const updateIsTwoCNChar = () => {
125
+ var _buttonRef$value$text, _buttonRef$value;
126
+ if (!autoInsertSpaceInButton.value) {
127
+ if (isTwoCNChar.value) isTwoCNChar.value = false;
128
+ return;
129
+ }
130
+ const textContent = (_buttonRef$value$text = (_buttonRef$value = buttonRef.value) === null || _buttonRef$value === void 0 || (_buttonRef$value = _buttonRef$value.textContent) === null || _buttonRef$value === void 0 ? void 0 : _buttonRef$value.replace(/\s/g, "")) !== null && _buttonRef$value$text !== void 0 ? _buttonRef$value$text : "";
131
+ const value = regexTwoCNChar.test(textContent);
132
+ if (value !== isTwoCNChar.value) isTwoCNChar.value = value;
133
+ };
134
+ onMounted(updateIsTwoCNChar);
135
+ onUpdated(updateIsTwoCNChar);
112
136
  const cls = computed(() => {
113
137
  var _ref, _props$type, _ref2, _props$shape, _ref3, _props$status;
114
138
  return [
@@ -120,8 +144,10 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
120
144
  {
121
145
  [`${prefixCls}-long`]: props.long,
122
146
  [`${prefixCls}-loading`]: props.loading,
147
+ [`${prefixCls}-loading-fixed-width`]: props.loadingFixedWidth,
123
148
  [`${prefixCls}-disabled`]: mergedDisabled.value,
124
- [`${prefixCls}-link`]: isString(props.href)
149
+ [`${prefixCls}-link`]: isString(props.href),
150
+ [`${prefixCls}-two-chinese-chars`]: autoInsertSpaceInButton.value && isTwoCNChar.value
125
151
  }
126
152
  ];
127
153
  });
@@ -135,6 +161,8 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
135
161
  return (_ctx, _cache) => {
136
162
  return __props.href ? (openBlock(), createElementBlock("a", {
137
163
  key: 0,
164
+ ref_key: "buttonRef",
165
+ ref: buttonRef,
138
166
  class: normalizeClass([cls.value, { [`${unref(prefixCls)}-only-icon`]: _ctx.$slots.icon && !_ctx.$slots.default }]),
139
167
  href: unref(mergedDisabled) || __props.loading ? void 0 : __props.href,
140
168
  onClick: handleClick
@@ -144,8 +172,10 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
144
172
  }, [__props.loading ? (openBlock(), createBlock(unref(IconLoading), {
145
173
  key: 0,
146
174
  spin: ""
147
- })) : renderSlot(_ctx.$slots, "icon", { key: 1 })], 2)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default")], 10, _hoisted_1)) : (openBlock(), createElementBlock("button", {
175
+ })) : renderSlot(_ctx.$slots, "icon", { key: 1 })], 2)) : createCommentVNode("", true), !isTwoCNChar.value ? renderSlot(_ctx.$slots, "default", { key: 1 }) : (openBlock(), createElementBlock("span", _hoisted_2, [renderSlot(_ctx.$slots, "default")]))], 10, _hoisted_1)) : (openBlock(), createElementBlock("button", {
148
176
  key: 1,
177
+ ref_key: "buttonRef",
178
+ ref: buttonRef,
149
179
  class: normalizeClass([cls.value, { [`${unref(prefixCls)}-only-icon`]: _ctx.$slots.icon && !_ctx.$slots.default }]),
150
180
  type: __props.htmlType,
151
181
  disabled: unref(mergedDisabled),
@@ -157,7 +187,7 @@ var button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
157
187
  }, [__props.loading ? (openBlock(), createBlock(unref(IconLoading), {
158
188
  key: 0,
159
189
  spin: true
160
- })) : renderSlot(_ctx.$slots, "icon", { key: 1 })], 2)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default")], 10, _hoisted_2));
190
+ })) : renderSlot(_ctx.$slots, "icon", { key: 1 })], 2)) : createCommentVNode("", true), !isTwoCNChar.value ? renderSlot(_ctx.$slots, "default", { key: 1 }) : (openBlock(), createElementBlock("span", _hoisted_4, [renderSlot(_ctx.$slots, "default")]))], 10, _hoisted_3));
161
191
  };
162
192
  }
163
193
  }));