@tu-design/vue 0.5.7 → 0.5.9

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 (56) hide show
  1. package/dist/index.d.mts +363 -175
  2. package/dist/index.mjs +1953 -569
  3. package/dist/registry/vue/alert-dialog.json +1 -1
  4. package/dist/registry/vue/alert.json +1 -1
  5. package/dist/registry/vue/avatar-group.json +1 -1
  6. package/dist/registry/vue/avatar.json +1 -1
  7. package/dist/registry/vue/badge.json +1 -1
  8. package/dist/registry/vue/button.json +1 -1
  9. package/dist/registry/vue/calendar.json +3 -3
  10. package/dist/registry/vue/card.json +1 -1
  11. package/dist/registry/vue/cascader.json +1 -1
  12. package/dist/registry/vue/checkbox.json +2 -2
  13. package/dist/registry/vue/context-menu.json +1 -1
  14. package/dist/registry/vue/currency-input.json +2 -2
  15. package/dist/registry/vue/date-picker.json +1 -1
  16. package/dist/registry/vue/date-range-picker.json +1 -1
  17. package/dist/registry/vue/date-shared.json +3 -3
  18. package/dist/registry/vue/dialog.json +1 -1
  19. package/dist/registry/vue/drawer.json +1 -1
  20. package/dist/registry/vue/dropdown-menu.json +1 -1
  21. package/dist/registry/vue/empty.json +1 -1
  22. package/dist/registry/vue/form-render.json +14 -14
  23. package/dist/registry/vue/form.json +2 -2
  24. package/dist/registry/vue/icon-shared.json +8 -2
  25. package/dist/registry/vue/input.json +2 -2
  26. package/dist/registry/vue/label.json +1 -1
  27. package/dist/registry/vue/month-picker.json +1 -1
  28. package/dist/registry/vue/number-input.json +3 -3
  29. package/dist/registry/vue/overlay-shared.json +5 -5
  30. package/dist/registry/vue/password-input.json +1 -1
  31. package/dist/registry/vue/pin-input.json +1 -1
  32. package/dist/registry/vue/popconfirm.json +1 -1
  33. package/dist/registry/vue/popover.json +1 -1
  34. package/dist/registry/vue/progress.json +1 -1
  35. package/dist/registry/vue/radio-group.json +1 -1
  36. package/dist/registry/vue/registry.json +54 -54
  37. package/dist/registry/vue/select.json +2 -2
  38. package/dist/registry/vue/separator.json +1 -1
  39. package/dist/registry/vue/skeleton.json +1 -1
  40. package/dist/registry/vue/slider.json +1 -1
  41. package/dist/registry/vue/slot.json +2 -2
  42. package/dist/registry/vue/spin.json +1 -1
  43. package/dist/registry/vue/switch.json +1 -1
  44. package/dist/registry/vue/table-render.json +26 -13
  45. package/dist/registry/vue/tabs.json +1 -1
  46. package/dist/registry/vue/textarea.json +2 -2
  47. package/dist/registry/vue/timeline.json +2 -2
  48. package/dist/registry/vue/toast.json +2 -2
  49. package/dist/registry/vue/tokens.json +1 -1
  50. package/dist/registry/vue/tooltip.json +1 -1
  51. package/dist/registry/vue/tree-select.json +1 -1
  52. package/dist/registry/vue/tree-shared.json +9 -9
  53. package/dist/registry/vue/utils.json +2 -2
  54. package/dist/registry/vue/week-picker.json +2 -2
  55. package/dist/registry/vue/year-picker.json +1 -1
  56. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -25,6 +25,11 @@ import { Progress } from "@ark-ui/vue/progress";
25
25
  import { Toast, Toaster, createToaster } from "@ark-ui/vue/toast";
26
26
  import { Drawer } from "@ark-ui/vue/drawer";
27
27
  //#region src/lib/utils.ts
28
+ /**
29
+ * 合并 Tailwind CSS 类名:clsx 组合条件类名,tailwind-merge 消解冲突规则。
30
+ * @param inputs - 任意数量的类名值(字符串、数组或对象)
31
+ * @returns 消解冲突后的类名字符串
32
+ */
28
33
  function cn(...inputs) {
29
34
  return twMerge(clsx(inputs));
30
35
  }
@@ -94,6 +99,12 @@ const COMPONENT_NAMES = [
94
99
  "WeekPicker",
95
100
  "YearPicker"
96
101
  ];
102
+ /**
103
+ * 创建 unplugin-vue-components 的自动导入 Resolver:T 前缀(PascalCase)且命中
104
+ * 白名单的组件名(如 TButton)被解析为对应库导出;其余名称返回 undefined
105
+ * 交由后续 Resolver 或默认流程处理。
106
+ * @returns Resolver 函数(组件名到导入描述的映射)
107
+ */
97
108
  function TuDesignResolver() {
98
109
  return (name) => {
99
110
  if (!/^T[A-Z]/.test(name)) return;
@@ -107,7 +118,11 @@ function TuDesignResolver() {
107
118
  }
108
119
  //#endregion
109
120
  //#region src/components/slot/Slot.ts
110
- /** 递归展平 `<slot />` 插槽出口(renderSlot)产生的 Fragment 包裹,取出真实子节点。 */
121
+ /**
122
+ * 递归展平 `<slot />` 插槽出口(renderSlot)产生的 Fragment 包裹,取出真实子节点。
123
+ * @param children - 插槽渲染输出的 vnode 数组
124
+ * @returns 展平后的 vnode 数组(已剥离 Fragment 包裹层级)
125
+ */
111
126
  function flattenVNodes(children) {
112
127
  const out = [];
113
128
  for (const child of children) if (child.type === Fragment && Array.isArray(child.children)) out.push(...flattenVNodes(child.children));
@@ -279,7 +294,7 @@ const _sfc_main$19 = defineComponent({
279
294
  });
280
295
  //#endregion
281
296
  //#region src/components/form/FormDescription.vue
282
- const _hoisted_1$32 = ["id"];
297
+ const _hoisted_1$33 = ["id"];
283
298
  const _sfc_main$20 = /*@__PURE__*/ defineComponent({
284
299
  __name: "FormDescription",
285
300
  props: { class: {} },
@@ -293,37 +308,20 @@ const _sfc_main$20 = /*@__PURE__*/ defineComponent({
293
308
  return openBlock(), createElementBlock("p", {
294
309
  id: unref(itemCtx)?.descriptionId,
295
310
  class: normalizeClass(unref(cn)("text-muted-foreground text-sm", props.class))
296
- }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1$32);
311
+ }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1$33);
297
312
  };
298
313
  }
299
314
  });
300
315
  //#endregion
301
316
  //#region src/components/form/FormField.vue
302
- /**
303
- * 渲染 TanStack `form.Field` 并经 provide 下发 field 上下文。
304
- * field 实例只能在 form.Field 的插槽执行期取得(时序早于子组件 setup),
305
- * 故用 defineComponent + render function 在插槽回调中写入 ShallowRef。
306
- */
307
- const _sfc_main$21 = defineComponent({
308
- name: "TuFormField",
309
- props: {
310
- /** 字段名(TanStack 深层 key 的运行时形态) */
311
- name: {
312
- type: String,
313
- required: true
314
- },
315
- /** 校验器配置,原样透传(值可为函数或 Standard Schema,如 valibot) */
316
- validators: {
317
- type: Object,
318
- default: void 0
319
- },
320
- /** 字段模式:value 单值(默认);array 数组字段,解锁 pushValue/removeValue 等行操作 */
321
- mode: {
322
- type: String,
323
- default: "value"
324
- }
325
- },
326
- setup(props, { slots }) {
317
+ const _sfc_main$21 = defineComponent(
318
+ /**
319
+ * @param props - 组件 props(name/validators/mode)
320
+ * @param ctx - setup 上下文(slots/attrs/emit)
321
+ * @returns 渲染函数:Form 内渲染 TanStack form.Field 并捕获 field 实例;缺席时降级直渲插槽
322
+ */
323
+ (props, ctx) => {
324
+ const { slots } = ctx;
327
325
  const form = inject(FORM_KEY);
328
326
  if (!form && import.meta.env.DEV) console.warn("[tu-design] <FormField> 必须在 <Form> 内使用");
329
327
  const fieldRef = shallowRef();
@@ -340,11 +338,28 @@ const _sfc_main$21 = defineComponent({
340
338
  fieldRef.value = slotProps.field;
341
339
  return slots.default?.(slotProps);
342
340
  } });
341
+ },
342
+ {
343
+ name: "TuFormField",
344
+ props: {
345
+ name: {
346
+ type: String,
347
+ required: true
348
+ },
349
+ validators: {
350
+ type: Object,
351
+ default: void 0
352
+ },
353
+ mode: {
354
+ type: String,
355
+ default: "value"
356
+ }
357
+ }
343
358
  }
344
- });
359
+ );
345
360
  //#endregion
346
361
  //#region src/components/form/FormItem.vue
347
- const _hoisted_1$31 = ["data-invalid"];
362
+ const _hoisted_1$32 = ["data-invalid"];
348
363
  const _sfc_main$22 = /*@__PURE__*/ defineComponent({
349
364
  __name: "FormItem",
350
365
  setup(__props) {
@@ -369,13 +384,13 @@ const _sfc_main$22 = /*@__PURE__*/ defineComponent({
369
384
  return openBlock(), createElementBlock("div", {
370
385
  class: normalizeClass(unref(cn)("group flex flex-col gap-1.5")),
371
386
  "data-invalid": isInvalid.value ? "" : void 0
372
- }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1$31);
387
+ }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1$32);
373
388
  };
374
389
  }
375
390
  });
376
391
  //#endregion
377
392
  //#region src/components/form/FormLabel.vue
378
- const _hoisted_1$30 = ["for", "data-invalid"];
393
+ const _hoisted_1$31 = ["for", "data-invalid"];
379
394
  const _sfc_main$23 = /*@__PURE__*/ defineComponent({
380
395
  __name: "FormLabel",
381
396
  props: { class: {} },
@@ -389,13 +404,13 @@ const _sfc_main$23 = /*@__PURE__*/ defineComponent({
389
404
  for: unref(itemCtx)?.controlId,
390
405
  "data-invalid": isInvalid.value ? "" : void 0,
391
406
  class: normalizeClass(unref(cn)("text-sm font-medium leading-none data-invalid:text-destructive", props.class))
392
- }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1$30);
407
+ }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_1$31);
393
408
  };
394
409
  }
395
410
  });
396
411
  //#endregion
397
412
  //#region src/components/form/FormMessage.vue
398
- const _hoisted_1$29 = ["id"];
413
+ const _hoisted_1$30 = ["id"];
399
414
  const _sfc_main$24 = /*@__PURE__*/ defineComponent({
400
415
  __name: "FormMessage",
401
416
  props: {
@@ -420,7 +435,7 @@ const _sfc_main$24 = /*@__PURE__*/ defineComponent({
420
435
  key: 0,
421
436
  id: unref(itemCtx)?.messageId,
422
437
  class: normalizeClass(unref(cn)("text-destructive text-sm", props.class))
423
- }, toDisplayString(errorText.value), 11, _hoisted_1$29)) : createCommentVNode("v-if", true);
438
+ }, toDisplayString(errorText.value), 11, _hoisted_1$30)) : createCommentVNode("v-if", true);
424
439
  };
425
440
  }
426
441
  });
