duck-vue-components 0.1.8 → 0.1.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.
- package/dist/{controls-CXpx_MLk.cjs → controls-B7qU1vjR.cjs} +16 -62
- package/dist/{controls-Dk08t8aW.js → controls-BXlqLD72.js} +2 -48
- package/dist/controls.cjs +1 -1
- package/dist/controls.js +1 -1
- package/dist/hooks.cjs +140 -0
- package/dist/hooks.d.cts +50 -0
- package/dist/hooks.d.ts +50 -0
- package/dist/hooks.js +133 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -1
|
@@ -2,6 +2,7 @@ const require_chunk = require("./chunk-CZWwpsFl.cjs");
|
|
|
2
2
|
const require_utils = require("./utils-D8ZjYN3B.cjs");
|
|
3
3
|
const require_locale = require("./locale-DTHxb_wp.cjs");
|
|
4
4
|
const require_stores = require("./stores.cjs");
|
|
5
|
+
const require_hooks = require("./hooks.cjs");
|
|
5
6
|
let element_plus = require("element-plus");
|
|
6
7
|
let pinia = require("pinia");
|
|
7
8
|
let vue = require("vue");
|
|
@@ -989,53 +990,6 @@ function init$30(name, templateName, buttons, options = {}) {
|
|
|
989
990
|
return dialogControl;
|
|
990
991
|
}
|
|
991
992
|
//#endregion
|
|
992
|
-
//#region src/packages/hooks/useFormValue.ts
|
|
993
|
-
/**
|
|
994
|
-
* 表单组件值绑定 Hook
|
|
995
|
-
* 支持 v-model 与 FormData 上下文的双向绑定,优先使用 v-model
|
|
996
|
-
* @param componentName 组件名称(用于警告信息)
|
|
997
|
-
* @param control 表单控件配置(必须包含 name 属性)
|
|
998
|
-
* @param modelPropName v-model 绑定的属性名(默认 "modelValue")
|
|
999
|
-
* @returns 包含计算属性 fieldValue 的对象
|
|
1000
|
-
*/
|
|
1001
|
-
function useFormValue(componentName, control, modelPropName = "modelValue") {
|
|
1002
|
-
const instance = (0, vue.getCurrentInstance)();
|
|
1003
|
-
if (!instance) throw new Error(`[${componentName}] useFormValue 必须在组件实例中调用`);
|
|
1004
|
-
const formData = (0, vue.inject)(require_utils.FormDataKey, null);
|
|
1005
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && formData) {
|
|
1006
|
-
const trackId = `[${formData.formId}] ${control.name}`;
|
|
1007
|
-
console.time(`useFormValue:${trackId}`);
|
|
1008
|
-
(0, vue.onUnmounted)(() => console.timeEnd(`useFormValue:${trackId}`));
|
|
1009
|
-
}
|
|
1010
|
-
const fieldValue = (0, vue.computed)({
|
|
1011
|
-
get: () => {
|
|
1012
|
-
if (instance.props[modelPropName] !== void 0) return instance.props[modelPropName];
|
|
1013
|
-
if (formData) return formData.getFieldValue(control.name);
|
|
1014
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 未绑定数据源。请使用 v-model 或在 RwForm 组件内使用`);
|
|
1015
|
-
},
|
|
1016
|
-
set: (value) => {
|
|
1017
|
-
const props = instance.props;
|
|
1018
|
-
if (props[modelPropName] !== void 0 || props.control && typeof props.control === "object" && "isModel" in props.control && props.control.isModel) {
|
|
1019
|
-
instance.emit(`update:${modelPropName}`, value);
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
if (formData) {
|
|
1023
|
-
try {
|
|
1024
|
-
formData.setFieldValue(control.name, value);
|
|
1025
|
-
} catch (error) {
|
|
1026
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.error(`[${componentName}] 更新字段 '${control.name}' 失败:`, error);
|
|
1027
|
-
}
|
|
1028
|
-
return;
|
|
1029
|
-
}
|
|
1030
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 无数据接收器,值变更将丢失。`);
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
(0, vue.onUnmounted)(() => {
|
|
1034
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {}
|
|
1035
|
-
});
|
|
1036
|
-
return { fieldValue };
|
|
1037
|
-
}
|
|
1038
|
-
//#endregion
|
|
1039
993
|
//#region src/packages/controls/input/input.vue?vue&type=script&setup=true&lang.ts
|
|
1040
994
|
const _hoisted_1$19 = {
|
|
1041
995
|
class: "minput-box",
|
|
@@ -1100,7 +1054,7 @@ var input_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
1100
1054
|
resizeObserver.observe(el);
|
|
1101
1055
|
}
|
|
1102
1056
|
}, { flush: "post" });
|
|
1103
|
-
const { fieldValue } = useFormValue("RwInput", props.control);
|
|
1057
|
+
const { fieldValue } = require_hooks.useFormValue("RwInput", props.control);
|
|
1104
1058
|
const createEmptyLangObject = () => {
|
|
1105
1059
|
const langObj = {};
|
|
1106
1060
|
require_locale.localeOptions.forEach((option) => {
|
|
@@ -1471,7 +1425,7 @@ var select_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
1471
1425
|
const { lists, showCheckAll, groupBy, remoteUrl, loading, optionTemplate, tagTemplate, empty, prefix, ...rest } = props.control || {};
|
|
1472
1426
|
return rest;
|
|
1473
1427
|
});
|
|
1474
|
-
const { fieldValue } = useFormValue("RwSelect", props.control);
|
|
1428
|
+
const { fieldValue } = require_hooks.useFormValue("RwSelect", props.control);
|
|
1475
1429
|
const placeholder = (0, vue.computed)(() => {
|
|
1476
1430
|
const { placeholder, label, moduleName, name } = props.control;
|
|
1477
1431
|
if (placeholder) return t(`${moduleName}.${placeholder}`);
|
|
@@ -1783,7 +1737,7 @@ var inputTag_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
1783
1737
|
const { prefix, suffix, tag, ...rest } = props.control;
|
|
1784
1738
|
return rest;
|
|
1785
1739
|
});
|
|
1786
|
-
const { fieldValue } = useFormValue("RwInputTag", props.control);
|
|
1740
|
+
const { fieldValue } = require_hooks.useFormValue("RwInputTag", props.control);
|
|
1787
1741
|
const currentValue = (0, vue.computed)({
|
|
1788
1742
|
get: () => {
|
|
1789
1743
|
if (typeof fieldValue.value === "string" && fieldValue.value.indexOf(",") !== -1) return fieldValue.value.split(",");
|
|
@@ -1905,7 +1859,7 @@ var inputNumber_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
1905
1859
|
const { prefix, suffix, decreaseIcon, increaseIcon, ...rest } = props.control;
|
|
1906
1860
|
return rest;
|
|
1907
1861
|
});
|
|
1908
|
-
const { fieldValue } = useFormValue("RwInputNumber", props.control);
|
|
1862
|
+
const { fieldValue } = require_hooks.useFormValue("RwInputNumber", props.control);
|
|
1909
1863
|
const placeholder = (0, vue.computed)(() => {
|
|
1910
1864
|
const { placeholder, label, moduleName, name } = props.control;
|
|
1911
1865
|
if (placeholder) return require_locale.t(`${moduleName}.${placeholder}`);
|
|
@@ -2002,7 +1956,7 @@ var radio_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE
|
|
|
2002
1956
|
emits: ["update:modelValue"],
|
|
2003
1957
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2004
1958
|
const props = __props;
|
|
2005
|
-
const { fieldValue } = useFormValue("RwRadio", props.control);
|
|
1959
|
+
const { fieldValue } = require_hooks.useFormValue("RwRadio", props.control);
|
|
2006
1960
|
const optionsData = (0, vue.ref)([]);
|
|
2007
1961
|
const isLoading = (0, vue.ref)(false);
|
|
2008
1962
|
const error = (0, vue.ref)("");
|
|
@@ -2244,7 +2198,7 @@ var mergeInput_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2244
2198
|
const currentComponent = (0, vue.computed)(() => {
|
|
2245
2199
|
return componentMap[props.control.inputType || "input"];
|
|
2246
2200
|
});
|
|
2247
|
-
const { fieldValue } = useFormValue("RwMergeInput", props.control);
|
|
2201
|
+
const { fieldValue } = require_hooks.useFormValue("RwMergeInput", props.control);
|
|
2248
2202
|
return (_ctx, _cache) => {
|
|
2249
2203
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(currentComponent.value), {
|
|
2250
2204
|
modelValue: (0, vue.unref)(fieldValue),
|
|
@@ -2307,7 +2261,7 @@ var switch_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
2307
2261
|
const { activeAction, inactiveAction, ...rest } = props.control;
|
|
2308
2262
|
return rest;
|
|
2309
2263
|
});
|
|
2310
|
-
const { fieldValue } = useFormValue("RwSwitch", props.control);
|
|
2264
|
+
const { fieldValue } = require_hooks.useFormValue("RwSwitch", props.control);
|
|
2311
2265
|
return (_ctx, _cache) => {
|
|
2312
2266
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(element_plus.ElSwitch), (0, vue.mergeProps)(switchProps.value, {
|
|
2313
2267
|
modelValue: (0, vue.unref)(fieldValue),
|
|
@@ -2534,7 +2488,7 @@ var mergeSelect_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @
|
|
|
2534
2488
|
const optionsList = (0, vue.ref)([]);
|
|
2535
2489
|
const dataCache = (0, vue.ref)({});
|
|
2536
2490
|
const emit = __emit;
|
|
2537
|
-
const { fieldValue } = useFormValue("RwMergeSelect", props.control);
|
|
2491
|
+
const { fieldValue } = require_hooks.useFormValue("RwMergeSelect", props.control);
|
|
2538
2492
|
const fieldValueAsStringOrNumber = (0, vue.computed)({
|
|
2539
2493
|
get: () => fieldValue.value,
|
|
2540
2494
|
set: (value) => {
|
|
@@ -2996,7 +2950,7 @@ var map_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2996
2950
|
const mapContainer = (0, vue.ref)(null);
|
|
2997
2951
|
const appConfig = require_utils.useAppConfigStore();
|
|
2998
2952
|
const props = __props;
|
|
2999
|
-
const { fieldValue } = useFormValue("RwMap", props.control);
|
|
2953
|
+
const { fieldValue } = require_hooks.useFormValue("RwMap", props.control);
|
|
3000
2954
|
const currVal = (0, vue.ref)(fieldValue.value);
|
|
3001
2955
|
const inputControl = (0, vue.reactive)(init$29(props.control.moduleName ?? "", props.control.name, {
|
|
3002
2956
|
readonly: true,
|
|
@@ -4414,7 +4368,7 @@ var upload_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PUR
|
|
|
4414
4368
|
"faf3e6da-control.imgWidth ? (control.imgHeight ? control.imgHeight + \"px\" : control.imgWidth + \"px\") : \"var(--el-upload-list-picture-card-size, 148px)\"": _ctx.control.imgWidth ? _ctx.control.imgHeight ? _ctx.control.imgHeight + "px" : _ctx.control.imgWidth + "px" : "var(--el-upload-list-picture-card-size, 148px)"
|
|
4415
4369
|
}));
|
|
4416
4370
|
const props = __props;
|
|
4417
|
-
const { fieldValue } = useFormValue("RwUpload", props.control);
|
|
4371
|
+
const { fieldValue } = require_hooks.useFormValue("RwUpload", props.control);
|
|
4418
4372
|
const dialogShow = (0, vue.ref)(false);
|
|
4419
4373
|
const fileList = (0, vue.ref)([]);
|
|
4420
4374
|
const isLoading = (0, vue.ref)(false);
|
|
@@ -4644,7 +4598,7 @@ var tree_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
4644
4598
|
setup(__props, { expose: __expose }) {
|
|
4645
4599
|
const props = __props;
|
|
4646
4600
|
const treeRef = (0, vue.ref)();
|
|
4647
|
-
const { fieldValue } = useFormValue("RwTree", props.control);
|
|
4601
|
+
const { fieldValue } = require_hooks.useFormValue("RwTree", props.control);
|
|
4648
4602
|
const optionsData = (0, vue.ref)([]);
|
|
4649
4603
|
const isLoading = (0, vue.ref)(false);
|
|
4650
4604
|
const error = (0, vue.ref)("");
|
|
@@ -4971,7 +4925,7 @@ var text_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
4971
4925
|
setup(__props) {
|
|
4972
4926
|
const { pageTable, system } = (0, pinia.storeToRefs)(require_stores.useLocalSettingStore());
|
|
4973
4927
|
const props = __props;
|
|
4974
|
-
const { fieldValue } = useFormValue("RwIext", props.control);
|
|
4928
|
+
const { fieldValue } = require_hooks.useFormValue("RwIext", props.control);
|
|
4975
4929
|
const showTextValue = (0, vue.computed)(() => {
|
|
4976
4930
|
if (props.control.multiLang) try {
|
|
4977
4931
|
return JSON.parse(fieldValue.value);
|
|
@@ -5121,7 +5075,7 @@ var table_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE
|
|
|
5121
5075
|
}
|
|
5122
5076
|
const props = __props;
|
|
5123
5077
|
const formObj = getFormContent(props.control.columns);
|
|
5124
|
-
const { fieldValue } = useFormValue("RwTable", props.control, "defaultData");
|
|
5078
|
+
const { fieldValue } = require_hooks.useFormValue("RwTable", props.control, "defaultData");
|
|
5125
5079
|
const emits = __emit;
|
|
5126
5080
|
function checkRow(row) {
|
|
5127
5081
|
props.control.clickRow = row;
|
|
@@ -5619,7 +5573,7 @@ var tagComp_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
5619
5573
|
setup(__props, { emit: __emit }) {
|
|
5620
5574
|
require_stores.useLocalSettingStore();
|
|
5621
5575
|
const props = __props;
|
|
5622
|
-
const { fieldValue } = useFormValue("RwTagComp", props.control);
|
|
5576
|
+
const { fieldValue } = require_hooks.useFormValue("RwTagComp", props.control);
|
|
5623
5577
|
const tagProps = (0, vue.computed)(() => {
|
|
5624
5578
|
const { collapseNum, optionValues, optionFrom, buttonIcon, buttonLabel, ...rest } = props.control;
|
|
5625
5579
|
return {
|
|
@@ -6068,7 +6022,7 @@ var segmented_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
6068
6022
|
const { ...rest } = props.control;
|
|
6069
6023
|
return rest;
|
|
6070
6024
|
});
|
|
6071
|
-
const { fieldValue } = useFormValue("RwSegmented", props.control);
|
|
6025
|
+
const { fieldValue } = require_hooks.useFormValue("RwSegmented", props.control);
|
|
6072
6026
|
return (_ctx, _cache) => {
|
|
6073
6027
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(element_plus.ElSegmented), (0, vue.mergeProps)({
|
|
6074
6028
|
modelValue: (0, vue.unref)(fieldValue),
|
|
@@ -2,9 +2,10 @@ import { t as __exportAll } from "./chunk-pbuEa-1d.js";
|
|
|
2
2
|
import { Et as isHTML, Lt as renderTemplate, P as withInstall, a as bd09ToGcj02, h as http, n as PathUtils, o as gcj02ToBd09, qt as loadScript, r as createFormData, s as exportExcel, t as FormDataKey, tt as assignmentData, u as useAppConfigStore, ut as transDataToString, xt as isComponent } from "./utils-CUQ01uOs.js";
|
|
3
3
|
import { a as localeOptions, i as locale, t as i18n, u as t$3 } from "./locale-B3sWTtoq.js";
|
|
4
4
|
import { useColumnsSettingStore, useLocalSettingStore } from "./stores.js";
|
|
5
|
+
import { useFormValue } from "./hooks.js";
|
|
5
6
|
import { ElAffix, ElAutocomplete, ElButton, ElButtonGroup, ElCheckbox, ElCheckboxButton, ElCheckboxGroup, ElCol, ElConfigProvider, ElDialog, ElDivider, ElDrawer, ElDropdown, ElDropdownItem, ElDropdownMenu, ElForm, ElFormItem, ElIcon, ElImage, ElInput, ElInputNumber, ElInputTag, ElMessage, ElMessageBox, ElNotification, ElOption, ElOptionGroup, ElPagination, ElPopconfirm, ElPopover, ElRadio, ElRadioButton, ElRadioGroup, ElRow, ElSegmented, ElSelect, ElSlider, ElSwitch, ElTabPane, ElTableColumn, ElTabs, ElTag, ElText, ElTooltip, ElTree, ElTreeSelect, ElUpload, ElWatermark } from "element-plus";
|
|
6
7
|
import { storeToRefs } from "pinia";
|
|
7
|
-
import { Fragment, TransitionGroup, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent,
|
|
8
|
+
import { Fragment, TransitionGroup, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, isReactive, isRef, markRaw, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeMount, onBeforeUnmount, onMounted, onUnmounted, onUpdated, openBlock, provide, reactive, readonly, ref, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, toDisplayString, toRaw, unref, useCssVars, useModel, vShow, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
8
9
|
import { debounce } from "lodash-es";
|
|
9
10
|
import axios from "axios";
|
|
10
11
|
import Cookies from "js-cookie";
|
|
@@ -986,53 +987,6 @@ function init$30(name, templateName, buttons, options = {}) {
|
|
|
986
987
|
return dialogControl;
|
|
987
988
|
}
|
|
988
989
|
//#endregion
|
|
989
|
-
//#region src/packages/hooks/useFormValue.ts
|
|
990
|
-
/**
|
|
991
|
-
* 表单组件值绑定 Hook
|
|
992
|
-
* 支持 v-model 与 FormData 上下文的双向绑定,优先使用 v-model
|
|
993
|
-
* @param componentName 组件名称(用于警告信息)
|
|
994
|
-
* @param control 表单控件配置(必须包含 name 属性)
|
|
995
|
-
* @param modelPropName v-model 绑定的属性名(默认 "modelValue")
|
|
996
|
-
* @returns 包含计算属性 fieldValue 的对象
|
|
997
|
-
*/
|
|
998
|
-
function useFormValue(componentName, control, modelPropName = "modelValue") {
|
|
999
|
-
const instance = getCurrentInstance();
|
|
1000
|
-
if (!instance) throw new Error(`[${componentName}] useFormValue 必须在组件实例中调用`);
|
|
1001
|
-
const formData = inject(FormDataKey, null);
|
|
1002
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && formData) {
|
|
1003
|
-
const trackId = `[${formData.formId}] ${control.name}`;
|
|
1004
|
-
console.time(`useFormValue:${trackId}`);
|
|
1005
|
-
onUnmounted(() => console.timeEnd(`useFormValue:${trackId}`));
|
|
1006
|
-
}
|
|
1007
|
-
const fieldValue = computed({
|
|
1008
|
-
get: () => {
|
|
1009
|
-
if (instance.props[modelPropName] !== void 0) return instance.props[modelPropName];
|
|
1010
|
-
if (formData) return formData.getFieldValue(control.name);
|
|
1011
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 未绑定数据源。请使用 v-model 或在 RwForm 组件内使用`);
|
|
1012
|
-
},
|
|
1013
|
-
set: (value) => {
|
|
1014
|
-
const props = instance.props;
|
|
1015
|
-
if (props[modelPropName] !== void 0 || props.control && typeof props.control === "object" && "isModel" in props.control && props.control.isModel) {
|
|
1016
|
-
instance.emit(`update:${modelPropName}`, value);
|
|
1017
|
-
return;
|
|
1018
|
-
}
|
|
1019
|
-
if (formData) {
|
|
1020
|
-
try {
|
|
1021
|
-
formData.setFieldValue(control.name, value);
|
|
1022
|
-
} catch (error) {
|
|
1023
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.error(`[${componentName}] 更新字段 '${control.name}' 失败:`, error);
|
|
1024
|
-
}
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 无数据接收器,值变更将丢失。`);
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
onUnmounted(() => {
|
|
1031
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {}
|
|
1032
|
-
});
|
|
1033
|
-
return { fieldValue };
|
|
1034
|
-
}
|
|
1035
|
-
//#endregion
|
|
1036
990
|
//#region src/packages/controls/input/input.vue?vue&type=script&setup=true&lang.ts
|
|
1037
991
|
const _hoisted_1$19 = {
|
|
1038
992
|
class: "minput-box",
|
package/dist/controls.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_controls = require("./controls-
|
|
2
|
+
const require_controls = require("./controls-B7qU1vjR.cjs");
|
|
3
3
|
exports.MyButton = require_controls.MyButton_default;
|
|
4
4
|
Object.defineProperty(exports, "RwAffix", {
|
|
5
5
|
enumerable: true,
|
package/dist/controls.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as select_exports, C as mergeSelect_exports, D as radio_exports, E as mergeInput_exports, F as popconfirm_exports, I as button_exports, L as autocomplete_exports, M as dialog_exports, N as buttonGroup_exports, O as inputNumber_exports, P as dropdown_exports, R as affix_exports, S as slider_exports, T as switch_exports, _ as text_exports, a as pageForm_exports, b as pagination_exports, c as pageBase_exports, d as tabPane_exports, f as RwFormItems, g as tag_exports, h as tagComp_exports, i as pageTable_exports, j as input_exports, k as inputTag_exports, l as RwForm, m as table_exports, n as search_exports, o as pageStruct_exports, p as segmented_exports, r as mTreeSTable_exports, s as tableStruct_exports, u as tabs_exports, v as tree_exports, w as image_exports, x as map_exports, y as upload_exports, z as MyButton_default } from "./controls-
|
|
1
|
+
import { A as select_exports, C as mergeSelect_exports, D as radio_exports, E as mergeInput_exports, F as popconfirm_exports, I as button_exports, L as autocomplete_exports, M as dialog_exports, N as buttonGroup_exports, O as inputNumber_exports, P as dropdown_exports, R as affix_exports, S as slider_exports, T as switch_exports, _ as text_exports, a as pageForm_exports, b as pagination_exports, c as pageBase_exports, d as tabPane_exports, f as RwFormItems, g as tag_exports, h as tagComp_exports, i as pageTable_exports, j as input_exports, k as inputTag_exports, l as RwForm, m as table_exports, n as search_exports, o as pageStruct_exports, p as segmented_exports, r as mTreeSTable_exports, s as tableStruct_exports, u as tabs_exports, v as tree_exports, w as image_exports, x as map_exports, y as upload_exports, z as MyButton_default } from "./controls-BXlqLD72.js";
|
|
2
2
|
export { MyButton_default as MyButton, affix_exports as RwAffix, autocomplete_exports as RwAutocomplete, button_exports as RwButton, buttonGroup_exports as RwButtonGroup, dialog_exports as RwDialog, dropdown_exports as RwDropdown, RwForm, RwFormItems, image_exports as RwImage, input_exports as RwInput, inputNumber_exports as RwInputNumber, inputTag_exports as RwInputTag, mTreeSTable_exports as RwMTreeSTable, map_exports as RwMap, mergeInput_exports as RwMergeInput, mergeSelect_exports as RwMergeSelect, pageBase_exports as RwPageBase, pageForm_exports as RwPageForm, pageTable_exports as RwPageTable, pagination_exports as RwPagination, popconfirm_exports as RwPopconfirm, radio_exports as RwRadio, search_exports as RwSearch, segmented_exports as RwSegmented, select_exports as RwSelect, slider_exports as RwSlider, switch_exports as RwSwitch, tabPane_exports as RwTabPane, table_exports as RwTable, tabs_exports as RwTabs, tag_exports as RwTag, tagComp_exports as RwTagComp, text_exports as RwText, tree_exports as RwTree, upload_exports as RwUpload, pageStruct_exports as pageStruct, tableStruct_exports as tableStruct };
|
package/dist/hooks.cjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./chunk-CZWwpsFl.cjs");
|
|
3
|
+
const require_utils = require("./utils-D8ZjYN3B.cjs");
|
|
4
|
+
let vue = require("vue");
|
|
5
|
+
//#region src/packages/hooks/use-namespace/index.ts
|
|
6
|
+
const defaultNamespace = "el";
|
|
7
|
+
const statePrefix = "is-";
|
|
8
|
+
const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
9
|
+
let cls = `${namespace}-${block}`;
|
|
10
|
+
if (blockSuffix) cls += `-${blockSuffix}`;
|
|
11
|
+
if (element) cls += `__${element}`;
|
|
12
|
+
if (modifier) cls += `--${modifier}`;
|
|
13
|
+
return cls;
|
|
14
|
+
};
|
|
15
|
+
const namespaceContextKey = Symbol("namespaceContextKey");
|
|
16
|
+
const useGetDerivedNamespace = (namespaceOverrides) => {
|
|
17
|
+
const derivedNamespace = namespaceOverrides || ((0, vue.getCurrentInstance)() ? (0, vue.inject)(namespaceContextKey, (0, vue.ref)("el")) : (0, vue.ref)("el"));
|
|
18
|
+
return (0, vue.computed)(() => {
|
|
19
|
+
return (0, vue.unref)(derivedNamespace) || "el";
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const useNamespace = (block, namespaceOverrides) => {
|
|
23
|
+
const namespace = useGetDerivedNamespace(namespaceOverrides);
|
|
24
|
+
const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
|
|
25
|
+
const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
|
|
26
|
+
const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
|
|
27
|
+
const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
|
|
28
|
+
const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
|
|
29
|
+
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
|
|
30
|
+
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
|
|
31
|
+
const is = (name, ...args) => {
|
|
32
|
+
const state = args.length >= 1 ? args[0] : true;
|
|
33
|
+
return name && state ? `${statePrefix}${name}` : "";
|
|
34
|
+
};
|
|
35
|
+
const cssVar = (object) => {
|
|
36
|
+
const styles = {};
|
|
37
|
+
for (const key in object) if (object[key]) styles[`--${namespace.value}-${key}`] = object[key];
|
|
38
|
+
return styles;
|
|
39
|
+
};
|
|
40
|
+
const cssVarBlock = (object) => {
|
|
41
|
+
const styles = {};
|
|
42
|
+
for (const key in object) if (object[key]) styles[`--${namespace.value}-${block}-${key}`] = object[key];
|
|
43
|
+
return styles;
|
|
44
|
+
};
|
|
45
|
+
const cssVarName = (name) => `--${namespace.value}-${name}`;
|
|
46
|
+
const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
|
|
47
|
+
return {
|
|
48
|
+
namespace,
|
|
49
|
+
b,
|
|
50
|
+
e,
|
|
51
|
+
m,
|
|
52
|
+
be,
|
|
53
|
+
em,
|
|
54
|
+
bm,
|
|
55
|
+
bem,
|
|
56
|
+
is,
|
|
57
|
+
cssVar,
|
|
58
|
+
cssVarName,
|
|
59
|
+
cssVarBlock,
|
|
60
|
+
cssVarBlockName
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/packages/hooks/useFormValue.ts
|
|
65
|
+
/**
|
|
66
|
+
* 表单组件值绑定 Hook
|
|
67
|
+
* 支持 v-model 与 FormData 上下文的双向绑定,优先使用 v-model
|
|
68
|
+
* @param componentName 组件名称(用于警告信息)
|
|
69
|
+
* @param control 表单控件配置(必须包含 name 属性)
|
|
70
|
+
* @param modelPropName v-model 绑定的属性名(默认 "modelValue")
|
|
71
|
+
* @returns 包含计算属性 fieldValue 的对象
|
|
72
|
+
*/
|
|
73
|
+
function useFormValue(componentName, control, modelPropName = "modelValue") {
|
|
74
|
+
const instance = (0, vue.getCurrentInstance)();
|
|
75
|
+
if (!instance) throw new Error(`[${componentName}] useFormValue 必须在组件实例中调用`);
|
|
76
|
+
const formData = (0, vue.inject)(require_utils.FormDataKey, null);
|
|
77
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && formData) {
|
|
78
|
+
const trackId = `[${formData.formId}] ${control.name}`;
|
|
79
|
+
console.time(`useFormValue:${trackId}`);
|
|
80
|
+
(0, vue.onUnmounted)(() => console.timeEnd(`useFormValue:${trackId}`));
|
|
81
|
+
}
|
|
82
|
+
const fieldValue = (0, vue.computed)({
|
|
83
|
+
get: () => {
|
|
84
|
+
if (instance.props[modelPropName] !== void 0) return instance.props[modelPropName];
|
|
85
|
+
if (formData) return formData.getFieldValue(control.name);
|
|
86
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 未绑定数据源。请使用 v-model 或在 RwForm 组件内使用`);
|
|
87
|
+
},
|
|
88
|
+
set: (value) => {
|
|
89
|
+
const props = instance.props;
|
|
90
|
+
if (props[modelPropName] !== void 0 || props.control && typeof props.control === "object" && "isModel" in props.control && props.control.isModel) {
|
|
91
|
+
instance.emit(`update:${modelPropName}`, value);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (formData) {
|
|
95
|
+
try {
|
|
96
|
+
formData.setFieldValue(control.name, value);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.error(`[${componentName}] 更新字段 '${control.name}' 失败:`, error);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 无数据接收器,值变更将丢失。`);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
(0, vue.onUnmounted)(() => {
|
|
106
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {}
|
|
107
|
+
});
|
|
108
|
+
return { fieldValue };
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/packages/hooks/useMouse.ts
|
|
112
|
+
function useMouse() {
|
|
113
|
+
const show = (0, vue.ref)(true);
|
|
114
|
+
const timeoutId = (0, vue.ref)();
|
|
115
|
+
const isAnimating = (0, vue.ref)(false);
|
|
116
|
+
const handleMouseEnter = () => {
|
|
117
|
+
if (isAnimating.value) return;
|
|
118
|
+
if (timeoutId.value) clearTimeout(timeoutId.value);
|
|
119
|
+
isAnimating.value = true;
|
|
120
|
+
show.value = false;
|
|
121
|
+
timeoutId.value = setTimeout(() => {
|
|
122
|
+
show.value = true;
|
|
123
|
+
}, 500);
|
|
124
|
+
};
|
|
125
|
+
const handleMouseLeave = () => {
|
|
126
|
+
isAnimating.value = false;
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
show,
|
|
130
|
+
handleMouseEnter,
|
|
131
|
+
handleMouseLeave
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
exports.defaultNamespace = defaultNamespace;
|
|
136
|
+
exports.namespaceContextKey = namespaceContextKey;
|
|
137
|
+
exports.useFormValue = useFormValue;
|
|
138
|
+
exports.useGetDerivedNamespace = useGetDerivedNamespace;
|
|
139
|
+
exports.useMouse = useMouse;
|
|
140
|
+
exports.useNamespace = useNamespace;
|
package/dist/hooks.d.cts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { InjectionKey, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/packages/hooks/use-namespace/index.d.ts
|
|
5
|
+
declare const defaultNamespace = "el";
|
|
6
|
+
declare const namespaceContextKey: InjectionKey<Ref<string | undefined>>;
|
|
7
|
+
declare const useGetDerivedNamespace: (namespaceOverrides?: Ref<string | undefined>) => _$vue.ComputedRef<string>;
|
|
8
|
+
declare const useNamespace: (block: string, namespaceOverrides?: Ref<string | undefined>) => {
|
|
9
|
+
namespace: _$vue.ComputedRef<string>;
|
|
10
|
+
b: (blockSuffix?: string) => string;
|
|
11
|
+
e: (element?: string) => string;
|
|
12
|
+
m: (modifier?: string) => string;
|
|
13
|
+
be: (blockSuffix?: string, element?: string) => string;
|
|
14
|
+
em: (element?: string, modifier?: string) => string;
|
|
15
|
+
bm: (blockSuffix?: string, modifier?: string) => string;
|
|
16
|
+
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
|
|
17
|
+
is: {
|
|
18
|
+
(name: string, state: boolean | undefined): string;
|
|
19
|
+
(name: string): string;
|
|
20
|
+
};
|
|
21
|
+
cssVar: (object: Record<string, string>) => Record<string, string>;
|
|
22
|
+
cssVarName: (name: string) => string;
|
|
23
|
+
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
|
24
|
+
cssVarBlockName: (name: string) => string;
|
|
25
|
+
};
|
|
26
|
+
type UseNamespaceReturn = ReturnType<typeof useNamespace>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/packages/hooks/useFormValue.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* 表单组件值绑定 Hook
|
|
31
|
+
* 支持 v-model 与 FormData 上下文的双向绑定,优先使用 v-model
|
|
32
|
+
* @param componentName 组件名称(用于警告信息)
|
|
33
|
+
* @param control 表单控件配置(必须包含 name 属性)
|
|
34
|
+
* @param modelPropName v-model 绑定的属性名(默认 "modelValue")
|
|
35
|
+
* @returns 包含计算属性 fieldValue 的对象
|
|
36
|
+
*/
|
|
37
|
+
declare function useFormValue<T extends {
|
|
38
|
+
name: string;
|
|
39
|
+
}>(componentName: string, control: T, modelPropName?: string): {
|
|
40
|
+
fieldValue: _$vue.WritableComputedRef<any, any>;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/packages/hooks/useMouse.d.ts
|
|
44
|
+
declare function useMouse(): {
|
|
45
|
+
show: _$vue.Ref<boolean, boolean>;
|
|
46
|
+
handleMouseEnter: () => void;
|
|
47
|
+
handleMouseLeave: () => void;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { UseNamespaceReturn, defaultNamespace, namespaceContextKey, useFormValue, useGetDerivedNamespace, useMouse, useNamespace };
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { InjectionKey, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/packages/hooks/use-namespace/index.d.ts
|
|
5
|
+
declare const defaultNamespace = "el";
|
|
6
|
+
declare const namespaceContextKey: InjectionKey<Ref<string | undefined>>;
|
|
7
|
+
declare const useGetDerivedNamespace: (namespaceOverrides?: Ref<string | undefined>) => _$vue.ComputedRef<string>;
|
|
8
|
+
declare const useNamespace: (block: string, namespaceOverrides?: Ref<string | undefined>) => {
|
|
9
|
+
namespace: _$vue.ComputedRef<string>;
|
|
10
|
+
b: (blockSuffix?: string) => string;
|
|
11
|
+
e: (element?: string) => string;
|
|
12
|
+
m: (modifier?: string) => string;
|
|
13
|
+
be: (blockSuffix?: string, element?: string) => string;
|
|
14
|
+
em: (element?: string, modifier?: string) => string;
|
|
15
|
+
bm: (blockSuffix?: string, modifier?: string) => string;
|
|
16
|
+
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
|
|
17
|
+
is: {
|
|
18
|
+
(name: string, state: boolean | undefined): string;
|
|
19
|
+
(name: string): string;
|
|
20
|
+
};
|
|
21
|
+
cssVar: (object: Record<string, string>) => Record<string, string>;
|
|
22
|
+
cssVarName: (name: string) => string;
|
|
23
|
+
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
|
24
|
+
cssVarBlockName: (name: string) => string;
|
|
25
|
+
};
|
|
26
|
+
type UseNamespaceReturn = ReturnType<typeof useNamespace>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/packages/hooks/useFormValue.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* 表单组件值绑定 Hook
|
|
31
|
+
* 支持 v-model 与 FormData 上下文的双向绑定,优先使用 v-model
|
|
32
|
+
* @param componentName 组件名称(用于警告信息)
|
|
33
|
+
* @param control 表单控件配置(必须包含 name 属性)
|
|
34
|
+
* @param modelPropName v-model 绑定的属性名(默认 "modelValue")
|
|
35
|
+
* @returns 包含计算属性 fieldValue 的对象
|
|
36
|
+
*/
|
|
37
|
+
declare function useFormValue<T extends {
|
|
38
|
+
name: string;
|
|
39
|
+
}>(componentName: string, control: T, modelPropName?: string): {
|
|
40
|
+
fieldValue: _$vue.WritableComputedRef<any, any>;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/packages/hooks/useMouse.d.ts
|
|
44
|
+
declare function useMouse(): {
|
|
45
|
+
show: _$vue.Ref<boolean, boolean>;
|
|
46
|
+
handleMouseEnter: () => void;
|
|
47
|
+
handleMouseLeave: () => void;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { UseNamespaceReturn, defaultNamespace, namespaceContextKey, useFormValue, useGetDerivedNamespace, useMouse, useNamespace };
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { t as FormDataKey } from "./utils-CUQ01uOs.js";
|
|
2
|
+
import { computed, getCurrentInstance, inject, onUnmounted, ref, unref } from "vue";
|
|
3
|
+
//#region src/packages/hooks/use-namespace/index.ts
|
|
4
|
+
const defaultNamespace = "el";
|
|
5
|
+
const statePrefix = "is-";
|
|
6
|
+
const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
7
|
+
let cls = `${namespace}-${block}`;
|
|
8
|
+
if (blockSuffix) cls += `-${blockSuffix}`;
|
|
9
|
+
if (element) cls += `__${element}`;
|
|
10
|
+
if (modifier) cls += `--${modifier}`;
|
|
11
|
+
return cls;
|
|
12
|
+
};
|
|
13
|
+
const namespaceContextKey = Symbol("namespaceContextKey");
|
|
14
|
+
const useGetDerivedNamespace = (namespaceOverrides) => {
|
|
15
|
+
const derivedNamespace = namespaceOverrides || (getCurrentInstance() ? inject(namespaceContextKey, ref("el")) : ref("el"));
|
|
16
|
+
return computed(() => {
|
|
17
|
+
return unref(derivedNamespace) || "el";
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const useNamespace = (block, namespaceOverrides) => {
|
|
21
|
+
const namespace = useGetDerivedNamespace(namespaceOverrides);
|
|
22
|
+
const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
|
|
23
|
+
const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
|
|
24
|
+
const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
|
|
25
|
+
const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
|
|
26
|
+
const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
|
|
27
|
+
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
|
|
28
|
+
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
|
|
29
|
+
const is = (name, ...args) => {
|
|
30
|
+
const state = args.length >= 1 ? args[0] : true;
|
|
31
|
+
return name && state ? `${statePrefix}${name}` : "";
|
|
32
|
+
};
|
|
33
|
+
const cssVar = (object) => {
|
|
34
|
+
const styles = {};
|
|
35
|
+
for (const key in object) if (object[key]) styles[`--${namespace.value}-${key}`] = object[key];
|
|
36
|
+
return styles;
|
|
37
|
+
};
|
|
38
|
+
const cssVarBlock = (object) => {
|
|
39
|
+
const styles = {};
|
|
40
|
+
for (const key in object) if (object[key]) styles[`--${namespace.value}-${block}-${key}`] = object[key];
|
|
41
|
+
return styles;
|
|
42
|
+
};
|
|
43
|
+
const cssVarName = (name) => `--${namespace.value}-${name}`;
|
|
44
|
+
const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
|
|
45
|
+
return {
|
|
46
|
+
namespace,
|
|
47
|
+
b,
|
|
48
|
+
e,
|
|
49
|
+
m,
|
|
50
|
+
be,
|
|
51
|
+
em,
|
|
52
|
+
bm,
|
|
53
|
+
bem,
|
|
54
|
+
is,
|
|
55
|
+
cssVar,
|
|
56
|
+
cssVarName,
|
|
57
|
+
cssVarBlock,
|
|
58
|
+
cssVarBlockName
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/packages/hooks/useFormValue.ts
|
|
63
|
+
/**
|
|
64
|
+
* 表单组件值绑定 Hook
|
|
65
|
+
* 支持 v-model 与 FormData 上下文的双向绑定,优先使用 v-model
|
|
66
|
+
* @param componentName 组件名称(用于警告信息)
|
|
67
|
+
* @param control 表单控件配置(必须包含 name 属性)
|
|
68
|
+
* @param modelPropName v-model 绑定的属性名(默认 "modelValue")
|
|
69
|
+
* @returns 包含计算属性 fieldValue 的对象
|
|
70
|
+
*/
|
|
71
|
+
function useFormValue(componentName, control, modelPropName = "modelValue") {
|
|
72
|
+
const instance = getCurrentInstance();
|
|
73
|
+
if (!instance) throw new Error(`[${componentName}] useFormValue 必须在组件实例中调用`);
|
|
74
|
+
const formData = inject(FormDataKey, null);
|
|
75
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production" && formData) {
|
|
76
|
+
const trackId = `[${formData.formId}] ${control.name}`;
|
|
77
|
+
console.time(`useFormValue:${trackId}`);
|
|
78
|
+
onUnmounted(() => console.timeEnd(`useFormValue:${trackId}`));
|
|
79
|
+
}
|
|
80
|
+
const fieldValue = computed({
|
|
81
|
+
get: () => {
|
|
82
|
+
if (instance.props[modelPropName] !== void 0) return instance.props[modelPropName];
|
|
83
|
+
if (formData) return formData.getFieldValue(control.name);
|
|
84
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 未绑定数据源。请使用 v-model 或在 RwForm 组件内使用`);
|
|
85
|
+
},
|
|
86
|
+
set: (value) => {
|
|
87
|
+
const props = instance.props;
|
|
88
|
+
if (props[modelPropName] !== void 0 || props.control && typeof props.control === "object" && "isModel" in props.control && props.control.isModel) {
|
|
89
|
+
instance.emit(`update:${modelPropName}`, value);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (formData) {
|
|
93
|
+
try {
|
|
94
|
+
formData.setFieldValue(control.name, value);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.error(`[${componentName}] 更新字段 '${control.name}' 失败:`, error);
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") console.warn(`[${componentName}] 字段 '${control.name}' 无数据接收器,值变更将丢失。`);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
onUnmounted(() => {
|
|
104
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {}
|
|
105
|
+
});
|
|
106
|
+
return { fieldValue };
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/packages/hooks/useMouse.ts
|
|
110
|
+
function useMouse() {
|
|
111
|
+
const show = ref(true);
|
|
112
|
+
const timeoutId = ref();
|
|
113
|
+
const isAnimating = ref(false);
|
|
114
|
+
const handleMouseEnter = () => {
|
|
115
|
+
if (isAnimating.value) return;
|
|
116
|
+
if (timeoutId.value) clearTimeout(timeoutId.value);
|
|
117
|
+
isAnimating.value = true;
|
|
118
|
+
show.value = false;
|
|
119
|
+
timeoutId.value = setTimeout(() => {
|
|
120
|
+
show.value = true;
|
|
121
|
+
}, 500);
|
|
122
|
+
};
|
|
123
|
+
const handleMouseLeave = () => {
|
|
124
|
+
isAnimating.value = false;
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
show,
|
|
128
|
+
handleMouseEnter,
|
|
129
|
+
handleMouseLeave
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { defaultNamespace, namespaceContextKey, useFormValue, useGetDerivedNamespace, useMouse, useNamespace };
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
|
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("./chunk-CZWwpsFl.cjs");
|
|
6
6
|
const require_config = require("./config.cjs");
|
|
7
|
-
const require_controls = require("./controls-
|
|
7
|
+
const require_controls = require("./controls-B7qU1vjR.cjs");
|
|
8
8
|
const require_locale = require("./locale-DTHxb_wp.cjs");
|
|
9
9
|
require("element-plus/dist/index.css");
|
|
10
10
|
require("element-plus/theme-chalk/dark/css-vars.css");
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as config_exports } from "./config.js";
|
|
2
|
-
import { t as controls_exports } from "./controls-
|
|
2
|
+
import { t as controls_exports } from "./controls-BXlqLD72.js";
|
|
3
3
|
import { d as tw_default, f as en_default, p as cn_default } from "./locale-B3sWTtoq.js";
|
|
4
4
|
import "element-plus/dist/index.css";
|
|
5
5
|
import "element-plus/theme-chalk/dark/css-vars.css";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "duck-vue-components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.9",
|
|
5
5
|
"description": "A Vue 3 component library with controls, utils, stores and more.",
|
|
6
6
|
"author": "Your Name <your.email@mail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"import": "./dist/controls.js",
|
|
38
38
|
"require": "./dist/controls.cjs"
|
|
39
39
|
},
|
|
40
|
+
"./hooks": {
|
|
41
|
+
"import": "./dist/hooks.js",
|
|
42
|
+
"require": "./dist/hooks.cjs"
|
|
43
|
+
},
|
|
40
44
|
"./locale": {
|
|
41
45
|
"import": "./dist/locale.js",
|
|
42
46
|
"require": "./dist/locale.cjs"
|