@shwfed/config 2.3.28 → 2.3.29

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 (127) hide show
  1. package/dist/mcp.mjs +3124 -1268
  2. package/dist/module.json +1 -1
  3. package/dist/preview/assets/{config-fvkC2rB8.js → config-6IiXCmyu.js} +1 -1
  4. package/dist/preview/assets/{config--PcXQV_r.js → config-BJzUh1_G.js} +1 -1
  5. package/dist/preview/assets/{config-B5avpKJE.js → config-Bl80ye-i.js} +1 -1
  6. package/dist/preview/assets/{config-DDfTl9Cs.js → config-CZOeZ8ty.js} +1 -1
  7. package/dist/preview/assets/{config-CJHPt8Gx.js → config-DaZD4ZSa.js} +1 -1
  8. package/dist/preview/assets/{config-CNo3isHa.js → config-DhsbcNzx.js} +1 -1
  9. package/dist/preview/assets/{config-5KVDXgUF.js → config-Diuyh0Ex.js} +1 -1
  10. package/dist/preview/assets/{config-D0_1yZdF.js → config-aK67Rsw5.js} +1 -1
  11. package/dist/preview/assets/{config-CQHS6cZe.js → config-rpX_Mc6I.js} +1 -1
  12. package/dist/preview/assets/{definition.vue_vue_type_script_setup_true_lang-RM-qDh0R.js → definition.vue_vue_type_script_setup_true_lang-C_jU8d47.js} +1 -1
  13. package/dist/preview/assets/{index-a2QwAots.css → index-2eQR4s3q.css} +1 -1
  14. package/dist/preview/assets/index-DEF3_MKr.js +659 -0
  15. package/dist/preview/assets/index-Df-thth9.js +1 -0
  16. package/dist/preview/assets/{runtime-Dr_10emf.js → runtime-3p1K6te5.js} +1 -1
  17. package/dist/preview/assets/{runtime-C_XX6a0C.js → runtime-BcLnafic.js} +1 -1
  18. package/dist/preview/assets/{runtime-CtqwtTE_.js → runtime-CSaV-359.js} +1 -1
  19. package/dist/preview/assets/{runtime-CCbyrqQT.js → runtime-CjR8Vi5N.js} +1 -1
  20. package/dist/preview/assets/{runtime-BGTWf-O7.js → runtime-D_fJCKX_.js} +1 -1
  21. package/dist/preview/assets/{runtime-BPjZQmcY.js → runtime-DpeCgGEG.js} +1 -1
  22. package/dist/preview/assets/{runtime-DcrzodsN.js → runtime-K2a1x0TJ.js} +1 -1
  23. package/dist/preview/assets/{runtime-Dy4ZmQ-n.js → runtime-g9Zu3VNQ.js} +1 -1
  24. package/dist/preview/assets/{runtime-Bq3fmxeF.js → runtime-jTnh_6Dm.js} +1 -1
  25. package/dist/preview/index.html +2 -2
  26. package/dist/runtime/components/block-layout-editor/index.d.vue.ts +10 -2
  27. package/dist/runtime/components/block-layout-editor/index.vue +44 -8
  28. package/dist/runtime/components/block-layout-editor/index.vue.d.ts +10 -2
  29. package/dist/runtime/components/config/config.vue +35 -0
  30. package/dist/runtime/components/config/use-editor.d.ts +11 -1
  31. package/dist/runtime/components/config/use-editor.js +27 -1
  32. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/config.d.vue.ts +163 -0
  33. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/config.vue +745 -0
  34. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/config.vue.d.ts +163 -0
  35. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/runtime.d.vue.ts +8 -0
  36. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/runtime.vue +383 -0
  37. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/runtime.vue.d.ts +8 -0
  38. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/schema.d.ts +264 -0
  39. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/schema.js +183 -0
  40. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/config.d.vue.ts +163 -0
  41. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/config.vue +745 -0
  42. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/config.vue.d.ts +163 -0
  43. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/runtime.d.vue.ts +8 -0
  44. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/runtime.vue +402 -0
  45. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/runtime.vue.d.ts +8 -0
  46. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/schema.d.ts +264 -0
  47. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/schema.js +209 -0
  48. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/config.d.vue.ts +129 -0
  49. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/config.vue +618 -0
  50. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/config.vue.d.ts +129 -0
  51. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/runtime.d.vue.ts +8 -0
  52. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/runtime.vue +501 -0
  53. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/runtime.vue.d.ts +8 -0
  54. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/schema.d.ts +99 -0
  55. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/schema.js +133 -0
  56. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/config.d.vue.ts +127 -0
  57. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/config.vue +550 -0
  58. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/config.vue.d.ts +127 -0
  59. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/runtime.d.vue.ts +8 -0
  60. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/runtime.vue +496 -0
  61. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/runtime.vue.d.ts +8 -0
  62. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/schema.d.ts +96 -0
  63. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/schema.js +125 -0
  64. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/config.d.vue.ts +133 -0
  65. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/config.vue +605 -0
  66. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/config.vue.d.ts +133 -0
  67. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/runtime.d.vue.ts +8 -0
  68. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/runtime.vue +401 -0
  69. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/runtime.vue.d.ts +8 -0
  70. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/schema.d.ts +102 -0
  71. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/schema.js +142 -0
  72. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/config.d.vue.ts +131 -0
  73. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/config.vue +560 -0
  74. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/config.vue.d.ts +131 -0
  75. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/runtime.d.vue.ts +8 -0
  76. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/runtime.vue +395 -0
  77. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/runtime.vue.d.ts +8 -0
  78. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/schema.d.ts +96 -0
  79. package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/schema.js +118 -0
  80. package/dist/runtime/components/form/fields/2026-05-28/tree-combobox-shared.d.ts +35 -0
  81. package/dist/runtime/components/form/fields/2026-05-28/tree-combobox-shared.js +31 -0
  82. package/dist/runtime/components/form/unit-config.vue +45 -1
  83. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/config.d.vue.ts +183 -0
  84. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/config.vue +931 -0
  85. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/config.vue.d.ts +183 -0
  86. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/runtime.d.vue.ts +9 -0
  87. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/runtime.vue +463 -0
  88. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/runtime.vue.d.ts +9 -0
  89. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/schema.d.ts +283 -0
  90. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/schema.js +275 -0
  91. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/config.d.vue.ts +183 -0
  92. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/config.vue +931 -0
  93. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/config.vue.d.ts +183 -0
  94. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/runtime.d.vue.ts +9 -0
  95. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/runtime.vue +414 -0
  96. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/runtime.vue.d.ts +9 -0
  97. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/schema.d.ts +283 -0
  98. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/schema.js +275 -0
  99. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/config.d.vue.ts +133 -0
  100. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/config.vue +632 -0
  101. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/config.vue.d.ts +133 -0
  102. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/runtime.d.vue.ts +9 -0
  103. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/runtime.vue +461 -0
  104. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/runtime.vue.d.ts +9 -0
  105. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/schema.d.ts +93 -0
  106. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/schema.js +161 -0
  107. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/config.d.vue.ts +131 -0
  108. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/config.vue +563 -0
  109. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/config.vue.d.ts +131 -0
  110. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/runtime.d.vue.ts +9 -0
  111. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/runtime.vue +443 -0
  112. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/runtime.vue.d.ts +9 -0
  113. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/schema.d.ts +90 -0
  114. package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/schema.js +153 -0
  115. package/dist/runtime/components/table/columns/2026-05-28/tree-combobox-shared.d.ts +35 -0
  116. package/dist/runtime/components/table/columns/2026-05-28/tree-combobox-shared.js +31 -0
  117. package/dist/runtime/components/table/config.vue +1 -30
  118. package/dist/runtime/components/ui/command/CommandItem.d.vue.ts +7 -0
  119. package/dist/runtime/components/ui/command/CommandItem.vue +13 -4
  120. package/dist/runtime/components/ui/command/CommandItem.vue.d.ts +7 -0
  121. package/dist/runtime/share/clipboard.d.ts +26 -0
  122. package/dist/runtime/share/clipboard.js +82 -0
  123. package/dist/runtime/share/layout.d.ts +4 -0
  124. package/dist/runtime/share/layout.js +35 -0
  125. package/package.json +1 -1
  126. package/dist/preview/assets/index-DNd8J9Zv.js +0 -643
  127. package/dist/preview/assets/index-DrIMqXAa.js +0 -1
