knt-shared 1.7.0 → 1.7.2
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/components/Form/BasicForm.vue.d.ts +2 -2
- package/dist/components/Form/BasicForm.vue.d.ts.map +1 -1
- package/dist/components/Form/types.d.ts +31 -3
- package/dist/components/Form/types.d.ts.map +1 -1
- package/dist/components/Table/BasicTable.vue.d.ts +1 -1
- package/dist/index.cjs.js +104 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +104 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/calc.d.ts +45 -0
- package/dist/utils/calc.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/components/Loading/__tests__/BasicLoading.spec.d.ts +0 -2
- package/dist/components/Loading/__tests__/BasicLoading.spec.d.ts.map +0 -1
- package/dist/components/Loading/__tests__/createLoading.spec.d.ts +0 -2
- package/dist/components/Loading/__tests__/createLoading.spec.d.ts.map +0 -1
- package/dist/components/Loading/__tests__/setup.d.ts +0 -2
- package/dist/components/Loading/__tests__/setup.d.ts.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -4312,10 +4312,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4312
4312
|
};
|
|
4313
4313
|
};
|
|
4314
4314
|
const getPlaceholderText = (schema) => {
|
|
4315
|
-
var _a;
|
|
4316
4315
|
const propsData = unref(getProps);
|
|
4317
|
-
|
|
4318
|
-
|
|
4316
|
+
const resolvedProps = resolveComponentProps(schema);
|
|
4317
|
+
if (resolvedProps.placeholder) {
|
|
4318
|
+
return resolvedProps.placeholder;
|
|
4319
4319
|
}
|
|
4320
4320
|
if (!propsData.autoSetPlaceHolder) {
|
|
4321
4321
|
return "";
|
|
@@ -4330,7 +4330,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4330
4330
|
disabled = typeof schema.disabled === "boolean" ? schema.disabled : schema.disabled(formModel);
|
|
4331
4331
|
}
|
|
4332
4332
|
return {
|
|
4333
|
-
...schema
|
|
4333
|
+
...resolveComponentProps(schema),
|
|
4334
4334
|
disabled
|
|
4335
4335
|
};
|
|
4336
4336
|
};
|
|
@@ -4390,6 +4390,31 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4390
4390
|
}
|
|
4391
4391
|
return null;
|
|
4392
4392
|
};
|
|
4393
|
+
const getFormActionType = () => ({
|
|
4394
|
+
getFieldsValue,
|
|
4395
|
+
setFieldsValue,
|
|
4396
|
+
resetFields,
|
|
4397
|
+
validate,
|
|
4398
|
+
clearValidate,
|
|
4399
|
+
updateSchema,
|
|
4400
|
+
removeSchema,
|
|
4401
|
+
getSchema,
|
|
4402
|
+
resetSchema,
|
|
4403
|
+
setProps,
|
|
4404
|
+
scrollToField,
|
|
4405
|
+
submit: handleSubmit
|
|
4406
|
+
});
|
|
4407
|
+
const resolveComponentProps = (schema) => {
|
|
4408
|
+
const { componentProps } = schema;
|
|
4409
|
+
if (typeof componentProps === "function") {
|
|
4410
|
+
return componentProps({
|
|
4411
|
+
schema,
|
|
4412
|
+
formActionType: getFormActionType(),
|
|
4413
|
+
formModel
|
|
4414
|
+
});
|
|
4415
|
+
}
|
|
4416
|
+
return componentProps ?? {};
|
|
4417
|
+
};
|
|
4393
4418
|
const handleSubmit = async (data) => {
|
|
4394
4419
|
try {
|
|
4395
4420
|
submitLoading.value = true;
|
|
@@ -4453,7 +4478,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4453
4478
|
);
|
|
4454
4479
|
if (index !== -1) {
|
|
4455
4480
|
const oldSchema = internalSchemas.value[index];
|
|
4456
|
-
const mergedComponentProps =
|
|
4481
|
+
const mergedComponentProps = (() => {
|
|
4482
|
+
if (!item.componentProps) return oldSchema.componentProps;
|
|
4483
|
+
if (typeof item.componentProps === "function" || typeof oldSchema.componentProps === "function") {
|
|
4484
|
+
return item.componentProps;
|
|
4485
|
+
}
|
|
4486
|
+
return { ...oldSchema.componentProps, ...item.componentProps };
|
|
4487
|
+
})();
|
|
4457
4488
|
internalSchemas.value[index] = {
|
|
4458
4489
|
...oldSchema,
|
|
4459
4490
|
...item,
|
|
@@ -4594,7 +4625,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4594
4625
|
key: 2,
|
|
4595
4626
|
value: formModel[schema.field],
|
|
4596
4627
|
component: getComponentString(((_a = schema.readonlyConfig) == null ? void 0 : _a.component) || schema.component),
|
|
4597
|
-
componentProps: schema
|
|
4628
|
+
componentProps: resolveComponentProps(schema),
|
|
4598
4629
|
labelMap: (_b = schema.readonlyConfig) == null ? void 0 : _b.labelMap,
|
|
4599
4630
|
fetchOptions: (_c = schema.readonlyConfig) == null ? void 0 : _c.fetchOptions,
|
|
4600
4631
|
emptyText: (_d = schema.readonlyConfig) == null ? void 0 : _d.emptyText,
|
|
@@ -9454,6 +9485,69 @@ function fallbackCopyToClipboard(text) {
|
|
|
9454
9485
|
document.body.removeChild(textarea);
|
|
9455
9486
|
}
|
|
9456
9487
|
}
|
|
9488
|
+
const calcMul = (a, b) => {
|
|
9489
|
+
let c = 0;
|
|
9490
|
+
const d = a.toString();
|
|
9491
|
+
const e = b.toString();
|
|
9492
|
+
try {
|
|
9493
|
+
c += d.split(".")[1].length;
|
|
9494
|
+
} catch {
|
|
9495
|
+
}
|
|
9496
|
+
try {
|
|
9497
|
+
c += e.split(".")[1].length;
|
|
9498
|
+
} catch {
|
|
9499
|
+
}
|
|
9500
|
+
return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
|
|
9501
|
+
};
|
|
9502
|
+
const calcAdd = (a, b) => {
|
|
9503
|
+
let c;
|
|
9504
|
+
let d;
|
|
9505
|
+
let e;
|
|
9506
|
+
try {
|
|
9507
|
+
c = a.toString().split(".")[1].length;
|
|
9508
|
+
} catch {
|
|
9509
|
+
c = 0;
|
|
9510
|
+
}
|
|
9511
|
+
try {
|
|
9512
|
+
d = b.toString().split(".")[1].length;
|
|
9513
|
+
} catch {
|
|
9514
|
+
d = 0;
|
|
9515
|
+
}
|
|
9516
|
+
e = Math.pow(10, Math.max(c, d));
|
|
9517
|
+
return (calcMul(a, e) + calcMul(b, e)) / e;
|
|
9518
|
+
};
|
|
9519
|
+
const calcSub = (a, b) => {
|
|
9520
|
+
let c;
|
|
9521
|
+
let d;
|
|
9522
|
+
let e;
|
|
9523
|
+
try {
|
|
9524
|
+
c = a.toString().split(".")[1].length;
|
|
9525
|
+
} catch {
|
|
9526
|
+
c = 0;
|
|
9527
|
+
}
|
|
9528
|
+
try {
|
|
9529
|
+
d = b.toString().split(".")[1].length;
|
|
9530
|
+
} catch {
|
|
9531
|
+
d = 0;
|
|
9532
|
+
}
|
|
9533
|
+
e = Math.pow(10, Math.max(c, d));
|
|
9534
|
+
return (calcMul(a, e) - calcMul(b, e)) / e;
|
|
9535
|
+
};
|
|
9536
|
+
const calcDiv = (a, b) => {
|
|
9537
|
+
let e = 0;
|
|
9538
|
+
let f = 0;
|
|
9539
|
+
try {
|
|
9540
|
+
e = a.toString().split(".")[1].length;
|
|
9541
|
+
} catch {
|
|
9542
|
+
}
|
|
9543
|
+
try {
|
|
9544
|
+
f = b.toString().split(".")[1].length;
|
|
9545
|
+
} catch {
|
|
9546
|
+
}
|
|
9547
|
+
const c = Number(a.toString().replace(".", ""));
|
|
9548
|
+
const d = Number(b.toString().replace(".", ""));
|
|
9549
|
+
return calcMul(c / d, Math.pow(10, f - e));
|
|
9550
|
+
};
|
|
9457
9551
|
function useDebounce(value, delay = 300) {
|
|
9458
9552
|
const debouncedValue = ref(value.value);
|
|
9459
9553
|
let timer = null;
|
|
@@ -9513,6 +9607,10 @@ export {
|
|
|
9513
9607
|
VideoPreview,
|
|
9514
9608
|
VideoPreviewModal,
|
|
9515
9609
|
arrayToMap,
|
|
9610
|
+
calcAdd,
|
|
9611
|
+
calcDiv,
|
|
9612
|
+
calcMul,
|
|
9613
|
+
calcSub,
|
|
9516
9614
|
classifyFiles,
|
|
9517
9615
|
clearAllCache,
|
|
9518
9616
|
clearApiCache,
|