@@ -450,7 +465,7 @@ const _sfc_main$26 = /*@__PURE__*/ defineComponent({
450
465
  * aria 接线(id/aria-invalid/aria-describedby)由 FormControl 的 cloneVNode 机制继承。
451
466
  * widget 调用发生在 FormField 插槽期,拿到 field 实例后组装 WidgetContext。
452
467
  */
453
- const _sfc_main$64 = defineComponent({
468
+ const _sfc_main$65 = defineComponent({
454
469
  name: "TuFormRenderField",
455
470
  props: {
456
471
  item: {
@@ -462,7 +477,7 @@ const _sfc_main$64 = defineComponent({
462
477
  type: Function,
463
478
  required: true
464
479
  },
465
- /** 响应式全量表单值(FormRender 经 useSelector 建立,S1) */
480
+ /** 响应式全量表单值(FormRender 经 useSelector 建立) */
466
481
  values: {
467
482
  type: Object,
468
483
  required: true
@@ -492,7 +507,7 @@ const _sfc_main$64 = defineComponent({
492
507
  });
493
508
  //#endregion
494
509
  //#region src/components/checkbox/Checkbox.vue
495
- const _hoisted_1$28 = {
510
+ const _hoisted_1$29 = {
496
511
  key: 0,
497
512
  viewBox: "0 0 24 24",
498
513
  fill: "none",
@@ -565,7 +580,7 @@ const _sfc_main$9 = /*@__PURE__*/ defineComponent({
565
580
  createVNode(unref(Checkbox).HiddenInput),
566
581
  createVNode(unref(Checkbox).Control, { class: "border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 peer size-4 shrink-0 rounded-[4px] border bg-transparent shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50" }, {
567
582
  default: withCtx(() => [createVNode(unref(Checkbox).Indicator, { class: "flex items-center justify-center text-current" }, {
568
- default: withCtx(() => [createCommentVNode(" 半选态(data-state=indeterminate)显示短横线,选中态显示对勾 "), isChecked.value === "indeterminate" ? (openBlock(), createElementBlock("svg", _hoisted_1$28, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M5 12h14" }, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_2$18, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M20 6 9 17l-5-5" }, null, -1)])]))]),
583
+ default: withCtx(() => [createCommentVNode(" 半选态(data-state=indeterminate)显示短横线,选中态显示对勾 "), isChecked.value === "indeterminate" ? (openBlock(), createElementBlock("svg", _hoisted_1$29, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M5 12h14" }, null, -1)])])) : (openBlock(), createElementBlock("svg", _hoisted_2$18, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M20 6 9 17l-5-5" }, null, -1)])]))]),
569
584
  _: 1
570
585
  })]),
571
586
  _: 1
@@ -674,6 +689,9 @@ const SLIDER = {
674
689
  /**
675
690
  * TanStack field → 控件 props 的统一绑定:
676
691
  * 值回显(field.state.value)+ 写回(handleChange)+ 失焦(handleBlur)。
692
+ * @param field - TanStack 表单字段实例,提供值读取与变更/失焦句柄
693
+ * @param spec - 绑定形态描述,决定值 prop 名、事件名与可选的双向转换
694
+ * @returns 可展开到组件 props 上的对象(值 prop、onUpdate:<event>、onBlur)
677
695
  */
678
696
  function bindField(field, spec) {
679
697
  return {
@@ -687,6 +705,8 @@ function bindField(field, spec) {
687
705
  /**
688
706
  * checkbox/switch widget:boolean 形态(值 prop 为 checked,非 modelValue)。
689
707
  * 单行布局倾向 hideLabel + label 经 item.title 展示由使用者决定。
708
+ * @param options - widget 选项,整体展开后经 checked 受控绑定与 componentProps 透传给 Checkbox
709
+ * @returns 渲染函数,接收渲染上下文并产出 Checkbox vnode
690
710
  */
691
711
  function renderCheckboxItem(options = {}) {
692
712
  return (ctx) => h(_sfc_main$9, {
@@ -695,6 +715,11 @@ function renderCheckboxItem(options = {}) {
695
715
  ...ctx.item.componentProps
696
716
  });
697
717
  }
718
+ /**
719
+ * switch widget:boolean 开关(checked 受控形态,绑定与 checkbox 一致)
720
+ * @param options - widget 选项,整体展开后经 checked 受控绑定与 componentProps 透传给 Switch
721
+ * @returns 渲染函数,接收渲染上下文并产出 Switch vnode
722
+ */
698
723
  function renderSwitchItem(options = {}) {
699
724
  return (ctx) => h(_sfc_main$42, {
700
725
  ...options,
@@ -715,6 +740,10 @@ const UNIT_FEN_EXP = {
715
740
  * 解析输入文本为 valueUnit 单位的数值(number|null)。
716
741
  * 全程十进制字符串移位(BigInt),仅在超出整数分精度时一次四舍五入;
717
742
  * 白名单 ^\d*(\.\d*)?$,负号/非法字符/无数字一律 null。
743
+ * @param raw - 用户键入的数字文本(labelUnit 单位)
744
+ * @param labelUnit - 输入文本的货币单位
745
+ * @param valueUnit - 输出数值的目标货币单位
746
+ * @returns valueUnit 单位的数值;格式非法或不含数字时返回 null
718
747
  */
719
748
  function parseCurrency(raw, labelUnit, valueUnit) {
720
749
  if (!/^\d*(\.\d*)?$/.test(raw) || !/\d/.test(raw)) return null;
@@ -733,6 +762,10 @@ function parseCurrency(raw, labelUnit, valueUnit) {
733
762
  /**
734
763
  * 受控值(valueUnit 单位)反算为 labelUnit 单位的回显文本。
735
764
  * 值先取整到整数分(吸收浮点噪声),再做十进制移位并去尾零。
765
+ * @param value - 受控值(valueUnit 单位)
766
+ * @param valueUnit - 受控值的货币单位
767
+ * @param labelUnit - 回显文本的目标货币单位
768
+ * @returns labelUnit 单位的回显文本(已去尾零);非有限值返回空串
736
769
  */
737
770
  function formatCurrency(value, valueUnit, labelUnit) {
738
771
  if (!Number.isFinite(value)) return "";
@@ -750,7 +783,7 @@ function formatCurrency(value, valueUnit, labelUnit) {
750
783
  }
751
784
  //#endregion
752
785
  //#region src/components/currency-input/CurrencyInput.vue
753
- const _hoisted_1$27 = ["data-invalid"];
786
+ const _hoisted_1$28 = ["data-invalid"];
754
787
  const _hoisted_2$17 = [
755
788
  "value",
756
789
  "placeholder",
@@ -829,7 +862,7 @@ const _sfc_main$11 = /*@__PURE__*/ defineComponent({
829
862
  }), null, 16, _hoisted_2$17), createElementVNode("div", {
830
863
  "aria-hidden": "true",
831
864
  class: normalizeClass(unref(cn)("border-input text-muted-foreground flex h-full shrink-0 items-center border-l bg-muted/40 px-3 text-sm", props.disabled && "opacity-50"))
832
- }, toDisplayString(props.labelUnit), 3)], 10, _hoisted_1$27);
865
+ }, toDisplayString(props.labelUnit), 3)], 10, _hoisted_1$28);
833
866
  };
834
867
  }
835
868
  });
@@ -845,7 +878,11 @@ const _sfc_main$11 = /*@__PURE__*/ defineComponent({
845
878
  * 独立使用时 inject 落到 fallback false → 自建 Root(standalone 独立形态,恒开)。
846
879
  */
847
880
  const CALENDAR_IN_PICKER = Symbol("tu-calendar-in-picker");
848
- /** zag 按 locale 分隔符清洗键入字符(zh-CN 为 "/"),解析前统一归一为 "-" */
881
+ /**
882
+ * zag 按 locale 分隔符清洗键入字符(zh-CN 为 "/"),解析前统一归一为 "-"。
883
+ * @param raw - 原始键入文本
884
+ * @returns 去除首尾空白并把 "/" 归一为 "-" 后的文本
885
+ */
849
886
  function normalizeSeparators(raw) {
850
887
  return raw.trim().replace(/\//g, "-");
851
888
  }
@@ -853,6 +890,8 @@ function normalizeSeparators(raw) {
853
890
  * "yyyy-MM-dd" → DateValue(@internationalized/date 纯日历解析,无时区参与)。
854
891
  * 兼容 "/" 分隔(zag 键入清洗路径,如 "2026/10/09"),归一后做严格 ISO 校验;
855
892
  * 非法/非补零(如 "abc"、"2026-2-3")返回 undefined,由调用方忽略。
893
+ * @param raw - 待解析的日期文本
894
+ * @returns 解析成功返回对应 DateValue;非法/非补零输入返回 undefined
856
895
  */
857
896
  function parseIsoDate(raw) {
858
897
  const normalized = normalizeSeparators(raw);
@@ -863,11 +902,19 @@ function parseIsoDate(raw) {
863
902
  return;
864
903
  }
865
904
  }
866
- /** DateValue → "yyyy-MM-dd"(CalendarDate.toString 原生 ISO 输出) */
905
+ /**
906
+ * DateValue → "yyyy-MM-dd"(CalendarDate.toString 原生 ISO 输出)。
907
+ * @param date - 目标日期
908
+ * @returns ISO "yyyy-MM-dd" 格式日期串
909
+ */
867
910
  function formatIsoDate(date) {
868
911
  return date.toString();
869
912
  }
870
- /** "yyyy-MM" → DateValue(锚定 1 日);非法/非补零返回 undefined */
913
+ /**
914
+ * "yyyy-MM" → DateValue(锚定 1 日);非法/非补零返回 undefined。
915
+ * @param raw - 待解析的月份文本
916
+ * @returns 解析成功返回锚定 1 日的 DateValue;非法输入返回 undefined
917
+ */
871
918
  function parseIsoMonth(raw) {
872
919
  const normalized = normalizeSeparators(raw);
873
920
  if (!/^\d{4}-\d{2}$/.test(normalized)) return void 0;
@@ -877,11 +924,19 @@ function parseIsoMonth(raw) {
877
924
  return;
878
925
  }
879
926
  }
880
- /** DateValue → "yyyy-MM"(不能走 toString(),会带 day) */
927
+ /**
928
+ * DateValue → "yyyy-MM"(不能走 toString(),会带 day)。
929
+ * @param date - 目标日期
930
+ * @returns 补零的 "yyyy-MM" 格式月份串
931
+ */
881
932
  function formatIsoMonth(date) {
882
933
  return `${date.year}-${String(date.month).padStart(2, "0")}`;
883
934
  }
884
- /** "yyyy" → DateValue(锚定 1 月 1 日);非四位年份返回 undefined */
935
+ /**
936
+ * "yyyy" → DateValue(锚定 1 月 1 日);非四位年份返回 undefined。
937
+ * @param raw - 待解析的年份文本
938
+ * @returns 解析成功返回锚定 1 月 1 日的 DateValue;非法输入返回 undefined
939
+ */
885
940
  function parseIsoYear(raw) {
886
941
  const normalized = normalizeSeparators(raw);
887
942
  if (!/^\d{4}$/.test(normalized)) return void 0;
@@ -891,13 +946,19 @@ function parseIsoYear(raw) {
891
946
  return;
892
947
  }
893
948
  }
894
- /** DateValue → "yyyy" */
949
+ /**
950
+ * DateValue → "yyyy"。
951
+ * @param date - 目标日期
952
+ * @returns 四位年份串
953
+ */
895
954
  function formatIsoYear(date) {
896
955
  return String(date.year);
897
956
  }
898
957
  /**
899
958
  * locale 周起点(1=周一 … 7=周日,ISO 语义)。
900
959
  * 取 Intl.Locale.weekInfo.firstDay(Node ≥ 22 / 现代浏览器可用),异常兜底周一。
960
+ * @param locale - BCP 47 语言标签(如 "zh-CN"、"en-US")
961
+ * @returns 该 locale 的周起点序号(1=周一 … 7=周日);异常时兜底 1(周一)
901
962
  */
902
963
  function localeFirstDay(locale) {
903
964
  try {
@@ -906,24 +967,49 @@ function localeFirstDay(locale) {
906
967
  } catch {}
907
968
  return 1;
908
969
  }
909
- /** DateValue → 周起点(跟随 locale;zh-CN 周一起始、en-US 周日起始) */
970
+ /**
971
+ * DateValue → 周起点(跟随 locale;zh-CN 周一起始、en-US 周日起始)。
972
+ * @param date - 目标日期
973
+ * @param locale - BCP 47 语言标签,决定每周起始日
974
+ * @returns 该日期所在周的起点日期
975
+ */
910
976
  function weekStartOf(date, locale = "zh-CN") {
911
977
  const diff = (new Date(Date.UTC(date.year, date.month - 1, date.day)).getUTCDay() - localeFirstDay(locale) % 7 + 7) % 7;
912
978
  return diff === 0 ? date : date.subtract({ days: diff });
913
979
  }
914
- /** DateValue → 周终点(= 周起点 + 6 天) */
980
+ /**
981
+ * DateValue → 周终点(= 周起点 + 6 天)。
982
+ * @param date - 目标日期
983
+ * @param locale - BCP 47 语言标签,决定每周起始日
984
+ * @returns 该日期所在周的终点日期
985
+ */
915
986
  function weekEndOf(date, locale = "zh-CN") {
916
987
  return weekStartOf(date, locale).add({ days: 6 });
917
988
  }
918
- /** 两日期是否同属一周(跟随 locale) */
989
+ /**
990
+ * 两日期是否同属一周(跟随 locale)。
991
+ * @param a - 待比较的第一个日期
992
+ * @param b - 待比较的第二个日期
993
+ * @param locale - BCP 47 语言标签,决定每周起始日
994
+ * @returns 两日期同属一周时返回 true,否则返回 false
995
+ */
919
996
  function isSameWeek(a, b, locale = "zh-CN") {
920
997
  return weekStartOf(a, locale).compare(weekStartOf(b, locale)) === 0;
921
998
  }
922
- /** DateValue → "yyyy-MM-dd ~ yyyy-MM-dd"(所在周区间,输入框回显用) */
999
+ /**
1000
+ * DateValue → "yyyy-MM-dd ~ yyyy-MM-dd"(所在周区间,输入框回显用)。
1001
+ * @param date - 目标日期
1002
+ * @param locale - BCP 47 语言标签,决定每周起始日
1003
+ * @returns 形如 "yyyy-MM-dd ~ yyyy-MM-dd" 的周区间串
1004
+ */
923
1005
  function formatIsoWeek(date, locale = "zh-CN") {
924
1006
  return `${formatIsoDate(weekStartOf(date, locale))} ~ ${formatIsoDate(weekEndOf(date, locale))}`;
925
1007
  }
926
- /** 区间解析:逐侧 parseIsoDate + 顺序归一(start ≤ end);null / 任一侧非法返回 undefined */
1008
+ /**
1009
+ * 区间解析:逐侧 parseIsoDate + 顺序归一(start ≤ end);null / 任一侧非法返回 undefined。
1010
+ * @param raw - [起, 止] 文本二元组,可为 null 或 undefined
1011
+ * @returns 顺序归一后的 [start, end];输入为空或任一侧非法时返回 undefined
1012
+ */
927
1013
  function parseIsoRange(raw) {
928
1014
  if (!raw) return void 0;
929
1015
  const start = parseIsoDate(raw[0] ?? "");
@@ -942,8 +1028,8 @@ var export_helper_default = (sfc, props) => {
942
1028
  };
943
1029
  //#endregion
944
1030
  //#region src/components/icon-shared/ChevronIcon.vue
945
- const _sfc_main$63 = {};
946
- const _hoisted_1$26 = {
1031
+ const _sfc_main$64 = {};
1032
+ const _hoisted_1$27 = {
947
1033
  viewBox: "0 0 24 24",
948
1034
  fill: "none",
949
1035
  stroke: "currentColor",
@@ -952,10 +1038,10 @@ const _hoisted_1$26 = {
952
1038
  "stroke-linejoin": "round",
953
1039
  "aria-hidden": "true"
954
1040
  };
955
- function _sfc_render$2(_ctx, _cache) {
956
- return openBlock(), createElementBlock("svg", _hoisted_1$26, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "m9 18 6-6-6-6" }, null, -1)])]);
1041
+ function _sfc_render$3(_ctx, _cache) {
1042
+ return openBlock(), createElementBlock("svg", _hoisted_1$27, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "m9 18 6-6-6-6" }, null, -1)])]);
957
1043
  }
958
- var ChevronIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$63, [["render", _sfc_render$2]]);
1044
+ var ChevronIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$64, [["render", _sfc_render$3]]);
959
1045
  //#endregion
960
1046
  //#region src/components/calendar/CalendarNav.vue
961
1047
  /**
@@ -968,8 +1054,12 @@ const viewControlCls = "flex items-center justify-between px-1 pb-3";
968
1054
  const navBtnCls = "text-muted-foreground inline-flex size-8 items-center justify-center rounded-md outline-none hover:bg-accent disabled:cursor-not-allowed disabled:opacity-40";
969
1055
  const viewTriggerCls = "hover:bg-accent inline-flex items-center gap-1 rounded-[3px] px-3 py-1.5 text-sm font-semibold text-foreground outline-none transition-colors disabled:pointer-events-none";
970
1056
  const viewTitleCls = "text-sm font-semibold text-foreground";
971
- /** 年代范围文本(zag 无现成 part,由 focusedValue.year 推算):2026 → "2020 - 2029" */
972
- const _sfc_main$62 = /*@__PURE__*/ defineComponent({
1057
+ /**
1058
+ * 年代范围文本(zag 无现成 part,由 focusedValue.year 推算):2026 → "2020 - 2029"
1059
+ * @param year - 聚焦年份
1060
+ * @returns "起 - 止" 形式的年代范围文本
1061
+ */
1062
+ const _sfc_main$63 = /*@__PURE__*/ defineComponent({
973
1063
  __name: "CalendarNav",
974
1064
  props: {
975
1065
  /** 导航条服务的视图,决定中间内容形态:day=ViewTrigger(上钻)/ month=年份 / year=年代 */
@@ -1023,7 +1113,7 @@ view: {
1023
1113
  });
1024
1114
  //#endregion
1025
1115
  //#region src/components/calendar/CalendarBody.vue
1026
- const _hoisted_1$25 = { class: "flex gap-6" };
1116
+ const _hoisted_1$26 = { class: "flex gap-6" };
1027
1117
  const dayTriggerCls = "group relative flex h-8 w-full cursor-pointer items-center justify-center outline-none data-[outside-view]:pointer-events-none data-[disabled]:pointer-events-none data-[in-range]:not-data-[outside-view]:not-data-[range-start]:not-data-[range-end]:bg-primary/10 data-[range-start]:rounded-l-[3px] data-[range-end]:rounded-r-[3px] data-[week-selected]:bg-primary data-[week-selected]:data-[outside-view]:bg-primary/40 data-[week-selected]:hover:data-[outside-view]:bg-primary/40 group-hover/week-row:not-data-[week-selected]:not-data-[outside-view]:bg-primary/10 group-hover/week-row:data-[outside-view]:not-data-[week-selected]:bg-primary/5";
1028
1118
  const dayDotCls = "flex size-6 items-center justify-center rounded-[3px] text-sm transition-colors group-hover:not-group-data-[week-selected]:bg-accent group-data-[focus]:not-group-data-[outside-view]:not-group-data-[week-selected]:bg-accent group-data-[selected]:not-group-data-[week-selected]:not-group-data-[outside-view]:bg-primary group-data-[selected]:not-group-data-[week-selected]:not-group-data-[outside-view]:font-medium group-data-[selected]:not-group-data-[week-selected]:not-group-data-[outside-view]:text-primary-foreground group-data-[week-selected]:bg-transparent group-data-[week-selected]:font-medium group-data-[week-selected]:text-primary-foreground group-data-[week-selected]:hover:bg-white/20 group-data-[today]:not-group-data-[selected]:text-primary group-data-[today]:not-group-data-[selected]:font-semibold group-data-[unavailable]:line-through group-data-[unavailable]:opacity-30 group-data-[disabled]:opacity-40 group-data-[outside-view]:opacity-30";
1029
1119
  const cellCls = "flex h-9 w-full items-center justify-center rounded-[3px] text-sm outline-none hover:bg-accent data-[selected]:bg-primary data-[selected]:font-medium data-[selected]:text-primary-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-40";
@@ -1031,8 +1121,13 @@ const tableCls = "w-full min-w-0 flex-1 table-fixed border-collapse";
1031
1121
  const headCellCls = "text-muted-foreground h-8 border-x-0! border-t-0! border-b border-border p-0! text-center! text-xs! align-middle font-normal whitespace-nowrap";
1032
1122
  const bodyCellCls = "border-0! p-0! text-center";
1033
1123
  const rowCls = "bg-transparent!";
1034
- /** 表 i 的锚点月起点(zag getOffset({months: i-1}).visibleRange.start) */
1035
- const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1124
+ /**
1125
+ * 表 i 的锚点月起点(zag getOffset({months: i-1}).visibleRange.start)
1126
+ * @param context - zag Table 上下文
1127
+ * @param i - 表序号(1-based,相对当前锚点月偏移 i-1 个月)
1128
+ * @returns 该表锚点月的起始日期
1129
+ */
1130
+ const _sfc_main$62 = /*@__PURE__*/ defineComponent({
1036
1131
  __name: "CalendarBody",
1037
1132
  props: {
1038
1133
  mode: { default: "day" },
@@ -1049,7 +1144,12 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1049
1144
  function tableAnchor(context, i) {
1050
1145
  return context.getOffset({ months: i - 1 })?.visibleRange?.start;
1051
1146
  }
1052
- /** 格子日期不属于锚点月(年或月不一致)即为补位格 */
1147
+ /**
1148
+ * 格子日期不属于锚点月(年或月不一致)即为补位格
1149
+ * @param day - 格子日期
1150
+ * @param anchor - 所在表的锚点月起点
1151
+ * @returns 是否为补位格
1152
+ */
1053
1153
  function isOutsideView(day, anchor) {
1054
1154
  return !!anchor && (day.year !== anchor.year || day.month !== anchor.month);
1055
1155
  }
@@ -1058,6 +1158,9 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1058
1158
  * 与 data-week-selected(视觉标记,驱动 trigger 整行条带与 dot 层反色变体);
1059
1159
  * 非 week 形态返回空对象,完全不下发属性,选中视觉交回 zag 原生绑定,避免 fallthrough 覆盖。
1060
1160
  * 走显式函数而非模板内联,避免与日视图 v-for 的 `week` 循环变量同名遮蔽。
1161
+ * @param day - 格子日期
1162
+ * @param selected - 当前选中日期集合(单选语义,取首个)
1163
+ * @returns 需下发的 data 属性对象(无命中时为空对象)
1061
1164
  */
1062
1165
  function weekSelectedAttrs(day, selected) {
1063
1166
  return weekSelected(day, selected) ? {
@@ -1073,7 +1176,7 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1073
1176
  createVNode(unref(DatePicker).View, { view: "day" }, {
1074
1177
  default: withCtx(() => [
1075
1178
  createCommentVNode(" day 视图导航条在 View 内:viewProps=day → GOTO.NEXT=focusNextPage(翻月) "),
1076
- createVNode(_sfc_main$62, { view: "day" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1179
+ createVNode(_sfc_main$63, { view: "day" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1077
1180
  name: "prev-icon",
1078
1181
  fn: withCtx(() => [renderSlot(_ctx.$slots, "prev-icon")]),
1079
1182
  key: "0"
@@ -1083,7 +1186,7 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1083
1186
  key: "1"
1084
1187
  } : void 0]), 1024),
1085
1188
  createVNode(unref(DatePicker).Context, null, {
1086
- default: withCtx((context) => [createElementVNode("div", _hoisted_1$25, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.numOfMonths, (i) => {
1189
+ default: withCtx((context) => [createElementVNode("div", _hoisted_1$26, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.numOfMonths, (i) => {
1087
1190
  return openBlock(), createBlock(unref(DatePicker).Table, {
1088
1191
  key: i,
1089
1192
  class: normalizeClass(tableCls)
@@ -1140,7 +1243,7 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1140
1243
  createVNode(unref(DatePicker).View, { view: "month" }, {
1141
1244
  default: withCtx(() => [
1142
1245
  createCommentVNode(" 切换视图导航条也在 View 内:DatePicker 切月视图后 GOTO.NEXT=focusNextYear(修复 backlog) "),
1143
- createVNode(_sfc_main$62, { view: "month" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1246
+ createVNode(_sfc_main$63, { view: "month" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1144
1247
  name: "prev-icon",
1145
1248
  fn: withCtx(() => [renderSlot(_ctx.$slots, "prev-icon")]),
1146
1249
  key: "0"
@@ -1186,7 +1289,7 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1186
1289
  _: 3
1187
1290
  }),
1188
1291
  createVNode(unref(DatePicker).View, { view: "year" }, {
1189
- default: withCtx(() => [createVNode(_sfc_main$62, { view: "year" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1292
+ default: withCtx(() => [createVNode(_sfc_main$63, { view: "year" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1190
1293
  name: "prev-icon",
1191
1294
  fn: withCtx(() => [renderSlot(_ctx.$slots, "prev-icon")]),
1192
1295
  key: "0"
@@ -1232,7 +1335,7 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1232
1335
  }, {
1233
1336
  default: withCtx(() => [
1234
1337
  createCommentVNode(" 导航条必须在 View 子树内:Prev/NextTrigger 才能拿到 view=\"month\"(GOTO.NEXT=focusNextYear) "),
1235
- createVNode(_sfc_main$62, { view: "month" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1338
+ createVNode(_sfc_main$63, { view: "month" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1236
1339
  name: "prev-icon",
1237
1340
  fn: withCtx(() => [renderSlot(_ctx.$slots, "prev-icon")]),
1238
1341
  key: "0"
@@ -1282,7 +1385,7 @@ const _sfc_main$61 = /*@__PURE__*/ defineComponent({
1282
1385
  }, {
1283
1386
  default: withCtx(() => [
1284
1387
  createCommentVNode(" 导航条必须在 View 子树内:Prev/NextTrigger 才能拿到 view=\"year\"(GOTO.NEXT=focusNextDecade) "),
1285
- createVNode(_sfc_main$62, { view: "year" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1388
+ createVNode(_sfc_main$63, { view: "year" }, createSlots({ _: 2 }, [_ctx.$slots["prev-icon"] ? {
1286
1389
  name: "prev-icon",
1287
1390
  fn: withCtx(() => [renderSlot(_ctx.$slots, "prev-icon")]),
1288
1391
  key: "0"
@@ -1413,7 +1516,7 @@ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
1413
1516
  "onUpdate:modelValue": handleValueUpdate
1414
1517
  }, {
1415
1518
  default: withCtx(() => [createVNode(unref(DatePicker).Content, null, {
1416
- default: withCtx(() => [createVNode(_sfc_main$61, {
1519
+ default: withCtx(() => [createVNode(_sfc_main$62, {
1417
1520
  mode: props.mode,
1418
1521
  "num-of-months": props.numOfMonths,
1419
1522
  week: props.week,
@@ -1444,7 +1547,7 @@ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
1444
1547
  "max",
1445
1548
  "is-date-unavailable",
1446
1549
  "locale"
1447
- ])], 2)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" embedded 内嵌形态:宿主 Picker 的 Root 供能,纯卡片内核 "), createVNode(_sfc_main$61, {
1550
+ ])], 2)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" embedded 内嵌形态:宿主 Picker 的 Root 供能,纯卡片内核 "), createVNode(_sfc_main$62, {
1448
1551
  mode: props.mode,
1449
1552
  "num-of-months": props.numOfMonths,
1450
1553
  week: props.week,
@@ -1468,8 +1571,8 @@ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
1468
1571
  });
1469
1572
  //#endregion
1470
1573
  //#region src/components/icon-shared/CalendarIcon.vue
1471
- const _sfc_main$60 = {};
1472
- const _hoisted_1$24 = {
1574
+ const _sfc_main$61 = {};
1575
+ const _hoisted_1$25 = {
1473
1576
  viewBox: "0 0 24 24",
1474
1577
  fill: "none",
1475
1578
  stroke: "currentColor",
@@ -1478,8 +1581,8 @@ const _hoisted_1$24 = {
1478
1581
  "stroke-linejoin": "round",
1479
1582
  "aria-hidden": "true"
1480
1583
  };
1481
- function _sfc_render$1(_ctx, _cache) {
1482
- return openBlock(), createElementBlock("svg", _hoisted_1$24, [..._cache[0] || (_cache[0] = [
1584
+ function _sfc_render$2(_ctx, _cache) {
1585
+ return openBlock(), createElementBlock("svg", _hoisted_1$25, [..._cache[0] || (_cache[0] = [
1483
1586
  createElementVNode("rect", {
1484
1587
  width: "18",
1485
1588
  height: "18",
@@ -1492,11 +1595,11 @@ function _sfc_render$1(_ctx, _cache) {
1492
1595
  createElementVNode("path", { d: "M3 10h18" }, null, -1)
1493
1596
  ])]);
1494
1597
  }
1495
- var CalendarIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$60, [["render", _sfc_render$1]]);
1598
+ var CalendarIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$61, [["render", _sfc_render$2]]);
1496
1599
  //#endregion
1497
1600
  //#region src/components/icon-shared/CloseIcon.vue
1498
- const _sfc_main$59 = {};
1499
- const _hoisted_1$23 = {
1601
+ const _sfc_main$60 = {};
1602
+ const _hoisted_1$24 = {
1500
1603
  viewBox: "0 0 24 24",
1501
1604
  fill: "none",
1502
1605
  stroke: "currentColor",
@@ -1505,10 +1608,10 @@ const _hoisted_1$23 = {
1505
1608
  "stroke-linejoin": "round",
1506
1609
  "aria-hidden": "true"
1507
1610
  };
1508
- function _sfc_render(_ctx, _cache) {
1509
- return openBlock(), createElementBlock("svg", _hoisted_1$23, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M18 6 6 18" }, null, -1), createElementVNode("path", { d: "m6 6 12 12" }, null, -1)])]);
1611
+ function _sfc_render$1(_ctx, _cache) {
1612
+ return openBlock(), createElementBlock("svg", _hoisted_1$24, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M18 6 6 18" }, null, -1), createElementVNode("path", { d: "m6 6 12 12" }, null, -1)])]);
1510
1613
  }
1511
- var CloseIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$59, [["render", _sfc_render]]);
1614
+ var CloseIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$60, [["render", _sfc_render$1]]);
1512
1615
  //#endregion
1513
1616
  //#region src/components/overlay-shared/sandbox.ts
1514
1617
  /**
@@ -1531,12 +1634,18 @@ var CloseIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$59, [["ren
1531
1634
  * - fixed 面板在祖先滚动时依赖 autoUpdate 重算,重算前一帧有视口驻留(瞬时视觉差异)
1532
1635
  * - 若未来出现「非 iframe 的 graft 型沙箱」,本探测无法覆盖,需追加该沙箱的 marker 信号
1533
1636
  */
1534
- /** 组件 JS 是否运行在 iframe realm(wujie / iframe 型沙箱 / 普通 iframe 嵌入) */
1637
+ /**
1638
+ * 组件 JS 是否运行在 iframe realm(wujie / iframe 型沙箱 / 普通 iframe 嵌入)。
1639
+ * @returns 运行在 iframe realm 时返回 true,否则返回 false
1640
+ */
1535
1641
  function isInIframeRealm() {
1536
1642
  return typeof window !== "undefined" && window.self !== window.top;
1537
1643
  }
1538
- /** 是否处于 wujie graft 沙箱(getRootNode/父链被 wujie patch 伪装,结构探测失效,
1539
- * 依赖官方标记;wujie 在子应用脚本执行前注入,时序可靠) */
1644
+ /**
1645
+ * 是否处于 wujie graft 沙箱(getRootNode/父链被 wujie patch 伪装,结构探测失效,
1646
+ * 依赖官方标记;wujie 在子应用脚本执行前注入,时序可靠)。
1647
+ * @returns 处于 wujie graft 沙箱时返回 true,否则返回 false
1648
+ */
1540
1649
  function isInWujie() {
1541
1650
  return typeof window !== "undefined" && window.__POWERED_BY_WUJIE__ === true;
1542
1651
  }
@@ -1594,7 +1703,7 @@ function withSandboxStrategy(user, merged) {
1594
1703
  //#endregion
1595
1704
  //#region src/components/date-shared/PickerShell.vue
1596
1705
  /** 单值日期族(Date/Month/Year/Week)共用外壳:触发器 + 清空/日历按钮 + 弹层容器。 */
1597
- const _sfc_main$58 = /*@__PURE__*/ defineComponent({
1706
+ const _sfc_main$59 = /*@__PURE__*/ defineComponent({
1598
1707
  inheritAttrs: false,
1599
1708
  __name: "PickerShell",
1600
1709
  props: {
@@ -1763,6 +1872,8 @@ const _sfc_main$58 = /*@__PURE__*/ defineComponent({
1763
1872
  /**
1764
1873
  * 业务组件惯例:Ark Root 恒走受控,非受控语义由内部 ref 实现。
1765
1874
  * `controlled()` 返回 undefined 时用内部值,否则永远跟随外部 prop。
1875
+ * @param options - 受控/非受控配置:受控值读取器、非受控初值与变更回调
1876
+ * @returns isOpen(当前开合状态)与 setOpen(写入状态并同步 onChange)
1766
1877
  */
1767
1878
  function useControlledBoolean(options) {
1768
1879
  const internal = ref(options.defaultValue?.() ?? false);
@@ -1781,6 +1892,8 @@ function useControlledBoolean(options) {
1781
1892
  /**
1782
1893
  * 单值日期选择器的受控桥接:值以内部 ref 为镜像、Root 恒走受控,
1783
1894
  * 开合复用 useControlledBoolean,openFromInput 统一「点击/↓ 输入框即开」。
1895
+ * @param options - 桥接配置:值与开合的受控/非受控读写、解析与回写转换、事件回调
1896
+ * @returns rootValue(zag 受控值)、isOpen 与 setOpen(开合状态)、openFromInput(输入框驱动开弹层)与 handleValueUpdate(日历值更新处理)
1784
1897
  */
1785
1898
  function usePickerBridge(options) {
1786
1899
  const initial = options.defaultValue();
@@ -1909,7 +2022,7 @@ const _sfc_main$12 = /*@__PURE__*/ defineComponent({
1909
2022
  const minDate = computed(() => parseIsoDate(props.min ?? ""));
1910
2023
  const maxDate = computed(() => parseIsoDate(props.max ?? ""));
1911
2024
  return (_ctx, _cache) => {
1912
- return openBlock(), createBlock(_sfc_main$58, mergeProps(_ctx.$attrs, {
2025
+ return openBlock(), createBlock(_sfc_main$59, mergeProps(_ctx.$attrs, {
1913
2026
  "model-value": unref(rootValue),
1914
2027
  open: unref(isOpen),
1915
2028
  locale: props.locale,
@@ -2265,7 +2378,7 @@ const _sfc_main$29 = /*@__PURE__*/ defineComponent({
2265
2378
  return anchor ? anchor.set({ day: 31 }) : void 0;
2266
2379
  });
2267
2380
  return (_ctx, _cache) => {
2268
- return openBlock(), createBlock(_sfc_main$58, mergeProps(_ctx.$attrs, {
2381
+ return openBlock(), createBlock(_sfc_main$59, mergeProps(_ctx.$attrs, {
2269
2382
  "model-value": unref(rootValue),
2270
2383
  open: unref(isOpen),
2271
2384
  locale: props.locale,
@@ -2310,7 +2423,11 @@ const _sfc_main$29 = /*@__PURE__*/ defineComponent({
2310
2423
  });
2311
2424
  //#endregion
2312
2425
  //#region src/components/number-input/utils.ts
2313
- /** Ark ValueChangeDetails → number|null(空串/NaN 归一 null,numberOrNull 为可单测的纯函数) */
2426
+ /**
2427
+ * Ark ValueChangeDetails → number|null(空串/NaN 归一 null,numberOrNull 为可单测的纯函数)
2428
+ * @param details - Ark NumberInput 的 ValueChangeDetails
2429
+ * @returns 有效数字;空串或 NaN 时返回 null
2430
+ */
2314
2431
  function numberOrNull(details) {
2315
2432
  return details.value === "" || Number.isNaN(details.valueAsNumber) ? null : details.valueAsNumber;
2316
2433
  }
@@ -2362,7 +2479,10 @@ const _sfc_main$30 = /*@__PURE__*/ defineComponent({
2362
2479
  const current = computed(() => props.modelValue === void 0 ? internalValue.value : props.modelValue);
2363
2480
  /** number → Ark 受控 string(null/NaN → 空串) */
2364
2481
  const arkValue = computed(() => current.value == null || Number.isNaN(current.value) ? "" : String(current.value));
2365
- /** Ark details(value: string / valueAsNumber: number)→ number|null(空串/NaN 归一 null) */
2482
+ /**
2483
+ * Ark details(value: string / valueAsNumber: number)→ number|null(空串/NaN 归一 null)
2484
+ * @param details - Ark NumberInput 的 ValueChangeDetails
2485
+ */
2366
2486
  function handleValueChange(details) {
2367
2487
  const next = numberOrNull(details);
2368
2488
  internalValue.value = next;
@@ -2425,7 +2545,7 @@ const _sfc_main$30 = /*@__PURE__*/ defineComponent({
2425
2545
  });
2426
2546
  //#endregion
2427
2547
  //#region src/components/password-input/PasswordInput.vue
2428
- const _hoisted_1$22 = ["data-invalid"];
2548
+ const _hoisted_1$23 = ["data-invalid"];
2429
2549
  const _hoisted_2$16 = [
2430
2550
  "type",
2431
2551
  "value",
@@ -2450,7 +2570,7 @@ const _hoisted_4$10 = {
2450
2570
  class: "size-4",
2451
2571
  "aria-hidden": "true"
2452
2572
  };
2453
- const _hoisted_5$7 = {
2573
+ const _hoisted_5$8 = {
2454
2574
  key: 1,
2455
2575
  viewBox: "0 0 24 24",
2456
2576
  fill: "none",
@@ -2544,17 +2664,17 @@ const _sfc_main$31 = /*@__PURE__*/ defineComponent({
2544
2664
  y1: "2",
2545
2665
  y2: "22"
2546
2666
  }, null, -1)
2547
- ])])) : (openBlock(), createElementBlock("svg", _hoisted_5$7, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" }, null, -1), createElementVNode("circle", {
2667
+ ])])) : (openBlock(), createElementBlock("svg", _hoisted_5$8, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" }, null, -1), createElementVNode("circle", {
2548
2668
  cx: "12",
2549
2669
  cy: "12",
2550
2670
  r: "3"
2551
- }, null, -1)])]))])], 8, _hoisted_3$12)], 10, _hoisted_1$22);
2671
+ }, null, -1)])]))])], 8, _hoisted_3$12)], 10, _hoisted_1$23);
2552
2672
  };
2553
2673
  }
2554
2674
  });
2555
2675
  //#endregion
2556
2676
  //#region src/components/textarea/Textarea.vue
2557
- const _hoisted_1$21 = ["aria-invalid"];
2677
+ const _hoisted_1$22 = ["aria-invalid"];
2558
2678
  const _sfc_main$46 = /*@__PURE__*/ defineComponent({
2559
2679
  __name: "Textarea",
2560
2680
  props: /*@__PURE__*/ mergeModels({
@@ -2566,14 +2686,18 @@ const _sfc_main$46 = /*@__PURE__*/ defineComponent({
2566
2686
  }),
2567
2687
  emits: ["update:modelValue"],
2568
2688
  setup(__props) {
2569
- const modelValue = useModel(__props, "modelValue");
2689
+ const looseToNumber = (val) => {
2690
+ const n = Number.parseFloat(String(val));
2691
+ return Number.isNaN(n) ? val : n;
2692
+ };
2693
+ const modelValue = useModel(__props, "modelValue", { set: (v) => typeof modelValue.value === "number" ? looseToNumber(v) : v });
2570
2694
  const props = __props;
2571
2695
  return (_ctx, _cache) => {
2572
2696
  return withDirectives((openBlock(), createElementBlock("textarea", {
2573
2697
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
2574
2698
  "aria-invalid": props.invalid ? "true" : void 0,
2575
2699
  class: normalizeClass(unref(cn)("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive md:text-sm", props.class))
2576
- }, null, 10, _hoisted_1$21)), [[vModelText, modelValue.value]]);
2700
+ }, null, 10, _hoisted_1$22)), [[vModelText, modelValue.value]]);
2577
2701
  };
2578
2702
  }
2579
2703
  });
@@ -2660,7 +2784,11 @@ const _sfc_main$51 = /*@__PURE__*/ defineComponent({
2660
2784
  const props = __props;
2661
2785
  const emit = __emit;
2662
2786
  provide(CALENDAR_IN_PICKER, true);
2663
- /** "yyyy-MM-dd" → 归一到所在周起始日的 ISO 串(非法输入返回 undefined) */
2787
+ /**
2788
+ * "yyyy-MM-dd" → 归一到所在周起始日的 ISO 串(非法输入返回 undefined)
2789
+ * @param raw - 输入的 ISO 日期串
2790
+ * @returns 该日期所在周起始日的 ISO 串;解析失败返回 undefined
2791
+ */
2664
2792
  function formatIsoWeekStart(raw) {
2665
2793
  const date = parseIsoDate(raw);
2666
2794
  return date ? weekStartOf(date, props.locale).toString() : void 0;
@@ -2688,7 +2816,7 @@ const _sfc_main$51 = /*@__PURE__*/ defineComponent({
2688
2816
  return date ? weekStartOf(date, props.locale) : void 0;
2689
2817
  }
2690
2818
  return (_ctx, _cache) => {
2691
- return openBlock(), createBlock(_sfc_main$58, mergeProps(_ctx.$attrs, {
2819
+ return openBlock(), createBlock(_sfc_main$59, mergeProps(_ctx.$attrs, {
2692
2820
  "model-value": unref(rootValue),
2693
2821
  open: unref(isOpen),
2694
2822
  locale: props.locale,
@@ -2825,7 +2953,7 @@ const _sfc_main$52 = /*@__PURE__*/ defineComponent({
2825
2953
  const minDate = computed(() => parseIsoYear(props.min ?? ""));
2826
2954
  const maxDate = computed(() => parseIsoYear(props.max ?? ""));
2827
2955
  return (_ctx, _cache) => {
2828
- return openBlock(), createBlock(_sfc_main$58, mergeProps(_ctx.$attrs, {
2956
+ return openBlock(), createBlock(_sfc_main$59, mergeProps(_ctx.$attrs, {
2829
2957
  "model-value": unref(rootValue),
2830
2958
  open: unref(isOpen),
2831
2959
  locale: props.locale,
@@ -2873,9 +3001,13 @@ const _sfc_main$52 = /*@__PURE__*/ defineComponent({
2873
3001
  /**
2874
3002
  * modelValue 形态 widgets 统一展开模式(方案 C):
2875
3003
  * item 级缺省 → options 整体展开(命名穿透,组件全 props)→ 受控绑定 → 逃逸口。
2876
- * options.placeholder 为 undefined 时 Vue 视为未传,item 级缺省保留(I1 语义)。
3004
+ * options.placeholder 为 undefined 时 Vue 视为未传,item 级缺省保留。
3005
+ */
3006
+ /**
3007
+ * password widget:密码输入(autoComplete 为组件真实 prop,直接派生透传)
3008
+ * @param options - widget 选项,整体展开后经 modelValue 受控绑定与 componentProps 透传给 PasswordInput
3009
+ * @returns 渲染函数,接收渲染上下文并产出 PasswordInput vnode
2877
3010
  */
2878
- /** password widget:密码输入(autoComplete 为组件真实 prop,直接派生透传) */
2879
3011
  function renderPasswordItem(options = {}) {
2880
3012
  return (ctx) => h(_sfc_main$31, {
2881
3013
  placeholder: ctx.item.placeholder,
@@ -2884,7 +3016,11 @@ function renderPasswordItem(options = {}) {
2884
3016
  ...ctx.item.componentProps
2885
3017
  });
2886
3018
  }
2887
- /** number widget:数值输入(modelValue: number|null) */
3019
+ /**
3020
+ * number widget:数值输入(modelValue: number|null)
3021
+ * @param options - widget 选项,整体展开后经 modelValue 受控绑定与 componentProps 透传给 NumberInput
3022
+ * @returns 渲染函数,接收渲染上下文并产出 NumberInput vnode
3023
+ */
2888
3024
  function renderNumberItem(options = {}) {
2889
3025
  return (ctx) => h(_sfc_main$30, {
2890
3026
  ...options,
@@ -2892,7 +3028,11 @@ function renderNumberItem(options = {}) {
2892
3028
  ...ctx.item.componentProps
2893
3029
  });
2894
3030
  }
2895
- /** currency widget:金额输入(labelUnit/valueUnit 单位展示) */
3031
+ /**
3032
+ * currency widget:金额输入(labelUnit/valueUnit 单位展示)
3033
+ * @param options - widget 选项,整体展开后经 modelValue 受控绑定与 componentProps 透传给 CurrencyInput
3034
+ * @returns 渲染函数,接收渲染上下文并产出 CurrencyInput vnode
3035
+ */
2896
3036
  function renderCurrencyItem(options = {}) {
2897
3037
  return (ctx) => h(_sfc_main$11, {
2898
3038
  placeholder: ctx.item.placeholder,
@@ -2901,7 +3041,11 @@ function renderCurrencyItem(options = {}) {
2901
3041
  ...ctx.item.componentProps
2902
3042
  });
2903
3043
  }
2904
- /** textarea widget:多行文本(placeholder/rows 为原生 attr 透传) */
3044
+ /**
3045
+ * textarea widget:多行文本(placeholder/rows 为原生 attr 透传)
3046
+ * @param options - widget 选项,整体展开后经 modelValue 受控绑定与 componentProps 透传给 Textarea
3047
+ * @returns 渲染函数,接收渲染上下文并产出 Textarea vnode
3048
+ */
2905
3049
  function renderTextareaItem(options = {}) {
2906
3050
  return (ctx) => h(_sfc_main$46, {
2907
3051
  placeholder: ctx.item.placeholder,
@@ -2913,6 +3057,9 @@ function renderTextareaItem(options = {}) {
2913
3057
  /**
2914
3058
  * 日期类 widget 共用工厂:入口各自携带强类型(DatePicker/Month/Year/DateRange 的
2915
3059
  * props 面互不相同,见 types.ts 各派生接口),内部共享实现无需重复泛型关联。
3060
+ * @param component - 日期类组件(DatePicker/MonthPicker/YearPicker/DateRangePicker/WeekPicker)
3061
+ * @param options - widget 选项,整体展开后经 modelValue 受控绑定与 componentProps 透传给组件
3062
+ * @returns 渲染函数,接收渲染上下文并产出对应日期组件的 vnode
2916
3063
  */
2917
3064
  function pickerRenderer(component, options) {
2918
3065
  return (ctx) => h(component, {
@@ -2922,25 +3069,49 @@ function pickerRenderer(component, options) {
2922
3069
  ...ctx.item.componentProps
2923
3070
  });
2924
3071
  }
3072
+ /**
3073
+ * datePicker widget:日期选择(单日,modelValue 受控形态)
3074
+ * @param options - widget 选项,经 pickerRenderer 共享实现透传给 DatePicker
3075
+ * @returns 渲染函数,接收渲染上下文并产出 DatePicker vnode
3076
+ */
2925
3077
  function renderDatePickerItem(options = {}) {
2926
3078
  return pickerRenderer(_sfc_main$12, options);
2927
3079
  }
3080
+ /**
3081
+ * monthPicker widget:月份选择(modelValue 受控形态)
3082
+ * @param options - widget 选项,经 pickerRenderer 共享实现透传给 MonthPicker
3083
+ * @returns 渲染函数,接收渲染上下文并产出 MonthPicker vnode
3084
+ */
2928
3085
  function renderMonthPickerItem(options = {}) {
2929
3086
  return pickerRenderer(_sfc_main$29, options);
2930
3087
  }
3088
+ /**
3089
+ * yearPicker widget:年份选择(modelValue 受控形态)
3090
+ * @param options - widget 选项,经 pickerRenderer 共享实现透传给 YearPicker
3091
+ * @returns 渲染函数,接收渲染上下文并产出 YearPicker vnode
3092
+ */
2931
3093
  function renderYearPickerItem(options = {}) {
2932
3094
  return pickerRenderer(_sfc_main$52, options);
2933
3095
  }
2934
- /** dateRangePicker widget:[start, end] | null 形态 */
3096
+ /**
3097
+ * dateRangePicker widget:[start, end] | null 形态
3098
+ * @param options - widget 选项,经 pickerRenderer 共享实现透传给 DateRangePicker
3099
+ * @returns 渲染函数,接收渲染上下文并产出 DateRangePicker vnode
3100
+ */
2935
3101
  function renderDateRangePickerItem(options = {}) {
2936
3102
  return pickerRenderer(_sfc_main$13, options);
2937
3103
  }
3104
+ /**
3105
+ * weekPicker widget:周选择(modelValue 受控形态)
3106
+ * @param options - widget 选项,经 pickerRenderer 共享实现透传给 WeekPicker
3107
+ * @returns 渲染函数,接收渲染上下文并产出 WeekPicker vnode
3108
+ */
2938
3109
  function renderWeekPickerItem(options = {}) {
2939
3110
  return pickerRenderer(_sfc_main$51, options);
2940
3111
  }
2941
3112
  //#endregion
2942
3113
  //#region src/components/input/Input.vue
2943
- const _hoisted_1$20 = ["aria-invalid"];
3114
+ const _hoisted_1$21 = ["aria-invalid"];
2944
3115
  const _sfc_main$27 = /*@__PURE__*/ defineComponent({
2945
3116
  __name: "Input",
2946
3117
  props: /*@__PURE__*/ mergeModels({
@@ -2952,20 +3123,28 @@ const _sfc_main$27 = /*@__PURE__*/ defineComponent({
2952
3123
  }),
2953
3124
  emits: ["update:modelValue"],
2954
3125
  setup(__props) {
2955
- const modelValue = useModel(__props, "modelValue");
3126
+ const looseToNumber = (val) => {
3127
+ const n = Number.parseFloat(String(val));
3128
+ return Number.isNaN(n) ? val : n;
3129
+ };
3130
+ const modelValue = useModel(__props, "modelValue", { set: (v) => typeof modelValue.value === "number" ? looseToNumber(v) : v });
2956
3131
  const props = __props;
2957
3132
  return (_ctx, _cache) => {
2958
3133
  return withDirectives((openBlock(), createElementBlock("input", {
2959
3134
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
2960
3135
  "aria-invalid": props.invalid ? "true" : void 0,
2961
3136
  class: normalizeClass(unref(cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive", props.class))
2962
- }, null, 10, _hoisted_1$20)), [[vModelText, modelValue.value]]);
3137
+ }, null, 10, _hoisted_1$21)), [[vModelText, modelValue.value]]);
2963
3138
  };
2964
3139
  }
2965
3140
  });
2966
3141
  //#endregion
2967
3142
  //#region src/components/form-render/widgets/input.ts
2968
- /** input widget:单行文本输入(placeholder 为原生 attr 透传,aria-invalid 由 FormControl 接线) */
3143
+ /**
3144
+ * input widget:单行文本输入(placeholder 为原生 attr 透传,aria-invalid 由 FormControl 接线)
3145
+ * @param options - widget 选项,整体展开后经 modelValue 受控绑定与 componentProps 透传给 Input
3146
+ * @returns 渲染函数,接收渲染上下文并产出 Input vnode
3147
+ */
2969
3148
  function renderInputItem(options = {}) {
2970
3149
  return (ctx) => h(_sfc_main$27, {
2971
3150
  placeholder: ctx.item.placeholder,
@@ -2999,11 +3178,17 @@ function renderInputItem(options = {}) {
2999
3178
  * 边界:parts 只声明「字符串型覆盖口」的 part;函数型 part(如 select 的
3000
3179
  * item/itemGroup/itemGroupLabel——元素必渲染,[id="…"] 首查即命中,无炸点)不进
3001
3180
  * parts,由 user 经 attrs.ids 直传原样保留。user 永远最后展开:显式传入以其为准。
3181
+ * @param attrs - 组件透传 attrs(其中的 ids 为用户覆盖项,可为 undefined)
3182
+ * @param options - 生成配置:primary 为主 part(stemId 不加后缀),parts 为声明覆盖口的 part 列表
3183
+ * @returns ids(合并用户覆盖后的完整 id 映射,供 :ids 受控绑定)与 resolveId(取实际生效的字符串 id,供 aria 手动接线)
3002
3184
  */
3003
3185
  function useOverlayIds(attrs, options) {
3004
3186
  const stemId = useId();
3005
3187
  const userIds = computed(() => attrs.ids ?? {});
3006
- /** 默认派生值(不含 user 覆盖),独立于 ids 供 resolveId 回退;构造恒为字符串 */
3188
+ /**
3189
+ * 默认派生值(不含 user 覆盖),独立于 ids 供 resolveId 回退;构造恒为字符串。
3190
+ * @returns 以 part 为键的默认 id 映射
3191
+ */
3007
3192
  const buildBase = () => {
3008
3193
  const base = {};
3009
3194
  for (const part of options.parts) base[part] = part === options.primary ? stemId : `${stemId}-${part}`;
@@ -3013,7 +3198,11 @@ function useOverlayIds(attrs, options) {
3013
3198
  ...buildBase(),
3014
3199
  ...userIds.value
3015
3200
  }));
3016
- /** aria 接线用:user 字符串覆盖优先,函数型 user 回退默认值 */
3201
+ /**
3202
+ * aria 接线用:user 字符串覆盖优先,函数型 user 回退默认值。
3203
+ * @param part - 目标 part 名(如 "title"、"trigger")
3204
+ * @returns 该 part 实际生效的字符串 id;part 未声明覆盖口时返回 undefined
3205
+ */
3017
3206
  const resolveId = (part) => {
3018
3207
  const v = userIds.value[part];
3019
3208
  return typeof v === "string" ? v : buildBase()[part];
@@ -3025,6 +3214,11 @@ function useOverlayIds(attrs, options) {
3025
3214
  }
3026
3215
  //#endregion
3027
3216
  //#region src/components/select/types.ts
3217
+ /**
3218
+ * 将字符串简写归一为完整选项对象:字符串同时作为 label 与 value。
3219
+ * @param item - 字符串简写或完整选项对象
3220
+ * @returns 归一后的选项对象(字符串入参转为 label/value 同值的选项)
3221
+ */
3028
3222
  function normalizeSelectItem(item) {
3029
3223
  return typeof item === "string" ? {
3030
3224
  label: item,
@@ -3033,7 +3227,7 @@ function normalizeSelectItem(item) {
3033
3227
  }
3034
3228
  //#endregion
3035
3229
  //#region src/components/select/Select.vue
3036
- const _hoisted_1$19 = { class: "min-w-0 flex-1 truncate" };
3230
+ const _hoisted_1$20 = { class: "min-w-0 flex-1 truncate" };
3037
3231
  const _sfc_main$37 = /*@__PURE__*/ defineComponent({
3038
3232
  __name: "Select",
3039
3233
  props: {
@@ -3141,7 +3335,7 @@ const _sfc_main$37 = /*@__PURE__*/ defineComponent({
3141
3335
  default: withCtx(() => [createVNode(unref(Select).Trigger, { class: normalizeClass(unref(cn)("border-input data-[placeholder]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus-visible:outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4", props.triggerClass)) }, {
3142
3336
  default: withCtx(() => [
3143
3337
  createCommentVNode(" 截断层:触发器 w-full 定宽后,超长选中值/placeholder 走 ellipsis(flex 子项 overflow 非 visible 时自动最小尺寸归零,min-w-0 双保险)。\n 注意:不能向 ValueText 传插槽内容,其内部会对默认插槽做字符串化渲染 "),
3144
- createElementVNode("span", _hoisted_1$19, [createVNode(unref(Select).ValueText, { placeholder: props.placeholder }, null, 8, ["placeholder"])]),
3338
+ createElementVNode("span", _hoisted_1$20, [createVNode(unref(Select).ValueText, { placeholder: props.placeholder }, null, 8, ["placeholder"])]),
3145
3339
  renderSlot(_ctx.$slots, "trigger-icon", {}, () => [createVNode(ChevronIcon_default, { class: "size-4 rotate-90 opacity-50" })])
3146
3340
  ]),
3147
3341
  _: 3
@@ -3200,7 +3394,9 @@ const _sfc_main$37 = /*@__PURE__*/ defineComponent({
3200
3394
  /**
3201
3395
  * select widget:Select 已单组件化,items/placeholder 均为正式 prop 直写。
3202
3396
  * v3 命名穿透:options 整体透传给 Select(内部做 string 归一化);
3203
- * placeholder 解构出来做 item 级缺省回退(options 优先,I1 语义)。
3397
+ * placeholder 解构出来做 item 级缺省回退(options 优先)。
3398
+ * @param options - widget 选项,items/placeholder 直写为组件 prop,其余整体透传给 Select
3399
+ * @returns 渲染函数,接收渲染上下文并产出 Select vnode
3204
3400
  */
3205
3401
  function renderSelectItem(options) {
3206
3402
  const { placeholder, items, ...rootProps } = options;
@@ -3362,6 +3558,8 @@ const _sfc_main$40 = /*@__PURE__*/ defineComponent({
3362
3558
  /**
3363
3559
  * radioGroup widget:单选组(值 prop 为 value)。
3364
3560
  * 命名穿透:选项字段为组件 required prop `items`,整体直传,widget 不做组装。
3561
+ * @param options - widget 选项,整体展开后经 value 受控绑定与 componentProps 透传给 RadioGroup
3562
+ * @returns 渲染函数,接收渲染上下文并产出 RadioGroup vnode
3365
3563
  */
3366
3564
  function renderRadioGroupItem(options) {
3367
3565
  return (ctx) => h(_sfc_main$36, {
@@ -3373,6 +3571,8 @@ function renderRadioGroupItem(options) {
3373
3571
  /**
3374
3572
  * slider widget:number ↔ number[] 混合绑定特例
3375
3573
  * (值 prop 为 `value`,事件却是 `update:modelValue` 且数组语义,由 SLIDER spec 转换)。
3574
+ * @param options - widget 选项,整体展开后经 SLIDER 受控绑定与 componentProps 透传给 Slider
3575
+ * @returns 渲染函数,接收渲染上下文并产出 Slider vnode
3376
3576
  */
3377
3577
  function renderSliderItem(options = {}) {
3378
3578
  return (ctx) => h(_sfc_main$40, {
@@ -3383,7 +3583,7 @@ function renderSliderItem(options = {}) {
3383
3583
  }
3384
3584
  //#endregion
3385
3585
  //#region src/components/tree-shared/ValueTags.vue
3386
- const _hoisted_1$18 = ["data-key"];
3586
+ const _hoisted_1$19 = ["data-key"];
3387
3587
  const _hoisted_2$15 = { class: "truncate" };
3388
3588
  const _hoisted_3$11 = ["aria-label", "onClick"];
3389
3589
  const _hoisted_4$9 = {
@@ -3391,7 +3591,7 @@ const _hoisted_4$9 = {
3391
3591
  "data-part": "tag-overflow",
3392
3592
  class: "text-xs text-muted-foreground"
3393
3593
  };
3394
- const _sfc_main$57 = /*@__PURE__*/ defineComponent({
3594
+ const _sfc_main$58 = /*@__PURE__*/ defineComponent({
3395
3595
  __name: "ValueTags",
3396
3596
  props: {
3397
3597
  /** 展示的选中值(key + label) */
@@ -3435,7 +3635,7 @@ const _sfc_main$57 = /*@__PURE__*/ defineComponent({
3435
3635
  class: "text-muted-foreground hover:text-foreground",
3436
3636
  "aria-label": `移除 ${v.label}`,
3437
3637
  onClick: withModifiers(($event) => emit("remove", v.key), ["stop"])
3438
- }, [createVNode(CloseIcon_default, { class: "size-3" })], 8, _hoisted_3$11)) : createCommentVNode("v-if", true)], 8, _hoisted_1$18);
3638
+ }, [createVNode(CloseIcon_default, { class: "size-3" })], 8, _hoisted_3$11)) : createCommentVNode("v-if", true)], 8, _hoisted_1$19);
3439
3639
  }), 128)),
3440
3640
  overflow.value > 0 ? (openBlock(), createElementBlock("span", _hoisted_4$9, "+" + toDisplayString(overflow.value), 1)) : createCommentVNode("v-if", true),
3441
3641
  __props.clearable && !__props.disabled ? (openBlock(), createElementBlock("button", {
@@ -3457,15 +3657,33 @@ const _sfc_main$57 = /*@__PURE__*/ defineComponent({
3457
3657
  * MIT License · Copyright (c) 07akioni
3458
3658
  * 本地改动:defaultGetChildren 返回类型同步 GetChildren 塌缩为 `unknown`(语义不变)。
3459
3659
  */
3660
+ /**
3661
+ * 把任意值归一为数组:本身是数组则原样返回,否则包装为单元素数组。
3662
+ * @param arg - 任意输入值
3663
+ * @returns 数组形式的输入值
3664
+ */
3460
3665
  function toArray(arg) {
3461
3666
  if (Array.isArray(arg)) return arg;
3462
3667
  return [arg];
3463
3668
  }
3464
3669
  const TRAVERSE_COMMAND = { STOP: "STOP" };
3670
+ /**
3671
+ * 深度优先遍历节点子树,callback 返回 STOP 指令时终止该分支的继续下钻。
3672
+ * @param treeNode - 遍历起点节点
3673
+ * @param callback - 访问每个节点时执行的回调
3674
+ * @returns 无返回值
3675
+ */
3465
3676
  function traverseWithCb(treeNode, callback) {
3466
3677
  const command = callback(treeNode);
3467
3678
  if (treeNode.children !== void 0 && command !== TRAVERSE_COMMAND.STOP) treeNode.children.forEach((childNode) => traverseWithCb(childNode, callback));
3468
3679
  }
3680
+ /**
3681
+ * 收集树中所有非叶子节点的 key;preserveGroup 为 true 时保留 group 节点,
3682
+ * 否则排除 group,仅返回普通父节点 key。
3683
+ * @param treeNodes - 待收集的节点树
3684
+ * @param options - 选项;preserveGroup 控制是否包含 group 节点
3685
+ * @returns 非叶子节点 key 列表
3686
+ */
3469
3687
  function getNonLeafKeys(treeNodes, options = {}) {
3470
3688
  const { preserveGroup = false } = options;
3471
3689
  const keys = [];
@@ -3480,38 +3698,88 @@ function getNonLeafKeys(treeNodes, options = {}) {
3480
3698
  traverse(node.children);
3481
3699
  }
3482
3700
  };
3701
+ /**
3702
+ * 用预设回调遍历当前层节点列表。
3703
+ * @param nodes - 当前层的节点列表
3704
+ * @returns 无返回值
3705
+ */
3483
3706
  function traverse(nodes) {
3484
3707
  nodes.forEach(cb);
3485
3708
  }
3486
3709
  traverse(treeNodes);
3487
3710
  return keys;
3488
3711
  }
3712
+ /**
3713
+ * 判断原始节点是否为叶子:显式 isLeaf 字段优先,否则以取不到子节点视为叶子。
3714
+ * @param rawNode - 原始节点数据
3715
+ * @param getChildren - 取子节点的函数
3716
+ * @returns 是否为叶子节点
3717
+ */
3489
3718
  function isLeaf(rawNode, getChildren) {
3490
3719
  const { isLeaf } = rawNode;
3491
3720
  if (isLeaf !== void 0) return isLeaf;
3492
3721
  else if (!getChildren(rawNode)) return true;
3493
3722
  return false;
3494
3723
  }
3724
+ /**
3725
+ * 默认取子节点实现:读取节点数据的 children 字段。
3726
+ * @param node - 原始节点数据
3727
+ * @returns 子节点数组或 undefined
3728
+ */
3495
3729
  function defaultGetChildren(node) {
3496
3730
  return node.children;
3497
3731
  }
3732
+ /**
3733
+ * 默认取 key 实现:读取节点数据的 key 字段。
3734
+ * @param node - 原始节点数据
3735
+ * @returns 节点 key
3736
+ */
3498
3737
  function defaultGetKey(node) {
3499
3738
  return node.key;
3500
3739
  }
3740
+ /**
3741
+ * 默认的节点忽略判定:始终返回 false。
3742
+ * @returns 恒为 false
3743
+ */
3501
3744
  function isIgnored() {
3502
3745
  return false;
3503
3746
  }
3747
+ /**
3748
+ * 判断节点是否处于浅加载完成状态:显式 isLeaf=false 但取不到子节点数组时视为未加载,
3749
+ * 其余情况(含已加载)均视为完成。
3750
+ * @param rawNode - 原始节点数据
3751
+ * @param getChildren - 取子节点的函数
3752
+ * @returns 节点是否已浅加载
3753
+ */
3504
3754
  function isShallowLoaded(rawNode, getChildren) {
3505
3755
  const { isLeaf } = rawNode;
3506
3756
  if (isLeaf === false && !Array.isArray(getChildren(rawNode))) return false;
3507
3757
  return true;
3508
3758
  }
3759
+ /**
3760
+ * 判断原始节点是否被禁用。
3761
+ * @param rawNode - 原始节点数据
3762
+ * @returns disabled === true 时返回 true
3763
+ */
3509
3764
  function isDisabled(rawNode) {
3510
3765
  return rawNode.disabled === true;
3511
3766
  }
3767
+ /**
3768
+ * 判断节点是否显式未加载:isLeaf === false 且 getChildren 未返回数组
3769
+ * (异步加载占位,子树尚未到位)。
3770
+ * @param rawNode - 原始节点数据
3771
+ * @param getChildren - 取子节点的函数
3772
+ * @returns 是否显式未加载
3773
+ */
3512
3774
  function isExpilicitlyNotLoaded(rawNode, getChildren) {
3513
3775
  return rawNode.isLeaf === false && !Array.isArray(getChildren(rawNode));
3514
3776
  }
3777
+ /**
3778
+ * 判断节点数据是否非法:声明 isLeaf === true 却仍返回非空子节点数组。
3779
+ * @param rawNode - 原始节点数据
3780
+ * @param getChildren - 取子节点的函数
3781
+ * @returns 数据非法时返回 true
3782
+ */
3515
3783
  function isNodeInvalid(rawNode, getChildren) {
3516
3784
  if (rawNode.isLeaf === true) {
3517
3785
  const children = getChildren(rawNode);
@@ -3519,15 +3787,33 @@ function isNodeInvalid(rawNode, getChildren) {
3519
3787
  }
3520
3788
  return false;
3521
3789
  }
3790
+ /**
3791
+ * 从勾选结果中取出选中 key 列表:兼容 key 数组直传与 merged 结果对象两种形态,
3792
+ * 空值返回空数组。
3793
+ * @param result - 勾选结果(key 数组、merged 对象或空值)
3794
+ * @returns 选中 key 数组
3795
+ */
3522
3796
  function unwrapCheckedKeys(result) {
3523
3797
  if (result === void 0 || result === null) return [];
3524
3798
  if (Array.isArray(result)) return result;
3525
3799
  return result.checkedKeys ?? [];
3526
3800
  }
3801
+ /**
3802
+ * 从勾选结果中取出半选 key 列表:仅 merged 结果对象包含该信息,
3803
+ * 数组与空值均返回空数组。
3804
+ * @param result - 勾选结果(key 数组、merged 对象或空值)
3805
+ * @returns 半选 key 数组
3806
+ */
3527
3807
  function unwrapIndeterminateKeys(result) {
3528
3808
  if (result === void 0 || result === null || Array.isArray(result)) return [];
3529
3809
  return result.indeterminateKeys ?? [];
3530
3810
  }
3811
+ /**
3812
+ * 求并集:把 keysToAdd 中不存在的 key 追加到 originalKeys,保持原有顺序。
3813
+ * @param originalKeys - 原始 key 列表
3814
+ * @param keysToAdd - 待追加的 key 列表
3815
+ * @returns 合并去重后的 key 列表
3816
+ */
3531
3817
  function merge(originalKeys, keysToAdd) {
3532
3818
  const set = new Set(originalKeys);
3533
3819
  keysToAdd.forEach((key) => {
@@ -3535,6 +3821,12 @@ function merge(originalKeys, keysToAdd) {
3535
3821
  });
3536
3822
  return Array.from(set);
3537
3823
  }
3824
+ /**
3825
+ * 求差集:从 originalKeys 中移除 keysToRemove 里出现的 key,保持原有顺序。
3826
+ * @param originalKeys - 原始 key 列表
3827
+ * @param keysToRemove - 待移除的 key 列表
3828
+ * @returns 移除后的 key 列表
3829
+ */
3538
3830
  function minus(originalKeys, keysToRemove) {
3539
3831
  const set = new Set(originalKeys);
3540
3832
  keysToRemove.forEach((key) => {
@@ -3542,6 +3834,11 @@ function minus(originalKeys, keysToRemove) {
3542
3834
  });
3543
3835
  return Array.from(set);
3544
3836
  }
3837
+ /**
3838
+ * 判断原始节点是否为 group 分组节点(type === "group")。
3839
+ * @param rawNode - 原始节点数据
3840
+ * @returns 是否 group 节点
3841
+ */
3545
3842
  function isGroup(rawNode) {
3546
3843
  return rawNode?.type === "group";
3547
3844
  }
@@ -3558,9 +3855,23 @@ var SubtreeNotLoadedError = class extends Error {
3558
3855
  this.message = "SubtreeNotLoadedError: checking a subtree whose required nodes are not fully loaded.";
3559
3856
  }
3560
3857
  };
3858
+ /**
3859
+ * 计算勾选后的完整选中 key 集合:把新增勾选并入当前选中集,再级联扩展到子孙节点。
3860
+ * @param checkKeys - 本次新增勾选的节点 key 列表
3861
+ * @param currentCheckedKeys - 当前已选中的 key 列表
3862
+ * @param treeMate - 树 mate 实例,用于查询节点与子树
3863
+ * @returns 扩展后的选中 key 集合
3864
+ */
3561
3865
  function getExtendedCheckedKeySetAfterCheck(checkKeys, currentCheckedKeys, treeMate) {
3562
3866
  return getExtendedCheckedKeySet(currentCheckedKeys.concat(checkKeys), treeMate);
3563
3867
  }
3868
+ /**
3869
+ * 收集取消勾选节点的可用祖先 key 集合(级联反选时这些祖先需同步取消勾选);
3870
+ * 上溯在遇到 disabled 节点或已访问节点时截断。
3871
+ * @param uncheckedKeys - 被取消勾选的节点 key 列表
3872
+ * @param treeMate - 树 mate 实例,用于查询节点父子关系
3873
+ * @returns 需要联动取消勾选的祖先 key 集合
3874
+ */
3564
3875
  function getAvailableAscendantNodeSet(uncheckedKeys, treeMate) {
3565
3876
  const visitedKeys = /* @__PURE__ */ new Set();
3566
3877
  uncheckedKeys.forEach((uncheckedKey) => {
@@ -3577,6 +3888,14 @@ function getAvailableAscendantNodeSet(uncheckedKeys, treeMate) {
3577
3888
  });
3578
3889
  return visitedKeys;
3579
3890
  }
3891
+ /**
3892
+ * 计算取消勾选后的完整选中 key 集合:从扩展选中集移除被取消的 key
3893
+ * 及其可用祖先,返回剩余集合。
3894
+ * @param uncheckedKeys - 本次取消勾选的节点 key 列表
3895
+ * @param currentCheckedKeys - 当前已选中的 key 列表
3896
+ * @param treeMate - 树 mate 实例
3897
+ * @returns 取消勾选后剩余的选中 key 集合
3898
+ */
3580
3899
  function getExtendedCheckedKeySetAfterUncheck(uncheckedKeys, currentCheckedKeys, treeMate) {
3581
3900
  const extendedCheckedKeySet = getExtendedCheckedKeySet(currentCheckedKeys, treeMate);
3582
3901
  const extendedKeySetToUncheck = getExtendedCheckedKeySet(uncheckedKeys, treeMate, true);
@@ -3588,6 +3907,15 @@ function getExtendedCheckedKeySetAfterUncheck(uncheckedKeys, currentCheckedKeys,
3588
3907
  keysToRemove.forEach((key) => extendedCheckedKeySet.delete(key));
3589
3908
  return extendedCheckedKeySet;
3590
3909
  }
3910
+ /**
3911
+ * 计算树勾选结果:cascade=false 时直接在现有选中集上增删;
3912
+ * cascade=true 时先扩展选中集,再自底向上按层归并出最终勾选状态
3913
+ * (checkStrategy 为 all/parent/child 时分别保留全部/父节点/叶子选中)。
3914
+ * @param options - 勾选参数:当前选中与半选 key、本次勾选/取消的 key、
3915
+ * cascade、leafOnly 与 checkStrategy
3916
+ * @param treeMate - 树 mate 实例,提供层级节点表用于自底向上归并
3917
+ * @returns 最终的选中 key 列表与半选 key 列表
3918
+ */
3591
3919
  function getCheckedKeys(options, treeMate) {
3592
3920
  const { checkedKeys, keysToCheck, keysToUncheck, indeterminateKeys, cascade, leafOnly, checkStrategy } = options;
3593
3921
  if (!cascade) {
@@ -3655,6 +3983,14 @@ function getCheckedKeys(options, treeMate) {
3655
3983
  indeterminateKeys: Array.from(syntheticIndeterminateKeySet)
3656
3984
  };
3657
3985
  }
3986
+ /**
3987
+ * 计算扩展选中 key 集合:把每个选中节点连同其可达子孙并入集合,遇 disabled 子树停止下钻;
3988
+ * 子树未完全加载时,勾选流程抛出 SubtreeNotLoadedError,取消勾选流程安全截断。
3989
+ * @param checkedKeys - 当前选中的节点 key 列表
3990
+ * @param treeMate - 树 mate 实例,提供节点映射与 getChildren
3991
+ * @param isUnchecking - 是否处于取消勾选流程,决定未加载子树的处理方式
3992
+ * @returns 含全部级联选中节点的 key 集合
3993
+ */
3658
3994
  function getExtendedCheckedKeySet(checkedKeys, treeMate, isUnchecking = false) {
3659
3995
  const { treeNodeMap, getChildren } = treeMate;
3660
3996
  const visitedKeySet = /* @__PURE__ */ new Set();
@@ -3682,6 +4018,16 @@ function getExtendedCheckedKeySet(checkedKeys, treeMate, isUnchecking = false) {
3682
4018
  * MIT License · Copyright (c) 07akioni
3683
4019
  * 本地改动:无实质改动。
3684
4020
  */
4021
+ /**
4022
+ * 计算指定节点的路径信息:从目标节点沿父链上溯收集并反转,得到根到该节点的
4023
+ * keyPath 与 treeNodePath;ignored 节点返回空路径且 treeNode 为 null。
4024
+ * @param key - 目标节点 key;null/undefined 时返回空路径
4025
+ * @param root0 - 路径选项
4026
+ * @param root0.includeGroup - 是否在路径中包含 group 节点
4027
+ * @param root0.includeSelf - 是否在路径中包含自身节点
4028
+ * @param treeMate - 树 mate 实例,提供节点映射查询
4029
+ * @returns 合并后的路径对象(keyPath、treeNodePath 与 treeNode)
4030
+ */
3685
4031
  function getPath(key, { includeGroup = false, includeSelf = true }, treeMate) {
3686
4032
  const treeNodeMap = treeMate.treeNodeMap;
3687
4033
  let treeNode = key === null || key === void 0 ? null : treeNodeMap.get(key) ?? null;
@@ -3710,12 +4056,24 @@ function getPath(key, { includeGroup = false, includeSelf = true }, treeMate) {
3710
4056
  * MIT License · Copyright (c) 07akioni
3711
4057
  * 本地改动:无实质改动。
3712
4058
  */
4059
+ /**
4060
+ * 返回树中第一个可用节点(非 group、非 ignored、非 disabled);
4061
+ * 首节点不可用时沿 getNext 继续向后找。
4062
+ * @param nodes - 顶层节点列表
4063
+ * @returns 首个可用节点;整树不可用时返回 null
4064
+ */
3713
4065
  function getFirstAvailableNode(nodes) {
3714
4066
  if (nodes.length === 0) return null;
3715
4067
  const node = nodes[0];
3716
4068
  if (node.isGroup || node.ignored || node.disabled) return node.getNext();
3717
4069
  return node;
3718
4070
  }
4071
+ /**
4072
+ * 取同级下一兄弟节点;loop 为 true 时越过末尾循环回首节点,否则返回 null。
4073
+ * @param node - 当前节点
4074
+ * @param loop - 是否循环绕回
4075
+ * @returns 下一兄弟节点或 null
4076
+ */
3719
4077
  function rawGetNext(node, loop) {
3720
4078
  const sibs = node.siblings;
3721
4079
  const l = sibs.length;
@@ -3726,11 +4084,26 @@ function rawGetNext(node, loop) {
3726
4084
  return sibs[index + 1];
3727
4085
  }
3728
4086
  }
4087
+ /**
4088
+ * 沿 dir 方向游标移动到下一个可用节点(非 group、非 ignored;disabled 需 includeDisabled),
4089
+ * 遇 group 节点下钻其子节点;loop 为 true 时绕树循环一周回到起点即以起点为结果。
4090
+ * @param fromNode - 起始节点
4091
+ * @param dir - 移动方向:prev 向前、next 向后
4092
+ * @param root0 - 移动选项对象(GetPrevNextOptions)
4093
+ * @param root0.loop - 到达端点后是否循环绕回
4094
+ * @param root0.includeDisabled - 是否把 disabled 节点纳入游标可达范围
4095
+ * @returns 目标节点;无可达节点时返回 null
4096
+ */
3729
4097
  function move(fromNode, dir, { loop = false, includeDisabled = false } = {}) {
3730
4098
  const iterate = dir === "prev" ? rawGetPrev : rawGetNext;
3731
4099
  const getChildOptions = { reverse: dir === "prev" };
3732
4100
  let meet = false;
3733
4101
  let endNode = null;
4102
+ /**
4103
+ * 沿方向游标遍历,记录第一个遇到的可用节点。
4104
+ * @param node - 当前游标节点
4105
+ * @returns 无返回值
4106
+ */
3734
4107
  function traverse(node) {
3735
4108
  if (node === null) return;
3736
4109
  if (node === fromNode) {
@@ -3760,6 +4133,12 @@ function move(fromNode, dir, { loop = false, includeDisabled = false } = {}) {
3760
4133
  traverse(fromNode);
3761
4134
  return endNode;
3762
4135
  }
4136
+ /**
4137
+ * 取同级上一兄弟节点;loop 为 true 时越过开头循环回尾节点,否则返回 null。
4138
+ * @param node - 当前节点
4139
+ * @param loop - 是否循环绕回
4140
+ * @returns 上一兄弟节点或 null
4141
+ */
3763
4142
  function rawGetPrev(node, loop) {
3764
4143
  const sibs = node.siblings;
3765
4144
  const l = sibs.length;
@@ -3770,9 +4149,21 @@ function rawGetPrev(node, loop) {
3770
4149
  return sibs[index - 1];
3771
4150
  }
3772
4151
  }
4152
+ /**
4153
+ * 取节点的直接父节点。
4154
+ * @param node - 当前节点
4155
+ * @returns 父节点;根节点返回 null
4156
+ */
3773
4157
  function rawGetParent(node) {
3774
4158
  return node.parent;
3775
4159
  }
4160
+ /**
4161
+ * 取节点下第一个可用子节点(非 disabled、非 ignored,递归下钻 group);
4162
+ * reverse 为 true 时从末尾向前查找。
4163
+ * @param node - 父节点
4164
+ * @param options - 查找选项;reverse 表示从末尾向前查找
4165
+ * @returns 可用子节点;不存在时返回 null
4166
+ */
3776
4167
  function getChild(node, options = {}) {
3777
4168
  const { reverse = false } = options;
3778
4169
  const { children } = node;
@@ -3817,9 +4208,21 @@ const moveMethods = {
3817
4208
  * MIT License · Copyright (c) 07akioni
3818
4209
  * 本地改动:无实质改动。
3819
4210
  */
4211
+ /**
4212
+ * 按展开状态把节点树拍平为一维列表:group 节点总是下钻;普通节点仅在
4213
+ * 未提供 expandedKeys 或其 key 在展开集合内时下钻;ignored 节点不下钻。
4214
+ * @param treeNodes - 待拍平的节点树
4215
+ * @param expandedKeys - 已展开节点的 key 列表;缺省视为全部展开
4216
+ * @returns 深度优先顺序的一维节点列表
4217
+ */
3820
4218
  function flatten(treeNodes, expandedKeys) {
3821
4219
  const expandedKeySet = expandedKeys ? new Set(expandedKeys) : void 0;
3822
4220
  const flattenedNodes = [];
4221
+ /**
4222
+ * 深度优先收集当前层节点并按展开状态决定是否下钻。
4223
+ * @param treeNodes - 当前层的节点列表
4224
+ * @returns 无返回值
4225
+ */
3823
4226
  function traverse(treeNodes) {
3824
4227
  treeNodes.forEach((treeNode) => {
3825
4228
  flattenedNodes.push(treeNode);
@@ -3838,6 +4241,12 @@ function flatten(treeNodes, expandedKeys) {
3838
4241
  * MIT License · Copyright (c) 07akioni
3839
4242
  * 本地改动:无实质改动。
3840
4243
  */
4244
+ /**
4245
+ * 判断 child 是否为 parent 的后代(含自身),沿父链逐级上溯比对 key。
4246
+ * @param parent - 祖先节点
4247
+ * @param child - 待判定的节点,可为 null 或 undefined
4248
+ * @returns child 位于 parent 子树内(含相等)时返回 true
4249
+ */
3841
4250
  function contains(parent, child) {
3842
4251
  const parentKey = parent.key;
3843
4252
  while (child) {
@@ -3853,6 +4262,18 @@ function contains(parent, child) {
3853
4262
  * MIT License · Copyright (c) 07akioni
3854
4263
  * 本地改动:process.env.NODE_ENV 守卫替换为 import.meta.env?.DEV。
3855
4264
  */
4265
+ /**
4266
+ * 递归构建树节点:以 nodeProto 为原型创建实例,回填 siblings/level/index/父子
4267
+ * 等结构信息,并把每个节点登记进 treeNodeMap 与 levelTreeNodeMap。
4268
+ * @param rawNodes - 当前层级的原始节点数组
4269
+ * @param treeNodeMap - key → 节点 的全量映射(原地写入)
4270
+ * @param levelTreeNodeMap - 层级 → 该层节点列表 的映射(原地写入)
4271
+ * @param nodeProto - 节点实例共享的原型(惰性 getter 与移动方法)
4272
+ * @param getChildren - 取子节点的函数
4273
+ * @param parent - 父节点;根层调用时为 null
4274
+ * @param level - 当前层级,根为 0
4275
+ * @returns 当前层级构建好的节点数组
4276
+ */
3856
4277
  function createTreeNodes(rawNodes, treeNodeMap, levelTreeNodeMap, nodeProto, getChildren, parent = null, level = 0) {
3857
4278
  const treeNodes = [];
3858
4279
  rawNodes.forEach((rawNode, index) => {
@@ -3876,6 +4297,14 @@ function createTreeNodes(rawNodes, treeNodeMap, levelTreeNodeMap, nodeProto, get
3876
4297
  });
3877
4298
  return treeNodes;
3878
4299
  }
4300
+ /**
4301
+ * 创建 TreeMate 实例:以 options 覆盖默认的取 key/子节点/禁用等策略,构建共享节点原型
4302
+ * (惰性 getter 与移动、contains 方法),并暴露节点查询、路径、展开拍平与勾选级联计算等 API。
4303
+ * @param rawNodes - 原始节点树
4304
+ * @param options - 自定义策略(getKey/getChildren/getDisabled/getIgnored/getIsGroup、
4305
+ * ignoreEmptyChildren 等);缺省走默认实现
4306
+ * @returns TreeMate 实例
4307
+ */
3879
4308
  function createTreeMate(rawNodes, options = {}) {
3880
4309
  const treeNodeMap = /* @__PURE__ */ new Map();
3881
4310
  const levelTreeNodeMap = /* @__PURE__ */ new Map();
@@ -4011,6 +4440,11 @@ function createTreeMate(rawNodes, options = {}) {
4011
4440
  * 计算键盘移动后的活动节点 key。
4012
4441
  * - 仅在非 disabled 节点间移动;loop 默认 true(末尾循环回首行)。
4013
4442
  * - activeKey 为 null 或不在候选序列时,ArrowDown 从首行开始、ArrowUp 从末行开始。
4443
+ * @param flattened - 已展开的扁平节点列表
4444
+ * @param activeKey - 当前活动节点 key;null 表示尚无活动节点
4445
+ * @param key - 本次键盘操作(ArrowDown/ArrowUp/Home/End)
4446
+ * @param options - 选项;loop 控制到端点后是否循环绕回(默认 true)
4447
+ * @returns 移动后的活动节点 key;无可用候选节点时返回 null
4014
4448
  */
4015
4449
  function nextActiveKey(flattened, activeKey, key, options) {
4016
4450
  const loop = options?.loop ?? true;
@@ -4036,7 +4470,7 @@ function nextActiveKey(flattened, activeKey, key, options) {
4036
4470
  }
4037
4471
  //#endregion
4038
4472
  //#region src/components/cascader/CascaderPanel.vue
4039
- const _hoisted_1$17 = ["aria-label"];
4473
+ const _hoisted_1$18 = ["aria-label"];
4040
4474
  const _hoisted_2$14 = [
4041
4475
  "data-key",
4042
4476
  "aria-selected",
@@ -4059,7 +4493,7 @@ const _hoisted_4$8 = {
4059
4493
  "stroke-width": "3",
4060
4494
  class: "size-3"
4061
4495
  };
4062
- const _hoisted_5$6 = {
4496
+ const _hoisted_5$7 = {
4063
4497
  key: 1,
4064
4498
  viewBox: "0 0 24 24",
4065
4499
  fill: "none",
@@ -4072,7 +4506,7 @@ const _hoisted_7$4 = {
4072
4506
  key: 0,
4073
4507
  class: "px-3 py-1.5 text-sm text-muted-foreground"
4074
4508
  };
4075
- const _sfc_main$56 = /*@__PURE__*/ defineComponent({
4509
+ const _sfc_main$57 = /*@__PURE__*/ defineComponent({
4076
4510
  __name: "CascaderPanel",
4077
4511
  props: {
4078
4512
  /** 列数据:columns[0] 为根层,后续每列为展开路径的子层 */
@@ -4172,21 +4606,21 @@ const _sfc_main$56 = /*@__PURE__*/ defineComponent({
4172
4606
  "data-part": "checkbox",
4173
4607
  class: normalizeClass(["flex size-4 shrink-0 items-center justify-center rounded-sm border", checkedSet.value.has(node.key) ? "border-primary bg-primary text-primary-foreground" : "border-input"]),
4174
4608
  onClick: withModifiers(($event) => toggleCheck(node), ["stop"])
4175
- }, [checkedSet.value.has(node.key) ? (openBlock(), createElementBlock("svg", _hoisted_4$8, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M20 6 9 17l-5-5" }, null, -1)])])) : indeterminateSet.value.has(node.key) ? (openBlock(), createElementBlock("svg", _hoisted_5$6, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M5 12h14" }, null, -1)])])) : createCommentVNode("v-if", true)], 10, _hoisted_3$10)) : createCommentVNode("v-if", true),
4609
+ }, [checkedSet.value.has(node.key) ? (openBlock(), createElementBlock("svg", _hoisted_4$8, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M20 6 9 17l-5-5" }, null, -1)])])) : indeterminateSet.value.has(node.key) ? (openBlock(), createElementBlock("svg", _hoisted_5$7, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M5 12h14" }, null, -1)])])) : createCommentVNode("v-if", true)], 10, _hoisted_3$10)) : createCommentVNode("v-if", true),
4176
4610
  createElementVNode("span", _hoisted_6$5, toDisplayString(labelOf(node)), 1),
4177
4611
  node.children?.length ? (openBlock(), createBlock(ChevronIcon_default, {
4178
4612
  key: 1,
4179
4613
  class: normalizeClass(unref(cn)("size-3.5 shrink-0 text-muted-foreground transition-transform", props.isExpanded(node) && "rotate-90"))
4180
4614
  }, null, 8, ["class"])) : createCommentVNode("v-if", true)
4181
4615
  ], 40, _hoisted_2$14);
4182
- }), 128)), !column.length ? (openBlock(), createElementBlock("div", _hoisted_7$4, "无数据")) : createCommentVNode("v-if", true)], 8, _hoisted_1$17);
4616
+ }), 128)), !column.length ? (openBlock(), createElementBlock("div", _hoisted_7$4, "无数据")) : createCommentVNode("v-if", true)], 8, _hoisted_1$18);
4183
4617
  }), 128))], 2);
4184
4618
  };
4185
4619
  }
4186
4620
  });
4187
4621
  //#endregion
4188
4622
  //#region src/components/cascader/Cascader.vue
4189
- const _hoisted_1$16 = ["aria-expanded", "aria-disabled"];
4623
+ const _hoisted_1$17 = ["aria-expanded", "aria-disabled"];
4190
4624
  const _hoisted_2$13 = {
4191
4625
  key: 1,
4192
4626
  class: "truncate text-muted-foreground"
@@ -4199,7 +4633,7 @@ const _hoisted_4$7 = {
4199
4633
  key: 1,
4200
4634
  class: "truncate text-muted-foreground"
4201
4635
  };
4202
- const _hoisted_5$5 = { class: "ml-auto flex shrink-0 items-center gap-1" };
4636
+ const _hoisted_5$6 = { class: "ml-auto flex shrink-0 items-center gap-1" };
4203
4637
  const _sfc_main$8 = /*@__PURE__*/ defineComponent({
4204
4638
  inheritAttrs: false,
4205
4639
  __name: "Cascader",
@@ -4533,7 +4967,7 @@ const _sfc_main$8 = /*@__PURE__*/ defineComponent({
4533
4967
  class: unref(cn)(unref(controlCls), "min-h-9 cursor-pointer gap-2 px-3 py-1.5 text-sm", props.disabled && "cursor-not-allowed opacity-50", props.class),
4534
4968
  onClick: openFromInput,
4535
4969
  onKeydown: handleKeydown
4536
- }), [isMulti.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [tags.value.length ? (openBlock(), createBlock(_sfc_main$57, {
4970
+ }), [isMulti.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [tags.value.length ? (openBlock(), createBlock(_sfc_main$58, {
4537
4971
  key: 0,
4538
4972
  values: tags.value,
4539
4973
  "max-tag-count": props.maxTagCount,
@@ -4543,14 +4977,14 @@ const _sfc_main$8 = /*@__PURE__*/ defineComponent({
4543
4977
  "values",
4544
4978
  "max-tag-count",
4545
4979
  "disabled"
4546
- ])) : createCommentVNode("v-if", true), !tags.value.length ? (openBlock(), createElementBlock("span", _hoisted_2$13, toDisplayString(props.placeholder), 1)) : createCommentVNode("v-if", true)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [singleLabel.value ? (openBlock(), createElementBlock("span", _hoisted_3$9, toDisplayString(singleLabel.value), 1)) : (openBlock(), createElementBlock("span", _hoisted_4$7, toDisplayString(props.placeholder), 1))], 64)), createElementVNode("span", _hoisted_5$5, [props.clearable && hasValue.value && !props.disabled ? (openBlock(), createElementBlock("span", {
4980
+ ])) : createCommentVNode("v-if", true), !tags.value.length ? (openBlock(), createElementBlock("span", _hoisted_2$13, toDisplayString(props.placeholder), 1)) : createCommentVNode("v-if", true)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [singleLabel.value ? (openBlock(), createElementBlock("span", _hoisted_3$9, toDisplayString(singleLabel.value), 1)) : (openBlock(), createElementBlock("span", _hoisted_4$7, toDisplayString(props.placeholder), 1))], 64)), createElementVNode("span", _hoisted_5$6, [props.clearable && hasValue.value && !props.disabled ? (openBlock(), createElementBlock("span", {
4547
4981
  key: 0,
4548
4982
  role: "button",
4549
4983
  "data-part": "clear",
4550
4984
  class: "text-muted-foreground hover:text-foreground",
4551
4985
  "aria-label": "清空",
4552
4986
  onClick: withModifiers(handleClear, ["stop"])
4553
- }, [createVNode(CloseIcon_default, { class: "size-4 shrink-0" })])) : createCommentVNode("v-if", true), createVNode(ChevronIcon_default, { class: normalizeClass(unref(cn)("size-4 shrink-0 text-muted-foreground transition-transform", unref(isOpen) ? "-rotate-90" : "rotate-90")) }, null, 8, ["class"])])], 16, _hoisted_1$16)]),
4987
+ }, [createVNode(CloseIcon_default, { class: "size-4 shrink-0" })])) : createCommentVNode("v-if", true), createVNode(ChevronIcon_default, { class: normalizeClass(unref(cn)("size-4 shrink-0 text-muted-foreground transition-transform", unref(isOpen) ? "-rotate-90" : "rotate-90")) }, null, 8, ["class"])])], 16, _hoisted_1$17)]),
4554
4988
  _: 1
4555
4989
  }), (openBlock(), createBlock(Teleport, { to: unref(teleportTarget) }, [createVNode(unref(Popover).Positioner, { class: "z-[var(--z-overlay)]" }, {
4556
4990
  default: withCtx(() => [createVNode(unref(Popover).Content, {
@@ -4558,7 +4992,7 @@ const _sfc_main$8 = /*@__PURE__*/ defineComponent({
4558
4992
  style: normalizeStyle({ minWidth: panelMinWidth.value }),
4559
4993
  onKeydown: handleKeydown
4560
4994
  }, {
4561
- default: withCtx(() => [createVNode(_sfc_main$56, {
4995
+ default: withCtx(() => [createVNode(_sfc_main$57, {
4562
4996
  columns: columns.value,
4563
4997
  "expand-trigger": props.expandTrigger,
4564
4998
  "selected-keys": isMulti.value ? selectedKeys.value : [],
@@ -4595,7 +5029,7 @@ const _sfc_main$8 = /*@__PURE__*/ defineComponent({
4595
5029
  });
4596
5030
  //#endregion
4597
5031
  //#region src/components/tree-select/TreePanel.vue
4598
- const _hoisted_1$15 = [
5032
+ const _hoisted_1$16 = [
4599
5033
  "aria-level",
4600
5034
  "aria-selected",
4601
5035
  "aria-checked",
@@ -4614,7 +5048,7 @@ const _hoisted_3$8 = {
4614
5048
  "aria-hidden": "true"
4615
5049
  };
4616
5050
  const _hoisted_4$6 = ["data-checked", "data-indeterminate"];
4617
- const _hoisted_5$4 = {
5051
+ const _hoisted_5$5 = {
4618
5052
  key: 0,
4619
5053
  viewBox: "0 0 24 24",
4620
5054
  fill: "none",
@@ -4638,7 +5072,7 @@ const _hoisted_8$1 = {
4638
5072
  key: 0,
4639
5073
  class: "px-2 py-6 text-center text-sm text-muted-foreground"
4640
5074
  };
4641
- const _sfc_main$55 = /*@__PURE__*/ defineComponent({
5075
+ const _sfc_main$56 = /*@__PURE__*/ defineComponent({
4642
5076
  __name: "TreePanel",
4643
5077
  props: {
4644
5078
  /** 展开态扁平化的可见节点序列(来自 treeMate.getFlattenedNodes(expandedKeys)) */
@@ -4739,23 +5173,23 @@ const _sfc_main$55 = /*@__PURE__*/ defineComponent({
4739
5173
  "data-indeterminate": isIndeterminate(node) ? "" : void 0,
4740
5174
  class: "flex size-4 shrink-0 items-center justify-center rounded-[3px] border border-input bg-background text-background data-[checked]:border-primary data-[checked]:bg-primary data-[indeterminate]:border-primary data-[indeterminate]:bg-primary",
4741
5175
  "aria-hidden": "true"
4742
- }, [isChecked(node) ? (openBlock(), createElementBlock("svg", _hoisted_5$4, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M20 6 9 17l-5-5" }, null, -1)])])) : isIndeterminate(node) ? (openBlock(), createElementBlock("svg", _hoisted_6$4, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M5 12h14" }, null, -1)])])) : createCommentVNode("v-if", true)], 8, _hoisted_4$6)) : createCommentVNode("v-if", true),
5176
+ }, [isChecked(node) ? (openBlock(), createElementBlock("svg", _hoisted_5$5, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M20 6 9 17l-5-5" }, null, -1)])])) : isIndeterminate(node) ? (openBlock(), createElementBlock("svg", _hoisted_6$4, [..._cache[1] || (_cache[1] = [createElementVNode("path", { d: "M5 12h14" }, null, -1)])])) : createCommentVNode("v-if", true)], 8, _hoisted_4$6)) : createCommentVNode("v-if", true),
4743
5177
  createElementVNode("span", _hoisted_7$3, toDisplayString(label(node)), 1)
4744
- ], 12, _hoisted_1$15);
5178
+ ], 12, _hoisted_1$16);
4745
5179
  }), 128)), __props.nodes.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_8$1, " 无数据 ")) : createCommentVNode("v-if", true)], 2);
4746
5180
  };
4747
5181
  }
4748
5182
  });
4749
5183
  //#endregion
4750
5184
  //#region src/components/tree-select/TreeSelect.vue
4751
- const _hoisted_1$14 = ["aria-expanded", "aria-disabled"];
5185
+ const _hoisted_1$15 = ["aria-expanded", "aria-disabled"];
4752
5186
  const _hoisted_2$11 = ["placeholder", "aria-label"];
4753
5187
  const _hoisted_3$7 = {
4754
5188
  key: 2,
4755
5189
  class: "truncate text-muted-foreground"
4756
5190
  };
4757
5191
  const _hoisted_4$5 = ["placeholder", "aria-label"];
4758
- const _hoisted_5$3 = {
5192
+ const _hoisted_5$4 = {
4759
5193
  key: 0,
4760
5194
  class: "truncate"
4761
5195
  };
@@ -5112,7 +5546,7 @@ const _sfc_main$50 = /*@__PURE__*/ defineComponent({
5112
5546
  onClick: openFromInput,
5113
5547
  onKeydown: handleKeydown
5114
5548
  }), [isMulti.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
5115
- tags.value.length ? (openBlock(), createBlock(_sfc_main$57, {
5549
+ tags.value.length ? (openBlock(), createBlock(_sfc_main$58, {
5116
5550
  key: 0,
5117
5551
  values: tags.value,
5118
5552
  "max-tag-count": props.maxTagCount,
@@ -5141,14 +5575,14 @@ const _sfc_main$50 = /*@__PURE__*/ defineComponent({
5141
5575
  class: "h-full w-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground",
5142
5576
  placeholder: singleLabel.value || props.placeholder,
5143
5577
  "aria-label": props.placeholder
5144
- }, null, 8, _hoisted_4$5)), [[vModelText, pattern.value]]) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [singleLabel.value ? (openBlock(), createElementBlock("span", _hoisted_5$3, toDisplayString(singleLabel.value), 1)) : (openBlock(), createElementBlock("span", _hoisted_6$3, toDisplayString(props.placeholder), 1))], 64))], 64)), createElementVNode("span", _hoisted_7$2, [props.clearable && hasValue.value && !props.disabled ? (openBlock(), createElementBlock("span", {
5578
+ }, null, 8, _hoisted_4$5)), [[vModelText, pattern.value]]) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [singleLabel.value ? (openBlock(), createElementBlock("span", _hoisted_5$4, toDisplayString(singleLabel.value), 1)) : (openBlock(), createElementBlock("span", _hoisted_6$3, toDisplayString(props.placeholder), 1))], 64))], 64)), createElementVNode("span", _hoisted_7$2, [props.clearable && hasValue.value && !props.disabled ? (openBlock(), createElementBlock("span", {
5145
5579
  key: 0,
5146
5580
  role: "button",
5147
5581
  "data-part": "clear",
5148
5582
  class: "text-muted-foreground hover:text-foreground",
5149
5583
  "aria-label": "清空",
5150
5584
  onClick: withModifiers(handleClear, ["stop"])
5151
- }, [createVNode(CloseIcon_default, { class: "size-4 shrink-0" })])) : createCommentVNode("v-if", true), createVNode(ChevronIcon_default, { class: normalizeClass(unref(cn)("size-4 shrink-0 text-muted-foreground transition-transform", unref(isOpen) ? "-rotate-90" : "rotate-90")) }, null, 8, ["class"])])], 16, _hoisted_1$14)]),
5585
+ }, [createVNode(CloseIcon_default, { class: "size-4 shrink-0" })])) : createCommentVNode("v-if", true), createVNode(ChevronIcon_default, { class: normalizeClass(unref(cn)("size-4 shrink-0 text-muted-foreground transition-transform", unref(isOpen) ? "-rotate-90" : "rotate-90")) }, null, 8, ["class"])])], 16, _hoisted_1$15)]),
5152
5586
  _: 1
5153
5587
  }),
5154
5588
  createCommentVNode(" 弹层 Teleport:脱离表单 DOM,消除 overflow 容器裁剪隐患(DatePicker 同款);\n 目标经沙箱适配降级(shadow DOM / wujie graft → 应用挂载容器) "),
@@ -5158,7 +5592,7 @@ const _sfc_main$50 = /*@__PURE__*/ defineComponent({
5158
5592
  style: normalizeStyle({ minWidth: panelMinWidth.value }),
5159
5593
  onKeydown: handleKeydown
5160
5594
  }, {
5161
- default: withCtx(() => [createVNode(_sfc_main$55, {
5595
+ default: withCtx(() => [createVNode(_sfc_main$56, {
5162
5596
  nodes: filteredNodes.value,
5163
5597
  "selected-keys": selectedKeys.value,
5164
5598
  "expanded-keys": expandedKeys.value,
@@ -5194,6 +5628,12 @@ const _sfc_main$50 = /*@__PURE__*/ defineComponent({
5194
5628
  });
5195
5629
  //#endregion
5196
5630
  //#region src/components/form-render/widgets/tree.ts
5631
+ /**
5632
+ * treeSelect widget:树形下拉选择,options 原名直传(TreeOption 命名穿透),
5633
+ * placeholder 先用 item 级回退,options.placeholder 展开时覆盖。
5634
+ * @param options - widget 选项,原名直传给 TreeSelect,placeholder 以 item 级缺省兜底
5635
+ * @returns 渲染函数,接收渲染上下文并产出 TreeSelect vnode
5636
+ */
5197
5637
  function renderTreeSelectItem(options) {
5198
5638
  const { placeholder, ...rest } = options;
5199
5639
  return (ctx) => h(_sfc_main$50, {
@@ -5203,6 +5643,12 @@ function renderTreeSelectItem(options) {
5203
5643
  ...ctx.item.componentProps
5204
5644
  });
5205
5645
  }
5646
+ /**
5647
+ * cascader widget:级联选择,绑定与 treeSelect 一致(modelValue 受控形态),
5648
+ * placeholder 先用 item 级回退,options.placeholder 展开时覆盖。
5649
+ * @param options - widget 选项,原名直传给 Cascader,placeholder 以 item 级缺省兜底
5650
+ * @returns 渲染函数,接收渲染上下文并产出 Cascader vnode
5651
+ */
5206
5652
  function renderCascaderItem(options) {
5207
5653
  const { placeholder, ...rest } = options;
5208
5654
  return (ctx) => h(_sfc_main$8, {
@@ -5218,6 +5664,7 @@ function renderCascaderItem(options) {
5218
5664
  * widget 注册表:`r.input({...})` 等柯里化工厂的运行时对象。
5219
5665
  * 文件按绑定形态聚合:input / model-value(modelValue 系)/ boolean(checked 系)/
5220
5666
  * value(radioGroup/slider)/ select(多子组件组装)。
5667
+ * @returns 各 widget 类型的柯里化工厂映射(render 为恒等直通),供 FormRender 渲染时调用
5221
5668
  */
5222
5669
  function widgetRenders() {
5223
5670
  return {
@@ -5243,7 +5690,7 @@ function widgetRenders() {
5243
5690
  }
5244
5691
  //#endregion
5245
5692
  //#region src/components/form-render/FormRender.vue
5246
- const _hoisted_1$13 = {
5693
+ const _hoisted_1$14 = {
5247
5694
  key: 0,
5248
5695
  class: "col-span-full flex justify-end gap-2"
5249
5696
  };
@@ -5315,8 +5762,11 @@ const _sfc_main$25 = /*@__PURE__*/ defineComponent({
5315
5762
  if (import.meta.env.DEV && actions) {
5316
5763
  if (props.searchable !== void 0 || props.submitable !== void 0 || props.resetable !== void 0 || props.cancelable !== void 0 || props.searchText !== void 0 || props.submitText !== void 0 || props.resetText !== void 0) console.warn("[tu-design] <FormRender> definition.actions 与按钮 props 同传,已按 actions 渲染。");
5317
5764
  }
5318
- /** I4:校验失败时 isFieldsValid=false,不 emit;成功后才 emit(事件回调中一次性读取不受 S1 限制)。
5319
- * 校验语义单点化(R30):definition 存在时复用 definition.submit();拆分式 :form + :items 走内联逻辑 */
5765
+ /**
5766
+ * 校验失败时 isFieldsValid=false,不 emit;成功后才 emit(事件回调中一次性读取不受非响应式限制)。
5767
+ * 校验语义单点化:definition 存在时复用 definition.submit();拆分式 :form + :items 走内联逻辑
5768
+ * @param mode - 提交语义:"search" 触发 search 事件(查询按钮),"submit" 触发 submit 事件
5769
+ */
5320
5770
  async function submit(mode) {
5321
5771
  if (!instance) return;
5322
5772
  let valid;
@@ -5347,7 +5797,7 @@ const _sfc_main$25 = /*@__PURE__*/ defineComponent({
5347
5797
  return openBlock(), createElementBlock("div", {
5348
5798
  key: String(item.key),
5349
5799
  style: normalizeStyle(spanStyle(item.span))
5350
- }, [createVNode(_sfc_main$64, {
5800
+ }, [createVNode(_sfc_main$65, {
5351
5801
  item,
5352
5802
  widget: widgetOf(item),
5353
5803
  values: unref(valuesRef)
@@ -5356,7 +5806,7 @@ const _sfc_main$25 = /*@__PURE__*/ defineComponent({
5356
5806
  "widget",
5357
5807
  "values"
5358
5808
  ])], 4);
5359
- }), 128)), showActions.value ? (openBlock(), createElementBlock("div", _hoisted_1$13, [renderSlot(_ctx.$slots, "actions", {}, () => [
5809
+ }), 128)), showActions.value ? (openBlock(), createElementBlock("div", _hoisted_1$14, [renderSlot(_ctx.$slots, "actions", {}, () => [
5360
5810
  searchable.value ? (openBlock(), createBlock(unref(_sfc_main$5), {
5361
5811
  key: 0,
5362
5812
  onClick: _cache[0] || (_cache[0] = ($event) => submit("search"))
@@ -5399,6 +5849,8 @@ const _sfc_main$25 = /*@__PURE__*/ defineComponent({
5399
5849
  * - `defaultValues` 从 `items[].default` 派生(值或同步工厂,缺省 null)——单一真相源;
5400
5850
  * - 显式泛型 `useForm<T>`,保住 onSubmit `{ value: T }` 全链路推断;
5401
5851
  * - 须在组件 setup 中调用(TanStack useForm 内部 `onMounted(formApi.mount)`)。
5852
+ * @param options - 表单选项:字段定义、校验 schema、提交回调、按钮预设七项与 TanStack 透传项
5853
+ * @returns 表单渲染 definition(items + form + resetToDefaults + submit + actions?)
5402
5854
  */
5403
5855
  function useFormRender(options) {
5404
5856
  const { items, schema, onSubmit, formOptions, searchable, submitable, resetable, cancelable, searchText, submitText, resetText } = options;
@@ -5439,10 +5891,12 @@ function useFormRender(options) {
5439
5891
  * - `items` / `form` 传给 `<FormRender>`(支持 `:definition` 单 prop 或 `:form` + `:items` 拆分);
5440
5892
  * - `form` 可直接 `reset()` / `validate()` / `handleSubmit()`;
5441
5893
  * - `resetToDefaults()` 重置到 `items.default`(搜索表单"重置"语义);
5442
- * - `submit()` 全量校验并返回是否通过(R30,组合式查询链路);
5443
- * - `actions` 按钮预设(searchable 等七项直传):存在时 `<FormRender>` 组件按钮 props 全量忽略(A1 块级互斥)。
5894
+ * - `submit()` 全量校验并返回是否通过(组合式查询链路);
5895
+ * - `actions` 按钮预设(searchable 等七项直传):存在时 `<FormRender>` 组件按钮 props 全量忽略(块级互斥)。
5444
5896
  *
5445
5897
  * 须在组件 setup 中调用(TanStack useForm 约束)。
5898
+ * @param config - 表单配置:字段定义、校验 schema、提交回调、按钮预设七项与 TanStack 透传项
5899
+ * @returns 表单渲染 definition(items + form + resetToDefaults + submit + actions?),直接传给 <FormRender>
5446
5900
  */
5447
5901
  function defineForm(config) {
5448
5902
  return useFormRender(config);
@@ -5748,7 +6202,7 @@ const cardVariants = cva("relative rounded-xl border border-border bg-card text-
5748
6202
  });
5749
6203
  //#endregion
5750
6204
  //#region src/components/dialog/Dialog.vue
5751
- const _hoisted_1$12 = {
6205
+ const _hoisted_1$13 = {
5752
6206
  key: 0,
5753
6207
  class: "flex flex-col gap-2 text-center sm:text-left"
5754
6208
  };
@@ -5850,7 +6304,7 @@ const _sfc_main$14 = /*@__PURE__*/ defineComponent({
5850
6304
  default: withCtx(() => [createVNode(unref(Dialog).Content, { class: normalizeClass(contentClass.value) }, {
5851
6305
  default: withCtx(() => [
5852
6306
  createCommentVNode(" 标题/描述:#title / #description 插槽优先,回退 title/description props;皆无则不渲染对应 DOM "),
5853
- hasHeader.value || _ctx.$slots.title || _ctx.$slots.description ? (openBlock(), createElementBlock("div", _hoisted_1$12, [_ctx.$slots.title || props.title ? (openBlock(), createBlock(unref(Dialog).Title, {
6307
+ hasHeader.value || _ctx.$slots.title || _ctx.$slots.description ? (openBlock(), createElementBlock("div", _hoisted_1$13, [_ctx.$slots.title || props.title ? (openBlock(), createBlock(unref(Dialog).Title, {
5854
6308
  key: 0,
5855
6309
  class: "text-lg font-semibold leading-none tracking-tight"
5856
6310
  }, {
@@ -5897,7 +6351,7 @@ const _sfc_main$14 = /*@__PURE__*/ defineComponent({
5897
6351
  const itemCls = "relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0";
5898
6352
  const labelCls = "px-2 py-1.5 text-sm font-medium";
5899
6353
  const separatorCls = "-mx-1 my-1 h-px bg-muted";
5900
- const _sfc_main$54 = /*@__PURE__*/ defineComponent({
6354
+ const _sfc_main$55 = /*@__PURE__*/ defineComponent({
5901
6355
  __name: "MenuItems",
5902
6356
  props: { items: {} },
5903
6357
  setup(__props) {
@@ -6021,7 +6475,7 @@ const _sfc_main$16 = /*@__PURE__*/ defineComponent({
6021
6475
  }, 8, ["class"]),
6022
6476
  createVNode(unref(Menu).Positioner, { class: "z-[var(--z-overlay)]" }, {
6023
6477
  default: withCtx(() => [createVNode(unref(Menu).Content, mergeProps(unref(attrs), { class: unref(cn)(contentCls$1, props.contentClass) }), {
6024
- default: withCtx(() => [createVNode(_sfc_main$54, { items: props.items }, createSlots({ _: 2 }, [_ctx.$slots.item ? {
6478
+ default: withCtx(() => [createVNode(_sfc_main$55, { items: props.items }, createSlots({ _: 2 }, [_ctx.$slots.item ? {
6025
6479
  name: "item",
6026
6480
  fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "item", normalizeProps(guardReactiveProps(slotProps)))]),
6027
6481
  key: "0"
@@ -6414,7 +6868,7 @@ const _sfc_main$34 = /*@__PURE__*/ defineComponent({
6414
6868
  });
6415
6869
  //#endregion
6416
6870
  //#region src/components/separator/Separator.vue
6417
- const _hoisted_1$11 = ["data-orientation"];
6871
+ const _hoisted_1$12 = ["data-orientation"];
6418
6872
  const _sfc_main$38 = /*@__PURE__*/ defineComponent({
6419
6873
  __name: "Separator",
6420
6874
  props: {
@@ -6428,7 +6882,7 @@ const _sfc_main$38 = /*@__PURE__*/ defineComponent({
6428
6882
  return openBlock(), createElementBlock("div", {
6429
6883
  "data-orientation": props.orientation,
6430
6884
  class: normalizeClass(unref(cn)("bg-border shrink-0", orientationClass.value, props.class))
6431
- }, null, 10, _hoisted_1$11);
6885
+ }, null, 10, _hoisted_1$12);
6432
6886
  };
6433
6887
  }
6434
6888
  });
@@ -6449,14 +6903,14 @@ const _sfc_main$39 = /*@__PURE__*/ defineComponent({
6449
6903
  });
6450
6904
  //#endregion
6451
6905
  //#region src/components/table-render/TablePagination.vue
6452
- const _hoisted_1$10 = {
6906
+ const _hoisted_1$11 = {
6453
6907
  key: 0,
6454
6908
  class: "flex items-center gap-2 text-muted-foreground"
6455
6909
  };
6456
6910
  const _hoisted_2$9 = { key: 0 };
6457
6911
  const _hoisted_3$6 = ["value"];
6458
6912
  const _hoisted_4$4 = ["value"];
6459
- const _hoisted_5$2 = {
6913
+ const _hoisted_5$3 = {
6460
6914
  key: 0,
6461
6915
  xmlns: "http://www.w3.org/2000/svg",
6462
6916
  viewBox: "0 0 24 24",
@@ -6483,8 +6937,8 @@ const _hoisted_6$2 = {
6483
6937
  const _sfc_main$43 = /*@__PURE__*/ defineComponent({
6484
6938
  __name: "TablePagination",
6485
6939
  props: {
6486
- /** 组合式:传 defineTable 返回值,自动接线 page/动作并按 R13 单页自隐藏;
6487
- * 与手动分页 props 同传时以 definition 为准(DEV 警告,R29/R4 对齐) */
6940
+ /** 组合式:传 defineTable 返回值,自动接线 page/动作并单页自隐藏;
6941
+ * 与手动分页 props 同传时以 definition 为准(DEV 警告) */
6488
6942
  definition: { type: Object },
6489
6943
  /** 1-based 当前页码(手动模式) */
6490
6944
  pageIndex: {
@@ -6532,7 +6986,7 @@ const _sfc_main$43 = /*@__PURE__*/ defineComponent({
6532
6986
  const pageSizeOpts = computed(() => props.definition?.page.pageSizeOpts ?? props.pageSizeOpts);
6533
6987
  const total = computed(() => props.definition?.page.total ?? props.total);
6534
6988
  const totalPages = computed(() => Math.max(1, Math.ceil((total.value ?? 0) / (pageSize.value ?? 1))));
6535
- /** 可见性:definition 模式按 R13 单页自隐藏;手动模式须 pageIndex/pageSize/total 齐备(缺项 DEV 警告 + 不渲染) */
6989
+ /** 可见性:definition 模式单页自隐藏;手动模式须 pageIndex/pageSize/total 齐备(缺项 DEV 警告 + 不渲染) */
6536
6990
  const visible = computed(() => {
6537
6991
  if (props.definition !== void 0) return Math.ceil((total.value ?? 0) / (pageSize.value ?? 1)) > 1;
6538
6992
  return props.pageIndex !== void 0 && props.pageSize !== void 0 && props.total !== void 0;
@@ -6549,7 +7003,7 @@ const _sfc_main$43 = /*@__PURE__*/ defineComponent({
6549
7003
  props.definition?.setPageSize(value);
6550
7004
  emit("update:pageSize", value);
6551
7005
  }
6552
- /** 页码窗口:首页/尾页 + 当前页 ±1,跳过段用省略号(D12) */
7006
+ /** 页码窗口:首页/尾页 + 当前页 ±1,跳过段用省略号 */
6553
7007
  const pages = computed(() => {
6554
7008
  const count = totalPages.value;
6555
7009
  const current = pageIndex.value ?? 1;
@@ -6570,11 +7024,11 @@ const _sfc_main$43 = /*@__PURE__*/ defineComponent({
6570
7024
  return items;
6571
7025
  });
6572
7026
  return (_ctx, _cache) => {
6573
- return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" R31:不带 border-t(布局归使用方,TableRender 内置使用处显式补);左区缺省时页码靠右 "), visible.value ? (openBlock(), createElementBlock("div", {
7027
+ return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" 不带 border-t(布局归使用方,TableRender 内置使用处显式补);左区缺省时页码靠右 "), visible.value ? (openBlock(), createElementBlock("div", {
6574
7028
  key: 0,
6575
7029
  class: normalizeClass(unref(cn)("flex w-full items-center gap-4 p-2 text-sm", hasLeft.value ? "justify-between" : "justify-end", _ctx.$attrs.class))
6576
7030
  }, [
6577
- hasLeft.value ? (openBlock(), createElementBlock("div", _hoisted_1$10, [showTotalBar.value ? (openBlock(), createElementBlock("span", _hoisted_2$9, "共 " + toDisplayString(total.value) + " 条", 1)) : createCommentVNode("v-if", true), showSelect.value ? (openBlock(), createElementBlock("select", {
7031
+ hasLeft.value ? (openBlock(), createElementBlock("div", _hoisted_1$11, [showTotalBar.value ? (openBlock(), createElementBlock("span", _hoisted_2$9, "共 " + toDisplayString(total.value) + " 条", 1)) : createCommentVNode("v-if", true), showSelect.value ? (openBlock(), createElementBlock("select", {
6578
7032
  key: 1,
6579
7033
  class: "h-8 rounded-md border bg-transparent px-2 text-sm",
6580
7034
  value: pageSize.value,
@@ -6600,7 +7054,7 @@ const _sfc_main$43 = /*@__PURE__*/ defineComponent({
6600
7054
  disabled: (pageIndex.value ?? 1) <= 1,
6601
7055
  "aria-label": iconMode.value ? "上一页" : void 0
6602
7056
  }, {
6603
- default: withCtx(() => [iconMode.value ? (openBlock(), createElementBlock("svg", _hoisted_5$2, [..._cache[2] || (_cache[2] = [createElementVNode("path", { d: "m15 18-6-6 6-6" }, null, -1)])])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode("上一页")], 64))]),
7057
+ default: withCtx(() => [iconMode.value ? (openBlock(), createElementBlock("svg", _hoisted_5$3, [..._cache[2] || (_cache[2] = [createElementVNode("path", { d: "m15 18-6-6 6-6" }, null, -1)])])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode("上一页")], 64))]),
6604
7058
  _: 1
6605
7059
  }, 8, [
6606
7060
  "class",
@@ -6645,54 +7099,332 @@ const _sfc_main$43 = /*@__PURE__*/ defineComponent({
6645
7099
  }
6646
7100
  });
6647
7101
  //#endregion
6648
- //#region src/components/table-render/column-renders.ts
6649
- const pad = (value) => String(value).padStart(2, "0");
6650
- /** 迷你日期令牌格式化,不引入 date-fns;非法输入原样返回 */
6651
- function formatDate(input, pattern) {
6652
- const date = input instanceof Date ? input : new Date(input);
6653
- if (Number.isNaN(date.getTime())) return input;
6654
- const tokens = {
6655
- yyyy: String(date.getFullYear()),
6656
- MM: pad(date.getMonth() + 1),
6657
- dd: pad(date.getDate()),
6658
- HH: pad(date.getHours()),
6659
- mm: pad(date.getMinutes()),
6660
- ss: pad(date.getSeconds())
6661
- };
6662
- return pattern.replace(/yyyy|MM|dd|HH|mm|ss/g, (token) => tokens[token]);
6663
- }
7102
+ //#region src/components/overlay-shared/useConfirmPending.ts
6664
7103
  /**
6665
- * 内置列渲染器工厂(对标 x-render table-columns,v1:dict/date/currency/serial/button)。
6666
- * 返回值直接填入 TableColumnOptions.render;column 参数用于读取字段值。
6667
- * 与 FormRender widget 的 r.xxx() 范式共词根(D10)。
7104
+ * 确认弹层公共 pending 语义:@confirm 处理器返回 Promise 时锁定关闭通道,
7105
+ * resolve 后自动关闭,reject 保持打开并退出 loading;同步处理器直接关闭。
7106
+ * @param options - pending 配置:组件实例、confirm/cancel 补发与弹层关闭回调
7107
+ * @returns loading(确认进行中标记)、handleConfirm(异步确认处理)与 handleCancel(取消处理)
6668
7108
  */
6669
- function columnRenders() {
6670
- return {
6671
- render: (fn) => fn,
6672
- dict(mapping, options) {
6673
- return (record, _index, column) => {
6674
- const raw = record[column.key];
6675
- const entry = mapping[raw];
6676
- if (entry === void 0) return raw ?? "";
6677
- const label = typeof entry === "string" ? entry : entry.label;
6678
- const entryVariant = typeof entry === "object" ? entry.variant : void 0;
6679
- if (entryVariant !== void 0 || options?.badge !== void 0) {
6680
- const variant = entryVariant ?? (options?.badge === true ? void 0 : options?.badge);
6681
- return h(_sfc_main$4, { variant }, () => label);
6682
- }
6683
- return label;
6684
- };
6685
- },
6686
- date(pattern = "yyyy-MM-dd") {
6687
- return (record, _index, column) => formatDate(record[column.key], pattern);
6688
- },
6689
- currency(currency = "CNY", locale = "zh-CN") {
6690
- const format = new Intl.NumberFormat(locale, {
6691
- style: "currency",
6692
- currency
7109
+ function useConfirmPending(options) {
7110
+ const loading = ref(false);
7111
+ function handleConfirm() {
7112
+ if (loading.value) return;
7113
+ const handler = options.instance?.vnode.props?.onConfirm;
7114
+ const result = handler?.();
7115
+ if (!handler) options.emitConfirm();
7116
+ if (result instanceof Promise) {
7117
+ loading.value = true;
7118
+ result.then(() => {
7119
+ loading.value = false;
7120
+ options.close();
7121
+ }).catch(() => {
7122
+ loading.value = false;
6693
7123
  });
6694
- return (record, _index, column) => {
6695
- const raw = record[column.key];
7124
+ } else options.close();
7125
+ }
7126
+ function handleCancel() {
7127
+ if (loading.value) return;
7128
+ options.emitCancel();
7129
+ options.close();
7130
+ }
7131
+ return {
7132
+ loading,
7133
+ handleConfirm,
7134
+ handleCancel
7135
+ };
7136
+ }
7137
+ //#endregion
7138
+ //#region src/components/popconfirm/Popconfirm.vue
7139
+ const _hoisted_1$10 = { class: "mt-3 flex items-center justify-end gap-2" };
7140
+ const _hoisted_2$8 = {
7141
+ key: 0,
7142
+ viewBox: "0 0 24 24",
7143
+ fill: "none",
7144
+ stroke: "currentColor",
7145
+ "stroke-width": "2",
7146
+ "stroke-linecap": "round",
7147
+ class: "size-4 animate-spin",
7148
+ "aria-hidden": "true"
7149
+ };
7150
+ /**
7151
+ * 气泡确认:Popover 的一体式薄壳变体,面板内容内置 title/description + 确认/取消按钮。
7152
+ * 行为与 M2 AlertDialog 对齐:@confirm 处理器返回 Promise 时确认钮进入 loading 并锁定全部
7153
+ * 关闭通道(ESC/点外部/触发器/取消钮),resolve 后自动关闭、reject 保持打开;
7154
+ * 同步处理器点击确认/取消后自动关闭并派发对应事件。
7155
+ */
7156
+ const _sfc_main$33 = /*@__PURE__*/ defineComponent({
7157
+ inheritAttrs: false,
7158
+ __name: "Popconfirm",
7159
+ props: {
7160
+ /** 气泡标题(渲染为 Ark Popover.Title,content 自动接线 aria-labelledby) */
7161
+ title: {
7162
+ type: String,
7163
+ required: true
7164
+ },
7165
+ /** 气泡描述(可选,渲染为 Ark Popover.Description,content 自动接线 aria-describedby) */
7166
+ description: {
7167
+ type: String,
7168
+ default: void 0
7169
+ },
7170
+ /** 确认按钮文案 */
7171
+ confirmText: {
7172
+ type: String,
7173
+ default: "确定"
7174
+ },
7175
+ /** 取消按钮文案 */
7176
+ cancelText: {
7177
+ type: String,
7178
+ default: "取消"
7179
+ },
7180
+ /** 确认按钮风格:default 主色 / destructive 危险色 */
7181
+ variant: {
7182
+ type: String,
7183
+ default: "default"
7184
+ },
7185
+ /** 受控开关(配合 v-model:open);不传时为非受控,由内部状态管理 */
7186
+ open: {
7187
+ type: Boolean,
7188
+ default: void 0
7189
+ }
7190
+ },
7191
+ emits: [
7192
+ "update:open",
7193
+ "confirm",
7194
+ "cancel"
7195
+ ],
7196
+ setup(__props, { emit: __emit }) {
7197
+ const props = __props;
7198
+ const emit = __emit;
7199
+ const attrs = useAttrs();
7200
+ const instance = getCurrentInstance();
7201
+ const { isOpen, setOpen } = useControlledBoolean({
7202
+ controlled: () => props.open,
7203
+ onChange: (open) => emit("update:open", open)
7204
+ });
7205
+ function handleUpdate(open) {
7206
+ if (!open && loading.value) return;
7207
+ setOpen(open);
7208
+ }
7209
+ /** 关闭气泡:走受控桥把 open 置 false,定位回退/动画由 zag 处理 */
7210
+ function close() {
7211
+ handleUpdate(false);
7212
+ }
7213
+ const { loading, handleConfirm, handleCancel } = useConfirmPending({
7214
+ instance,
7215
+ emitConfirm: () => emit("confirm"),
7216
+ emitCancel: () => emit("cancel"),
7217
+ close
7218
+ });
7219
+ return (_ctx, _cache) => {
7220
+ return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" 薄壳复用 Popover:触发器 asChild、受控桥、定位与进出场动画均由 Popover 提供 "), createVNode(unref(_sfc_main$34), mergeProps(unref(attrs), {
7221
+ open: unref(isOpen),
7222
+ "content-class": "w-64 p-3",
7223
+ "onUpdate:open": handleUpdate
7224
+ }), {
7225
+ content: withCtx(() => [
7226
+ createVNode(unref(Popover).Title, { class: "text-sm font-medium" }, {
7227
+ default: withCtx(() => [createTextVNode(toDisplayString(props.title), 1)]),
7228
+ _: 1
7229
+ }),
7230
+ props.description ? (openBlock(), createBlock(unref(Popover).Description, {
7231
+ key: 0,
7232
+ class: "mt-1 text-xs text-muted-foreground"
7233
+ }, {
7234
+ default: withCtx(() => [createTextVNode(toDisplayString(props.description), 1)]),
7235
+ _: 1
7236
+ })) : createCommentVNode("v-if", true),
7237
+ createCommentVNode(" 操作区:取消 outline,确认按 variant 切换语义色;pending 时双钮禁用 + 确认钮转 loading "),
7238
+ createElementVNode("div", _hoisted_1$10, [createVNode(unref(_sfc_main$5), {
7239
+ variant: "outline",
7240
+ size: "sm",
7241
+ disabled: unref(loading),
7242
+ onClick: unref(handleCancel)
7243
+ }, {
7244
+ default: withCtx(() => [createTextVNode(toDisplayString(props.cancelText), 1)]),
7245
+ _: 1
7246
+ }, 8, ["disabled", "onClick"]), createVNode(unref(_sfc_main$5), {
7247
+ variant: props.variant === "destructive" ? "destructive" : "default",
7248
+ size: "sm",
7249
+ disabled: unref(loading),
7250
+ onClick: unref(handleConfirm)
7251
+ }, {
7252
+ default: withCtx(() => [unref(loading) ? (openBlock(), createElementBlock("svg", _hoisted_2$8, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }, null, -1)])])) : createCommentVNode("v-if", true), createTextVNode(" " + toDisplayString(props.confirmText), 1)]),
7253
+ _: 1
7254
+ }, 8, [
7255
+ "variant",
7256
+ "disabled",
7257
+ "onClick"
7258
+ ])])
7259
+ ]),
7260
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
7261
+ _: 3
7262
+ }, 16, ["open"])], 2112);
7263
+ };
7264
+ }
7265
+ });
7266
+ //#endregion
7267
+ //#region src/components/table-render/column-renders.ts
7268
+ /**
7269
+ * 两位补零
7270
+ * @param value - 数字(月/日/时/分/秒)
7271
+ * @returns 补零后的两位字符串
7272
+ */
7273
+ const pad = (value) => String(value).padStart(2, "0");
7274
+ /**
7275
+ * 迷你日期令牌格式化,不引入 date-fns;非法输入原样返回
7276
+ * @param input - 单元格原始值(Date 或可构造 Date 的字符串/数字)
7277
+ * @param pattern - 令牌模板(支持 yyyy/MM/dd/HH/mm/ss)
7278
+ * @returns 格式化后的文本;输入非法时原样返回
7279
+ */
7280
+ function formatDate(input, pattern) {
7281
+ const date = input instanceof Date ? input : new Date(input);
7282
+ if (Number.isNaN(date.getTime())) return input;
7283
+ const tokens = {
7284
+ yyyy: String(date.getFullYear()),
7285
+ MM: pad(date.getMonth() + 1),
7286
+ dd: pad(date.getDate()),
7287
+ HH: pad(date.getHours()),
7288
+ mm: pad(date.getMinutes()),
7289
+ ss: pad(date.getSeconds())
7290
+ };
7291
+ return pattern.replace(/yyyy|MM|dd|HH|mm|ss/g, (token) => tokens[token]);
7292
+ }
7293
+ const FIT_CLASS = {
7294
+ cover: "object-cover",
7295
+ contain: "object-contain",
7296
+ fill: "object-fill",
7297
+ none: "object-none",
7298
+ "scale-down": "object-scale-down"
7299
+ };
7300
+ const SHAPE_CLASS = {
7301
+ rounded: "rounded-md",
7302
+ square: "rounded-none",
7303
+ circle: "rounded-full"
7304
+ };
7305
+ /**
7306
+ * 单元格图片内部组件(不导出):error 计数状态机驱动 原图 → fallback → 占位盒。
7307
+ * errors 单调递增防循环切换;watch src 复位,防虚拟滚动/分页行复用串图。
7308
+ */
7309
+ const CellImage = defineComponent({
7310
+ name: "TuCellImage",
7311
+ props: {
7312
+ src: {
7313
+ type: String,
7314
+ required: true
7315
+ },
7316
+ alt: {
7317
+ type: String,
7318
+ default: ""
7319
+ },
7320
+ fallback: {
7321
+ type: String,
7322
+ default: void 0
7323
+ },
7324
+ size: {
7325
+ type: Number,
7326
+ default: 40
7327
+ },
7328
+ fit: {
7329
+ type: String,
7330
+ default: "cover"
7331
+ },
7332
+ shape: {
7333
+ type: String,
7334
+ default: "rounded"
7335
+ }
7336
+ },
7337
+ setup(props) {
7338
+ const errors = ref(0);
7339
+ watch(() => props.src, () => {
7340
+ errors.value = 0;
7341
+ });
7342
+ return () => {
7343
+ const sizeStyle = {
7344
+ width: `${props.size}px`,
7345
+ height: `${props.size}px`
7346
+ };
7347
+ const shapeClass = SHAPE_CLASS[props.shape];
7348
+ const currentSrc = errors.value === 0 ? props.src : errors.value === 1 ? props.fallback : void 0;
7349
+ if (!currentSrc) return h("div", {
7350
+ class: ["bg-muted text-muted-foreground flex items-center justify-center", shapeClass],
7351
+ style: sizeStyle,
7352
+ "aria-hidden": "true"
7353
+ }, [h("svg", {
7354
+ viewBox: "0 0 24 24",
7355
+ fill: "none",
7356
+ stroke: "currentColor",
7357
+ "stroke-width": "2",
7358
+ "stroke-linecap": "round",
7359
+ "stroke-linejoin": "round",
7360
+ class: "size-1/2",
7361
+ "aria-hidden": "true"
7362
+ }, [
7363
+ h("rect", {
7364
+ width: "18",
7365
+ height: "18",
7366
+ x: "3",
7367
+ y: "3",
7368
+ rx: "2",
7369
+ ry: "2"
7370
+ }),
7371
+ h("circle", {
7372
+ cx: "9",
7373
+ cy: "9",
7374
+ r: "2"
7375
+ }),
7376
+ h("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
7377
+ ])]);
7378
+ return h("img", {
7379
+ src: currentSrc,
7380
+ alt: props.alt,
7381
+ loading: "lazy",
7382
+ class: [
7383
+ "bg-muted",
7384
+ shapeClass,
7385
+ FIT_CLASS[props.fit]
7386
+ ],
7387
+ style: sizeStyle,
7388
+ onError: () => {
7389
+ errors.value++;
7390
+ }
7391
+ });
7392
+ };
7393
+ }
7394
+ });
7395
+ /**
7396
+ * 内置列渲染器工厂:dict/date/currency/serial/button/image。
7397
+ * 返回值直接填入 TableColumnOptions.render;column 参数用于读取字段值。
7398
+ * 与 FormRender widget 的 r.xxx() 范式共词根。
7399
+ * @returns 各内置渲染器集合(render/dict/date/currency/serial/button/image)
7400
+ */
7401
+ function columnRenders() {
7402
+ return {
7403
+ render: (fn) => fn,
7404
+ dict(mapping, options) {
7405
+ return (record, _index, column) => {
7406
+ const raw = record[column.key];
7407
+ const entry = mapping[raw];
7408
+ if (entry === void 0) return raw ?? "";
7409
+ const label = typeof entry === "string" ? entry : entry.label;
7410
+ const entryVariant = typeof entry === "object" ? entry.variant : void 0;
7411
+ if (entryVariant !== void 0 || options?.badge !== void 0) {
7412
+ const variant = entryVariant ?? (options?.badge === true ? void 0 : options?.badge);
7413
+ return h(_sfc_main$4, { variant }, () => label);
7414
+ }
7415
+ return label;
7416
+ };
7417
+ },
7418
+ date(pattern = "yyyy-MM-dd") {
7419
+ return (record, _index, column) => formatDate(record[column.key], pattern);
7420
+ },
7421
+ currency(currency = "CNY", locale = "zh-CN") {
7422
+ const format = new Intl.NumberFormat(locale, {
7423
+ style: "currency",
7424
+ currency
7425
+ });
7426
+ return (record, _index, column) => {
7427
+ const raw = record[column.key];
6696
7428
  const value = typeof raw === "string" ? Number(raw) : raw;
6697
7429
  if (typeof value !== "number" || Number.isNaN(value)) return raw;
6698
7430
  return format.format(value);
@@ -6704,16 +7436,42 @@ function columnRenders() {
6704
7436
  button(items) {
6705
7437
  return (record, index) => {
6706
7438
  if (items.length === 0) return "";
6707
- return h("div", { class: "flex items-center gap-1" }, items.map((item) => {
7439
+ return h("div", { class: "inline-flex items-center gap-1" }, items.map((item) => {
6708
7440
  const action = typeof item === "string" ? { text: item } : item;
6709
- return h(_sfc_main$5, {
7441
+ const buttonNode = h(_sfc_main$5, {
6710
7442
  size: "sm",
6711
7443
  variant: action.variant ?? "link",
6712
7444
  disabled: action.disabled?.(record, index),
6713
- onClick: () => action.onClick?.(record, index)
7445
+ onClick: action.confirm ? void 0 : () => action.onClick?.(record, index)
6714
7446
  }, () => typeof action.text === "function" ? action.text(record, index) : action.text);
7447
+ if (!action.confirm) return buttonNode;
7448
+ const confirm = typeof action.confirm === "string" ? { title: action.confirm } : action.confirm;
7449
+ const resolveText = (value) => typeof value === "function" ? value(record, index) : value;
7450
+ return h(_sfc_main$33, {
7451
+ title: resolveText(confirm.title),
7452
+ description: resolveText(confirm.description),
7453
+ confirmText: confirm.confirmText,
7454
+ cancelText: confirm.cancelText,
7455
+ variant: confirm.variant ?? (action.variant === "destructive" ? "destructive" : "default"),
7456
+ onConfirm: () => action.onClick?.(record, index)
7457
+ }, () => buttonNode);
6715
7458
  }));
6716
7459
  };
7460
+ },
7461
+ image(options) {
7462
+ return (record, index, column) => {
7463
+ const raw = record[column.key];
7464
+ if (typeof raw !== "string" || raw === "") return "";
7465
+ const resolveText = (value) => typeof value === "function" ? value(record, index) : value;
7466
+ return h(CellImage, {
7467
+ src: raw,
7468
+ alt: resolveText(options?.alt) ?? "",
7469
+ fallback: resolveText(options?.fallback),
7470
+ size: options?.size,
7471
+ fit: options?.fit,
7472
+ shape: options?.shape
7473
+ });
7474
+ };
6717
7475
  }
6718
7476
  };
6719
7477
  }
@@ -6835,14 +7593,53 @@ const _sfc_main$49 = /*@__PURE__*/ defineComponent({
6835
7593
  }
6836
7594
  });
6837
7595
  //#endregion
7596
+ //#region src/components/table-render/columns.ts
7597
+ /**
7598
+ * 列节点工具:分组判别与叶子扁平化(多级表头支撑)。
7599
+ *
7600
+ * 设计取向:叶子口径全局不变 —— 引擎(TanStack 列定义)、列显隐、sticky 偏移、
7601
+ * min-width 求和、体单元格矩阵全部继续消费「扁平叶子」,分组能力只叠加在
7602
+ * 表头渲染与列设置面板两处。故此处是唯一的结构归一入口。
7603
+ */
7604
+ /**
7605
+ * 判别节点是否为分组(含 children)。
7606
+ * @param node - 列节点(叶子或分组)
7607
+ * @returns 该节点是否为分组
7608
+ */
7609
+ function isColumnGroup(node) {
7610
+ return Array.isArray(node.children);
7611
+ }
7612
+ /**
7613
+ * 扁平化列节点树为叶子列数组(深度优先,保持声明顺序)。
7614
+ * @param nodes - 列节点树
7615
+ * @returns 深度优先展开的叶子列数组(下游全部消费此层)
7616
+ */
7617
+ function flattenColumns(nodes) {
7618
+ const leaves = [];
7619
+ const walk = (list) => {
7620
+ for (const node of list) if (isColumnGroup(node)) walk(node.children);
7621
+ else leaves.push(node);
7622
+ };
7623
+ walk(nodes);
7624
+ return leaves;
7625
+ }
7626
+ //#endregion
6838
7627
  //#region src/components/table-render/constants.ts
6839
7628
  /** 选择列在 sticky 映射中的哨兵键(选择列不在 columns 内,表头/表体单独渲染) */
6840
7629
  const SELECTION_CELL = "__selection__";
7630
+ /** 拖拽把手列在 sticky 映射中的哨兵键(同选择列:不在 columns 内,表头/表体单独渲染) */
7631
+ const DRAG_CELL = "__drag__";
6841
7632
  /** 布局容器与 TableRender 的跨包填充协议 key:provide(true) 声明容器内 TableRender 应填满、内部滚动、表头固定 */
6842
7633
  const PAGE_TABLE_FILL_KEY = "tu-design:page-table-fill";
6843
7634
  //#endregion
6844
7635
  //#region src/components/table-render/sticky.ts
6845
- /** sticky 定位样式;head 为 true 时 z-index 高于表体(表头压住表体 sticky) */
7636
+ /**
7637
+ * sticky 定位样式;head 为 true 时 z-index 高于表体(表头压住表体 sticky)
7638
+ * @param sticky - 列 key → sticky 信息的映射
7639
+ * @param key - 列 key
7640
+ * @param head - 是否为表头单元格(true 使用更高的 --z-sticky-head)
7641
+ * @returns inline style 对象;列非 sticky 时返回 undefined
7642
+ */
6846
7643
  function stickyStyle(sticky, key, head = false) {
6847
7644
  const info = sticky.get(key);
6848
7645
  if (!info) return void 0;
@@ -6852,7 +7649,12 @@ function stickyStyle(sticky, key, head = false) {
6852
7649
  zIndex: head ? "var(--z-sticky-head)" : "var(--z-sticky)"
6853
7650
  };
6854
7651
  }
6855
- /** sticky 底色(防滚动透出)与交界分隔边框 */
7652
+ /**
7653
+ * sticky 底色(防滚动透出)与交界分隔边框
7654
+ * @param sticky - 列 key → sticky 信息的映射
7655
+ * @param key - 列 key
7656
+ * @returns class 列表(未命中项为空串);列非 sticky 时返回 undefined
7657
+ */
6856
7658
  function stickyClass(sticky, key) {
6857
7659
  const info = sticky.get(key);
6858
7660
  if (!info) return void 0;
@@ -6863,15 +7665,36 @@ function stickyClass(sticky, key) {
6863
7665
  ];
6864
7666
  }
6865
7667
  //#endregion
7668
+ //#region src/components/icon-shared/GripIcon.vue
7669
+ const _sfc_main$54 = {};
7670
+ const _hoisted_1$9 = {
7671
+ viewBox: "0 0 24 24",
7672
+ fill: "none",
7673
+ stroke: "currentColor",
7674
+ "stroke-width": "2",
7675
+ "stroke-linecap": "round",
7676
+ "stroke-linejoin": "round",
7677
+ "aria-hidden": "true"
7678
+ };
7679
+ function _sfc_render(_ctx, _cache) {
7680
+ return openBlock(), createElementBlock("svg", _hoisted_1$9, [..._cache[0] || (_cache[0] = [createStaticVNode("<circle cx=\"9\" cy=\"12\" r=\"1\"></circle><circle cx=\"9\" cy=\"5\" r=\"1\"></circle><circle cx=\"9\" cy=\"19\" r=\"1\"></circle><circle cx=\"15\" cy=\"12\" r=\"1\"></circle><circle cx=\"15\" cy=\"5\" r=\"1\"></circle><circle cx=\"15\" cy=\"19\" r=\"1\"></circle>", 6)])]);
7681
+ }
7682
+ var GripIcon_default = /*#__PURE__*/ export_helper_default(_sfc_main$54, [["render", _sfc_render]]);
7683
+ //#endregion
6866
7684
  //#region src/components/table-render/TableBodyRow.vue
6867
- const _hoisted_1$9 = [
7685
+ const _hoisted_1$8 = [
6868
7686
  "checked",
6869
7687
  "disabled",
6870
7688
  "aria-label"
6871
7689
  ];
6872
- const _hoisted_2$8 = ["title", "onClick"];
6873
- const _hoisted_3$5 = ["aria-expanded", "aria-label"];
6874
- const _hoisted_4$3 = {
7690
+ const _hoisted_2$7 = [
7691
+ "disabled",
7692
+ "draggable",
7693
+ "aria-label"
7694
+ ];
7695
+ const _hoisted_3$5 = ["title", "onClick"];
7696
+ const _hoisted_4$3 = ["aria-expanded", "aria-label"];
7697
+ const _hoisted_5$2 = {
6875
7698
  key: 2,
6876
7699
  class: "min-w-0 truncate"
6877
7700
  };
@@ -6905,6 +7728,21 @@ const _sfc_main$53 = /*@__PURE__*/ defineComponent({
6905
7728
  treeIndent: {
6906
7729
  type: Number,
6907
7730
  default: void 0
7731
+ },
7732
+ /** 是否渲染拖拽把手列(draggable 启用且未被守卫降级) */
7733
+ dragColumn: {
7734
+ type: Boolean,
7735
+ default: false
7736
+ },
7737
+ /** 本行把手禁用(排序激活 / rowKey 缺失 / 行级谓词 false) */
7738
+ dragDisabled: {
7739
+ type: Boolean,
7740
+ default: false
7741
+ },
7742
+ /** 本行正在被拖拽(占位态:半透明 + 虚线描边,实时让位预览中即落点提示) */
7743
+ dragging: {
7744
+ type: Boolean,
7745
+ default: false
6908
7746
  }
6909
7747
  },
6910
7748
  emits: [
@@ -6912,7 +7750,11 @@ const _sfc_main$53 = /*@__PURE__*/ defineComponent({
6912
7750
  "row-click",
6913
7751
  "row-dblclick",
6914
7752
  "row-contextmenu",
6915
- "cell-click"
7753
+ "cell-click",
7754
+ "drag-start",
7755
+ "drag-over",
7756
+ "drop",
7757
+ "drag-end"
6916
7758
  ],
6917
7759
  setup(__props, { emit: __emit }) {
6918
7760
  const props = __props;
@@ -6921,8 +7763,13 @@ const _sfc_main$53 = /*@__PURE__*/ defineComponent({
6921
7763
  const value = line.cells[index];
6922
7764
  return isVNode(value) ? "" : String(value ?? "");
6923
7765
  }
6924
- /** ellipsis: "tooltip" 的单元格内容:默认插槽承载截断内容(触发元素本体,不额外包裹),content 显示完整文本。
6925
- * VNode(render 工厂)单元格经 cloneVNode 复制进触发位(VNode 不可二次挂载)。 */
7766
+ /**
7767
+ * ellipsis: "tooltip" 的单元格内容:默认插槽承载截断内容(触发元素本体,不额外包裹),content 显示完整文本。
7768
+ * VNode(render 工厂)单元格经 cloneVNode 复制进触发位(VNode 不可二次挂载)。
7769
+ * @param value - 单元格原始内容(VNode 或文本)
7770
+ * @param text - 用于 tooltip content 与纯文本兜底的完整文本
7771
+ * @returns 包裹 Tooltip 后的渲染结果
7772
+ */
6926
7773
  function tooltipCell(value, text) {
6927
7774
  const trigger = isVNode(value) ? cloneVNode(value) : h("span", { class: "block truncate" }, text);
6928
7775
  return h(_sfc_main$49, {
@@ -6932,15 +7779,17 @@ const _sfc_main$53 = /*@__PURE__*/ defineComponent({
6932
7779
  }
6933
7780
  return (_ctx, _cache) => {
6934
7781
  return openBlock(), createElementBlock("tr", {
6935
- class: "border-b transition-colors hover:bg-muted/50",
6936
- onClick: _cache[4] || (_cache[4] = ($event) => emit("row-click", $event)),
6937
- onDblclick: _cache[5] || (_cache[5] = ($event) => emit("row-dblclick", $event)),
6938
- onContextmenu: _cache[6] || (_cache[6] = ($event) => emit("row-contextmenu", $event))
7782
+ class: normalizeClass(["border-b transition-colors hover:bg-muted/50", { "opacity-50 [&>td]:outline-2 [&>td]:outline-dashed [&>td]:-outline-offset-2 [&>td]:outline-primary/40": props.dragging }]),
7783
+ onClick: _cache[7] || (_cache[7] = ($event) => emit("row-click", $event)),
7784
+ onDblclick: _cache[8] || (_cache[8] = ($event) => emit("row-dblclick", $event)),
7785
+ onContextmenu: _cache[9] || (_cache[9] = ($event) => emit("row-contextmenu", $event)),
7786
+ onDragover: _cache[10] || (_cache[10] = ($event) => emit("drag-over", $event)),
7787
+ onDrop: _cache[11] || (_cache[11] = ($event) => emit("drop", $event))
6939
7788
  }, [
6940
- createCommentVNode(" 选择单元格:阻断冒泡避免触发行 row-click(S5);radio 为原生控件 "),
7789
+ createCommentVNode(" 选择单元格:阻断冒泡避免触发行 row-click;radio 为原生控件 "),
6941
7790
  props.selection ? (openBlock(), createElementBlock("td", {
6942
7791
  key: 0,
6943
- class: normalizeClass(["w-12 p-2 align-middle", unref(stickyClass)(props.sticky, unref(SELECTION_CELL))]),
7792
+ class: normalizeClass(["w-12 p-2 text-center align-middle", unref(stickyClass)(props.sticky, unref(SELECTION_CELL))]),
6944
7793
  style: normalizeStyle(unref(stickyStyle)(props.sticky, unref(SELECTION_CELL), false)),
6945
7794
  onClick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"]))
6946
7795
  }, [props.selection === "radio" ? (openBlock(), createElementBlock("input", {
@@ -6951,7 +7800,7 @@ const _sfc_main$53 = /*@__PURE__*/ defineComponent({
6951
7800
  disabled: !props.line.canSelect,
6952
7801
  "aria-label": `选择第 ${props.line.index + 1} 行`,
6953
7802
  onClick: _cache[0] || (_cache[0] = ($event) => emit("select", !props.selected))
6954
- }, null, 8, _hoisted_1$9)) : (openBlock(), createBlock(unref(_sfc_main$9), {
7803
+ }, null, 8, _hoisted_1$8)) : (openBlock(), createBlock(unref(_sfc_main$9), {
6955
7804
  key: 1,
6956
7805
  checked: props.selected,
6957
7806
  disabled: !props.line.canSelect,
@@ -6962,12 +7811,28 @@ const _sfc_main$53 = /*@__PURE__*/ defineComponent({
6962
7811
  "disabled",
6963
7812
  "aria-label"
6964
7813
  ]))], 6)) : createCommentVNode("v-if", true),
7814
+ createCommentVNode(" 拖拽把手单元格:仅把手可起拖(draggable 在按钮上,整行不可拖);阻断冒泡避免触发行 row-click "),
7815
+ props.dragColumn ? (openBlock(), createElementBlock("td", {
7816
+ key: 1,
7817
+ class: normalizeClass(["p-1 text-center align-middle", unref(stickyClass)(props.sticky, unref(DRAG_CELL))]),
7818
+ style: normalizeStyle(unref(stickyStyle)(props.sticky, unref(DRAG_CELL), false)),
7819
+ onClick: _cache[5] || (_cache[5] = withModifiers(() => {}, ["stop"]))
7820
+ }, [createElementVNode("button", {
7821
+ type: "button",
7822
+ "data-drag-handle": "",
7823
+ class: "text-muted-foreground inline-flex size-6 cursor-grab items-center justify-center rounded-sm active:cursor-grabbing disabled:cursor-not-allowed disabled:opacity-50",
7824
+ disabled: props.dragDisabled,
7825
+ draggable: !props.dragDisabled,
7826
+ "aria-label": `拖拽排序第 ${props.line.index + 1} 行`,
7827
+ onDragstart: _cache[3] || (_cache[3] = ($event) => emit("drag-start", $event)),
7828
+ onDragend: _cache[4] || (_cache[4] = ($event) => emit("drag-end", $event))
7829
+ }, [createVNode(GripIcon_default, { class: "size-4" })], 40, _hoisted_2$7)], 6)) : createCommentVNode("v-if", true),
6965
7830
  (openBlock(true), createElementBlock(Fragment, null, renderList(props.line.cells, (value, index) => {
6966
7831
  return openBlock(), createElementBlock("td", {
6967
7832
  key: props.columns[index].key,
6968
7833
  class: normalizeClass(["p-2 align-middle", [unref(stickyClass)(props.sticky, props.columns[index].key), { truncate: props.columns[index].ellipsis === true }]]),
6969
7834
  title: props.columns[index].ellipsis === true ? cellText(props.line, index) : void 0,
6970
- style: normalizeStyle([{ textAlign: props.columns[index].align }, unref(stickyStyle)(props.sticky, props.columns[index].key, false)]),
7835
+ style: normalizeStyle([{ textAlign: props.columns[index].align ?? "center" }, unref(stickyStyle)(props.sticky, props.columns[index].key, false)]),
6971
7836
  onClick: ($event) => emit("cell-click", props.columns[index].key, $event)
6972
7837
  }, [createCommentVNode(" 首列(tree 启用时):depth 缩进 + 展开 caret(点击 stop 避免误触发行点击) "), props.treeIndent !== void 0 && index === 0 ? (openBlock(), createElementBlock("span", {
6973
7838
  key: 0,
@@ -6980,13 +7845,13 @@ const _sfc_main$53 = /*@__PURE__*/ defineComponent({
6980
7845
  class: "hover:bg-muted text-muted-foreground inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm",
6981
7846
  "aria-expanded": props.line.row.getIsExpanded(),
6982
7847
  "aria-label": props.line.row.getIsExpanded() ? "收起" : "展开",
6983
- onClick: _cache[3] || (_cache[3] = withModifiers(($event) => props.line.row.toggleExpanded(), ["stop"]))
6984
- }, [createVNode(ChevronIcon_default, { class: normalizeClass(["size-3.5 transition-transform", { "rotate-90": props.line.row.getIsExpanded() }]) }, null, 8, ["class"])], 8, _hoisted_3$5)) : createCommentVNode("v-if", true),
7848
+ onClick: _cache[6] || (_cache[6] = withModifiers(($event) => props.line.row.toggleExpanded(), ["stop"]))
7849
+ }, [createVNode(ChevronIcon_default, { class: normalizeClass(["size-3.5 transition-transform", { "rotate-90": props.line.row.getIsExpanded() }]) }, null, 8, ["class"])], 8, _hoisted_4$3)) : createCommentVNode("v-if", true),
6985
7850
  createCommentVNode(" VNode 必须走子节点渲染;文本插值会序列化 vnode 导致循环引用 "),
6986
- isVNode(value) ? (openBlock(), createBlock(resolveDynamicComponent(value), { key: 1 })) : (openBlock(), createElementBlock("span", _hoisted_4$3, toDisplayString(value), 1))
6987
- ], 4)) : props.columns[index].ellipsis === "tooltip" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" ellipsis: \"tooltip\":Tooltip 包装(VNode 经 cloneVNode 复制,避免二次挂载) "), (openBlock(), createBlock(resolveDynamicComponent(tooltipCell(value, cellText(props.line, index)))))], 2112)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [createCommentVNode(" VNode 必须走子节点渲染;文本插值会序列化 vnode 导致循环引用 "), isVNode(value) ? (openBlock(), createBlock(resolveDynamicComponent(value), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(value), 1)], 64))], 64))], 14, _hoisted_2$8);
7851
+ isVNode(value) ? (openBlock(), createBlock(resolveDynamicComponent(value), { key: 1 })) : (openBlock(), createElementBlock("span", _hoisted_5$2, toDisplayString(value), 1))
7852
+ ], 4)) : props.columns[index].ellipsis === "tooltip" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" ellipsis: \"tooltip\":Tooltip 包装(VNode 经 cloneVNode 复制,避免二次挂载) "), (openBlock(), createBlock(resolveDynamicComponent(tooltipCell(value, cellText(props.line, index)))))], 2112)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [createCommentVNode(" VNode 必须走子节点渲染;文本插值会序列化 vnode 导致循环引用 "), isVNode(value) ? (openBlock(), createBlock(resolveDynamicComponent(value), { key: 0 })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(value), 1)], 64))], 64))], 14, _hoisted_3$5);
6988
7853
  }), 128))
6989
- ], 32);
7854
+ ], 34);
6990
7855
  };
6991
7856
  }
6992
7857
  });
@@ -6998,11 +7863,18 @@ const DEFAULT_PAGE_SIZE_OPTS = [
6998
7863
  50,
6999
7864
  100
7000
7865
  ];
7001
- /** 数值配置防御:受控 getter(组件层)与数值配置(defineTable 层)同字段共存时只认数字 */
7866
+ /**
7867
+ * 数值配置防御:受控 getter(组件层)与数值配置(defineTable 层)同字段共存时只认数字
7868
+ * @param value - 待判定的配置值
7869
+ * @returns 值为数字时原样返回,否则返回 undefined
7870
+ */
7002
7871
  function numericOption(value) {
7003
7872
  return typeof value === "number" ? value : void 0;
7004
7873
  }
7005
- /** DEV 兜底提示:生产构建静默,只留可读的降级行为(R1–R7) */
7874
+ /**
7875
+ * DEV 兜底提示:生产构建静默,只留可读的降级行为
7876
+ * @param message - 提示文本
7877
+ */
7006
7878
  function warn(message) {
7007
7879
  if (import.meta.env.DEV) console.warn(`[tu-design] <TableRender> ${message}`);
7008
7880
  }
@@ -7011,9 +7883,13 @@ function warn(message) {
7011
7883
  *
7012
7884
  * 状态真相源是 TanStack 引擎(pageIndex 为 0-based),
7013
7885
  * `page`/`sort` 是对外的 1-based 只读投影,由 watch 同步。
7886
+ * @param options - 表格配置:列定义、数据源(静态 data 或服务端 onLoad)、分页排序、
7887
+ * 行选择、树形、列显隐、搜索表单等
7888
+ * @returns 表格渲染定义(含只读投影与实例动作),供 TableRender 组件消费
7014
7889
  */
7015
7890
  function useTableRender(options) {
7016
- const columns = options.columns;
7891
+ const columnTree = options.columns;
7892
+ const columns = flattenColumns(options.columns);
7017
7893
  const serverMode = typeof options.onLoad === "function";
7018
7894
  if (columns.length === 0) warn("columns 为空,表格将没有表头。");
7019
7895
  if (serverMode && options.data !== void 0) warn("onLoad 与 data 不能同时传入,已按 onLoad(服务端模式)处理。");
@@ -7030,7 +7906,10 @@ function useTableRender(options) {
7030
7906
  }
7031
7907
  const childrenKey = tree?.childrenKey ?? "children";
7032
7908
  let search;
7033
- /** search 唯一装配入口:静态模式 / 缺 form·items 时 DEV 警告并忽略 */
7909
+ /**
7910
+ * search 唯一装配入口:静态模式 / 缺 form·items 时 DEV 警告并忽略
7911
+ * @param next - 待装配的搜索表单定义,undefined 表示移除
7912
+ */
7034
7913
  function applySearch(next) {
7035
7914
  if (next === void 0) {
7036
7915
  search = void 0;
@@ -7049,7 +7928,10 @@ function useTableRender(options) {
7049
7928
  search = next;
7050
7929
  }
7051
7930
  applySearch(options.search);
7052
- /** 拆分式/组件级装配口:definition 未配置 search 时由 TableRender 回填 prop(对齐 setRowKey) */
7931
+ /**
7932
+ * 拆分式/组件级装配口:definition 未配置 search 时由 TableRender 回填 prop(对齐 setRowKey)
7933
+ * @param next - 待回填的搜索表单定义
7934
+ */
7053
7935
  function setSearch(next) {
7054
7936
  if (search || !next) return;
7055
7937
  applySearch(next);
@@ -7072,15 +7954,29 @@ function useTableRender(options) {
7072
7954
  const loading = ref(false);
7073
7955
  const error = ref(void 0);
7074
7956
  const rows = shallowRef([]);
7957
+ let draggableConfig;
7958
+ if (options.draggable !== void 0 && options.draggable !== false) {
7959
+ if (tree) warn("draggable 与 tree 不能同时启用,已忽略 draggable。");
7960
+ else if (options.virtual === true) warn("draggable 与 virtual 不能同时启用,已忽略 draggable。");
7961
+ else {
7962
+ const config = options.draggable === true ? {} : options.draggable;
7963
+ if (config.width !== void 0 && typeof config.width !== "number") {
7964
+ warn("draggable.width 必须是数字,已按默认 32 处理。");
7965
+ delete config.width;
7966
+ }
7967
+ draggableConfig = config;
7968
+ if (sort.value !== void 0) warn("draggable 与初始排序(defaultSort/受控 sort)同时配置,排序激活期间拖拽不可用。");
7969
+ }
7970
+ }
7075
7971
  const rawSelection = options.rowSelection;
7076
7972
  const selectionConfig = rawSelection === void 0 ? void 0 : typeof rawSelection === "string" ? { type: rawSelection } : rawSelection;
7077
7973
  const rowKey = ref(options.rowKey);
7078
7974
  const selectionEnabled = computed(() => selectionConfig !== void 0 && !!rowKey.value);
7079
7975
  const selectedKeys = ref(/* @__PURE__ */ new Set());
7080
7976
  const selectionRows = shallowRef([]);
7081
- /** key → 最近一次出现的行对象;跨页选中行由此返回快照(S6) */
7977
+ /** key → 最近一次出现的行对象;跨页选中行由此返回快照 */
7082
7978
  const selectionSnapshot = /* @__PURE__ */ new Map();
7083
- /** 选中但当前数据中不存在的 key(reserveOnPageChange 语义,S12) */
7979
+ /** 选中但当前数据中不存在的 key(reserveOnPageChange 语义) */
7084
7980
  const dirtyKeys = /* @__PURE__ */ new Set();
7085
7981
  /** 受控选择状态:单一真相源,onRowSelectionChange 只通知不落盘(避免 setRowSelection 回环) */
7086
7982
  const rowSelectionState = ref({});
@@ -7090,18 +7986,26 @@ function useTableRender(options) {
7090
7986
  selectedKeys.value = keys;
7091
7987
  selectionRows.value = [...keys].map((key) => selectionSnapshot.get(String(key)) ?? { [rowKey.value]: key });
7092
7988
  }
7093
- /** 选中集写入的唯一入口:赋受控 state + 重建对外投影 */
7989
+ /**
7990
+ * 选中集写入的唯一入口:赋受控 state + 重建对外投影
7991
+ * @param next - TanStack 行选择状态(row id → 是否选中)
7992
+ */
7094
7993
  function applyRowSelection(next) {
7095
7994
  rowSelectionState.value = next;
7096
7995
  selectionEmitSafe();
7097
7996
  }
7098
- /** 行主键 → TanStack row id;rowKey 缺失时退化为索引(仅非选择场景可达,S1) */
7997
+ /**
7998
+ * 行主键 → TanStack row id;rowKey 缺失时退化为索引(仅非选择场景可达)
7999
+ * @param record - 行记录
8000
+ * @param index - 行索引(rowKey 缺失时的退化 id 来源)
8001
+ * @returns 稳定的行标识字符串
8002
+ */
7099
8003
  function rowIdOf(record, index) {
7100
8004
  const key = rowKey.value;
7101
8005
  const value = key ? record[key] : void 0;
7102
8006
  return value === void 0 || value === null ? `index-${index}` : String(value);
7103
8007
  }
7104
- /** 数据窗口变化时刷新快照中已存在 key 的行对象(S6:后写覆盖) */
8008
+ /** 数据窗口变化时刷新快照中已存在 key 的行对象(后写覆盖) */
7105
8009
  function refreshSnapshot() {
7106
8010
  const key = rowKey.value;
7107
8011
  if (!key) return;
@@ -7191,8 +8095,10 @@ function useTableRender(options) {
7191
8095
  table.setPageSize(pageSize);
7192
8096
  table.setPageIndex(0);
7193
8097
  }
7194
- /** 排序应用的唯一管线:服务端模式归位第 1 页(R8)+ 投影落值 + TanStack setSorting。
7195
- * 受控 sort 的外部同步与此共用(直接 setSorting 会漏服务端重载) */
8098
+ /** 排序应用的唯一管线:服务端模式归位第 1 页+ 投影落值 + TanStack setSorting。
8099
+ * 受控 sort 的外部同步与此共用(直接 setSorting 会漏服务端重载)
8100
+ * @param next - 目标排序(key + direction),undefined 表示取消排序
8101
+ */
7196
8102
  function applySort(next) {
7197
8103
  if (serverMode && page.pageIndex !== 1) setPageIndex(1);
7198
8104
  sort.value = next;
@@ -7201,7 +8107,10 @@ function useTableRender(options) {
7201
8107
  desc: next.direction === "desc"
7202
8108
  }] : []);
7203
8109
  }
7204
- /** 排序三态:无 → asc → desc → 取消;非 sortable 列为空操作(R8) */
8110
+ /**
8111
+ * 排序三态:无 → asc → desc → 取消;非 sortable 列为空操作
8112
+ * @param key - 目标列 key
8113
+ */
7205
8114
  function toggleSort(key) {
7206
8115
  if (!columns.some((column) => column.key === key && column.sortable === true)) return;
7207
8116
  const current = sort.value;
@@ -7211,6 +8120,37 @@ function useTableRender(options) {
7211
8120
  direction
7212
8121
  } : void 0);
7213
8122
  }
8123
+ /**
8124
+ * 页内重排(drag-sort 唯一管线):from/to 为页内 0-based 索引。
8125
+ * 静态模式按对象身份定位全量位置后 splice(页内索引 → 全量映射不依赖裸索引 arithmetic,
8126
+ * 行对象与 rows.value 同引用);服务端模式 rows.value 即当前页数据,只算新序不落盘。
8127
+ * @param from - 源行页内索引
8128
+ * @param to - 目标行页内索引(拖拽落位行;源行移除后插入该原位)
8129
+ * @returns drag-sort 载荷;守卫不通过或索引无效时 undefined
8130
+ */
8131
+ function reorderRows(from, to) {
8132
+ if (!draggableConfig || sort.value !== void 0) return void 0;
8133
+ const pageRows = table.getRowModel().rows.map((row) => row.original);
8134
+ if (from === to || from < 0 || to < 0 || from >= pageRows.length || to >= pageRows.length) return;
8135
+ const record = pageRows[from];
8136
+ const next = [...pageRows];
8137
+ next.splice(from, 1);
8138
+ next.splice(to, 0, record);
8139
+ if (!serverMode) {
8140
+ const all = [...rows.value];
8141
+ const target = pageRows[to];
8142
+ all.splice(all.indexOf(record), 1);
8143
+ const targetIndex = all.indexOf(target);
8144
+ all.splice(from < to ? targetIndex + 1 : targetIndex, 0, record);
8145
+ rows.value = all;
8146
+ }
8147
+ return {
8148
+ from,
8149
+ to,
8150
+ record,
8151
+ rows: next
8152
+ };
8153
+ }
7214
8154
  let requestId = 0;
7215
8155
  async function load() {
7216
8156
  const id = ++requestId;
@@ -7274,7 +8214,11 @@ function useTableRender(options) {
7274
8214
  setSelection(next);
7275
8215
  }, { immediate: true });
7276
8216
  let emptyVisibleWarned = false;
7277
- /** 规范化:未知 key 静默忽略、按 columns 原序、空数组钳制为首列(R24,warn 一次) */
8217
+ /**
8218
+ * 规范化:未知 key 静默忽略、按 columns 原序、空数组钳制为首列(warn 一次)
8219
+ * @param keys - 目标可见列 key 列表(任意顺序,可含未知 key)
8220
+ * @returns 规范化后的可见列 key 列表(columns 原序)
8221
+ */
7278
8222
  function normalizeVisibleKeys(keys) {
7279
8223
  const known = columns.filter((column) => keys.includes(column.key)).map((column) => column.key);
7280
8224
  if (known.length > 0) return known;
@@ -7295,7 +8239,10 @@ function useTableRender(options) {
7295
8239
  return raw ? normalizeVisibleKeys(raw) : void 0;
7296
8240
  })();
7297
8241
  const visibleKeysInternal = ref(controlledVisibleKeys() ? normalizeVisibleKeys(controlledVisibleKeys()) : parsedDefaultVisibleKeys ?? columns.map((column) => column.key));
7298
- /** 列显隐动作(面板交互/程序化):规范化后更新统一投影 */
8242
+ /**
8243
+ * 列显隐动作(面板交互/程序化):规范化后更新统一投影
8244
+ * @param keys - 目标可见列 key 列表
8245
+ */
7299
8246
  function setVisibleKeys(keys) {
7300
8247
  visibleKeysInternal.value = normalizeVisibleKeys(keys);
7301
8248
  }
@@ -7318,7 +8265,10 @@ function useTableRender(options) {
7318
8265
  if (resetPage) setPageIndex(1);
7319
8266
  syncData();
7320
8267
  }
7321
- /** 程序化设置选中集;不存在的 key 保留进入 dirtyKeys(S12);不可选行被过滤(对齐 S5) */
8268
+ /**
8269
+ * 程序化设置选中集;不存在的 key 保留进入 dirtyKeys;不可选行被过滤
8270
+ * @param keys - 目标选中行的 key 列表(整体替换现有选中集)
8271
+ */
7322
8272
  function setSelection(keys) {
7323
8273
  const next = {};
7324
8274
  for (const key of keys) {
@@ -7344,7 +8294,10 @@ function useTableRender(options) {
7344
8294
  [key]: true
7345
8295
  });
7346
8296
  }
7347
- /** 拆分式装配口:TableRender setup 时回传组件 rowKey(S1) */
8297
+ /**
8298
+ * 拆分式装配口:TableRender setup 时回传组件 rowKey
8299
+ * @param key - 行主键字段名
8300
+ */
7348
8301
  function setRowKey(key) {
7349
8302
  if (rowKey.value === key) return;
7350
8303
  rowKey.value = key;
@@ -7356,6 +8309,7 @@ function useTableRender(options) {
7356
8309
  });
7357
8310
  return {
7358
8311
  columns,
8312
+ columnTree,
7359
8313
  table,
7360
8314
  page: readonly(page),
7361
8315
  sort: readonly(sort),
@@ -7390,6 +8344,8 @@ function useTableRender(options) {
7390
8344
  virtual: options.virtual,
7391
8345
  height: options.height,
7392
8346
  tree,
8347
+ draggable: draggableConfig,
8348
+ reorderRows,
7393
8349
  visibleKeys: readonly(visibleKeysInternal),
7394
8350
  setVisibleKeys,
7395
8351
  defaultVisibleKeys: parsedDefaultVisibleKeys,
@@ -7398,11 +8354,113 @@ function useTableRender(options) {
7398
8354
  };
7399
8355
  }
7400
8356
  //#endregion
8357
+ //#region src/components/table-render/useRowDrag.ts
8358
+ /**
8359
+ * 行拖拽状态机(原生 HTML5 DnD):内部状态是唯一事实源,不读 dataTransfer
8360
+ * (happy-dom 的 DragEvent 是 Event 别名、无 dataTransfer,测试直接派发普通 Event)。
8361
+ * dataTransfer 写入仅作真实浏览器兼容(Firefox 需 setData 才起拖、setDragImage 整行快照),
8362
+ * 全部 optional 守卫。
8363
+ *
8364
+ * 落位语义由组件层预览序决定(实时让位):本状态机只负责起拖/接收/落位/清理。
8365
+ * @returns 拖拽状态(draggingKey)与事件动作(start/over/drop/end)
8366
+ */
8367
+ function useRowDrag() {
8368
+ const draggingKey = ref(void 0);
8369
+ /**
8370
+ * 起拖(把手 dragstart)
8371
+ * @param key - 源行主键
8372
+ * @param event - 原生 dragstart 事件
8373
+ * @param image - 拖拽快照(离屏克隆元素 + 相对原行的抓取偏移);提供时幽灵影为整行截图
8374
+ */
8375
+ function start(key, event, image) {
8376
+ draggingKey.value = key;
8377
+ if (event.dataTransfer) {
8378
+ event.dataTransfer.effectAllowed = "move";
8379
+ event.dataTransfer.setData("text/plain", key);
8380
+ if (image) event.dataTransfer.setDragImage(image.el, image.offsetX, image.offsetY);
8381
+ }
8382
+ }
8383
+ /**
8384
+ * 悬停(行 dragover):持续 preventDefault 才允许 drop——**含被拖行占位自身**
8385
+ * (实时让位后光标恰停在占位上,不 preventDefault 则真实浏览器拒绝 drop)。
8386
+ * @param key - 悬停行主键
8387
+ * @param event - 原生 dragover 事件
8388
+ * @returns 是否接收让位(同源行返回 false:允许 drop 但不移动预览序)
8389
+ */
8390
+ function over(key, event) {
8391
+ if (!draggingKey.value) return false;
8392
+ event.preventDefault();
8393
+ if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
8394
+ return key !== draggingKey.value;
8395
+ }
8396
+ /**
8397
+ * 落位(行 drop):仅成功落位返回结果(取消路径走 end,不返回)。
8398
+ * 实时让位后被拖行占位恰在光标下,落在自身占位是有效提交(toKey = fromKey),
8399
+ * 最终序由组件层预览序决定;无预览时同源落位由组件层 from === to 守卫为空操作。
8400
+ * @param key - 落位行主键
8401
+ * @param event - 原生 drop 事件
8402
+ * @returns 源/目标行主键;无起拖状态时 undefined
8403
+ */
8404
+ function drop(key, event) {
8405
+ const fromKey = draggingKey.value;
8406
+ draggingKey.value = void 0;
8407
+ if (!fromKey) return void 0;
8408
+ event.preventDefault();
8409
+ return {
8410
+ fromKey,
8411
+ toKey: key
8412
+ };
8413
+ }
8414
+ /** 拖拽结束(把手 dragend,含取消路径):仅清理状态,不产生落位结果 */
8415
+ function end() {
8416
+ draggingKey.value = void 0;
8417
+ }
8418
+ return {
8419
+ draggingKey,
8420
+ start,
8421
+ over,
8422
+ drop,
8423
+ end
8424
+ };
8425
+ }
8426
+ /**
8427
+ * 整行拖拽快照:深克隆 tr 包进离屏临时 table(border-separate + 完整边框)。
8428
+ * border-collapse 下边框几何归属 table 而非 tr,直接截 tr 会缺上/左边框;
8429
+ * 克隆逐格复制实测宽度保证列宽一致。调用方负责在 drop/dragend 时 remove()。
8430
+ * @param tr - 源行元素
8431
+ * @returns 离屏快照 table(已挂 body,fixed 定位移出视口)
8432
+ */
8433
+ function createRowSnapshot(tr) {
8434
+ const clone = tr.cloneNode(true);
8435
+ const srcCells = tr.querySelectorAll("td");
8436
+ const cloneCells = clone.querySelectorAll("td");
8437
+ srcCells.forEach((td, index) => {
8438
+ const cell = cloneCells[index];
8439
+ if (cell) cell.style.width = `${td.offsetWidth}px`;
8440
+ });
8441
+ const tbody = document.createElement("tbody");
8442
+ tbody.appendChild(clone);
8443
+ const table = document.createElement("table");
8444
+ table.className = "border-separate border-spacing-0 border border-border bg-background";
8445
+ table.style.position = "fixed";
8446
+ table.style.left = "-9999px";
8447
+ table.style.top = "0";
8448
+ table.style.tableLayout = "fixed";
8449
+ table.style.width = `${tr.offsetWidth}px`;
8450
+ table.appendChild(tbody);
8451
+ document.body.appendChild(table);
8452
+ return table;
8453
+ }
8454
+ //#endregion
7401
8455
  //#region src/components/table-render/TableRender.vue
7402
- const _hoisted_1$8 = { class: "flex items-center justify-end gap-3 px-3 py-2" };
7403
- const _hoisted_2$7 = ["disabled"];
8456
+ const _hoisted_1$7 = { class: "flex items-center justify-end gap-3 px-3 py-2" };
8457
+ const _hoisted_2$6 = ["disabled"];
7404
8458
  const _hoisted_3$4 = { class: "max-h-64 overflow-y-auto py-1" };
7405
- const _hoisted_4$2 = ["data-column-key", "onClick"];
8459
+ const _hoisted_4$2 = [
8460
+ "data-column-key",
8461
+ "data-column-group",
8462
+ "onClick"
8463
+ ];
7406
8464
  const _hoisted_5$1 = { class: "min-w-0 flex-1 truncate" };
7407
8465
  const _hoisted_6$1 = {
7408
8466
  key: 0,
@@ -7416,23 +8474,40 @@ const _hoisted_6$1 = {
7416
8474
  class: "text-muted-foreground size-3 shrink-0",
7417
8475
  "aria-hidden": "true"
7418
8476
  };
7419
- const _hoisted_7$1 = ["aria-sort"];
7420
- const _hoisted_8 = ["onClick"];
7421
- const _hoisted_9 = {
8477
+ const _hoisted_7$1 = ["rowspan"];
8478
+ const _hoisted_8 = ["rowspan"];
8479
+ const _hoisted_9 = [
8480
+ "scope",
8481
+ "colspan",
8482
+ "rowspan",
8483
+ "aria-sort"
8484
+ ];
8485
+ const _hoisted_10 = ["onClick"];
8486
+ const _hoisted_11 = {
7422
8487
  "aria-hidden": "true",
7423
8488
  class: "text-xs"
7424
8489
  };
7425
- const _hoisted_10 = { class: "[&_tr:last-child]:border-0" };
7426
- const _hoisted_11 = { "data-error": "" };
7427
- const _hoisted_12 = ["colspan"];
7428
- const _hoisted_13 = { class: "flex flex-col items-center gap-3" };
8490
+ const _hoisted_12 = { class: "[&_tr:last-child]:border-0" };
8491
+ const _hoisted_13 = { "data-error": "" };
7429
8492
  const _hoisted_14 = ["colspan"];
7430
- const _hoisted_15 = ["colspan"];
7431
- const _hoisted_16 = {
8493
+ const _hoisted_15 = { class: "flex flex-col items-center gap-3" };
8494
+ const _hoisted_16 = ["colspan"];
8495
+ const _hoisted_17 = ["colspan"];
8496
+ const _hoisted_18 = {
7432
8497
  key: 4,
7433
8498
  "data-empty": ""
7434
8499
  };
7435
- const _hoisted_17 = ["colspan"];
8500
+ const _hoisted_19 = ["colspan"];
8501
+ /** 面板行派生:以原始列节点树(非可见剪枝)为准,保证隐藏后仍可恢复 */
8502
+ const HEADER_ROW_FALLBACK = 40;
8503
+ /**
8504
+ * 测量所有表头行高度并派生行顶偏移与 thead 总高(唯一测量源)。
8505
+ *
8506
+ * 两处口径有意区分:
8507
+ * - `rowTop`(多行 sticky 逐行 top)用兜底 h-10(40px)——测量不可用时避免表头行重叠;
8508
+ * - `theadOffset`(virtual 的 scrollMargin)用**实测原值**,与既有行为一致
8509
+ * (happy-dom 无布局 → 0;真实浏览器 → 真实高度)。
8510
+ */
7436
8511
  const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7437
8512
  __name: "TableRender",
7438
8513
  props: {
@@ -7443,7 +8518,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7443
8518
  type: String,
7444
8519
  required: true
7445
8520
  },
7446
- /** 拆分式:与 definition 二选一,definition 优先 */
8521
+ /** 拆分式:与 definition 二选一,definition 优先(支持分组列节点) */
7447
8522
  columns: { type: Array },
7448
8523
  onLoad: { type: Function },
7449
8524
  data: { type: Array },
@@ -7451,7 +8526,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7451
8526
  type: Boolean,
7452
8527
  default: void 0
7453
8528
  },
7454
- /** 每页条数 / 受控每页条数(D11):传入即受控(pageIndex 未受控时 R9 归位内部处理并通知) */
8529
+ /** 每页条数 / 受控每页条数:传入即受控(pageIndex 未受控时页码归位内部处理并通知) */
7455
8530
  pageSize: { type: Number },
7456
8531
  pageSizeOpts: { type: Array },
7457
8532
  loading: {
@@ -7475,6 +8550,11 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7475
8550
  height: { type: [Number, String] },
7476
8551
  /** 树形数据(子行展开/收起);拆分式直接传,聚合式请在 defineTable 配置 */
7477
8552
  tree: { type: Object },
8553
+ /** 行拖拽排序(仅拆分式生效;聚合式请在 defineTable 配置):true 或对象配置;与 tree/virtual 互斥 */
8554
+ draggable: {
8555
+ type: [Boolean, Object],
8556
+ default: void 0
8557
+ },
7478
8558
  /** 受控页码(1-based):传入即受控,缺省非受控;内部翻页经 update:page-index 通知 */
7479
8559
  pageIndex: { type: Number },
7480
8560
  /** 受控排序:传入即受控;内部/外部变化均经 sort-change 通知 */
@@ -7483,19 +8563,19 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7483
8563
  selectedKeys: { type: Array },
7484
8564
  /** 受控可见列 key(columns 原序子集):传入即受控;内部显隐经 update:visible-keys 通知 */
7485
8565
  visibleKeys: { type: Array },
7486
- /** 拆分式默认可见列集;与聚合式 columnVisibility.defaultVisibleKeys 同传时 DEV 警告(R26,definition 优先) */
8566
+ /** 拆分式默认可见列集;与聚合式 columnVisibility.defaultVisibleKeys 同传时 DEV 警告(definition 优先) */
7487
8567
  defaultVisibleKeys: { type: Array },
7488
8568
  /** 列设置触发器/面板开关(默认 true);false 时不渲染 UI,受控 API 不受影响 */
7489
8569
  columnSettings: {
7490
8570
  type: Boolean,
7491
8571
  default: void 0
7492
8572
  },
7493
- /** 搜索区渲染开关(R27):false 关闭内置搜索区(组合式外置 FormRender);数据链路不变 */
8573
+ /** 搜索区渲染开关:false 关闭内置搜索区(组合式外置 FormRender);数据链路不变 */
7494
8574
  showSearch: {
7495
8575
  type: Boolean,
7496
8576
  default: void 0
7497
8577
  },
7498
- /** 分页条渲染开关(R28):false 关闭内置分页条(组合式外置 TablePagination);缺省模式 R13 不变 */
8578
+ /** 分页条渲染开关:false 关闭内置分页条(组合式外置 TablePagination);缺省模式单页自隐藏不变 */
7499
8579
  showPagination: {
7500
8580
  type: Boolean,
7501
8581
  default: void 0
@@ -7523,14 +8603,15 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7523
8603
  "reset",
7524
8604
  "load-error",
7525
8605
  "update:visible-keys",
7526
- "column-visibility-change"
8606
+ "column-visibility-change",
8607
+ "drag-sort"
7527
8608
  ],
7528
8609
  setup(__props, { expose: __expose, emit: __emit }) {
7529
8610
  const props = __props;
7530
8611
  const pageTableFill = inject(PAGE_TABLE_FILL_KEY, false);
7531
8612
  const fill = props.fillHeight ?? pageTableFill;
7532
8613
  const emit = __emit;
7533
- /** 加载态骨架行数(R14) */
8614
+ /** 加载态骨架行数 */
7534
8615
  const SKELETON_ROWS = [
7535
8616
  1,
7536
8617
  2,
@@ -7542,6 +8623,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7542
8623
  const RENDERS = columnRenders();
7543
8624
  if (props.definition && props.columns && import.meta.env.DEV) console.warn("[tu-design] <TableRender> definition 与 columns 同时传入,已按 definition 渲染。");
7544
8625
  if (props.definition && props.rowSelection && import.meta.env.DEV) console.warn("[tu-design] <TableRender> 聚合式下 rowSelection 请在 defineTable 配置,组件 prop 已忽略。");
8626
+ if (props.definition && props.draggable !== void 0 && import.meta.env.DEV) console.warn("[tu-design] <TableRender> 聚合式下 draggable 请在 defineTable 配置,组件 prop 已忽略。");
7545
8627
  const instance = props.definition ?? useTableRender({
7546
8628
  columns: props.columns ?? [],
7547
8629
  onLoad: props.onLoad,
@@ -7554,6 +8636,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7554
8636
  virtual: props.virtual,
7555
8637
  height: props.height,
7556
8638
  tree: props.tree,
8639
+ draggable: props.draggable,
7557
8640
  pageIndex: () => props.pageIndex,
7558
8641
  pageSize: () => props.pageSize,
7559
8642
  sort: () => props.sort,
@@ -7573,7 +8656,10 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7573
8656
  watch(() => props.visibleKeys, (next) => {
7574
8657
  if (props.definition && next !== void 0) instance.setVisibleKeys(next);
7575
8658
  }, { immediate: true });
7576
- /** 当前搜索表单值快照(浅拷贝;无 search 时为空对象) */
8659
+ /**
8660
+ * 当前搜索表单值快照(浅拷贝;无 search 时为空对象)
8661
+ * @returns 表单值快照
8662
+ */
7577
8663
  function searchValues() {
7578
8664
  return search ? { ...search.form.state.values } : {};
7579
8665
  }
@@ -7589,12 +8675,12 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7589
8675
  }
7590
8676
  const columns = computed(() => instance.columns);
7591
8677
  const rows = computed(() => instance.table.getRowModel().rows);
7592
- /** 内部加载态 ∪ 外部受控加载态(R14) */
8678
+ /** 内部加载态 ∪ 外部受控加载态 */
7593
8679
  const loading = computed(() => props.loading === true || instance.loading.value);
7594
8680
  const showPagination = computed(() => Math.ceil(instance.page.total / instance.page.pageSize) > 1);
7595
- /** 内置分页条开关(R28):showPagination=false 关闭;R13 仅作用于缺省模式 */
8681
+ /** 内置分页条开关:showPagination=false 关闭;单页自隐藏仅作用于缺省模式 */
7596
8682
  const showPaginationBar = computed(() => showPagination.value && props.showPagination !== false);
7597
- /** 内置搜索区开关(R27):配置了 search 且未被 showSearch=false 关闭;列设置触发器不受影响 */
8683
+ /** 内置搜索区开关:配置了 search 且未被 showSearch=false 关闭;列设置触发器不受影响 */
7598
8684
  const showSearchArea = computed(() => search !== void 0 && props.showSearch !== false);
7599
8685
  const loadError = computed(() => instance.error.value);
7600
8686
  const showError = computed(() => !loading.value && loadError.value !== void 0);
@@ -7608,14 +8694,81 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7608
8694
  const selectedKeys = instance.selectedKeys;
7609
8695
  const hasSelection = computed(() => selection.value.enabled);
7610
8696
  const visibleKeySet = computed(() => new Set(instance.visibleKeys.value));
7611
- /** 可见业务列(columns 原序子集):header/body/骨架/colspan/sticky 全部基于此渲染(R23/R25) */
8697
+ /** 可见业务列(columns 原序子集):header/body/骨架/colspan/sticky 全部基于此渲染 */
7612
8698
  const visibleColumns = computed(() => columns.value.filter((column) => visibleKeySet.value.has(column.key)));
8699
+ const columnsTree = computed(() => instance.columnTree ?? columns.value);
8700
+ /** 可见表头树节点:按 visibleKeySet 剪枝后的结构(空分组已被剔除) */
8701
+ function buildVisibleHeaderTree(nodes, parentPath) {
8702
+ const views = [];
8703
+ nodes.forEach((node, index) => {
8704
+ const path = parentPath === "" ? `${index}` : `${parentPath}-${index}`;
8705
+ if (isColumnGroup(node)) {
8706
+ const children = buildVisibleHeaderTree(node.children, path);
8707
+ if (children.length > 0) views.push({
8708
+ node,
8709
+ isGroup: true,
8710
+ path,
8711
+ children
8712
+ });
8713
+ } else if (visibleKeySet.value.has(node.key)) views.push({
8714
+ node,
8715
+ isGroup: false,
8716
+ path,
8717
+ children: []
8718
+ });
8719
+ });
8720
+ return views;
8721
+ }
8722
+ /** 唯一派生源:可见表头树(maxDepth 与表头矩阵同源于此,杜绝口径漂移) */
8723
+ const visibleHeaderTree = computed(() => buildVisibleHeaderTree(columnsTree.value, ""));
8724
+ /** 表头深度(可见树):无分组时为 1 */
8725
+ const maxDepth = computed(() => {
8726
+ const depthOf = (view) => view.children.length > 0 ? 1 + Math.max(...view.children.map(depthOf)) : 1;
8727
+ return visibleHeaderTree.value.length > 0 ? Math.max(...visibleHeaderTree.value.map(depthOf)) : 1;
8728
+ });
8729
+ /** 表头单元格:分组跨列、叶子下沉贴底 */
8730
+ const headerRows = computed(() => {
8731
+ const rows = Array.from({ length: maxDepth.value }, () => []);
8732
+ const collectLeaves = (view) => view.isGroup ? view.children.flatMap(collectLeaves) : [view.node.key];
8733
+ const walk = (views, depth) => {
8734
+ for (const view of views) {
8735
+ const leafKeys = collectLeaves(view);
8736
+ if (view.isGroup) rows[depth].push({
8737
+ node: view.node,
8738
+ key: `g:${view.path}`,
8739
+ path: view.path,
8740
+ depth,
8741
+ colSpan: leafKeys.length,
8742
+ rowSpan: 1,
8743
+ isGroup: true,
8744
+ leafKeys
8745
+ });
8746
+ else rows[depth].push({
8747
+ node: view.node,
8748
+ key: view.node.key,
8749
+ path: view.path,
8750
+ depth,
8751
+ colSpan: 1,
8752
+ rowSpan: maxDepth.value - depth,
8753
+ isGroup: false,
8754
+ leafKeys
8755
+ });
8756
+ walk(view.children, depth + 1);
8757
+ }
8758
+ };
8759
+ walk(visibleHeaderTree.value, 0);
8760
+ return rows;
8761
+ });
7613
8762
  /** 列设置触发器/面板开关(默认 true);false 时不渲染 UI,受控 API 不受影响 */
7614
8763
  const showColumnSettings = computed(() => props.columnSettings ?? true);
7615
8764
  function isColumnVisible(key) {
7616
8765
  return visibleKeySet.value.has(key);
7617
8766
  }
7618
- /** 最少一列(R20):唯一可见列不可隐藏 */
8767
+ /**
8768
+ * 最少一列:唯一可见列不可隐藏
8769
+ * @param key - 列 key
8770
+ * @returns 是否允许隐藏该列
8771
+ */
7619
8772
  function canHideColumn(key) {
7620
8773
  return !(instance.visibleKeys.value.length <= 1 && visibleKeySet.value.has(key));
7621
8774
  }
@@ -7623,26 +8776,97 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7623
8776
  if (!canHideColumn(key)) return;
7624
8777
  instance.setVisibleKeys(isColumnVisible(key) ? instance.visibleKeys.value.filter((k) => k !== key) : [...instance.visibleKeys.value, key]);
7625
8778
  }
7626
- const allColumnsVisible = computed(() => columns.value.length > 0 && visibleColumns.value.length === columns.value.length);
7627
- function selectAllColumns() {
7628
- if (allColumnsVisible.value) return;
7629
- instance.setVisibleKeys(columns.value.map((column) => column.key));
8779
+ const allColumnsVisible = computed(() => columns.value.length > 0 && visibleColumns.value.length === columns.value.length);
8780
+ function selectAllColumns() {
8781
+ if (allColumnsVisible.value) return;
8782
+ instance.setVisibleKeys(columns.value.map((column) => column.key));
8783
+ }
8784
+ function resetColumns() {
8785
+ instance.setVisibleKeys(instance.defaultVisibleKeys ?? columns.value.map((column) => column.key));
8786
+ }
8787
+ /** 面板行(全树扁平化,避免模板递归):分组行为父级三态,叶子行为勾选项 */
8788
+ const panelRows = computed(() => {
8789
+ const rows = [];
8790
+ const collectLeaves = (node) => isColumnGroup(node) ? node.children.flatMap(collectLeaves) : [node.key];
8791
+ const walk = (nodes, depth, parentPath) => {
8792
+ nodes.forEach((node, index) => {
8793
+ const path = parentPath === "" ? `${index}` : `${parentPath}-${index}`;
8794
+ const isGroup = isColumnGroup(node);
8795
+ rows.push({
8796
+ node,
8797
+ depth,
8798
+ isGroup,
8799
+ leafKeys: collectLeaves(node),
8800
+ path,
8801
+ key: isGroup ? `g:${path}` : node.key
8802
+ });
8803
+ if (isGroup) walk(node.children, depth + 1, path);
8804
+ });
8805
+ };
8806
+ walk(columnsTree.value, 0, "");
8807
+ return rows;
8808
+ });
8809
+ /**
8810
+ * 分组勾选三态:全部可见 = true,部分可见 = "indeterminate",全隐 = false
8811
+ * @param row - 面板分组行
8812
+ * @returns 该分组的三态勾选值
8813
+ */
8814
+ function groupCheckedState(row) {
8815
+ const visibleCount = row.leafKeys.filter((key) => visibleKeySet.value.has(key)).length;
8816
+ if (visibleCount === 0) return false;
8817
+ if (visibleCount === row.leafKeys.length) return true;
8818
+ return "indeterminate";
8819
+ }
8820
+ /**
8821
+ * 分组批量显隐(最少一列恒按叶子口径):
8822
+ * 隐藏整组会导致 0 列可见时,保留该组最后一枚可见叶子(父级呈 indeterminate)。
8823
+ * @param row - 面板分组行
8824
+ */
8825
+ function toggleGroupVisible(row) {
8826
+ const leafSet = new Set(row.leafKeys);
8827
+ if (!row.leafKeys.every((key) => visibleKeySet.value.has(key))) {
8828
+ instance.setVisibleKeys(columns.value.map((column) => column.key).filter((key) => visibleKeySet.value.has(key) || leafSet.has(key)));
8829
+ return;
8830
+ }
8831
+ const remaining = instance.visibleKeys.value.filter((key) => !leafSet.has(key));
8832
+ if (remaining.length === 0) {
8833
+ instance.setVisibleKeys([row.leafKeys[row.leafKeys.length - 1]]);
8834
+ return;
8835
+ }
8836
+ instance.setVisibleKeys(remaining);
7630
8837
  }
7631
- function resetColumns() {
7632
- instance.setVisibleKeys(instance.defaultVisibleKeys ?? columns.value.map((column) => column.key));
8838
+ /**
8839
+ * 面板行点击(分组批量显隐 / 叶子单列切换)
8840
+ * @param row - 面板行(分组或叶子)
8841
+ */
8842
+ function onPanelRowClick(row) {
8843
+ if (row.isGroup) toggleGroupVisible(row);
8844
+ else toggleColumnVisible(row.key);
7633
8845
  }
7634
8846
  watch(instance.visibleKeys, (keys) => {
7635
8847
  emit("update:visible-keys", [...keys]);
7636
8848
  emit("column-visibility-change", [...keys]);
7637
8849
  });
7638
- /** 总列数 = 可见业务列 + 选择列(空态 colspan 与骨架行,S8/R23) */
7639
- const columnCount = computed(() => visibleColumns.value.length + (hasSelection.value ? 1 : 0));
8850
+ /** 总列数 = 可见业务列 + 选择列(空态 colspan 与骨架行) */
8851
+ const columnCount = computed(() => visibleColumns.value.length + (hasSelection.value ? 1 : 0) + (dragEnabled.value ? 1 : 0));
7640
8852
  for (const column of columns.value) if (column.fixed !== void 0 && typeof column.width !== "number") console.warn(`[tu-design] <TableRender> fixed 列 "${column.key}" 需要数字 width,已忽略 fixed。`);
7641
- if (columns.value.length >= 10 && !columns.value.some((c) => typeof c.width === "number")) console.warn(`[tu-design] <TableRender> ${columns.value.length} 列均无数字 width,窄容器下不会出现横向滚动(R32);宽表请为列声明数字 width(px)。`);
8853
+ if (import.meta.env.DEV) {
8854
+ const validateNodes = (nodes, depth) => {
8855
+ for (const node of nodes) if (isColumnGroup(node)) {
8856
+ if ("key" in node && node.key !== void 0) console.warn("[tu-design] <TableRender> 分组节点不应配置 key(分组不是数据列),已忽略。");
8857
+ if (node.sortable !== void 0) console.warn(`[tu-design] <TableRender> 分组「${node.title}」不支持 sortable(仅叶子列可排序),已忽略。`);
8858
+ if (node.fixed !== void 0) console.warn(`[tu-design] <TableRender> 分组「${node.title}」不支持 fixed(请配置到叶子列),已忽略。`);
8859
+ if (node.children.length === 0) console.warn(`[tu-design] <TableRender> 分组「${node.title}」children 为空,将被忽略。`);
8860
+ validateNodes(node.children, depth + 1);
8861
+ } else if ("children" in node && node.children !== void 0) console.warn(`[tu-design] <TableRender> 叶子列 "${node.key}" 不应配置 children,已按叶子渲染。`);
8862
+ };
8863
+ validateNodes(columnsTree.value, 0);
8864
+ }
8865
+ if (columns.value.length >= 10 && !columns.value.some((c) => typeof c.width === "number")) console.warn(`[tu-design] <TableRender> ${columns.value.length} 列均无数字 width,窄容器下不会出现横向滚动;宽表请为列声明数字 width(px)。`);
7642
8866
  /** sticky 单元格映射(纯渲染层 computed,不进 TanStack pinning state):
7643
8867
  * 选择列视作最左 fixed 列参与累计(offset 0);fixed-left 按列序累加,
7644
8868
  * fixed-right 从最右列反向累计。edge = 该 sticky 组朝滚动方向的交界列(加分隔边框)。
7645
- * 全部基于**可见集**(R23):sticky 组因隐藏变空则无该组输出(不输出边框)。
8869
+ * 全部基于**可见集**:sticky 组因隐藏变空则无该组输出(不输出边框)。
7646
8870
  */
7647
8871
  const stickyOf = computed(() => {
7648
8872
  const map = /* @__PURE__ */ new Map();
@@ -7659,10 +8883,18 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7659
8883
  map.set(SELECTION_CELL, {
7660
8884
  side: "left",
7661
8885
  offset: 0,
7662
- edge: lefts.length === 0
8886
+ edge: lefts.length === 0 && !dragEnabled.value
7663
8887
  });
7664
8888
  acc = selection.value.width;
7665
8889
  }
8890
+ if (dragEnabled.value) {
8891
+ map.set(DRAG_CELL, {
8892
+ side: "left",
8893
+ offset: acc,
8894
+ edge: lefts.length === 0
8895
+ });
8896
+ acc += dragWidth;
8897
+ }
7666
8898
  lefts.forEach((left, index) => {
7667
8899
  map.set(left.key, {
7668
8900
  side: "left",
@@ -7687,21 +8919,92 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7687
8919
  let sum = 0;
7688
8920
  for (const column of visibleColumns.value) if (typeof column.width === "number" && column.width > 0) sum += column.width;
7689
8921
  if (hasSelection.value && selection.value.width > 0) sum += selection.value.width;
8922
+ if (dragEnabled.value && dragWidth > 0) sum += dragWidth;
7690
8923
  return sum;
7691
8924
  });
7692
- /** 列宽 inline style 值(R33):数字补 px 单位——Vue :style 不自动加单位,
7693
- * 裸数字会被浏览器当非法 CSS 值丢弃,列宽即失效;字符串视为已带单位原样输出。 */
8925
+ /** 列宽 inline style 值:数字补 px 单位——Vue :style 不自动加单位,
8926
+ * 裸数字会被浏览器当非法 CSS 值丢弃,列宽即失效;字符串视为已带单位原样输出。
8927
+ * @param width - 列宽配置
8928
+ * @returns 可直接用于 :style 的 CSS 宽度值;未配置返回 undefined
8929
+ */
7694
8930
  function widthOf(width) {
7695
8931
  return typeof width === "number" ? `${width}px` : width;
7696
8932
  }
7697
- /** 表头全选三态(S10):本页可选行与选中集求交派生(TanStack getter 追踪不稳,自算) */
8933
+ /** 混合固定组警告去重(同名分组仅警告一次) */
8934
+ const warnedMixedFixedGroups = /* @__PURE__ */ new Set();
8935
+ /**
8936
+ * 分组单元格的 sticky 样式:子树可见叶子同侧且连续固定时整格 sticky,
8937
+ * 偏移取首个可见叶子;混合侧 → 返回 undefined(降级普通格)并 DEV 警告一次。
8938
+ * @param cell - 表头单元格(分组)
8939
+ * @returns 分组单元格的 sticky inline style;不适用时返回 undefined
8940
+ */
8941
+ function groupStickyStyle(cell) {
8942
+ const sides = new Set(cell.leafKeys.map((key) => columns.value.find((column) => column.key === key)?.fixed).filter((side) => side !== void 0));
8943
+ if (sides.size > 1) {
8944
+ if (!warnedMixedFixedGroups.has(cell.key)) {
8945
+ warnedMixedFixedGroups.add(cell.key);
8946
+ if (import.meta.env.DEV) console.warn(`[tu-design] <TableRender> 分组「${cell.node.title}」内固定方向混合,已降级为普通表头格。`);
8947
+ }
8948
+ return;
8949
+ }
8950
+ if (sides.size === 0) return void 0;
8951
+ if (cell.leafKeys.filter((key) => {
8952
+ const column = columns.value.find((c) => c.key === key);
8953
+ return column?.fixed !== void 0 && typeof column.width === "number";
8954
+ }).length !== cell.leafKeys.length) return void 0;
8955
+ const side = [...sides][0];
8956
+ const first = stickyOf.value.get(cell.leafKeys[0]);
8957
+ if (!first) return void 0;
8958
+ return {
8959
+ position: "sticky",
8960
+ [side]: `${first.offset}px`,
8961
+ zIndex: "var(--z-sticky-head)"
8962
+ };
8963
+ }
8964
+ /**
8965
+ * 表头行的行级样式:sticky 模式下逐行累积 top 偏移(多行表头),避免顶边重叠。
8966
+ * @param rowIndex - 表头行下标
8967
+ * @returns 行级 inline style;非 sticky 模式返回 undefined
8968
+ */
8969
+ function headerRowStyle(rowIndex) {
8970
+ if (!theadSticky) return void 0;
8971
+ return { top: `${rowTop.value[rowIndex] ?? rowIndex * HEADER_ROW_FALLBACK}px` };
8972
+ }
8973
+ /**
8974
+ * 表头单元格的视觉规约:分组格与其后单元格之间加竖向分隔线。
8975
+ *
8976
+ * 横向底边线沿用既有机制(非 sticky 走 thead 行级 `[&_tr]:border-b`;
8977
+ * sticky 走 `theadThClass` 的 `border-b`),此处**不重复绘制**;
8978
+ * 单级表头(无分组)直接返回空,保证扁平列 DOM 零变化。
8979
+ * @param cell - 表头单元格
8980
+ * @param isLastInRow - 是否为本行最后一个单元格
8981
+ * @returns class 列表
8982
+ */
8983
+ function headerCellClass(cell, isLastInRow) {
8984
+ if (maxDepth.value === 1) return [];
8985
+ return cell.isGroup && !isLastInRow ? ["border-r border-border"] : [];
8986
+ }
8987
+ /**
8988
+ * 分组单元格水平对齐(分组无 align 以外的能力)
8989
+ * @param cell - 表头单元格
8990
+ * @returns 对齐值,默认居中
8991
+ */
8992
+ function headerCellAlign(cell) {
8993
+ return cell.isGroup ? cell.node.align ?? "center" : cell.node.align ?? "center";
8994
+ }
8995
+ /** 分组无需排序能力标记(sortable 仅叶子生效,对分组 sortable 警告) */
8996
+ /** 表头全选三态:本页可选行与选中集求交派生(TanStack getter 追踪不稳,自算) */
7698
8997
  const selectableKeys = computed(() => rows.value.filter((row) => row.getCanSelect()).map((row) => rowKeyOf(row.original, row.index)));
7699
8998
  const headerChecked = computed(() => hasSelection.value && selection.value.type === "checkbox" && selectableKeys.value.length > 0 && selectableKeys.value.every((key) => selectedKeys.value.has(key)));
7700
8999
  const headerIndeterminate = computed(() => hasSelection.value && !headerChecked.value && selectableKeys.value.some((key) => selectedKeys.value.has(key)));
7701
9000
  function onHeaderSelect(checked) {
7702
9001
  instance.table.toggleAllPageRowsSelected(checked);
7703
9002
  }
7704
- /** 行选择控件切换;radio 不可取消由引擎 S4 守卫,不选中态点击传 checked=true */
9003
+ /**
9004
+ * 行选择控件切换;radio 不可取消由引擎守卫,不选中态点击传 checked=true
9005
+ * @param line - 行数据(含行 key)
9006
+ * @param checked - 目标选中态
9007
+ */
7705
9008
  function onRowSelect(line, checked) {
7706
9009
  instance.toggleRowSelected(line.key, checked);
7707
9010
  }
@@ -7709,7 +9012,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7709
9012
  emit("selection-change", [...selection.value.value]);
7710
9013
  emit("update:selected-keys", [...keys]);
7711
9014
  });
7712
- /** 行 → 单元格值矩阵:render > formatter > record[key](R17) */
9015
+ /** 行 → 单元格值矩阵:render > formatter > record[key] */
7713
9016
  const body = computed(() => {
7714
9017
  const renderFns = new Map(columns.value.filter((c) => c.render).map((c) => [c, c.render(RENDERS)]));
7715
9018
  return rows.value.map((row) => ({
@@ -7718,7 +9021,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7718
9021
  key: rowKeyOf(row.original, row.index),
7719
9022
  index: row.index,
7720
9023
  record: row.original,
7721
- /** 行级可选过滤(S5):selectable 谓词交由引擎 enableRowSelection 判定 */
9024
+ /** 行级可选过滤:selectable 谓词交由引擎 enableRowSelection 判定 */
7722
9025
  canSelect: row.getCanSelect(),
7723
9026
  cells: visibleColumns.value.map((column) => {
7724
9027
  const render = renderFns.get(column);
@@ -7731,7 +9034,12 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7731
9034
  const tree = instance.tree;
7732
9035
  const treeIndent = tree?.indentSize ?? 16;
7733
9036
  let missingRowKeyWarned = false;
7734
- /** 行主键:rowKey 字段缺失时以行索引兜底(R3) */
9037
+ /**
9038
+ * 行主键:rowKey 字段缺失时以行索引兜底
9039
+ * @param record - 行记录
9040
+ * @param index - 行索引(兜底来源)
9041
+ * @returns 稳定的行主键字符串
9042
+ */
7735
9043
  function rowKeyOf(record, index) {
7736
9044
  const value = record[props.rowKey];
7737
9045
  if (value === void 0 || value === null) {
@@ -7747,6 +9055,109 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7747
9055
  const heightRaw = instance.height ?? props.height;
7748
9056
  if (virtualRaw === true && heightRaw === void 0 && !fill) console.warn("[tu-design] <TableRender> virtual 需要配置 height,已降级普通渲染。");
7749
9057
  const virtualEnabled = virtualRaw === true && (heightRaw !== void 0 || fill);
9058
+ const dragConfig = instance.draggable;
9059
+ const dragEnabled = computed(() => dragConfig !== void 0 && !virtualEnabled);
9060
+ const dragWidth = dragConfig?.width ?? 32;
9061
+ const drag = useRowDrag();
9062
+ const dragKeysValid = computed(() => !dragEnabled.value || body.value.every((line) => line.record[props.rowKey] != null));
9063
+ let dragRowKeyWarned = false;
9064
+ watch(dragKeysValid, (valid) => {
9065
+ if (!valid && !dragRowKeyWarned && import.meta.env.DEV) {
9066
+ dragRowKeyWarned = true;
9067
+ console.warn(`[tu-design] <TableRender> 部分记录缺少 rowKey 字段 "${props.rowKey}",已禁用行拖拽排序。`);
9068
+ }
9069
+ }, { immediate: true });
9070
+ /**
9071
+ * 本行把手禁用判定:排序激活(动态守卫,取消排序恢复)/ rowKey 缺失 / 行级谓词 false
9072
+ * @param line - 行数据
9073
+ * @returns 是否禁用本行把手
9074
+ */
9075
+ function rowDragDisabled(line) {
9076
+ if (instance.sort.value !== void 0 || !dragKeysValid.value) return true;
9077
+ return dragConfig?.draggable ? !dragConfig.draggable(line.record) : false;
9078
+ }
9079
+ const previewKeys = ref(void 0);
9080
+ /** 显示序:拖拽中按预览序重排(失效 key 过滤、新增行追加,防中途外部 data 变更);平时即引擎序 */
9081
+ const displayBody = computed(() => {
9082
+ const keys = previewKeys.value;
9083
+ if (!keys) return body.value;
9084
+ const byKey = new Map(body.value.map((line) => [line.key, line]));
9085
+ const ordered = [];
9086
+ for (const key of keys) {
9087
+ const line = byKey.get(key);
9088
+ if (line) {
9089
+ ordered.push(line);
9090
+ byKey.delete(key);
9091
+ }
9092
+ }
9093
+ return ordered.concat([...byKey.values()]);
9094
+ });
9095
+ /** 离屏整行快照(仅真实浏览器 dataTransfer 存在时创建);drop/dragend 时移除 */
9096
+ let dragSnapshot;
9097
+ function removeDragSnapshot() {
9098
+ dragSnapshot?.remove();
9099
+ dragSnapshot = void 0;
9100
+ }
9101
+ /**
9102
+ * 起拖(把手 dragstart):禁用行不接收;离屏克隆整行作为拖拽快照(幽灵影 = 带边框整行截图)
9103
+ * @param line - 源行数据
9104
+ * @param event - 原生 dragstart 事件
9105
+ */
9106
+ function onRowDragStart(line, event) {
9107
+ if (rowDragDisabled(line)) return;
9108
+ const tr = event.target?.closest?.("tr");
9109
+ let image;
9110
+ if (event.dataTransfer && tr) {
9111
+ const rect = tr.getBoundingClientRect();
9112
+ dragSnapshot = createRowSnapshot(tr);
9113
+ image = {
9114
+ el: dragSnapshot,
9115
+ offsetX: event.clientX - rect.left,
9116
+ offsetY: event.clientY - rect.top
9117
+ };
9118
+ }
9119
+ drag.start(line.key, event, image);
9120
+ }
9121
+ /**
9122
+ * 悬停让位:把被拖行移到悬停行在当前预览序中的位置(仅被拖行移动)
9123
+ * @param line - 悬停行数据
9124
+ * @param event - 原生 dragover 事件
9125
+ */
9126
+ function onRowDragOver(line, event) {
9127
+ if (!drag.over(line.key, event)) return;
9128
+ const dragging = drag.draggingKey.value;
9129
+ const keys = [...previewKeys.value ?? body.value.map((item) => item.key)];
9130
+ const fromIndex = keys.indexOf(dragging);
9131
+ const toIndex = keys.indexOf(line.key);
9132
+ if (fromIndex < 0 || toIndex < 0 || fromIndex === toIndex) return;
9133
+ keys.splice(fromIndex, 1);
9134
+ keys.splice(toIndex, 0, dragging);
9135
+ previewKeys.value = keys;
9136
+ }
9137
+ /**
9138
+ * 成功落位:提交预览序。多跳预览的复合结果 ≡ 单次「源行原位移 → 最终预览位」,
9139
+ * 故 from = 原 body 索引、to = 预览序中被拖行最终索引,直接复用引擎 reorderRows。
9140
+ * @param line - 落位行数据
9141
+ * @param event - 原生 drop 事件
9142
+ */
9143
+ function onRowDrop(line, event) {
9144
+ const preview = previewKeys.value;
9145
+ const result = drag.drop(line.key, event);
9146
+ previewKeys.value = void 0;
9147
+ removeDragSnapshot();
9148
+ if (!result) return;
9149
+ const from = body.value.findIndex((item) => item.key === result.fromKey);
9150
+ const to = preview ? preview.indexOf(result.fromKey) : body.value.findIndex((item) => item.key === result.toKey);
9151
+ if (from < 0 || to < 0) return;
9152
+ const payload = instance.reorderRows(from, to);
9153
+ if (payload) emit("drag-sort", payload);
9154
+ }
9155
+ /** 拖拽结束(含取消路径):清理状态 + 预览序弹回引擎原序 + 移除离屏快照 */
9156
+ function onRowDragEnd() {
9157
+ drag.end();
9158
+ previewKeys.value = void 0;
9159
+ removeDragSnapshot();
9160
+ }
7750
9161
  const scrollHeight = computed(() => typeof heightRaw === "number" ? `${heightRaw}px` : heightRaw);
7751
9162
  /** 表头 sticky 仅在组件内存在真实纵向滚动盒时生效(fill / virtual),普通模式不挂载,行为不变 */
7752
9163
  const theadSticky = fill || virtualEnabled;
@@ -7770,6 +9181,17 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7770
9181
  const theadEl = ref(null);
7771
9182
  /** 滚动容器内 thead 占据的前缀高度(scrollMargin);表头内容静态,挂载后测量一次 */
7772
9183
  const theadOffset = ref(0);
9184
+ /** 表头行元素(模板 ref 收集,逐行求高度) */
9185
+ const headerRowEls = ref([]);
9186
+ /** 各行顶部偏移(前缀和):多行 sticky 表头逐行钉住,避免顶边重叠 */
9187
+ const rowTop = ref([]);
9188
+ /** 行高兜底:表头行 class 为 h-10(2.5rem = 40px);happy-dom 下 offsetHeight 恒 0 */
9189
+ function measureHeaderRows() {
9190
+ const raw = headerRowEls.value.map((el) => el?.offsetHeight ?? 0);
9191
+ const heights = raw.map((height) => height || HEADER_ROW_FALLBACK);
9192
+ rowTop.value = heights.map((_, index) => heights.slice(0, index).reduce((a, h) => a + h, 0));
9193
+ if (virtualEnabled) theadOffset.value = raw.reduce((a, h) => a + h, 0);
9194
+ }
7773
9195
  const virtualizerRef = virtualEnabled ? useVirtualizer(computed(() => ({
7774
9196
  count: rows.value.length,
7775
9197
  getScrollElement: () => scrollEl.value,
@@ -7778,9 +9200,8 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7778
9200
  getItemKey: (index) => rowKeyOf(rows.value[index], index),
7779
9201
  scrollMargin: theadOffset.value
7780
9202
  }))) : null;
7781
- onMounted(() => {
7782
- if (virtualEnabled) theadOffset.value = theadEl.value?.offsetHeight ?? 0;
7783
- });
9203
+ onMounted(measureHeaderRows);
9204
+ watch(headerRows, () => void nextTick(measureHeaderRows), { flush: "post" });
7784
9205
  const virtualRows = computed(() => virtualizerRef ? virtualizerRef.value.getVirtualItems() : []);
7785
9206
  const virtualTotal = computed(() => virtualizerRef ? virtualizerRef.value.getTotalSize() : 0);
7786
9207
  /** 窗口行 + 对应全量行数据(cells 矩阵已由 body computed 缓存,虚拟化只裁剪 DOM 节点) */
@@ -7794,12 +9215,18 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7794
9215
  return items.length === 0 ? 0 : Math.max(0, virtualTotal.value - items[items.length - 1].end);
7795
9216
  });
7796
9217
  /** 行高动态测量:measureElement 读 data-index 把实测高度写回(行内容高度可变,不假设固定行高)。
7797
- * 行组件为函数 ref,拿到的是组件实例,需经 $el 取真实 tr。 */
9218
+ * 行组件为函数 ref,拿到的是组件实例,需经 $el 取真实 tr。
9219
+ * @param node - 函数 ref 收到的行元素或组件实例
9220
+ */
7798
9221
  function measureRow(node) {
7799
9222
  const el = node instanceof Element ? node : node?.$el;
7800
9223
  if (el instanceof Element) virtualizerRef?.value.measureElement(el);
7801
9224
  }
7802
- /** aria-sort 仅在该列当前被排序时标注(R16) */
9225
+ /**
9226
+ * aria-sort 仅在该列当前被排序时标注
9227
+ * @param column - 列配置
9228
+ * @returns 当前排序方向对应的 aria-sort 值;未排序返回 undefined
9229
+ */
7803
9230
  function ariaSort(column) {
7804
9231
  if (instance.sort.value?.key !== column.key) return void 0;
7805
9232
  return instance.sort.value.direction === "asc" ? "ascending" : "descending";
@@ -7868,7 +9295,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7868
9295
  });
7869
9296
  return (_ctx, _cache) => {
7870
9297
  return openBlock(), createElementBlock("div", { class: normalizeClass(unref(cn)("w-full", unref(fill) && "flex h-full min-h-0 flex-col", _ctx.$attrs.class)) }, [
7871
- createCommentVNode(" 搜索区 + 列设置触发器:同行右对齐(items-end);无搜索时触发器位于表格上方(R27:showSearch=false 关闭搜索区) "),
9298
+ createCommentVNode(" 搜索区 + 列设置触发器:同行右对齐(items-end);无搜索时触发器位于表格上方(showSearch=false 关闭搜索区) "),
7872
9299
  showSearchArea.value || showColumnSettings.value ? (openBlock(), createElementBlock("div", {
7873
9300
  key: 0,
7874
9301
  class: normalizeClass(unref(cn)("mb-2 flex items-end justify-between gap-2", unref(fill) && "shrink-0"))
@@ -7881,46 +9308,48 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7881
9308
  onSearch,
7882
9309
  onReset
7883
9310
  }, null, 8, ["definition", "searchable"])) : createCommentVNode("v-if", true),
7884
- createCommentVNode(" 列设置:Popover 面板(R20 最少一列 / R21 重置 / R22 不含选择列);\n 触发钮 Tooltip 手动受控开合(Tooltip 与 Popover 触发器嵌套会吞点击,故并列渲染、不走 hover 自动触发) "),
9311
+ createCommentVNode(" 列设置:Popover 面板(最少一列 / 重置 / 不含选择列);\n 触发钮 Tooltip 手动受控开合(Tooltip 与 Popover 触发器嵌套会吞点击,故并列渲染、不走 hover 自动触发) "),
7885
9312
  showColumnSettings.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
7886
9313
  createVNode(unref(_sfc_main$34), {
7887
9314
  align: "end",
7888
9315
  "content-class": "w-56 p-0"
7889
9316
  }, {
7890
9317
  content: withCtx(() => [
7891
- createElementVNode("div", _hoisted_1$8, [createElementVNode("button", {
9318
+ createElementVNode("div", _hoisted_1$7, [createElementVNode("button", {
7892
9319
  type: "button",
7893
9320
  class: "text-muted-foreground hover:text-foreground cursor-pointer text-xs disabled:cursor-not-allowed disabled:opacity-50",
7894
9321
  disabled: allColumnsVisible.value,
7895
9322
  onClick: selectAllColumns
7896
- }, " 全选 ", 8, _hoisted_2$7), createElementVNode("button", {
9323
+ }, " 全选 ", 8, _hoisted_2$6), createElementVNode("button", {
7897
9324
  type: "button",
7898
9325
  class: "text-muted-foreground hover:text-foreground cursor-pointer text-xs",
7899
9326
  onClick: resetColumns
7900
9327
  }, " 重置 ")]),
7901
9328
  createVNode(unref(_sfc_main$38)),
7902
- createElementVNode("div", _hoisted_3$4, [(openBlock(true), createElementBlock(Fragment, null, renderList(columns.value, (column) => {
9329
+ createElementVNode("div", _hoisted_3$4, [(openBlock(true), createElementBlock(Fragment, null, renderList(panelRows.value, (row) => {
7903
9330
  return openBlock(), createElementBlock("div", {
7904
- key: column.key,
9331
+ key: row.key,
7905
9332
  "data-column-item": "",
7906
- "data-column-key": column.key,
9333
+ "data-column-key": row.isGroup ? void 0 : row.key,
9334
+ "data-column-group": row.isGroup ? row.path : void 0,
7907
9335
  class: "hover:bg-accent/50 flex h-8 cursor-pointer items-center gap-2 px-3",
7908
- onClick: ($event) => toggleColumnVisible(column.key)
9336
+ style: normalizeStyle({ paddingLeft: `${12 + row.depth * 12}px` }),
9337
+ onClick: ($event) => onPanelRowClick(row)
7909
9338
  }, [
7910
9339
  createVNode(unref(_sfc_main$9), {
7911
- checked: isColumnVisible(column.key),
7912
- disabled: !canHideColumn(column.key),
7913
- "onUpdate:checked": ($event) => toggleColumnVisible(column.key),
9340
+ checked: row.isGroup ? groupCheckedState(row) : isColumnVisible(row.key),
9341
+ disabled: row.isGroup ? false : !canHideColumn(row.key),
9342
+ "onUpdate:checked": ($event) => onPanelRowClick(row),
7914
9343
  onClick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"]))
7915
9344
  }, null, 8, [
7916
9345
  "checked",
7917
9346
  "disabled",
7918
9347
  "onUpdate:checked"
7919
9348
  ]),
7920
- createElementVNode("span", _hoisted_5$1, toDisplayString(column.title), 1),
7921
- createCommentVNode(" 有效 fixed 列(数字 width)标识 "),
7922
- column.fixed !== void 0 && typeof column.width === "number" ? (openBlock(), createElementBlock("svg", _hoisted_6$1, [..._cache[4] || (_cache[4] = [createElementVNode("path", { d: "M12 17v5" }, null, -1), createElementVNode("path", { d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1z" }, null, -1)])])) : createCommentVNode("v-if", true)
7923
- ], 8, _hoisted_4$2);
9349
+ createElementVNode("span", _hoisted_5$1, toDisplayString(row.node.title), 1),
9350
+ createCommentVNode(" 有效 fixed 列(数字 width)标识:仅叶子 "),
9351
+ !row.isGroup && row.node.fixed !== void 0 && typeof row.node.width === "number" ? (openBlock(), createElementBlock("svg", _hoisted_6$1, [..._cache[6] || (_cache[6] = [createElementVNode("path", { d: "M12 17v5" }, null, -1), createElementVNode("path", { d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1z" }, null, -1)])])) : createCommentVNode("v-if", true)
9352
+ ], 12, _hoisted_4$2);
7924
9353
  }), 128))])
7925
9354
  ]),
7926
9355
  default: withCtx(() => [createVNode(unref(_sfc_main$5), {
@@ -7931,7 +9360,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7931
9360
  onPointerenter: _cache[0] || (_cache[0] = ($event) => settingsTipOpen.value = true),
7932
9361
  onPointerleave: _cache[1] || (_cache[1] = ($event) => settingsTipOpen.value = false)
7933
9362
  }, {
7934
- default: withCtx(() => [createCommentVNode(" lucide Settings2(内联 SVG,跟随项目图标现状) "), _cache[3] || (_cache[3] = createElementVNode("svg", {
9363
+ default: withCtx(() => [createCommentVNode(" lucide Settings2(内联 SVG,跟随项目图标现状) "), _cache[5] || (_cache[5] = createElementVNode("svg", {
7935
9364
  xmlns: "http://www.w3.org/2000/svg",
7936
9365
  viewBox: "0 0 24 24",
7937
9366
  fill: "none",
@@ -7979,67 +9408,97 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
7979
9408
  ref_key: "theadEl",
7980
9409
  ref: theadEl,
7981
9410
  class: normalizeClass(unref(theadSticky) ? void 0 : "[&_tr]:border-b")
7982
- }, [createElementVNode("tr", null, [
7983
- createCommentVNode(" 选择列:checkbox 型表头为本页全选三态(S3/S10);radio 型占位;视作最左固定列 "),
7984
- hasSelection.value ? (openBlock(), createElementBlock("th", {
7985
- key: 0,
7986
- scope: "col",
7987
- class: normalizeClass(["h-10 w-12 px-2 align-middle font-medium text-muted-foreground", [unref(stickyClass)(stickyOf.value, unref(SELECTION_CELL)), unref(theadThClass)]]),
7988
- style: normalizeStyle([{ width: `${selection.value.width}px` }, unref(stickyStyle)(stickyOf.value, unref(SELECTION_CELL), true)])
7989
- }, [selection.value.type === "checkbox" ? (openBlock(), createBlock(unref(_sfc_main$9), {
7990
- key: 0,
7991
- checked: headerIndeterminate.value ? "indeterminate" : headerChecked.value,
7992
- "aria-label": "全选本页",
7993
- "onUpdate:checked": onHeaderSelect
7994
- }, null, 8, ["checked"])) : createCommentVNode("v-if", true)], 6)) : createCommentVNode("v-if", true),
7995
- (openBlock(true), createElementBlock(Fragment, null, renderList(visibleColumns.value, (column) => {
7996
- return openBlock(), createElementBlock("th", {
7997
- key: column.key,
9411
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(headerRows.value, (cells, rowIndex) => {
9412
+ return openBlock(), createElementBlock("tr", {
9413
+ key: rowIndex,
9414
+ ref_for: true,
9415
+ ref: (el) => headerRowEls.value[rowIndex] = el,
9416
+ style: normalizeStyle(headerRowStyle(rowIndex))
9417
+ }, [
9418
+ createCommentVNode(" 选择列:checkbox 型表头为本页全选三态;radio 型占位;视作最左固定列 "),
9419
+ hasSelection.value && rowIndex === 0 ? (openBlock(), createElementBlock("th", {
9420
+ key: 0,
7998
9421
  scope: "col",
7999
- class: normalizeClass(["h-10 px-2 align-middle font-medium text-muted-foreground", [unref(stickyClass)(stickyOf.value, column.key), unref(theadThClass)]]),
8000
- style: normalizeStyle([{
8001
- width: widthOf(column.width),
8002
- textAlign: column.align
8003
- }, unref(stickyStyle)(stickyOf.value, column.key, true)]),
8004
- "aria-sort": ariaSort(column)
8005
- }, [column.sortable ? (openBlock(), createElementBlock("button", {
9422
+ rowspan: headerRows.value.length,
9423
+ class: normalizeClass(["h-10 w-12 px-2 text-center align-middle font-medium text-muted-foreground", [unref(stickyClass)(stickyOf.value, unref(SELECTION_CELL)), unref(theadThClass)]]),
9424
+ style: normalizeStyle([{ width: `${selection.value.width}px` }, unref(stickyStyle)(stickyOf.value, unref(SELECTION_CELL), true)])
9425
+ }, [selection.value.type === "checkbox" ? (openBlock(), createBlock(unref(_sfc_main$9), {
8006
9426
  key: 0,
8007
- type: "button",
8008
- class: "inline-flex items-center gap-1 hover:text-foreground",
8009
- onClick: ($event) => onSort(column.key)
8010
- }, [createTextVNode(toDisplayString(column.title) + " ", 1), createElementVNode("span", _hoisted_9, toDisplayString(sortMark(column)), 1)], 8, _hoisted_8)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(column.title), 1)], 64))], 14, _hoisted_7$1);
8011
- }), 128))
8012
- ])], 2), createElementVNode("tbody", _hoisted_10, [
8013
- createCommentVNode(" 加载态:固定 5 行骨架(R14);选择列一并占位(S8);骨架不虚拟化;loading 判定优先 "),
9427
+ checked: headerIndeterminate.value ? "indeterminate" : headerChecked.value,
9428
+ "aria-label": "全选本页",
9429
+ "onUpdate:checked": onHeaderSelect
9430
+ }, null, 8, ["checked"])) : createCommentVNode("v-if", true)], 14, _hoisted_7$1)) : createCommentVNode("v-if", true),
9431
+ createCommentVNode(" 拖拽把手列表头:占位(对齐 radio 选择列范式);视作最左固定列(紧随选择列) "),
9432
+ dragEnabled.value && rowIndex === 0 ? (openBlock(), createElementBlock("th", {
9433
+ key: 1,
9434
+ scope: "col",
9435
+ rowspan: headerRows.value.length,
9436
+ class: normalizeClass(["h-10 px-1 text-center align-middle font-medium text-muted-foreground", [unref(stickyClass)(stickyOf.value, unref(DRAG_CELL)), unref(theadThClass)]]),
9437
+ style: normalizeStyle([{ width: `${unref(dragWidth)}px` }, unref(stickyStyle)(stickyOf.value, unref(DRAG_CELL), true)])
9438
+ }, [..._cache[7] || (_cache[7] = [createElementVNode("span", { class: "sr-only" }, "拖拽排序", -1)])], 14, _hoisted_8)) : createCommentVNode("v-if", true),
9439
+ (openBlock(true), createElementBlock(Fragment, null, renderList(cells, (cell, cellIndex) => {
9440
+ return openBlock(), createElementBlock("th", {
9441
+ key: cell.key,
9442
+ scope: cell.isGroup ? "colgroup" : "col",
9443
+ colspan: cell.colSpan > 1 ? cell.colSpan : void 0,
9444
+ rowspan: cell.rowSpan > 1 ? cell.rowSpan : void 0,
9445
+ class: normalizeClass(["h-10 px-2 align-middle font-medium text-muted-foreground", [
9446
+ cell.isGroup ? void 0 : unref(stickyClass)(stickyOf.value, cell.key),
9447
+ unref(theadThClass),
9448
+ headerCellClass(cell, cellIndex === cells.length - 1)
9449
+ ]]),
9450
+ style: normalizeStyle([cell.isGroup ? { textAlign: headerCellAlign(cell) } : {
9451
+ width: widthOf(cell.node.width),
9452
+ textAlign: headerCellAlign(cell)
9453
+ }, cell.isGroup ? groupStickyStyle(cell) : unref(stickyStyle)(stickyOf.value, cell.key, true)]),
9454
+ "aria-sort": cell.isGroup ? void 0 : ariaSort(cell.node)
9455
+ }, [!cell.isGroup && cell.node.sortable ? (openBlock(), createElementBlock("button", {
9456
+ key: 0,
9457
+ type: "button",
9458
+ class: "inline-flex items-center gap-1 hover:text-foreground",
9459
+ onClick: ($event) => onSort(cell.node.key)
9460
+ }, [createTextVNode(toDisplayString(cell.node.title) + " ", 1), createElementVNode("span", _hoisted_11, toDisplayString(sortMark(cell.node)), 1)], 8, _hoisted_10)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(cell.node.title), 1)], 64))], 14, _hoisted_9);
9461
+ }), 128))
9462
+ ], 4);
9463
+ }), 128))], 2), createElementVNode("tbody", _hoisted_12, [
9464
+ createCommentVNode(" 加载态:固定 5 行骨架;选择列一并占位;骨架不虚拟化;loading 判定优先 "),
8014
9465
  loading.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, renderList(SKELETON_ROWS, (row) => {
8015
9466
  return createElementVNode("tr", {
8016
9467
  key: row,
8017
9468
  "data-skeleton": ""
8018
- }, [hasSelection.value ? (openBlock(), createElementBlock("td", {
8019
- key: 0,
8020
- class: normalizeClass(["p-2 align-middle", unref(stickyClass)(stickyOf.value, unref(SELECTION_CELL))]),
8021
- style: normalizeStyle(unref(stickyStyle)(stickyOf.value, unref(SELECTION_CELL), false))
8022
- }, [createVNode(unref(_sfc_main$39), { class: "size-4" })], 6)) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(visibleColumns.value, (column) => {
8023
- return openBlock(), createElementBlock("td", {
8024
- key: column.key,
8025
- class: normalizeClass(["p-2 align-middle", unref(stickyClass)(stickyOf.value, column.key)]),
8026
- style: normalizeStyle([{ textAlign: column.align }, unref(stickyStyle)(stickyOf.value, column.key, false)])
8027
- }, [createVNode(unref(_sfc_main$39), { class: "h-4 w-full" })], 6);
8028
- }), 128))]);
8029
- }), 64)) : showError.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" 错误态:error 优先于正常数据;插槽可自定义(slot props { error, retry }) "), createElementVNode("tr", _hoisted_11, [createElementVNode("td", {
9469
+ }, [
9470
+ hasSelection.value ? (openBlock(), createElementBlock("td", {
9471
+ key: 0,
9472
+ class: normalizeClass(["p-2 text-center align-middle", unref(stickyClass)(stickyOf.value, unref(SELECTION_CELL))]),
9473
+ style: normalizeStyle(unref(stickyStyle)(stickyOf.value, unref(SELECTION_CELL), false))
9474
+ }, [createVNode(unref(_sfc_main$39), { class: "size-4" })], 6)) : createCommentVNode("v-if", true),
9475
+ dragEnabled.value ? (openBlock(), createElementBlock("td", {
9476
+ key: 1,
9477
+ class: normalizeClass(["p-1 text-center align-middle", unref(stickyClass)(stickyOf.value, unref(DRAG_CELL))]),
9478
+ style: normalizeStyle(unref(stickyStyle)(stickyOf.value, unref(DRAG_CELL), false))
9479
+ }, [createVNode(unref(_sfc_main$39), { class: "size-4" })], 6)) : createCommentVNode("v-if", true),
9480
+ (openBlock(true), createElementBlock(Fragment, null, renderList(visibleColumns.value, (column) => {
9481
+ return openBlock(), createElementBlock("td", {
9482
+ key: column.key,
9483
+ class: normalizeClass(["p-2 align-middle", unref(stickyClass)(stickyOf.value, column.key)]),
9484
+ style: normalizeStyle([{ textAlign: column.align ?? "center" }, unref(stickyStyle)(stickyOf.value, column.key, false)])
9485
+ }, [createVNode(unref(_sfc_main$39), { class: "h-4 w-full" })], 6);
9486
+ }), 128))
9487
+ ]);
9488
+ }), 64)) : showError.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" 错误态:error 优先于正常数据;插槽可自定义(slot props { error, retry }) "), createElementVNode("tr", _hoisted_13, [createElementVNode("td", {
8030
9489
  colspan: columnCount.value,
8031
9490
  class: "p-8 text-center text-muted-foreground"
8032
9491
  }, [renderSlot(_ctx.$slots, "error", {
8033
9492
  error: loadError.value,
8034
9493
  retry
8035
- }, () => [createElementVNode("div", _hoisted_13, [createElementVNode("p", null, toDisplayString(loadError.value?.message ?? "加载失败"), 1), createVNode(unref(_sfc_main$5), {
9494
+ }, () => [createElementVNode("div", _hoisted_15, [createElementVNode("p", null, toDisplayString(loadError.value?.message ?? "加载失败"), 1), createVNode(unref(_sfc_main$5), {
8036
9495
  variant: "outline",
8037
9496
  size: "sm",
8038
9497
  onClick: retry
8039
9498
  }, {
8040
- default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("重试", -1)])]),
9499
+ default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("重试", -1)])]),
8041
9500
  _: 1
8042
- })])])], 8, _hoisted_12)])], 64)) : unref(virtualEnabled) ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
9501
+ })])])], 8, _hoisted_14)])], 64)) : unref(virtualEnabled) ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
8043
9502
  createCommentVNode(" 虚拟滚动:窗口行 + 前后占位行(总高撑开滚动区间;行高经 measureElement 动态测量) "),
8044
9503
  createElementVNode("tr", {
8045
9504
  "aria-hidden": "true",
@@ -8048,7 +9507,7 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
8048
9507
  }, [createElementVNode("td", {
8049
9508
  colspan: columnCount.value,
8050
9509
  class: "border-0 p-0"
8051
- }, null, 8, _hoisted_14)], 4),
9510
+ }, null, 8, _hoisted_16)], 4),
8052
9511
  (openBlock(true), createElementBlock(Fragment, null, renderList(virtualLines.value, (item) => {
8053
9512
  return openBlock(), createBlock(_sfc_main$53, {
8054
9513
  key: item.line.key,
@@ -8061,11 +9520,18 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
8061
9520
  selected: unref(selectedKeys).has(item.line.key),
8062
9521
  sticky: stickyOf.value,
8063
9522
  "tree-indent": unref(tree) ? unref(treeIndent) : void 0,
9523
+ "drag-column": dragEnabled.value,
9524
+ "drag-disabled": rowDragDisabled(item.line),
9525
+ dragging: unref(drag).draggingKey.value === item.line.key,
8064
9526
  onSelect: (checked) => onRowSelect(item.line, checked),
8065
9527
  onRowClick: ($event) => onRowClick(item.line.record, item.line.index, $event),
8066
9528
  onRowDblclick: ($event) => onRowDblclick(item.line.record, item.line.index, $event),
8067
9529
  onRowContextmenu: ($event) => onRowContextmenu(item.line.record, item.line.index, $event),
8068
- onCellClick: (columnKey, event) => onCellClick(item.line.record, columnKey, item.line.index, event)
9530
+ onCellClick: (columnKey, event) => onCellClick(item.line.record, columnKey, item.line.index, event),
9531
+ onDragStart: ($event) => onRowDragStart(item.line, $event),
9532
+ onDragOver: ($event) => onRowDragOver(item.line, $event),
9533
+ onDrop: ($event) => onRowDrop(item.line, $event),
9534
+ onDragEnd: _cache[3] || (_cache[3] = ($event) => onRowDragEnd())
8069
9535
  }, null, 8, [
8070
9536
  "data-index",
8071
9537
  "line",
@@ -8074,11 +9540,17 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
8074
9540
  "selected",
8075
9541
  "sticky",
8076
9542
  "tree-indent",
9543
+ "drag-column",
9544
+ "drag-disabled",
9545
+ "dragging",
8077
9546
  "onSelect",
8078
9547
  "onRowClick",
8079
9548
  "onRowDblclick",
8080
9549
  "onRowContextmenu",
8081
- "onCellClick"
9550
+ "onCellClick",
9551
+ "onDragStart",
9552
+ "onDragOver",
9553
+ "onDrop"
8082
9554
  ]);
8083
9555
  }), 128)),
8084
9556
  createElementVNode("tr", {
@@ -8088,8 +9560,8 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
8088
9560
  }, [createElementVNode("td", {
8089
9561
  colspan: columnCount.value,
8090
9562
  class: "border-0 p-0"
8091
- }, null, 8, _hoisted_15)], 4)
8092
- ], 64)) : (openBlock(true), createElementBlock(Fragment, { key: 3 }, renderList(body.value, (line) => {
9563
+ }, null, 8, _hoisted_17)], 4)
9564
+ ], 64)) : (openBlock(true), createElementBlock(Fragment, { key: 3 }, renderList(displayBody.value, (line) => {
8093
9565
  return openBlock(), createBlock(_sfc_main$53, {
8094
9566
  key: line.key,
8095
9567
  line,
@@ -8098,11 +9570,18 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
8098
9570
  selected: unref(selectedKeys).has(line.key),
8099
9571
  sticky: stickyOf.value,
8100
9572
  "tree-indent": unref(tree) ? unref(treeIndent) : void 0,
9573
+ "drag-column": dragEnabled.value,
9574
+ "drag-disabled": rowDragDisabled(line),
9575
+ dragging: unref(drag).draggingKey.value === line.key,
8101
9576
  onSelect: (checked) => onRowSelect(line, checked),
8102
9577
  onRowClick: ($event) => onRowClick(line.record, line.index, $event),
8103
9578
  onRowDblclick: ($event) => onRowDblclick(line.record, line.index, $event),
8104
9579
  onRowContextmenu: ($event) => onRowContextmenu(line.record, line.index, $event),
8105
- onCellClick: (columnKey, event) => onCellClick(line.record, columnKey, line.index, event)
9580
+ onCellClick: (columnKey, event) => onCellClick(line.record, columnKey, line.index, event),
9581
+ onDragStart: ($event) => onRowDragStart(line, $event),
9582
+ onDragOver: ($event) => onRowDragOver(line, $event),
9583
+ onDrop: ($event) => onRowDrop(line, $event),
9584
+ onDragEnd: _cache[4] || (_cache[4] = ($event) => onRowDragEnd())
8106
9585
  }, null, 8, [
8107
9586
  "line",
8108
9587
  "columns",
@@ -8110,20 +9589,26 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
8110
9589
  "selected",
8111
9590
  "sticky",
8112
9591
  "tree-indent",
9592
+ "drag-column",
9593
+ "drag-disabled",
9594
+ "dragging",
8113
9595
  "onSelect",
8114
9596
  "onRowClick",
8115
9597
  "onRowDblclick",
8116
9598
  "onRowContextmenu",
8117
- "onCellClick"
9599
+ "onCellClick",
9600
+ "onDragStart",
9601
+ "onDragOver",
9602
+ "onDrop"
8118
9603
  ]);
8119
9604
  }), 128)),
8120
9605
  createCommentVNode(" 空态:横跨全列的单单元格,不虚拟化;错误态优先 "),
8121
- !loading.value && !showError.value && body.value.length === 0 ? (openBlock(), createElementBlock("tr", _hoisted_16, [createElementVNode("td", {
9606
+ !loading.value && !showError.value && body.value.length === 0 ? (openBlock(), createElementBlock("tr", _hoisted_18, [createElementVNode("td", {
8122
9607
  colspan: columnCount.value,
8123
9608
  class: "p-8 text-center text-muted-foreground"
8124
- }, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode(toDisplayString(__props.emptyText ?? "暂无数据"), 1)])], 8, _hoisted_17)])) : createCommentVNode("v-if", true)
9609
+ }, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode(toDisplayString(__props.emptyText ?? "暂无数据"), 1)])], 8, _hoisted_19)])) : createCommentVNode("v-if", true)
8125
9610
  ])], 6)], 6),
8126
- createCommentVNode(" R31:手动接线(须经 onPageIndex/onPageSize 包装器保留受控去重);显式补 border-t 与 size select 保持现状 "),
9611
+ createCommentVNode(" 手动接线(须经 onPageIndex/onPageSize 包装器保留受控去重);显式补 border-t 与 size select 保持现状 "),
8127
9612
  showPaginationBar.value ? (openBlock(), createBlock(_sfc_main$43, {
8128
9613
  key: 1,
8129
9614
  class: normalizeClass(unref(cn)("border-t", unref(fill) && "shrink-0")),
@@ -8151,6 +9636,8 @@ const _sfc_main$44 = /*@__PURE__*/ defineComponent({
8151
9636
  * 列定义辅助:补全泛型推导,便于把列配置抽到独立文件。
8152
9637
  *
8153
9638
  * 纯类型辅助,原样返回入参——裸数组同样可直接传给 defineTable(无需此函数)。
9639
+ * @param columns - 列节点树(叶子列或分组)
9640
+ * @returns 原样返回的列节点树
8154
9641
  */
8155
9642
  function defineColumns(columns) {
8156
9643
  return columns;
@@ -8162,13 +9649,15 @@ function defineColumns(columns) {
8162
9649
  *
8163
9650
  * 返回值直接传给 `<TableRender :definition="def" />`;
8164
9651
  * 须在组件 setup 中调用(TanStack useVueTable 约束)。
9652
+ * @param config - 表格配置:列定义、数据源(静态 data 或服务端 onLoad)、分页排序、行选择等
9653
+ * @returns 表格渲染定义,直接传给 TableRender 组件的 definition prop
8165
9654
  */
8166
9655
  function defineTable(config) {
8167
9656
  return useTableRender(config);
8168
9657
  }
8169
9658
  //#endregion
8170
9659
  //#region src/components/tabs/Tabs.vue
8171
- const _hoisted_1$7 = [
9660
+ const _hoisted_1$6 = [
8172
9661
  "aria-label",
8173
9662
  "onClick",
8174
9663
  "onKeydown"
@@ -8303,7 +9792,7 @@ const _sfc_main$45 = /*@__PURE__*/ defineComponent({
8303
9792
  onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {}, ["prevent"])),
8304
9793
  onClick: withModifiers(($event) => emit("close", item.value), ["stop"]),
8305
9794
  onKeydown: [withKeys(withModifiers(($event) => emit("close", item.value), ["stop", "prevent"]), ["enter"]), withKeys(withModifiers(($event) => emit("close", item.value), ["stop", "prevent"]), ["space"])]
8306
- }, "×", 40, _hoisted_1$7)) : createCommentVNode("v-if", true)
9795
+ }, "×", 40, _hoisted_1$6)) : createCommentVNode("v-if", true)
8307
9796
  ]),
8308
9797
  _: 2
8309
9798
  }, 1032, [
@@ -8347,8 +9836,8 @@ const _sfc_main$45 = /*@__PURE__*/ defineComponent({
8347
9836
  });
8348
9837
  //#endregion
8349
9838
  //#region src/components/alert/Alert.vue
8350
- const _hoisted_1$6 = ["role"];
8351
- const _hoisted_2$6 = ["d"];
9839
+ const _hoisted_1$5 = ["role"];
9840
+ const _hoisted_2$5 = ["d"];
8352
9841
  const _hoisted_3$3 = { class: "min-w-0 flex-1" };
8353
9842
  const _hoisted_4$1 = {
8354
9843
  key: 0,
@@ -8405,7 +9894,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
8405
9894
  "stroke-linejoin": "round",
8406
9895
  "aria-hidden": "true",
8407
9896
  class: normalizeClass(unref(cn)(unref(alertIconVariants)({ variant: props.variant })))
8408
- }, [createElementVNode("path", { d: iconPath.value }, null, 8, _hoisted_2$6)], 2)) : createCommentVNode("v-if", true)]),
9897
+ }, [createElementVNode("path", { d: iconPath.value }, null, 8, _hoisted_2$5)], 2)) : createCommentVNode("v-if", true)]),
8409
9898
  createElementVNode("div", _hoisted_3$3, [props.title || unref(slots).title ? (openBlock(), createElementBlock("div", _hoisted_4$1, [renderSlot(_ctx.$slots, "title", {}, () => [createTextVNode(toDisplayString(props.title), 1)])])) : createCommentVNode("v-if", true), props.description || unref(slots).default ? (openBlock(), createElementBlock("div", {
8410
9899
  key: 1,
8411
9900
  class: normalizeClass(unref(cn)("text-sm leading-relaxed", (props.title || unref(slots).title) && "text-muted-foreground mt-1"))
@@ -8417,7 +9906,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
8417
9906
  class: "shrink-0 rounded-sm opacity-60 transition-opacity hover:opacity-100 focus-visible:outline-2 focus-visible:outline-ring -m-1 p-1",
8418
9907
  onClick: onClose
8419
9908
  }, [createVNode(CloseIcon_default, { class: "size-4" })])) : createCommentVNode("v-if", true)])
8420
- ], 10, _hoisted_1$6)) : createCommentVNode("v-if", true);
9909
+ ], 10, _hoisted_1$5)) : createCommentVNode("v-if", true);
8421
9910
  };
8422
9911
  }
8423
9912
  });
@@ -8460,8 +9949,8 @@ const alertIconPaths = {
8460
9949
  };
8461
9950
  //#endregion
8462
9951
  //#region src/components/empty/Empty.vue
8463
- const _hoisted_1$5 = { class: "text-muted-foreground/60 [&_svg]:size-24" };
8464
- const _hoisted_2$5 = { class: "text-sm text-muted-foreground" };
9952
+ const _hoisted_1$4 = { class: "text-muted-foreground/60 [&_svg]:size-24" };
9953
+ const _hoisted_2$4 = { class: "text-sm text-muted-foreground" };
8465
9954
  const _hoisted_3$2 = {
8466
9955
  key: 0,
8467
9956
  class: "mt-2 flex items-center gap-3"
@@ -8479,8 +9968,8 @@ const _sfc_main$17 = /*@__PURE__*/ defineComponent({
8479
9968
  role: "status",
8480
9969
  class: normalizeClass(unref(cn)("flex flex-col items-center justify-center gap-3 px-6 py-16 text-center", props.class))
8481
9970
  }, [
8482
- createElementVNode("div", _hoisted_1$5, [renderSlot(_ctx.$slots, "icon", {}, () => [createCommentVNode(" 内置插画:简洁空盒 "), _cache[0] || (_cache[0] = createStaticVNode("<svg viewBox=\"0 0 96 96\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M48 18 78 34v28L48 78 18 62V34L48 18Z\" opacity=\"0.55\"></path><path d=\"M18 34l30 16 30-16\" opacity=\"0.55\"></path><path d=\"M48 50v28\" opacity=\"0.55\"></path><path d=\"M48 18l-8 26 8 6 8-6-8-26Z\" fill=\"currentColor\" fill-opacity=\"0.12\" stroke=\"none\"></path><path d=\"M40 44l8 6 8-6\" opacity=\"0.75\"></path></svg>", 1))])]),
8483
- createElementVNode("p", _hoisted_2$5, toDisplayString(props.description), 1),
9971
+ createElementVNode("div", _hoisted_1$4, [renderSlot(_ctx.$slots, "icon", {}, () => [createCommentVNode(" 内置插画:简洁空盒 "), _cache[0] || (_cache[0] = createStaticVNode("<svg viewBox=\"0 0 96 96\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M48 18 78 34v28L48 78 18 62V34L48 18Z\" opacity=\"0.55\"></path><path d=\"M18 34l30 16 30-16\" opacity=\"0.55\"></path><path d=\"M48 50v28\" opacity=\"0.55\"></path><path d=\"M48 18l-8 26 8 6 8-6-8-26Z\" fill=\"currentColor\" fill-opacity=\"0.12\" stroke=\"none\"></path><path d=\"M40 44l8 6 8-6\" opacity=\"0.75\"></path></svg>", 1))])]),
9972
+ createElementVNode("p", _hoisted_2$4, toDisplayString(props.description), 1),
8484
9973
  _ctx.$slots.default ? (openBlock(), createElementBlock("div", _hoisted_3$2, [renderSlot(_ctx.$slots, "default")])) : createCommentVNode("v-if", true)
8485
9974
  ], 2);
8486
9975
  };
@@ -8560,8 +10049,8 @@ const _sfc_main$35 = /*@__PURE__*/ defineComponent({
8560
10049
  });
8561
10050
  //#endregion
8562
10051
  //#region src/components/spin/Spin.vue
8563
- const _hoisted_1$4 = ["inert"];
8564
- const _hoisted_2$4 = ["aria-busy", "aria-label"];
10052
+ const _hoisted_1$3 = ["inert"];
10053
+ const _hoisted_2$3 = ["aria-busy", "aria-label"];
8565
10054
  const _sfc_main$41 = /*@__PURE__*/ defineComponent({
8566
10055
  __name: "Spin",
8567
10056
  props: {
@@ -8613,7 +10102,7 @@ const _sfc_main$41 = /*@__PURE__*/ defineComponent({
8613
10102
  stroke: "currentColor",
8614
10103
  "stroke-width": "3",
8615
10104
  "stroke-linecap": "round"
8616
- }, null, -1)])], 2))])], 10, _hoisted_2$4)) : createCommentVNode("v-if", true)], 10, _hoisted_1$4)) : createCommentVNode("v-if", true);
10105
+ }, null, -1)])], 2))])], 10, _hoisted_2$3)) : createCommentVNode("v-if", true)], 10, _hoisted_1$3)) : createCommentVNode("v-if", true);
8617
10106
  };
8618
10107
  }
8619
10108
  });
@@ -8632,6 +10121,8 @@ let providerMounted = false;
8632
10121
  * 按 props 重建单例内部 store(ToastProvider 挂载时调用)。
8633
10122
  * 配置未变化时复用现有 store,避免 Provider 重挂载丢弃排队中的 toast。
8634
10123
  * 返回 store 供 Provider 的 <Toaster> 渲染使用。
10124
+ * @param props - Provider 传入的 placement/duration/max 配置,缺省项回退内置默认值
10125
+ * @returns 当前 toast store 实例
8635
10126
  */
8636
10127
  function __configureToaster(props = {}) {
8637
10128
  const next = {
@@ -8643,15 +10134,25 @@ function __configureToaster(props = {}) {
8643
10134
  current = createToaster(next);
8644
10135
  return current;
8645
10136
  }
8646
- /** 标记 Provider 已挂载/已卸载(Provider 生命周期与测试用) */
10137
+ /**
10138
+ * 标记 Provider 已挂载/已卸载(Provider 生命周期与测试用)。
10139
+ * @param value - true 表示 Provider 已挂载,false 表示已卸载
10140
+ */
8647
10141
  function __setToastMounted(value) {
8648
10142
  providerMounted = value;
8649
10143
  }
10144
+ /**
10145
+ * Provider 未挂载时在开发环境输出告警,提醒先在应用根部挂载 <ToastProvider>。
10146
+ */
8650
10147
  function warnIfUnmounted() {
8651
10148
  if (!providerMounted && import.meta.env.DEV) console.warn("[tu-design] 在 <ToastProvider> 挂载前调用了 toast。请在应用根部挂载一次 <ToastProvider>,否则提示不会渲染。");
8652
10149
  }
8653
10150
  const toastApi = {
8654
- /** 成功提示 */
10151
+ /**
10152
+ * 成功提示。
10153
+ * @param options - toast 配置(标题、描述、时长等)
10154
+ * @returns 该条 toast 的创建结果,可用于后续控制
10155
+ */
8655
10156
  success: (options) => {
8656
10157
  warnIfUnmounted();
8657
10158
  return current.create({
@@ -8659,7 +10160,11 @@ const toastApi = {
8659
10160
  type: "success"
8660
10161
  });
8661
10162
  },
8662
- /** 错误提示 */
10163
+ /**
10164
+ * 错误提示。
10165
+ * @param options - toast 配置(标题、描述、时长等)
10166
+ * @returns 该条 toast 的创建结果,可用于后续控制
10167
+ */
8663
10168
  error: (options) => {
8664
10169
  warnIfUnmounted();
8665
10170
  return current.create({
@@ -8667,7 +10172,11 @@ const toastApi = {
8667
10172
  type: "error"
8668
10173
  });
8669
10174
  },
8670
- /** 信息提示 */
10175
+ /**
10176
+ * 信息提示。
10177
+ * @param options - toast 配置(标题、描述、时长等)
10178
+ * @returns 该条 toast 的创建结果,可用于后续控制
10179
+ */
8671
10180
  info: (options) => {
8672
10181
  warnIfUnmounted();
8673
10182
  return current.create({
@@ -8675,7 +10184,11 @@ const toastApi = {
8675
10184
  type: "info"
8676
10185
  });
8677
10186
  },
8678
- /** 警告提示 */
10187
+ /**
10188
+ * 警告提示。
10189
+ * @param options - toast 配置(标题、描述、时长等)
10190
+ * @returns 该条 toast 的创建结果,可用于后续控制
10191
+ */
8679
10192
  warning: (options) => {
8680
10193
  warnIfUnmounted();
8681
10194
  return current.create({
@@ -8683,7 +10196,11 @@ const toastApi = {
8683
10196
  type: "warning"
8684
10197
  });
8685
10198
  },
8686
- /** 加载中提示 */
10199
+ /**
10200
+ * 加载中提示。
10201
+ * @param options - toast 配置(标题、描述、时长等)
10202
+ * @returns 该条 toast 的创建结果,可用于后续控制
10203
+ */
8687
10204
  loading: (options) => {
8688
10205
  warnIfUnmounted();
8689
10206
  return current.create({
@@ -8691,23 +10208,37 @@ const toastApi = {
8691
10208
  type: "loading"
8692
10209
  });
8693
10210
  },
8694
- /** 跟踪 Promise 状态的提示 */
10211
+ /**
10212
+ * 跟踪 Promise 状态的提示。
10213
+ * @param promise - 待跟踪的 Promise 或返回 Promise 的工厂函数
10214
+ * @param options - Promise 各阶段(loading/success/error)的 toast 配置
10215
+ * @param shared - 各阶段共享的基础配置(不含 type)
10216
+ * @returns 该条 toast 的创建结果,可用于后续控制
10217
+ */
8695
10218
  promise: (promise, options, shared) => {
8696
10219
  warnIfUnmounted();
8697
10220
  return current.promise(promise, options, shared);
8698
10221
  },
8699
- /** 关闭指定 toast;不传 id 时关闭全部 */
10222
+ /**
10223
+ * 关闭指定 toast;不传 id 时关闭全部。
10224
+ * @param id - 目标 toast 的 id;缺省时关闭全部
10225
+ */
8700
10226
  dismiss: (id) => {
8701
10227
  warnIfUnmounted();
8702
10228
  current.dismiss(id);
8703
10229
  }
8704
10230
  };
10231
+ /**
10232
+ * 获取 toast API。模块级单例外观对象,任意位置调用返回同一引用(引用稳定);
10233
+ * 内部转发到 Provider 挂载后重建的 store,调用前须在应用根部挂载 <ToastProvider>。
10234
+ * @returns toast 操作 API(success/error/info/warning/loading/promise/dismiss)
10235
+ */
8705
10236
  function useToast() {
8706
10237
  return toastApi;
8707
10238
  }
8708
10239
  //#endregion
8709
10240
  //#region src/components/toast/ToastProvider.vue
8710
- const _hoisted_1$3 = {
10241
+ const _hoisted_1$2 = {
8711
10242
  key: 0,
8712
10243
  viewBox: "0 0 24 24",
8713
10244
  fill: "none",
@@ -8717,7 +10248,7 @@ const _hoisted_1$3 = {
8717
10248
  "stroke-linejoin": "round",
8718
10249
  class: "size-4"
8719
10250
  };
8720
- const _hoisted_2$3 = {
10251
+ const _hoisted_2$2 = {
8721
10252
  key: 1,
8722
10253
  viewBox: "0 0 24 24",
8723
10254
  fill: "none",
@@ -8810,7 +10341,7 @@ const _sfc_main$48 = /*@__PURE__*/ defineComponent({
8810
10341
  t.type ? (openBlock(), createElementBlock("span", {
8811
10342
  key: 0,
8812
10343
  class: normalizeClass(["mt-0.5 shrink-0", { "animate-spin": t.type === "loading" }])
8813
- }, [renderSlot(_ctx.$slots, "icon", { type: t.type }, () => [t.type === "success" ? (openBlock(), createElementBlock("svg", _hoisted_1$3, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M21.801 10A10 10 0 1 1 17 3.335" }, null, -1), createElementVNode("path", { d: "m9 11 3 3L22 4" }, null, -1)])])) : t.type === "error" ? (openBlock(), createElementBlock("svg", _hoisted_2$3, [..._cache[1] || (_cache[1] = [
10344
+ }, [renderSlot(_ctx.$slots, "icon", { type: t.type }, () => [t.type === "success" ? (openBlock(), createElementBlock("svg", _hoisted_1$2, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M21.801 10A10 10 0 1 1 17 3.335" }, null, -1), createElementVNode("path", { d: "m9 11 3 3L22 4" }, null, -1)])])) : t.type === "error" ? (openBlock(), createElementBlock("svg", _hoisted_2$2, [..._cache[1] || (_cache[1] = [
8814
10345
  createElementVNode("circle", {
8815
10346
  cx: "12",
8816
10347
  cy: "12",
@@ -8860,43 +10391,9 @@ const _sfc_main$48 = /*@__PURE__*/ defineComponent({
8860
10391
  }
8861
10392
  });
8862
10393
  //#endregion
8863
- //#region src/components/overlay-shared/useConfirmPending.ts
8864
- /**
8865
- * 确认弹层公共 pending 语义:@confirm 处理器返回 Promise 时锁定关闭通道,
8866
- * resolve 后自动关闭,reject 保持打开并退出 loading;同步处理器直接关闭。
8867
- */
8868
- function useConfirmPending(options) {
8869
- const loading = ref(false);
8870
- function handleConfirm() {
8871
- if (loading.value) return;
8872
- const handler = options.instance?.vnode.props?.onConfirm;
8873
- const result = handler?.();
8874
- if (!handler) options.emitConfirm();
8875
- if (result instanceof Promise) {
8876
- loading.value = true;
8877
- result.then(() => {
8878
- loading.value = false;
8879
- options.close();
8880
- }).catch(() => {
8881
- loading.value = false;
8882
- });
8883
- } else options.close();
8884
- }
8885
- function handleCancel() {
8886
- if (loading.value) return;
8887
- options.emitCancel();
8888
- options.close();
8889
- }
8890
- return {
8891
- loading,
8892
- handleConfirm,
8893
- handleCancel
8894
- };
8895
- }
8896
- //#endregion
8897
10394
  //#region src/components/alert-dialog/AlertDialog.vue
8898
- const _hoisted_1$2 = { class: "flex flex-col gap-2 text-center sm:text-left" };
8899
- const _hoisted_2$2 = { class: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end" };
10395
+ const _hoisted_1$1 = { class: "flex flex-col gap-2 text-center sm:text-left" };
10396
+ const _hoisted_2$1 = { class: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end" };
8900
10397
  const _hoisted_3 = {
8901
10398
  key: 0,
8902
10399
  viewBox: "0 0 24 24",
@@ -8996,7 +10493,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
8996
10493
  "aria-modal": "true"
8997
10494
  }, {
8998
10495
  default: withCtx(() => [
8999
- createElementVNode("div", _hoisted_1$2, [createVNode(unref(Dialog).Title, { class: "text-lg font-semibold leading-none tracking-tight" }, {
10496
+ createElementVNode("div", _hoisted_1$1, [createVNode(unref(Dialog).Title, { class: "text-lg font-semibold leading-none tracking-tight" }, {
9000
10497
  default: withCtx(() => [renderSlot(_ctx.$slots, "title", {}, () => [createTextVNode(toDisplayString(props.title), 1)])]),
9001
10498
  _: 3
9002
10499
  }), _ctx.$slots.description || props.description ? (openBlock(), createBlock(unref(Dialog).Description, {
@@ -9009,7 +10506,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
9009
10506
  createCommentVNode(" 默认插槽:补充正文(可选) "),
9010
10507
  renderSlot(_ctx.$slots, "default"),
9011
10508
  createCommentVNode(" 底部操作区:取消 outline,确认按 destructive 切换语义色;pending 时确认钮转 loading "),
9012
- createElementVNode("div", _hoisted_2$2, [createVNode(unref(_sfc_main$5), {
10509
+ createElementVNode("div", _hoisted_2$1, [createVNode(unref(_sfc_main$5), {
9013
10510
  variant: "outline",
9014
10511
  disabled: unref(loading),
9015
10512
  onClick: unref(handleCancel)
@@ -9086,7 +10583,7 @@ const _sfc_main$10 = /*@__PURE__*/ defineComponent({
9086
10583
  }),
9087
10584
  createVNode(unref(Menu).Positioner, { class: "z-[var(--z-overlay)]" }, {
9088
10585
  default: withCtx(() => [createVNode(unref(Menu).Content, mergeProps(unref(attrs), { class: unref(cn)(contentCls) }), {
9089
- default: withCtx(() => [createVNode(_sfc_main$54, { items: props.items }, null, 8, ["items"])]),
10586
+ default: withCtx(() => [createVNode(_sfc_main$55, { items: props.items }, null, 8, ["items"])]),
9090
10587
  _: 1
9091
10588
  }, 16, ["class"])]),
9092
10589
  _: 1
@@ -9099,11 +10596,11 @@ const _sfc_main$10 = /*@__PURE__*/ defineComponent({
9099
10596
  });
9100
10597
  //#endregion
9101
10598
  //#region src/components/drawer/Drawer.vue
9102
- const _hoisted_1$1 = {
10599
+ const _hoisted_1 = {
9103
10600
  key: 0,
9104
10601
  class: "flex flex-col gap-1.5"
9105
10602
  };
9106
- const _hoisted_2$1 = {
10603
+ const _hoisted_2 = {
9107
10604
  key: 1,
9108
10605
  class: "mt-auto flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:justify-end"
9109
10606
  };
@@ -9253,7 +10750,7 @@ const _sfc_main$15 = /*@__PURE__*/ defineComponent({
9253
10750
  createVNode(unref(Drawer).Positioner, { class: normalizeClass(unref(cn)("fixed inset-0 z-[var(--z-overlay)] flex", config.value.positioner)) }, {
9254
10751
  default: withCtx(() => [createVNode(unref(Drawer).Content, { class: normalizeClass(contentClass.value) }, {
9255
10752
  default: withCtx(() => [
9256
- hasHeader.value || _ctx.$slots.title || _ctx.$slots.description ? (openBlock(), createElementBlock("div", _hoisted_1$1, [_ctx.$slots.title || props.title ? (openBlock(), createBlock(unref(Drawer).Title, {
10753
+ hasHeader.value || _ctx.$slots.title || _ctx.$slots.description ? (openBlock(), createElementBlock("div", _hoisted_1, [_ctx.$slots.title || props.title ? (openBlock(), createBlock(unref(Drawer).Title, {
9257
10754
  key: 0,
9258
10755
  class: "text-lg font-semibold leading-none tracking-tight"
9259
10756
  }, {
@@ -9267,7 +10764,7 @@ const _sfc_main$15 = /*@__PURE__*/ defineComponent({
9267
10764
  _: 3
9268
10765
  })) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true),
9269
10766
  renderSlot(_ctx.$slots, "default"),
9270
- _ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_2$1, [renderSlot(_ctx.$slots, "footer", { close })])) : createCommentVNode("v-if", true),
10767
+ _ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_2, [renderSlot(_ctx.$slots, "footer", { close })])) : createCommentVNode("v-if", true),
9271
10768
  props.showCloseButton ? (openBlock(), createBlock(unref(Drawer).CloseTrigger, {
9272
10769
  key: 2,
9273
10770
  "aria-label": "关闭",
@@ -9294,135 +10791,6 @@ const _sfc_main$15 = /*@__PURE__*/ defineComponent({
9294
10791
  }
9295
10792
  });
9296
10793
  //#endregion
9297
- //#region src/components/popconfirm/Popconfirm.vue
9298
- const _hoisted_1 = { class: "mt-3 flex items-center justify-end gap-2" };
9299
- const _hoisted_2 = {
9300
- key: 0,
9301
- viewBox: "0 0 24 24",
9302
- fill: "none",
9303
- stroke: "currentColor",
9304
- "stroke-width": "2",
9305
- "stroke-linecap": "round",
9306
- class: "size-4 animate-spin",
9307
- "aria-hidden": "true"
9308
- };
9309
- /**
9310
- * 气泡确认:Popover 的一体式薄壳变体,面板内容内置 title/description + 确认/取消按钮。
9311
- * 行为与 M2 AlertDialog 对齐:@confirm 处理器返回 Promise 时确认钮进入 loading 并锁定全部
9312
- * 关闭通道(ESC/点外部/触发器/取消钮),resolve 后自动关闭、reject 保持打开;
9313
- * 同步处理器点击确认/取消后自动关闭并派发对应事件。
9314
- */
9315
- const _sfc_main$33 = /*@__PURE__*/ defineComponent({
9316
- inheritAttrs: false,
9317
- __name: "Popconfirm",
9318
- props: {
9319
- /** 气泡标题(渲染为 Ark Popover.Title,content 自动接线 aria-labelledby) */
9320
- title: {
9321
- type: String,
9322
- required: true
9323
- },
9324
- /** 气泡描述(可选,渲染为 Ark Popover.Description,content 自动接线 aria-describedby) */
9325
- description: {
9326
- type: String,
9327
- default: void 0
9328
- },
9329
- /** 确认按钮文案 */
9330
- confirmText: {
9331
- type: String,
9332
- default: "确定"
9333
- },
9334
- /** 取消按钮文案 */
9335
- cancelText: {
9336
- type: String,
9337
- default: "取消"
9338
- },
9339
- /** 确认按钮风格:default 主色 / destructive 危险色 */
9340
- variant: {
9341
- type: String,
9342
- default: "default"
9343
- },
9344
- /** 受控开关(配合 v-model:open);不传时为非受控,由内部状态管理 */
9345
- open: {
9346
- type: Boolean,
9347
- default: void 0
9348
- }
9349
- },
9350
- emits: [
9351
- "update:open",
9352
- "confirm",
9353
- "cancel"
9354
- ],
9355
- setup(__props, { emit: __emit }) {
9356
- const props = __props;
9357
- const emit = __emit;
9358
- const attrs = useAttrs();
9359
- const instance = getCurrentInstance();
9360
- const { isOpen, setOpen } = useControlledBoolean({
9361
- controlled: () => props.open,
9362
- onChange: (open) => emit("update:open", open)
9363
- });
9364
- function handleUpdate(open) {
9365
- if (!open && loading.value) return;
9366
- setOpen(open);
9367
- }
9368
- /** 关闭气泡:走受控桥把 open 置 false,定位回退/动画由 zag 处理 */
9369
- function close() {
9370
- handleUpdate(false);
9371
- }
9372
- const { loading, handleConfirm, handleCancel } = useConfirmPending({
9373
- instance,
9374
- emitConfirm: () => emit("confirm"),
9375
- emitCancel: () => emit("cancel"),
9376
- close
9377
- });
9378
- return (_ctx, _cache) => {
9379
- return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" 薄壳复用 Popover:触发器 asChild、受控桥、定位与进出场动画均由 Popover 提供 "), createVNode(unref(_sfc_main$34), mergeProps(unref(attrs), {
9380
- open: unref(isOpen),
9381
- "content-class": "w-64 p-3",
9382
- "onUpdate:open": handleUpdate
9383
- }), {
9384
- content: withCtx(() => [
9385
- createVNode(unref(Popover).Title, { class: "text-sm font-medium" }, {
9386
- default: withCtx(() => [createTextVNode(toDisplayString(props.title), 1)]),
9387
- _: 1
9388
- }),
9389
- props.description ? (openBlock(), createBlock(unref(Popover).Description, {
9390
- key: 0,
9391
- class: "mt-1 text-xs text-muted-foreground"
9392
- }, {
9393
- default: withCtx(() => [createTextVNode(toDisplayString(props.description), 1)]),
9394
- _: 1
9395
- })) : createCommentVNode("v-if", true),
9396
- createCommentVNode(" 操作区:取消 outline,确认按 variant 切换语义色;pending 时双钮禁用 + 确认钮转 loading "),
9397
- createElementVNode("div", _hoisted_1, [createVNode(unref(_sfc_main$5), {
9398
- variant: "outline",
9399
- size: "sm",
9400
- disabled: unref(loading),
9401
- onClick: unref(handleCancel)
9402
- }, {
9403
- default: withCtx(() => [createTextVNode(toDisplayString(props.cancelText), 1)]),
9404
- _: 1
9405
- }, 8, ["disabled", "onClick"]), createVNode(unref(_sfc_main$5), {
9406
- variant: props.variant === "destructive" ? "destructive" : "default",
9407
- size: "sm",
9408
- disabled: unref(loading),
9409
- onClick: unref(handleConfirm)
9410
- }, {
9411
- default: withCtx(() => [unref(loading) ? (openBlock(), createElementBlock("svg", _hoisted_2, [..._cache[0] || (_cache[0] = [createElementVNode("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }, null, -1)])])) : createCommentVNode("v-if", true), createTextVNode(" " + toDisplayString(props.confirmText), 1)]),
9412
- _: 1
9413
- }, 8, [
9414
- "variant",
9415
- "disabled",
9416
- "onClick"
9417
- ])])
9418
- ]),
9419
- default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
9420
- _: 3
9421
- }, 16, ["open"])], 2112);
9422
- };
9423
- }
9424
- });
9425
- //#endregion
9426
10794
  //#region src/components/timeline/Timeline.vue
9427
10795
  const _sfc_main$47 = /*@__PURE__*/ defineComponent({
9428
10796
  __name: "Timeline",
@@ -9441,13 +10809,21 @@ const _sfc_main$47 = /*@__PURE__*/ defineComponent({
9441
10809
  }));
9442
10810
  const titleClass = computed(() => props.size === "sm" ? "text-xs leading-4 font-medium text-foreground" : "text-sm font-medium leading-5 text-foreground");
9443
10811
  const descriptionClass = computed(() => props.size === "sm" ? "mt-1 text-xs leading-relaxed text-muted-foreground" : "mt-1 text-sm leading-relaxed text-muted-foreground");
9444
- /** 连线类:首末项按 index 裁切(不用 first:/last: 伪类——line 恒为 li 首个子元素,伪类会全量误命中) */
10812
+ /**
10813
+ * 连线类:首末项按 index 裁切(不用 first:/last: 伪类——line 恒为 li 首个子元素,伪类会全量误命中)
10814
+ * @param index - 项在 items 中的下标
10815
+ * @returns 连线元素的 class
10816
+ */
9445
10817
  function lineClass(index) {
9446
10818
  const isFirst = index === 0;
9447
10819
  const isLast = index === props.items.length - 1;
9448
10820
  return cn("absolute w-0.5 -translate-x-1/2 bg-border", props.mode === "alternate" ? "left-1/2" : props.size === "sm" ? "left-[5px]" : "left-[6px]", isFirst ? "top-[10px]" : "top-0", isLast ? "bottom-[calc(100%-10px)]" : "bottom-0");
9449
10821
  }
9450
- /** 节点类:颜色/空心取自单项数据,位置与尺寸取自组件变体 */
10822
+ /**
10823
+ * 节点类:颜色/空心取自单项数据,位置与尺寸取自组件变体
10824
+ * @param item - 时间轴单项数据
10825
+ * @returns 节点元素的 class
10826
+ */
9451
10827
  function dotClass(item) {
9452
10828
  return cn(timelineDotVariants({
9453
10829
  mode: props.mode,
@@ -9456,13 +10832,21 @@ const _sfc_main$47 = /*@__PURE__*/ defineComponent({
9456
10832
  hollow: item.hollow
9457
10833
  }));
9458
10834
  }
9459
- /** 内容区类:right 占第 2 列;alternate 按奇偶交替占第 1/3 列并切换对齐 */
10835
+ /**
10836
+ * 内容区类:right 占第 2 列;alternate 按奇偶交替占第 1/3 列并切换对齐
10837
+ * @param index - 项在 items 中的下标(alternate 模式据此决定占列与对齐)
10838
+ * @returns 内容区元素的 class
10839
+ */
9460
10840
  function contentClass(index) {
9461
10841
  const base = "min-w-0 flex flex-col";
9462
10842
  if (props.mode === "alternate") return cn(base, index % 2 === 0 ? "col-start-1 row-start-1 pr-4 text-right" : "col-start-3 row-start-1 pl-4 text-left");
9463
10843
  return cn(base, props.size === "sm" ? "pl-2.5" : "pl-3");
9464
10844
  }
9465
- /** 时间戳类:bottom 时 DOM 仍在前部,仅切 order-last 移到内容下方(不分支 DOM) */
10845
+ /**
10846
+ * 时间戳类:bottom 时 DOM 仍在前部,仅切 order-last 移到内容下方(不分支 DOM)
10847
+ * @param item - 时间轴单项数据(读 timestampPlacement)
10848
+ * @returns 时间戳元素的 class
10849
+ */
9466
10850
  function timestampClass(item) {
9467
10851
  return item.timestampPlacement === "bottom" ? "mb-1 mt-1.5 order-last text-xs leading-4 text-muted-foreground tabular-nums" : "mb-1 text-xs leading-4 text-muted-foreground tabular-nums";
9468
10852
  }
@@ -9645,4 +11029,4 @@ const timelineDotVariants = cva("relative z-10 mt-1 block shrink-0 rounded-full"
9645
11029
  }
9646
11030
  });
9647
11031
  //#endregion
9648
- export { _sfc_main as Alert, _sfc_main$1 as AlertDialog, _sfc_main$2 as Avatar, _sfc_main$3 as AvatarGroup, _sfc_main$4 as Badge, _sfc_main$5 as Button, CHECKED, COMPONENT_NAMES, _sfc_main$6 as Calendar, _sfc_main$7 as Card, _sfc_main$8 as Cascader, _sfc_main$9 as Checkbox, _sfc_main$10 as ContextMenu, _sfc_main$11 as CurrencyInput, _sfc_main$12 as DatePicker, _sfc_main$13 as DateRangePicker, _sfc_main$14 as Dialog, _sfc_main$15 as Drawer, _sfc_main$16 as DropdownMenu, _sfc_main$17 as Empty, _sfc_main$18 as Form, _sfc_main$19 as FormControl, _sfc_main$20 as FormDescription, _sfc_main$21 as FormField, _sfc_main$22 as FormItem, _sfc_main$23 as FormLabel, _sfc_main$24 as FormMessage, _sfc_main$25 as FormRender, _sfc_main$26 as FormSubscribe, _sfc_main$27 as Input, _sfc_main$28 as Label, MODEL_VALUE, _sfc_main$29 as MonthPicker, _sfc_main$30 as NumberInput, PAGE_TABLE_FILL_KEY, _sfc_main$31 as PasswordInput, _sfc_main$32 as PinInput, _sfc_main$33 as Popconfirm, _sfc_main$34 as Popover, _sfc_main$35 as Progress, _sfc_main$36 as RadioGroup, SLIDER, _sfc_main$37 as Select, _sfc_main$38 as Separator, _sfc_main$39 as Skeleton, _sfc_main$40 as Slider, Slot, _sfc_main$41 as Spin, _sfc_main$42 as Switch, _sfc_main$43 as TablePagination, _sfc_main$44 as TableRender, _sfc_main$45 as Tabs, _sfc_main$46 as Textarea, _sfc_main$47 as Timeline, _sfc_main$48 as ToastProvider, _sfc_main$49 as Tooltip, _sfc_main$50 as TreeSelect, TuDesignResolver, VALUE, _sfc_main$51 as WeekPicker, _sfc_main$52 as YearPicker, alertIconPaths, alertIconVariants, alertVariants, avatarGroupKey, avatarVariants, badgeVariants, bindField, buttonVariants, cardVariants, cn, columnRenders, defineColumns, defineForm, defineTable, formatCurrency, numberOrNull, parseCurrency, timelineDotVariants, timelineItemVariants, timelineVariants, useFormRender, useTableRender, useToast, widgetRenders };
11032
+ export { _sfc_main as Alert, _sfc_main$1 as AlertDialog, _sfc_main$2 as Avatar, _sfc_main$3 as AvatarGroup, _sfc_main$4 as Badge, _sfc_main$5 as Button, CHECKED, COMPONENT_NAMES, _sfc_main$6 as Calendar, _sfc_main$7 as Card, _sfc_main$8 as Cascader, _sfc_main$9 as Checkbox, _sfc_main$10 as ContextMenu, _sfc_main$11 as CurrencyInput, _sfc_main$12 as DatePicker, _sfc_main$13 as DateRangePicker, _sfc_main$14 as Dialog, _sfc_main$15 as Drawer, _sfc_main$16 as DropdownMenu, _sfc_main$17 as Empty, _sfc_main$18 as Form, _sfc_main$19 as FormControl, _sfc_main$20 as FormDescription, _sfc_main$21 as FormField, _sfc_main$22 as FormItem, _sfc_main$23 as FormLabel, _sfc_main$24 as FormMessage, _sfc_main$25 as FormRender, _sfc_main$26 as FormSubscribe, _sfc_main$27 as Input, _sfc_main$28 as Label, MODEL_VALUE, _sfc_main$29 as MonthPicker, _sfc_main$30 as NumberInput, PAGE_TABLE_FILL_KEY, _sfc_main$31 as PasswordInput, _sfc_main$32 as PinInput, _sfc_main$33 as Popconfirm, _sfc_main$34 as Popover, _sfc_main$35 as Progress, _sfc_main$36 as RadioGroup, SLIDER, _sfc_main$37 as Select, _sfc_main$38 as Separator, _sfc_main$39 as Skeleton, _sfc_main$40 as Slider, Slot, _sfc_main$41 as Spin, _sfc_main$42 as Switch, _sfc_main$43 as TablePagination, _sfc_main$44 as TableRender, _sfc_main$45 as Tabs, _sfc_main$46 as Textarea, _sfc_main$47 as Timeline, _sfc_main$48 as ToastProvider, _sfc_main$49 as Tooltip, _sfc_main$50 as TreeSelect, TuDesignResolver, VALUE, _sfc_main$51 as WeekPicker, _sfc_main$52 as YearPicker, alertIconPaths, alertIconVariants, alertVariants, avatarGroupKey, avatarVariants, badgeVariants, bindField, buttonVariants, cardVariants, cn, columnRenders, defineColumns, defineForm, defineTable, flattenColumns, formatCurrency, isColumnGroup, numberOrNull, parseCurrency, timelineDotVariants, timelineItemVariants, timelineVariants, useFormRender, useTableRender, useToast, widgetRenders };