New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@d-render/shared

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@d-render/shared - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

6

CHANGELOG.md
# @d-render/shared
## 2.0.3
### Patch Changes
- fix(use-form-input): 修复`useOptions`的 autoSelect 功能
## 2.0.2

@@ -4,0 +10,0 @@

69

esm/hooks/use-form-input.js

@@ -252,22 +252,2 @@ import { ref, computed, watch, unref } from 'vue';

let unwatch = null;
const getOptions = (val, outVal) => __async(void 0, null, function* () {
var _a2, _b2;
if (props.config.asyncOptions) {
const asyncFunc = judgeUseFn("asyncOptions", props.config);
options.value = yield asyncFunc(val, outVal);
} else {
options.value = (_b2 = (_a2 = props.config) == null ? void 0 : _a2.options) != null ? _b2 : [];
}
if (unwatch)
unwatch();
unwatch = watch(() => props.changeCount, () => {
if (isEmpty(props.modelValue) && props.config.autoSelect && updateStream) {
const autoValue = isObjectOption.value ? options.value[0][optionProps.value.value] : options.value[0];
const autoLabel = isObjectOption.value ? options.value[0][optionProps.value.label] : options.value[0];
updateStream.appendValue(autoValue);
updateStream.appendOtherValue(autoLabel);
updateStream.end();
}
}, { immediate: true });
});
const isObjectOption = computed(() => {

@@ -332,16 +312,2 @@ return isObject(options.value[0]);

};
if (autoGet) {
if (!((_a = props.config.dependOn) == null ? void 0 : _a.length) && !((_b = props.config.outDependOn) == null ? void 0 : _b.length)) {
getOptions();
if (props.config.options) {
watch(() => props.config.options, () => {
getOptions();
});
}
} else {
watch([() => props.dependOnValues, () => props.outDependOnValues], ([dependOnValues, outDependOnValues]) => {
getOptions(dependOnValues || {}, outDependOnValues || {});
}, { immediate: true });
}
}
const proxyOptionsValue = computed({

@@ -384,2 +350,37 @@ get() {

});
const getOptions = (val, outVal) => __async(void 0, null, function* () {
var _a2, _b2;
if (props.config.asyncOptions) {
const asyncFunc = judgeUseFn("asyncOptions", props.config);
options.value = yield asyncFunc(val, outVal);
} else {
options.value = (_b2 = (_a2 = props.config) == null ? void 0 : _a2.options) != null ? _b2 : [];
}
if (unwatch)
unwatch();
unwatch = watch(() => props.changeCount, () => {
if (isEmpty(props.modelValue) && props.config.autoSelect && updateStream) {
const result = isObjectOption.value ? getFieldValue(options.value[0], optionProps.value.value) : options.value[0];
if (unref(multiple)) {
proxyOptionsValue.value = [result];
} else {
proxyOptionsValue.value = result;
}
}
}, { immediate: true });
});
if (autoGet) {
if (!((_a = props.config.dependOn) == null ? void 0 : _a.length) && !((_b = props.config.outDependOn) == null ? void 0 : _b.length)) {
getOptions();
if (props.config.options) {
watch(() => props.config.options, () => {
getOptions();
});
}
} else {
watch([() => props.dependOnValues, () => props.outDependOnValues], ([dependOnValues, outDependOnValues]) => {
getOptions(dependOnValues || {}, outDependOnValues || {});
}, { immediate: true });
}
}
return {

@@ -386,0 +387,0 @@ optionProps,

{
"name": "@d-render/shared",
"version": "2.0.2",
"version": "2.0.3",
"description": "d-render部分共享utils hooks helper",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -259,23 +259,2 @@ import { computed, ref, watch, unref, SetupContext, Ref, WatchStopHandle, ComputedRef } from 'vue'

let unwatch: WatchStopHandle|null = null
const getOptions = async (val?: IAnyObject, outVal?: IAnyObject) => {
if (props.config.asyncOptions) {
const asyncFunc = judgeUseFn('asyncOptions', props.config) as (val?: IAnyObject, outVal?: IAnyObject) => Promise<unknown[]>
options.value = await asyncFunc(val, outVal)
} else {
options.value = (props.config?.options as unknown[]) ?? []
}
if (unwatch) unwatch() // 获取一次options后重新开启监听
unwatch = watch(() => props.changeCount, () => {
if (isEmpty(props.modelValue) && props.config.autoSelect && updateStream) { // modelValue为空
const autoValue = isObjectOption.value ? (options.value as IAnyObject[])![0][optionProps.value.value] : options.value[0]
const autoLabel = isObjectOption.value ? (options.value as IAnyObject[])![0][optionProps.value.label] : options.value[0]
// eslint-disable-next-line no-unused-expressions
// emitInput(autoValue)
// emitOtherValue && emitOtherValue(autoLabel)
updateStream.appendValue(autoValue)
updateStream.appendOtherValue(autoLabel)
updateStream.end()
}
}, { immediate: true })
}
// 计算option类型

@@ -339,16 +318,2 @@ const isObjectOption = computed(() => {

}
if (autoGet) {
if (!(props.config.dependOn?.length) && !(props.config.outDependOn?.length)) {
getOptions() // .then(() => { console.log('[init]: getOptions') })
if (props.config.options) { // 动态表单设计时修改options需要触发此方法
watch(() => props.config.options, () => {
getOptions() // .then(() => { console.log('[config.options change]: getOptions') })
})
}
} else {
watch([() => props.dependOnValues, () => props.outDependOnValues], ([dependOnValues, outDependOnValues]) => {
getOptions(dependOnValues || {}, outDependOnValues || {}) // .then(() => { console.log('[dependOn change]: getOptions') })
}, { immediate: true })
}
}

@@ -383,6 +348,6 @@ // options部分组件重新定义proxyOptionsValue

if (!unref(multiple)) {
const path = getPathByValue(options.value, value, optionProps.value)
const path = getPathByValue(options.value as IAnyObject[], value, optionProps.value)
updateStream.appendOtherValue(path, 3)
} else {
const paths = (value as unknown[]).map(val => getPathByValue(options.value, val, optionProps.value))
const paths = (value as unknown[]).map(val => getPathByValue(options.value as IAnyObject[], val, optionProps.value))
updateStream.appendOtherValue(paths, 3)

@@ -398,2 +363,37 @@ }

})
const getOptions = async (val?: IAnyObject, outVal?: IAnyObject) => {
if (props.config.asyncOptions) {
const asyncFunc = judgeUseFn('asyncOptions', props.config) as (val?: IAnyObject, outVal?: IAnyObject) => Promise<unknown[]>
options.value = await asyncFunc(val, outVal)
} else {
options.value = (props.config?.options as unknown[]) ?? []
}
if (unwatch) unwatch() // 获取一次options后重新开启监听
unwatch = watch(() => props.changeCount, () => {
if (isEmpty(props.modelValue) && props.config.autoSelect && updateStream) { // modelValue为空
const result = (isObjectOption.value ? getFieldValue(options.value[0], optionProps.value.value) : options.value[0]) as string
if (unref(multiple)) {
proxyOptionsValue.value = [result]
} else {
proxyOptionsValue.value = result
}
}
}, { immediate: true })
}
if (autoGet) {
if (!(props.config.dependOn?.length) && !(props.config.outDependOn?.length)) {
getOptions() // .then(() => { console.log('[init]: getOptions') })
if (props.config.options) { // 动态表单设计时修改options需要触发此方法
watch(() => props.config.options, () => {
getOptions() // .then(() => { console.log('[config.options change]: getOptions') })
})
}
} else {
watch([() => props.dependOnValues, () => props.outDependOnValues], ([dependOnValues, outDependOnValues]) => {
getOptions(dependOnValues || {}, outDependOnValues || {}) // .then(() => { console.log('[dependOn change]: getOptions') })
}, { immediate: true })
}
}
return {

@@ -400,0 +400,0 @@ optionProps,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc