@tmagic/form 1.7.7 → 1.7.8-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +235 -164
  2. package/dist/es/Form.js +5 -0
  3. package/dist/es/Form.vue_vue_type_script_setup_true_lang.js +234 -0
  4. package/dist/es/FormBox.js +5 -0
  5. package/dist/es/FormBox.vue_vue_type_script_setup_true_lang.js +117 -0
  6. package/dist/es/FormDialog.js +5 -0
  7. package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +222 -0
  8. package/dist/es/FormDrawer.js +5 -0
  9. package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +176 -0
  10. package/dist/es/_virtual/_rolldown/runtime.js +27 -0
  11. package/dist/es/containers/Col.js +5 -0
  12. package/dist/es/containers/Col.vue_vue_type_script_setup_true_lang.js +60 -0
  13. package/dist/es/containers/Container.js +5 -0
  14. package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +439 -0
  15. package/dist/es/containers/Fieldset.js +5 -0
  16. package/dist/es/containers/Fieldset.vue_vue_type_script_setup_true_lang.js +153 -0
  17. package/dist/es/containers/FlexLayout.js +5 -0
  18. package/dist/es/containers/FlexLayout.vue_vue_type_script_setup_true_lang.js +64 -0
  19. package/dist/es/containers/FormLabel.js +5 -0
  20. package/dist/es/containers/FormLabel.vue_vue_type_script_setup_true_lang.js +51 -0
  21. package/dist/es/containers/GroupList.js +5 -0
  22. package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +164 -0
  23. package/dist/es/containers/GroupListItem.js +5 -0
  24. package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +221 -0
  25. package/dist/es/containers/Panel.js +5 -0
  26. package/dist/es/containers/Panel.vue_vue_type_script_setup_true_lang.js +130 -0
  27. package/dist/es/containers/Row.js +5 -0
  28. package/dist/es/containers/Row.vue_vue_type_script_setup_true_lang.js +65 -0
  29. package/dist/es/containers/Step.js +5 -0
  30. package/dist/es/containers/Step.vue_vue_type_script_setup_true_lang.js +85 -0
  31. package/dist/es/containers/Tabs.js +5 -0
  32. package/dist/es/containers/Tabs.vue_vue_type_script_setup_true_lang.js +194 -0
  33. package/dist/es/fields/Cascader.js +5 -0
  34. package/dist/es/fields/Cascader.vue_vue_type_script_setup_true_lang.js +123 -0
  35. package/dist/es/fields/Checkbox.js +5 -0
  36. package/dist/es/fields/Checkbox.vue_vue_type_script_setup_true_lang.js +61 -0
  37. package/dist/es/fields/CheckboxGroup.js +5 -0
  38. package/dist/es/fields/CheckboxGroup.vue_vue_type_script_setup_true_lang.js +63 -0
  39. package/dist/es/fields/ColorPicker.js +5 -0
  40. package/dist/es/fields/ColorPicker.vue_vue_type_script_setup_true_lang.js +42 -0
  41. package/dist/es/fields/Date.js +5 -0
  42. package/dist/es/fields/Date.vue_vue_type_script_setup_true_lang.js +52 -0
  43. package/dist/es/fields/DateTime.js +5 -0
  44. package/dist/es/fields/DateTime.vue_vue_type_script_setup_true_lang.js +57 -0
  45. package/dist/es/fields/Daterange.js +5 -0
  46. package/dist/es/fields/Daterange.vue_vue_type_script_setup_true_lang.js +99 -0
  47. package/dist/es/fields/Display.js +5 -0
  48. package/dist/es/fields/Display.vue_vue_type_script_setup_true_lang.js +36 -0
  49. package/dist/es/fields/DynamicField.js +5 -0
  50. package/dist/es/fields/DynamicField.vue_vue_type_script_setup_true_lang.js +91 -0
  51. package/dist/es/fields/Hidden.js +5 -0
  52. package/dist/es/fields/Hidden.vue_vue_type_script_setup_true_lang.js +24 -0
  53. package/dist/es/fields/Link.js +5 -0
  54. package/dist/es/fields/Link.vue_vue_type_script_setup_true_lang.js +104 -0
  55. package/dist/es/fields/Number.js +5 -0
  56. package/dist/es/fields/Number.vue_vue_type_script_setup_true_lang.js +65 -0
  57. package/dist/es/fields/NumberRange.js +5 -0
  58. package/dist/es/fields/NumberRange.vue_vue_type_script_setup_true_lang.js +76 -0
  59. package/dist/es/fields/RadioGroup.js +5 -0
  60. package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +74 -0
  61. package/dist/es/fields/Select.js +5 -0
  62. package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +337 -0
  63. package/dist/es/fields/Switch.js +5 -0
  64. package/dist/es/fields/Switch.vue_vue_type_script_setup_true_lang.js +59 -0
  65. package/dist/es/fields/Text.js +5 -0
  66. package/dist/es/fields/Text.vue_vue_type_script_setup_true_lang.js +215 -0
  67. package/dist/es/fields/Textarea.js +5 -0
  68. package/dist/es/fields/Textarea.vue_vue_type_script_setup_true_lang.js +60 -0
  69. package/dist/es/fields/Time.js +5 -0
  70. package/dist/es/fields/Time.vue_vue_type_script_setup_true_lang.js +49 -0
  71. package/dist/es/fields/Timerange.js +5 -0
  72. package/dist/es/fields/Timerange.vue_vue_type_script_setup_true_lang.js +100 -0
  73. package/dist/es/index.js +41 -0
  74. package/dist/es/plugin.js +74 -0
  75. package/dist/es/schema.js +2 -0
  76. package/dist/es/style.css +325 -0
  77. package/dist/es/table/ActionsColumn.js +5 -0
  78. package/dist/es/table/ActionsColumn.vue_vue_type_script_setup_true_lang.js +107 -0
  79. package/dist/es/table/SortColumn.js +5 -0
  80. package/dist/es/table/SortColumn.vue_vue_type_script_setup_true_lang.js +88 -0
  81. package/dist/es/table/Table.js +5 -0
  82. package/dist/es/table/Table.vue_vue_type_script_setup_true_lang.js +232 -0
  83. package/dist/es/table/useAdd.js +71 -0
  84. package/dist/es/table/useFullscreen.js +15 -0
  85. package/dist/es/table/useImport.js +46 -0
  86. package/dist/es/table/usePagination.js +26 -0
  87. package/dist/es/table/useSelection.js +26 -0
  88. package/dist/es/table/useSortable.js +39 -0
  89. package/dist/es/table/useTableColumns.js +160 -0
  90. package/dist/es/utils/config.js +15 -0
  91. package/dist/es/utils/form.js +173 -0
  92. package/dist/es/utils/useAddField.js +13 -0
  93. package/dist/style.css +1 -1
  94. package/dist/tmagic-form.umd.cjs +7693 -8924
  95. package/package.json +7 -6
  96. package/src/containers/Container.vue +16 -10
  97. package/src/fields/Hidden.vue +6 -2
  98. package/src/index.ts +8 -82
  99. package/src/plugin.ts +102 -0
  100. package/src/table/useSortable.ts +8 -4
  101. package/src/utils/config.ts +16 -1
  102. package/types/index.d.ts +1264 -1226
  103. package/dist/tmagic-form.js +0 -5940