@@ -0,0 +1,496 @@
1
+ <script setup>
2
+ import { Icon } from "@iconify/vue";
3
+ import { Effect, Fiber, Option } from "effect";
4
+ import { Fetch } from "fx-fetch";
5
+ import { computed, ref, shallowRef, watch } from "vue";
6
+ import { useI18n } from "vue-i18n";
7
+ import { cel as _rawCel } from "../../../../../utils/cel";
8
+ import { celBindings, injectCELContext } from "../../../../../utils/cel-context";
9
+ import { getLocalizedText } from "../../../../../share/locale";
10
+ import { Field, FieldLabel } from "../../../../ui/field";
11
+ import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../../../../ui/input-group";
12
+ import { Markdown } from "../../../../ui/markdown";
13
+ import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "../../../../ui/popover";
14
+ import { Skeleton } from "../../../../ui/skeleton";
15
+ import { Tree as UiTree } from "../../../../ui/tree";
16
+ import { interpolateMarkdown } from "../../../../table/utils/runtime";
17
+ import { DEFAULT_FIELD_ORIENTATION } from "../../../utils/common";
18
+ import { useFormReadonly } from "../../../utils/readonly";
19
+ import { useFormState } from "../../../utils/state";
20
+ import {
21
+ findWrappedPath,
22
+ getWrappedChildren,
23
+ wrapStructuralAll
24
+ } from "../tree-combobox-shared";
25
+ defineOptions({ name: "ShwfedTreeComboboxSingleFieldRuntime" });
26
+ const props = defineProps({
27
+ fieldId: { type: String, required: true },
28
+ config: { type: null, required: true }
29
+ });
30
+ const { locale, t } = useI18n({
31
+ inheritLocale: true,
32
+ messages: {
33
+ zh: {
34
+ "tree-combobox-single-placeholder": "\u8BF7\u9009\u62E9",
35
+ "tree-combobox-single-search-placeholder": "\u641C\u7D22\u2026",
36
+ "tree-combobox-single-search-clear": "\u6E05\u9664\u641C\u7D22",
37
+ "tree-combobox-single-empty": "\u65E0\u53EF\u9009\u9879",
38
+ "tree-combobox-single-load-error": "\u52A0\u8F7D\u5931\u8D25",
39
+ "tree-combobox-single-retry": "\u91CD\u8BD5",
40
+ "tree-combobox-single-readonly-empty": "\u2014"
41
+ },
42
+ en: {
43
+ "tree-combobox-single-placeholder": "Select\u2026",
44
+ "tree-combobox-single-search-placeholder": "Search\u2026",
45
+ "tree-combobox-single-search-clear": "Clear search",
46
+ "tree-combobox-single-empty": "No options",
47
+ "tree-combobox-single-load-error": "Failed to load",
48
+ "tree-combobox-single-retry": "Retry",
49
+ "tree-combobox-single-readonly-empty": "\u2014"
50
+ },
51
+ ja: {
52
+ "tree-combobox-single-placeholder": "\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044",
53
+ "tree-combobox-single-search-placeholder": "\u691C\u7D22\u2026",
54
+ "tree-combobox-single-search-clear": "\u691C\u7D22\u3092\u30AF\u30EA\u30A2",
55
+ "tree-combobox-single-empty": "\u9078\u629E\u80A2\u306A\u3057",
56
+ "tree-combobox-single-load-error": "\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
57
+ "tree-combobox-single-retry": "\u518D\u8A66\u884C",
58
+ "tree-combobox-single-readonly-empty": "\u2014"
59
+ }
60
+ }
61
+ });
62
+ const { state, getAt, setAt } = useFormState();
63
+ const inherited = injectCELContext();
64
+ const $cel = (expression, context) => _rawCel(expression, { ...celBindings(inherited), ...context });
65
+ const labelText = computed(() => getLocalizedText(props.config.label, locale.value));
66
+ const tooltipText = computed(
67
+ () => props.config.tooltip ? getLocalizedText(props.config.tooltip, locale.value) : void 0
68
+ );
69
+ const placeholderText = computed(
70
+ () => props.config.placeholder ? getLocalizedText(props.config.placeholder, locale.value) : t("tree-combobox-single-placeholder")
71
+ );
72
+ function evalBool(expression, label) {
73
+ if (!expression) return false;
74
+ try {
75
+ return Effect.runSync($cel(expression, { form: state.value ?? {} }));
76
+ } catch (err) {
77
+ console.error(`[shwfed-form] failed to evaluate ${label} for ${props.fieldId}:`, err);
78
+ return false;
79
+ }
80
+ }
81
+ const isDisabled = computed(() => evalBool(props.config.disabled, "disabled"));
82
+ const formReadonly = useFormReadonly();
83
+ const isReadonly = computed(
84
+ () => props.config.readonly != null ? evalBool(props.config.readonly, "readonly") : formReadonly.value
85
+ );
86
+ const effectiveReadonly = computed(() => isReadonly.value || props.config.derived?.mode === "formula");
87
+ const uncontrolled = ref(void 0);
88
+ const model = computed({
89
+ get: () => {
90
+ const path = props.config.binding;
91
+ const raw = path == null ? uncontrolled.value : getAt(path);
92
+ if (raw == null) return void 0;
93
+ return String(raw);
94
+ },
95
+ set: (next) => {
96
+ const v = next == null ? void 0 : String(next);
97
+ const path = props.config.binding;
98
+ if (path == null) {
99
+ uncontrolled.value = v;
100
+ return;
101
+ }
102
+ setAt(path, v);
103
+ }
104
+ });
105
+ function nodeCtx(raw) {
106
+ return { form: state.value ?? {}, node: raw };
107
+ }
108
+ function nodeKey(raw) {
109
+ try {
110
+ return String(Effect.runSync($cel(props.config.nodeKey, nodeCtx(raw))));
111
+ } catch (err) {
112
+ console.error(`[shwfed-form] failed to evaluate nodeKey for ${props.fieldId}:`, err);
113
+ return "";
114
+ }
115
+ }
116
+ function nodeChildrenList(raw) {
117
+ let v;
118
+ try {
119
+ v = Effect.runSync($cel(props.config.nodeChildren, nodeCtx(raw)));
120
+ } catch (err) {
121
+ console.error(`[shwfed-form] failed to evaluate nodeChildren for ${props.fieldId}:`, err);
122
+ return void 0;
123
+ }
124
+ if (v == null) return void 0;
125
+ if (!Array.isArray(v)) return void 0;
126
+ return v;
127
+ }
128
+ function safeInterpolate(tpl, raw) {
129
+ try {
130
+ return interpolateMarkdown(tpl, $cel, nodeCtx(raw));
131
+ } catch (err) {
132
+ console.error(`[shwfed-form] failed to interpolate node text for ${props.fieldId}:`, err);
133
+ return tpl;
134
+ }
135
+ }
136
+ function wrappedLabelText(w) {
137
+ const tpl = getLocalizedText(props.config.nodeLabel, locale.value) ?? "";
138
+ return tpl ? safeInterpolate(tpl, w.raw) : "";
139
+ }
140
+ function wrappedTooltipText(w) {
141
+ if (!props.config.nodeTooltip) return void 0;
142
+ const tpl = getLocalizedText(props.config.nodeTooltip, locale.value);
143
+ return tpl ? safeInterpolate(tpl, w.raw) : void 0;
144
+ }
145
+ function wrappedSelectable(w, _depth) {
146
+ if (isDisabled.value) return false;
147
+ const expr = props.config.nodeSelectable;
148
+ if (!expr) return true;
149
+ try {
150
+ return Effect.runSync($cel(expr, nodeCtx(w.raw)));
151
+ } catch {
152
+ return false;
153
+ }
154
+ }
155
+ function evalKeywords(raw) {
156
+ const expr = props.config.keywords;
157
+ if (!expr) return [];
158
+ try {
159
+ const v = Effect.runSync($cel(expr, nodeCtx(raw)));
160
+ if (!Array.isArray(v)) return [];
161
+ return v.map((k) => String(k));
162
+ } catch {
163
+ return [];
164
+ }
165
+ }
166
+ const rawRoots = shallowRef([]);
167
+ const loading = ref(false);
168
+ const fetchError = ref(null);
169
+ async function fetchTree() {
170
+ const dataSource = props.config.dataSource;
171
+ if (!dataSource) {
172
+ rawRoots.value = [];
173
+ return;
174
+ }
175
+ const effect = Effect.gen(function* () {
176
+ let jsonOpt = Option.none();
177
+ if (dataSource.request) {
178
+ const builder = yield* $cel(dataSource.request, {
179
+ form: state.value ?? {}
180
+ });
181
+ const response = yield* builder.json();
182
+ jsonOpt = Option.some(response);
183
+ }
184
+ const dataRaw = yield* $cel(dataSource.data, {
185
+ form: state.value ?? {},
186
+ json: jsonOpt
187
+ });
188
+ return Array.isArray(dataRaw) ? dataRaw : [];
189
+ });
190
+ const program = Effect.gen(function* () {
191
+ const showMaskFiber = yield* Effect.fork(
192
+ Effect.sync(() => {
193
+ loading.value = true;
194
+ }).pipe(Effect.delay("30 millis"))
195
+ );
196
+ return yield* Effect.ensuring(effect, Fiber.interrupt(showMaskFiber));
197
+ }).pipe(
198
+ Effect.ensuring(Effect.sync(() => {
199
+ loading.value = false;
200
+ }))
201
+ );
202
+ try {
203
+ const result = await Effect.runPromise(Effect.provide(program, Fetch.layer));
204
+ rawRoots.value = result;
205
+ fetchError.value = null;
206
+ } catch (e) {
207
+ console.warn("[shwfed-form] tree-combobox dataSource fetch failed", e);
208
+ fetchError.value = e;
209
+ }
210
+ }
211
+ watch(
212
+ () => [props.config.dataSource?.request, props.config.dataSource?.data],
213
+ () => {
214
+ void fetchTree();
215
+ },
216
+ { immediate: true }
217
+ );
218
+ const roots = computed(
219
+ () => wrapStructuralAll(rawRoots.value, {
220
+ nodeKey,
221
+ nodeChildren: nodeChildrenList
222
+ })
223
+ );
224
+ const triggerLabel = computed(() => {
225
+ const k = model.value;
226
+ if (!k) return "";
227
+ const path = findWrappedPath(roots.value, k);
228
+ if (!path || path.length === 0) return "";
229
+ const leaf = path[path.length - 1];
230
+ return wrappedLabelText(leaf);
231
+ });
232
+ const initialExpanded = computed(() => {
233
+ if (!props.config.expandAll) return [];
234
+ const out = [];
235
+ const stack = [...roots.value];
236
+ while (stack.length) {
237
+ const n = stack.pop();
238
+ if (n.kind === "branch") {
239
+ out.push(n.key);
240
+ stack.push(...n.children);
241
+ }
242
+ }
243
+ return out;
244
+ });
245
+ const filterQuery = ref("");
246
+ const searchCorpus = shallowRef(/* @__PURE__ */ new Map());
247
+ watch(
248
+ () => [
249
+ roots.value,
250
+ locale.value,
251
+ props.config.nodeLabel,
252
+ props.config.keywords
253
+ ],
254
+ () => {
255
+ const map = /* @__PURE__ */ new Map();
256
+ const stack = [...roots.value];
257
+ while (stack.length) {
258
+ const n = stack.pop();
259
+ const label = wrappedLabelText(n).trim().toLowerCase();
260
+ const kw = evalKeywords(n.raw).map((k) => k.trim().toLowerCase()).join("\n");
261
+ map.set(n.key, kw ? `${label}
262
+ ${kw}` : label);
263
+ if (n.kind === "branch") stack.push(...n.children);
264
+ }
265
+ searchCorpus.value = map;
266
+ },
267
+ { immediate: true }
268
+ );
269
+ function filterPredicate(w, query) {
270
+ const q = query.trim().toLowerCase();
271
+ if (!q) return true;
272
+ const hay = searchCorpus.value.get(w.key);
273
+ if (hay !== void 0) return hay.includes(q);
274
+ return wrappedLabelText(w).trim().toLowerCase().includes(q);
275
+ }
276
+ const open = ref(false);
277
+ function handleUpdate(next) {
278
+ const k = typeof next === "string" ? next : void 0;
279
+ model.value = k;
280
+ if (k) open.value = false;
281
+ }
282
+ const showClear = computed(
283
+ () => !isDisabled.value && !loading.value && !!model.value
284
+ );
285
+ function handleClear() {
286
+ model.value = void 0;
287
+ open.value = false;
288
+ }
289
+ const hoveredKey = ref(null);
290
+ watch(open, (isOpen) => {
291
+ if (!isOpen) hoveredKey.value = null;
292
+ });
293
+ function collectTooltipNodes(out, siblings) {
294
+ for (const n of siblings) {
295
+ if (wrappedTooltipText(n)) out.push(n.key);
296
+ if (n.kind === "branch") collectTooltipNodes(out, n.children);
297
+ }
298
+ }
299
+ const anyHasTooltip = computed(() => {
300
+ if (!props.config.nodeTooltip) return false;
301
+ const out = [];
302
+ collectTooltipNodes(out, roots.value);
303
+ return out.length > 0;
304
+ });
305
+ const hoveredTooltip = computed(() => {
306
+ const k = hoveredKey.value;
307
+ if (!k) return void 0;
308
+ const path = findWrappedPath(roots.value, k);
309
+ if (!path || path.length === 0) return void 0;
310
+ return wrappedTooltipText(path[path.length - 1]);
311
+ });
312
+ </script>
313
+
314
+ <template>
315
+ <Field
316
+ :orientation="config.orientation ?? DEFAULT_FIELD_ORIENTATION"
317
+ :data-disabled="isDisabled || void 0"
318
+ >
319
+ <FieldLabel
320
+ v-if="labelText"
321
+ :for="fieldId"
322
+ class="text-xs text-zinc-500"
323
+ >
324
+ <template
325
+ v-if="tooltipText"
326
+ #tooltip
327
+ >
328
+ <Markdown
329
+ :source="tooltipText"
330
+ class="prose prose-xs prose-zinc"
331
+ />
332
+ </template>
333
+ {{ labelText }}
334
+ </FieldLabel>
335
+
336
+ <div
337
+ v-if="effectiveReadonly"
338
+ class="min-h-9 py-1.5 text-sm text-zinc-700"
339
+ >
340
+ {{ triggerLabel || t("tree-combobox-single-readonly-empty") }}
341
+ </div>
342
+
343
+ <Popover
344
+ v-else
345
+ v-model:open="open"
346
+ >
347
+ <PopoverAnchor as-child>
348
+ <InputGroup
349
+ class="group/tree-combobox-single"
350
+ :data-disabled="isDisabled ? 'true' : void 0"
351
+ >
352
+ <PopoverTrigger as-child>
353
+ <InputGroupInput
354
+ :id="fieldId"
355
+ :model-value="triggerLabel"
356
+ :disabled="isDisabled"
357
+ :placeholder="placeholderText"
358
+ class="cursor-pointer text-left"
359
+ readonly
360
+ />
361
+ </PopoverTrigger>
362
+ <InputGroupAddon
363
+ v-if="loading"
364
+ align="inline-end"
365
+ data-slot="tree-combobox-single-loading"
366
+ class="text-zinc-400"
367
+ >
368
+ <Icon
369
+ icon="fluent:spinner-ios-20-regular"
370
+ class="animate-spin"
371
+ />
372
+ </InputGroupAddon>
373
+ <InputGroupAddon
374
+ v-else-if="showClear"
375
+ align="inline-end"
376
+ class="[@media(hover:hover)]:opacity-0 transition-opacity group-hover/tree-combobox-single:opacity-100 focus-within:opacity-100"
377
+ >
378
+ <InputGroupButton
379
+ size="icon-xs"
380
+ data-slot="tree-combobox-single-clear"
381
+ class="text-zinc-500 hover:text-zinc-700"
382
+ tabindex="-1"
383
+ @mousedown.prevent
384
+ @click.stop="handleClear"
385
+ >
386
+ <Icon icon="fluent:dismiss-20-regular" />
387
+ </InputGroupButton>
388
+ </InputGroupAddon>
389
+ </InputGroup>
390
+ </PopoverAnchor>
391
+ <PopoverContent
392
+ class="p-0"
393
+ :style="{ width: 'var(--reka-popover-trigger-width)' }"
394
+ >
395
+ <div
396
+ data-slot="tree-combobox-single-search"
397
+ class="flex h-9 items-center gap-2 border-b border-zinc-200 px-3"
398
+ >
399
+ <Icon
400
+ icon="fluent:search-20-filled"
401
+ class="size-3.5 shrink-0 opacity-50"
402
+ />
403
+ <input
404
+ v-model="filterQuery"
405
+ :disabled="isDisabled"
406
+ :placeholder="t('tree-combobox-single-search-placeholder')"
407
+ class="flex h-9 w-full bg-transparent text-sm outline-hidden placeholder:text-zinc-500 disabled:cursor-not-allowed disabled:opacity-50"
408
+ >
409
+ </div>
410
+ <div class="flex flex-col p-1">
411
+ <div
412
+ v-if="fetchError && roots.length === 0"
413
+ class="min-h-9 px-2 py-1.5 text-sm text-red-500"
414
+ >
415
+ {{ t("tree-combobox-single-load-error") }}
416
+ </div>
417
+ <div
418
+ v-else-if="loading && roots.length === 0"
419
+ class="flex flex-col gap-1.5 px-2 py-1"
420
+ aria-busy="true"
421
+ >
422
+ <Skeleton class="h-5 w-2/3" />
423
+ <Skeleton class="h-5 w-1/2" />
424
+ <Skeleton class="h-5 w-3/5" />
425
+ </div>
426
+
427
+ <UiTree
428
+ v-else
429
+ :roots="roots"
430
+ :get-key="(w) => w.key"
431
+ :get-children="getWrappedChildren"
432
+ selection-mode="single"
433
+ :model-value="model"
434
+ :selectable="wrappedSelectable"
435
+ :filter-predicate="filterPredicate"
436
+ :filter-query="filterQuery"
437
+ :initial-expanded="initialExpanded"
438
+ :show-focused-row="false"
439
+ :class="isDisabled ? 'pointer-events-none opacity-60' : void 0"
440
+ class="max-h-72 overflow-y-auto"
441
+ @update:model-value="handleUpdate"
442
+ >
443
+ <template #node="{ node, selected }">
444
+ <span
445
+ class="flex flex-1 min-w-0 items-center justify-between gap-2"
446
+ @mouseenter="hoveredKey = node.key"
447
+ @focusin="hoveredKey = node.key"
448
+ >
449
+ <Markdown
450
+ :source="wrappedLabelText(node)"
451
+ class="prose prose-sm prose-zinc text-zinc-700 min-w-0"
452
+ />
453
+ <Icon
454
+ v-if="selected"
455
+ icon="fluent:checkmark-20-regular"
456
+ class="size-3 shrink-0 text-zinc-700"
457
+ />
458
+ </span>
459
+ </template>
460
+
461
+ <template #empty>
462
+ <div class="min-h-9 px-2 py-1.5 text-sm text-zinc-400">
463
+ {{ t("tree-combobox-single-empty") }}
464
+ </div>
465
+ </template>
466
+
467
+ <template #error="{ error, retry }">
468
+ <span class="inline-flex items-center gap-1 text-xs text-red-500">
469
+ {{ t("tree-combobox-single-load-error") }}
470
+ <button
471
+ type="button"
472
+ class="underline hover:text-red-600"
473
+ @click.stop="retry"
474
+ >
475
+ {{ t("tree-combobox-single-retry") }}
476
+ </button>
477
+ <span class="sr-only">{{ String(error) }}</span>
478
+ </span>
479
+ </template>
480
+ </UiTree>
481
+ </div>
482
+ <div
483
+ v-if="anyHasTooltip && hoveredTooltip"
484
+ data-slot="tree-combobox-single-tooltip"
485
+ class="border-t border-zinc-200 px-3 py-2"
486
+ >
487
+ <Markdown
488
+ :source="hoveredTooltip"
489
+ block
490
+ class="prose prose-sm prose-zinc"
491
+ />
492
+ </div>
493
+ </PopoverContent>
494
+ </Popover>
495
+ </Field>
496
+ </template>
@@ -0,0 +1,8 @@
1
+ import type { Value } from './schema.js';
2
+ type __VLS_Props = {
3
+ fieldId: string;
4
+ config: Value;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,96 @@
1
+ import { Schema } from 'effect';
2
+ import type { Environment } from '../../../../../vendor/cel-js/lib/index.js';
3
+ import type { MigrateFn, MigrateSource } from '../../../utils/resolve.js';
4
+ export declare const type: "com.shwfed.form.field.tree.combobox.single";
5
+ export declare const compatibilityDate: "2026-05-28";
6
+ export declare const metadata: {
7
+ readonly name: "下拉树(单选)";
8
+ readonly icon: "fluent:tree-evergreen-20-regular";
9
+ readonly w: {
10
+ readonly initial: 8;
11
+ readonly min: 4;
12
+ readonly max: number;
13
+ };
14
+ readonly h: {
15
+ readonly initial: 2;
16
+ readonly min: 2;
17
+ readonly max: 2;
18
+ };
19
+ };
20
+ export declare function schema(configure: (env: Environment) => void): Schema.Struct<{
21
+ label: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
22
+ locale: Schema.Literal<["zh"]>;
23
+ message: Schema.SchemaClass<string, string, never>;
24
+ }>], [Schema.Struct<{
25
+ locale: Schema.Literal<["ja", "en", "ko"]>;
26
+ message: Schema.SchemaClass<string, string, never>;
27
+ }>]>>;
28
+ placeholder: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
29
+ locale: Schema.Literal<["zh"]>;
30
+ message: Schema.SchemaClass<string, string, never>;
31
+ }>], [Schema.Struct<{
32
+ locale: Schema.Literal<["ja", "en", "ko"]>;
33
+ message: Schema.SchemaClass<string, string, never>;
34
+ }>]>>;
35
+ tooltip: Schema.optional<Schema.TupleType<readonly [Schema.Struct<{
36
+ locale: Schema.Literal<["zh"]>;
37
+ message: Schema.SchemaClass<string, string, never>;
38
+ }>], [Schema.Struct<{
39
+ locale: Schema.Literal<["ja", "en", "ko"]>;
40
+ message: Schema.SchemaClass<string, string, never>;
41
+ }>]>>;
42
+ orientation: Schema.optional<Schema.Literal<["vertical", "floating"]>>;
43
+ binding: Schema.optional<Schema.refine<string, typeof Schema.String>>;
44
+ disabled: Schema.optional<Schema.Schema<string, string, never>>;
45
+ readonly: Schema.optional<Schema.Schema<string, string, never>>;
46
+ derived: Schema.optional<Schema.Struct<{
47
+ mode: Schema.Literal<["formula", "prefill"]>;
48
+ expression: Schema.Schema<string, string, never>;
49
+ }>>;
50
+ dataSource: Schema.Struct<{
51
+ request: Schema.optional<Schema.Schema<string, string, never>>;
52
+ data: Schema.Schema<string, string, never>;
53
+ }>;
54
+ nodeKey: Schema.Schema<string, string, never>;
55
+ nodeChildren: Schema.Schema<string, string, never>;
56
+ nodeLabel: Schema.refine<readonly [{
57
+ readonly locale: "zh";
58
+ readonly message: string;
59
+ }, ...{
60
+ readonly locale: "en" | "ja" | "ko";
61
+ readonly message: string;
62
+ }[]], Schema.TupleType<readonly [Schema.Struct<{
63
+ locale: Schema.Literal<["zh"]>;
64
+ message: Schema.SchemaClass<string, string, never>;
65
+ }>], [Schema.Struct<{
66
+ locale: Schema.Literal<["ja", "en", "ko"]>;
67
+ message: Schema.SchemaClass<string, string, never>;
68
+ }>]>>;
69
+ nodeTooltip: Schema.optional<Schema.refine<readonly [{
70
+ readonly locale: "zh";
71
+ readonly message: string;
72
+ }, ...{
73
+ readonly locale: "en" | "ja" | "ko";
74
+ readonly message: string;
75
+ }[]], Schema.TupleType<readonly [Schema.Struct<{
76
+ locale: Schema.Literal<["zh"]>;
77
+ message: Schema.SchemaClass<string, string, never>;
78
+ }>], [Schema.Struct<{
79
+ locale: Schema.Literal<["ja", "en", "ko"]>;
80
+ message: Schema.SchemaClass<string, string, never>;
81
+ }>]>>>;
82
+ nodeSelectable: Schema.optional<Schema.Schema<string, string, never>>;
83
+ keywords: Schema.optional<Schema.Schema<string, string, never>>;
84
+ expandAll: Schema.optionalWith<typeof Schema.Boolean, {
85
+ default: () => false;
86
+ }>;
87
+ id: Schema.refine<string, typeof Schema.String>;
88
+ displayName: Schema.optional<Schema.SchemaClass<string, string, never>>;
89
+ hidden: Schema.optional<Schema.Schema<string, string, never>>;
90
+ type: Schema.Literal<["com.shwfed.form.field.tree.combobox.single"]>;
91
+ compatibilityDate: Schema.Literal<["2026-05-28"]>;
92
+ }>;
93
+ export type Value = Schema.Schema.Type<ReturnType<typeof schema>>;
94
+ export declare function defaults(): Partial<Value>;
95
+ export declare const migrateFrom: ReadonlyArray<MigrateSource>;
96
+ export declare const migrate: MigrateFn;