@@ -0,0 +1,74 @@
1
+ import { useAddField } from "../utils/useAddField.js";
2
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
3
+ import { TMagicIcon, TMagicRadio, TMagicRadioButton, TMagicRadioGroup, TMagicTooltip } from "@tmagic/design";
4
+ //#region packages/form/src/fields/RadioGroup.vue?vue&type=script&setup=true&lang.ts
5
+ var RadioGroup_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
6
+ name: "MFormRadioGroup",
7
+ __name: "RadioGroup",
8
+ props: {
9
+ config: {},
10
+ model: {},
11
+ initValues: {},
12
+ values: {},
13
+ name: {},
14
+ prop: {},
15
+ disabled: { type: Boolean },
16
+ size: {},
17
+ lastValues: {},
18
+ isCompare: { type: Boolean }
19
+ },
20
+ emits: ["change"],
21
+ setup(__props, { emit: __emit }) {
22
+ const props = __props;
23
+ const itemComponent = computed(() => props.config.childType === "button" ? TMagicRadioButton : TMagicRadio);
24
+ const emit = __emit;
25
+ const clickHandler = (item) => {
26
+ emit("change", props.model[props.name] === item ? "" : item);
27
+ };
28
+ useAddField(props.prop);
29
+ const iconSize = computed(() => {
30
+ if (props.size === "small") return "12";
31
+ if (props.size === "large") return "16";
32
+ return "14";
33
+ });
34
+ return (_ctx, _cache) => {
35
+ return __props.model ? (openBlock(), createBlock(unref(TMagicRadioGroup), {
36
+ key: 0,
37
+ "model-value": __props.model[__props.name],
38
+ size: __props.size,
39
+ disabled: __props.disabled
40
+ }, {
41
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.config.options, (option) => {
42
+ return openBlock(), createBlock(resolveDynamicComponent(itemComponent.value), {
43
+ value: option.value,
44
+ key: `${option.value}`,
45
+ onClick: ($event) => clickHandler(option.value)
46
+ }, {
47
+ default: withCtx(() => [createVNode(unref(TMagicTooltip), {
48
+ disabled: !Boolean(option.tooltip),
49
+ placement: "top-start",
50
+ content: option.tooltip
51
+ }, {
52
+ default: withCtx(() => [createElementVNode("div", null, [option.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
53
+ key: 0,
54
+ size: iconSize.value
55
+ }, {
56
+ default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(option.icon)))]),
57
+ _: 2
58
+ }, 1032, ["size"])) : createCommentVNode("v-if", true), createElementVNode("span", null, toDisplayString(option.text), 1)])]),
59
+ _: 2
60
+ }, 1032, ["disabled", "content"])]),
61
+ _: 2
62
+ }, 1032, ["value", "onClick"]);
63
+ }), 128))]),
64
+ _: 1
65
+ }, 8, [
66
+ "model-value",
67
+ "size",
68
+ "disabled"
69
+ ])) : createCommentVNode("v-if", true);
70
+ };
71
+ }
72
+ });
73
+ //#endregion
74
+ export { RadioGroup_vue_vue_type_script_setup_true_lang_default as default };
@@ -0,0 +1,5 @@
1
+ import Select_vue_vue_type_script_setup_true_lang_default from "./Select.vue_vue_type_script_setup_true_lang.js";
2
+ //#region packages/form/src/fields/Select.vue
3
+ var Select_default = Select_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { Select_default as default };
@@ -0,0 +1,337 @@
1
+ import { useAddField } from "../utils/useAddField.js";
2
+ import { getConfig } from "../utils/config.js";
3
+ import { Fragment, createBlock, createCommentVNode, createElementBlock, defineComponent, inject, mergeProps, nextTick, onBeforeMount, openBlock, ref, renderList, resolveDirective, resolveDynamicComponent, unref, watch, watchEffect, withCtx, withDirectives } from "vue";
4
+ import { getValueByKeyPath } from "@tmagic/utils";
5
+ import { TMagicSelect, getDesignConfig } from "@tmagic/design";
6
+ //#region packages/form/src/fields/Select.vue?vue&type=script&setup=true&lang.ts
7
+ var _hoisted_1 = { key: 2 };
8
+ var Select_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
9
+ name: "MFormSelect",
10
+ __name: "Select",
11
+ props: {
12
+ config: {},
13
+ model: {},
14
+ initValues: {},
15
+ values: {},
16
+ name: {},
17
+ prop: {},
18
+ disabled: { type: Boolean },
19
+ size: {},
20
+ lastValues: {},
21
+ isCompare: { type: Boolean }
22
+ },
23
+ emits: ["change"],
24
+ setup(__props, { expose: __expose, emit: __emit }) {
25
+ const props = __props;
26
+ const emit = __emit;
27
+ const optionComponent = getDesignConfig("components")?.option;
28
+ const optionGroupComponent = getDesignConfig("components")?.optionGroup;
29
+ if (!props.model) throw new Error("不能没有model");
30
+ useAddField(props.prop);
31
+ const tMagicSelect = ref();
32
+ const mForm = inject("mForm");
33
+ const options = ref([]);
34
+ const localOptions = ref([]);
35
+ const loading = ref(false);
36
+ const moreLoadingVisible = ref(false);
37
+ const total = ref(0);
38
+ const pgIndex = ref(0);
39
+ const pgSize = ref(20);
40
+ const query = ref("");
41
+ const remoteData = ref([]);
42
+ const remote = ref(true);
43
+ const equalValue = (value, v) => {
44
+ if (typeof v === "object") {
45
+ const key = props.config.valueKey || "value";
46
+ return v[key] === value[key];
47
+ }
48
+ return value === v;
49
+ };
50
+ const mapOptions = (data) => {
51
+ const { option = {
52
+ text: "text",
53
+ value: "value"
54
+ } } = props.config;
55
+ const { text = "text", value = "value" } = option;
56
+ return data.map((item) => ({
57
+ text: typeof text === "function" ? text(item) : item[text],
58
+ value: typeof value === "function" ? value(item) : item[value]
59
+ }));
60
+ };
61
+ const getOptions = async () => {
62
+ if (!props.model) return [];
63
+ if (localOptions.value.length) return localOptions.value;
64
+ loading.value = true;
65
+ let items = [];
66
+ const { option } = props.config;
67
+ if (!option) return [];
68
+ const { root = "", totalKey = "total" } = option;
69
+ let { body = {}, url } = option;
70
+ if (typeof url === "function") url = await url(mForm, {
71
+ model: props.model,
72
+ formValue: mForm?.values
73
+ });
74
+ let postOptions = {
75
+ method: option.method || "POST",
76
+ url,
77
+ cache: option.cache,
78
+ timeout: option.timeout,
79
+ mode: option.mode,
80
+ headers: option.headers || {},
81
+ json: option.json || false
82
+ };
83
+ if (typeof body === "function") body = body(mForm, {
84
+ model: props.model,
85
+ formValue: mForm?.values,
86
+ formValues: mForm?.values,
87
+ config: props.config
88
+ });
89
+ body.query = query.value;
90
+ body.pgSize = pgSize.value;
91
+ body.pgIndex = pgIndex.value;
92
+ postOptions.data = body;
93
+ const requestFuc = getConfig("request");
94
+ if (typeof option.beforeRequest === "function") postOptions = await option.beforeRequest(mForm, postOptions, {
95
+ model: props.model,
96
+ formValue: mForm?.values,
97
+ formValues: mForm?.values,
98
+ prop: props.prop,
99
+ config: props.config
100
+ });
101
+ if (option.method?.toLocaleLowerCase() === "jsonp") postOptions.jsonpCallback = option.jsonpCallback || "callback";
102
+ let res = await requestFuc(postOptions);
103
+ if (typeof option.afterRequest === "function") res = await option.afterRequest(mForm, res, {
104
+ model: props.model,
105
+ formValue: mForm?.values,
106
+ formValues: mForm?.values,
107
+ config: props.config,
108
+ prop: props.prop,
109
+ postOptions
110
+ });
111
+ const optionsData = getValueByKeyPath(root, res);
112
+ const resTotal = globalThis.parseInt(getValueByKeyPath(totalKey, res), 10);
113
+ if (resTotal > 0) total.value = resTotal;
114
+ remoteData.value = remoteData.value.concat(optionsData);
115
+ if (optionsData) {
116
+ if (typeof option.item === "function") items = option.item(optionsData);
117
+ else if (optionsData.map) items = mapOptions(optionsData);
118
+ }
119
+ loading.value = false;
120
+ const selectedOptions = [];
121
+ if (props.config.multiple && props.model[props.name]) options.value.forEach((o) => {
122
+ if (props.model?.[props.name].includes(o.value) && !items.find((op) => op.value === o.value)) selectedOptions.push(o);
123
+ });
124
+ return pgIndex.value === 0 ? selectedOptions.concat(items) : options.value.concat(items);
125
+ };
126
+ const getInitLocalOption = async () => {
127
+ if (!props.model) return [];
128
+ const value = props.model[props.name];
129
+ const { config } = props;
130
+ localOptions.value = await getOptions();
131
+ remote.value = false;
132
+ if (config.group) {
133
+ if (config.multiple && value.findIndex) return localOptions.value.filter((group) => group.options.findIndex((item) => value.find((v) => equalValue(item.value, v)) > -1) > -1);
134
+ return localOptions.value.filter((group) => group.options.findIndex((item) => equalValue(item.value, value)) > -1);
135
+ }
136
+ if (config.multiple && value.findIndex) return localOptions.value.filter((item) => value.findIndex((v) => equalValue(item.value, v)) > -1);
137
+ return localOptions.value.filter((item) => equalValue(item.value, value));
138
+ };
139
+ const getInitOption = async () => {
140
+ if (!props.model) return [];
141
+ const { option } = props.config;
142
+ if (!option) return [];
143
+ const { root = "", initRoot = "" } = option;
144
+ let { initBody = {} } = option;
145
+ let options = [];
146
+ let url = option.initUrl;
147
+ if (!url) return getInitLocalOption();
148
+ if (typeof url === "function") url = await url(mForm, {
149
+ model: props.model,
150
+ formValue: mForm?.values
151
+ });
152
+ if (typeof initBody === "function") initBody = initBody(mForm, {
153
+ model: props.model,
154
+ formValue: mForm?.values,
155
+ formValues: mForm?.values,
156
+ config: props.config
157
+ });
158
+ let postOptions = {
159
+ method: option.method || "POST",
160
+ url,
161
+ data: {
162
+ id: props.model[props.name],
163
+ ...initBody
164
+ },
165
+ mode: option.mode,
166
+ headers: option.headers || {},
167
+ json: option.json || false
168
+ };
169
+ if (typeof option.beforeInitRequest === "function") postOptions = await option.beforeInitRequest(mForm, postOptions, {
170
+ model: props.model,
171
+ formValue: mForm?.values,
172
+ formValues: mForm?.values,
173
+ config: props.config,
174
+ prop: props.prop
175
+ });
176
+ if (option.method?.toLocaleLowerCase() === "jsonp") postOptions.jsonpCallback = option.jsonpCallback || "callback";
177
+ let res = await getConfig("request")(postOptions);
178
+ if (typeof option.afterRequest === "function") res = await option.afterRequest(mForm, res, {
179
+ model: props.model,
180
+ formValue: mForm?.values,
181
+ formValues: mForm?.values,
182
+ config: props.config,
183
+ prop: props.prop,
184
+ postOptions
185
+ });
186
+ let initData = getValueByKeyPath(initRoot || root, res);
187
+ if (initData) {
188
+ if (!Array.isArray(initData)) initData = [initData];
189
+ if (typeof option.item === "function") options = option.item(initData);
190
+ else if (initData.map) options = mapOptions(initData);
191
+ }
192
+ return options;
193
+ };
194
+ const setOptions = (data) => {
195
+ options.value = data;
196
+ };
197
+ if (typeof props.config.options === "function") watchEffect(() => {
198
+ typeof props.config.options === "function" && Promise.resolve(props.config.options(mForm, {
199
+ model: props.model,
200
+ prop: props.prop,
201
+ formValues: mForm?.values,
202
+ formValue: mForm?.values,
203
+ config: props.config
204
+ })).then((data) => {
205
+ setOptions(data);
206
+ });
207
+ });
208
+ else if (Array.isArray(props.config.options)) watchEffect(() => {
209
+ setOptions(props.config.options);
210
+ });
211
+ else if (props.config.option) onBeforeMount(() => {
212
+ if (!props.model) return;
213
+ const v = props.model[props.name];
214
+ if (Array.isArray(v) ? v.length : typeof v !== "undefined") getInitOption().then((data) => {
215
+ setOptions(data);
216
+ });
217
+ });
218
+ if (props.config.remote) {
219
+ const unWatch = watch(() => tMagicSelect.value?.scrollbarWrap, (scrollbarWrap) => {
220
+ if (!scrollbarWrap) return;
221
+ nextTick(() => unWatch());
222
+ scrollbarWrap.addEventListener("scroll", async (e) => {
223
+ const el = e.currentTarget;
224
+ if (moreLoadingVisible.value) return;
225
+ if (el.scrollHeight - el.clientHeight - el.scrollTop > 1) return;
226
+ if (total.value <= options.value.length) return;
227
+ moreLoadingVisible.value = true;
228
+ pgIndex.value += 1;
229
+ setOptions(await getOptions());
230
+ moreLoadingVisible.value = false;
231
+ });
232
+ }, { immediate: true });
233
+ }
234
+ const popperClass = mForm?.popperClass;
235
+ const changeHandler = (value) => {
236
+ emit("change", value);
237
+ };
238
+ const visibleHandler = async (visible) => {
239
+ if (!visible) return;
240
+ if (!props.config.remote) return;
241
+ if (query.value && tMagicSelect.value) {
242
+ tMagicSelect.value.setQuery(query.value);
243
+ tMagicSelect.value.setPreviousQuery(query.value);
244
+ tMagicSelect.value.setSelectedLabel(query.value);
245
+ } else if (options.value.length <= (props.config.multiple ? props.model?.[props.name].length : 1)) setOptions(await getOptions());
246
+ };
247
+ const remoteMethod = async (q) => {
248
+ if (!localOptions.value.length) {
249
+ query.value = q;
250
+ pgIndex.value = 0;
251
+ setOptions(await getOptions());
252
+ if (props.config.multiple) setTimeout(() => {
253
+ tMagicSelect.value?.setSelected();
254
+ }, 0);
255
+ }
256
+ };
257
+ __expose({
258
+ options,
259
+ setOptions
260
+ });
261
+ return (_ctx, _cache) => {
262
+ const _directive_loading = resolveDirective("loading");
263
+ return __props.model ? withDirectives((openBlock(), createBlock(unref(TMagicSelect), {
264
+ key: 0,
265
+ "model-value": __props.model[__props.name],
266
+ class: "m-select",
267
+ ref_key: "tMagicSelect",
268
+ ref: tMagicSelect,
269
+ clearable: typeof __props.config.clearable !== "undefined" ? __props.config.clearable : true,
270
+ filterable: typeof __props.config.filterable !== "undefined" ? __props.config.filterable : true,
271
+ "popper-class": `m-select-popper ${unref(popperClass)}`,
272
+ size: __props.size,
273
+ remote: remote.value,
274
+ placeholder: __props.config.placeholder,
275
+ multiple: __props.config.multiple,
276
+ "value-key": __props.config.valueKey || "value",
277
+ "allow-create": __props.config.allowCreate,
278
+ disabled: __props.disabled,
279
+ "remote-method": __props.config.remote && remoteMethod,
280
+ "onUpdate:modelValue": changeHandler,
281
+ onVisibleChange: visibleHandler
282
+ }, {
283
+ default: withCtx(() => [__props.config.group ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(options.value, (group, index) => {
284
+ return openBlock(), createBlock(resolveDynamicComponent(unref(optionGroupComponent)?.component || "el-option-group"), mergeProps({ key: index }, { ref_for: true }, unref(optionGroupComponent)?.props({
285
+ label: group.label,
286
+ disabled: group.disabled
287
+ }) || {
288
+ label: group.label,
289
+ disabled: group.disabled
290
+ }), {
291
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(group.options, (item, index) => {
292
+ return openBlock(), createBlock(resolveDynamicComponent(unref(optionComponent)?.component || "el-option"), mergeProps({ key: index }, { ref_for: true }, unref(optionComponent)?.props({
293
+ label: item.label || item.text,
294
+ value: item.value,
295
+ disabled: item.disabled
296
+ }) || {
297
+ label: item.label || item.text,
298
+ value: item.value,
299
+ disabled: item.disabled
300
+ }), null, 16);
301
+ }), 128))]),
302
+ _: 2
303
+ }, 1040);
304
+ }), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(options.value, (option) => {
305
+ return openBlock(), createBlock(resolveDynamicComponent(unref(optionComponent)?.component || "el-option"), mergeProps({
306
+ class: "tmagic-design-option",
307
+ key: __props.config.valueKey ? option.value[__props.config.valueKey] : option.value
308
+ }, { ref_for: true }, unref(optionComponent)?.props({
309
+ label: option.text,
310
+ value: option.value,
311
+ disabled: option.disabled
312
+ }) || {
313
+ label: option.text,
314
+ value: option.value,
315
+ disabled: option.disabled
316
+ }), null, 16);
317
+ }), 128)), moreLoadingVisible.value ? withDirectives((openBlock(), createElementBlock("div", _hoisted_1, null, 512)), [[_directive_loading, true]]) : createCommentVNode("v-if", true)]),
318
+ _: 1
319
+ }, 8, [
320
+ "model-value",
321
+ "clearable",
322
+ "filterable",
323
+ "popper-class",
324
+ "size",
325
+ "remote",
326
+ "placeholder",
327
+ "multiple",
328
+ "value-key",
329
+ "allow-create",
330
+ "disabled",
331
+ "remote-method"
332
+ ])), [[_directive_loading, loading.value]]) : createCommentVNode("v-if", true);
333
+ };
334
+ }
335
+ });
336
+ //#endregion
337
+ export { Select_vue_vue_type_script_setup_true_lang_default as default };
@@ -0,0 +1,5 @@
1
+ import Switch_vue_vue_type_script_setup_true_lang_default from "./Switch.vue_vue_type_script_setup_true_lang.js";
2
+ //#region packages/form/src/fields/Switch.vue
3
+ var Switch_default = Switch_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { Switch_default as default };
@@ -0,0 +1,59 @@
1
+ import { useAddField } from "../utils/useAddField.js";
2
+ import { computed, createBlock, defineComponent, openBlock, unref } from "vue";
3
+ import { TMagicSwitch } from "@tmagic/design";
4
+ //#region packages/form/src/fields/Switch.vue?vue&type=script&setup=true&lang.ts
5
+ var Switch_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
6
+ name: "MFormSwitch",
7
+ __name: "Switch",
8
+ props: {
9
+ config: {},
10
+ model: {},
11
+ initValues: {},
12
+ values: {},
13
+ name: {},
14
+ prop: {},
15
+ disabled: { type: Boolean },
16
+ size: {},
17
+ lastValues: {},
18
+ isCompare: { type: Boolean }
19
+ },
20
+ emits: ["change"],
21
+ setup(__props, { emit: __emit }) {
22
+ const props = __props;
23
+ const emit = __emit;
24
+ useAddField(props.prop);
25
+ const changeHandler = (value) => {
26
+ emit("change", value);
27
+ };
28
+ const activeValue = computed(() => {
29
+ if (typeof props.config.activeValue === "undefined") {
30
+ if (props.config.filter === "number") return 1;
31
+ } else return props.config.activeValue;
32
+ return true;
33
+ });
34
+ const inactiveValue = computed(() => {
35
+ if (typeof props.config.inactiveValue === "undefined") {
36
+ if (props.config.filter === "number") return 0;
37
+ } else return props.config.inactiveValue;
38
+ return false;
39
+ });
40
+ return (_ctx, _cache) => {
41
+ return openBlock(), createBlock(unref(TMagicSwitch), {
42
+ "model-value": __props.model[__props.name],
43
+ size: __props.size,
44
+ activeValue: activeValue.value,
45
+ inactiveValue: inactiveValue.value,
46
+ disabled: __props.disabled,
47
+ "onUpdate:modelValue": changeHandler
48
+ }, null, 8, [
49
+ "model-value",
50
+ "size",
51
+ "activeValue",
52
+ "inactiveValue",
53
+ "disabled"
54
+ ]);
55
+ };
56
+ }
57
+ });
58
+ //#endregion
59
+ export { Switch_vue_vue_type_script_setup_true_lang_default as default };
@@ -0,0 +1,5 @@
1
+ import Text_vue_vue_type_script_setup_true_lang_default from "./Text.vue_vue_type_script_setup_true_lang.js";
2
+ //#region packages/form/src/fields/Text.vue
3
+ var Text_default = Text_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { Text_default as default };