tiddy 2.0.4 → 2.0.6
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/index.css +15 -0
- package/dist/index.d.ts +22 -21
- package/dist/index.js +27 -21
- package/package.json +5 -5
package/dist/index.css
CHANGED
|
@@ -24,3 +24,18 @@
|
|
|
24
24
|
flex: 1;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
|
|
28
|
+
.field-enter-active, .field-leave-active {
|
|
29
|
+
transition: all 0.2s;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
.field-enter-to, .field-leave-from {
|
|
33
|
+
height: calc-size(auto, size) !important;
|
|
34
|
+
opacity: 1 !important;
|
|
35
|
+
}
|
|
36
|
+
.field-enter-from, .field-leave-to {
|
|
37
|
+
height: 0 !important;
|
|
38
|
+
margin-bottom: 0 !important;
|
|
39
|
+
opacity: 0 !important;
|
|
40
|
+
}
|
|
41
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as vue41 from "vue";
|
|
2
|
-
import { AllowedComponentProps, CSSProperties, Component,
|
|
2
|
+
import { AllowedComponentProps, CSSProperties, Component, DefineComponent, ExtractPublicPropTypes, PropType, Raw, Slot } from "vue";
|
|
3
3
|
import * as element_plus0 from "element-plus";
|
|
4
|
-
import { DialogInstance, DialogProps, FormInstance, FormItemProps, FormItemRule, FormProps, TableColumnInstance, TableInstance } from "element-plus";
|
|
4
|
+
import { DialogInstance, DialogProps, FormInstance, FormItemProp, FormItemProps, FormItemRule, FormProps, TableColumnInstance, TableInstance } from "element-plus";
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
7
7
|
type OrArray<T> = T | T[];
|
|
8
8
|
type OrFunction<T> = T | ((...args: any[]) => T);
|
|
9
9
|
type AnyFunction<A extends any[] = any[], R = any> = (...args: A) => R;
|
|
10
|
-
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
10
|
+
type MakeOptional<T, K$1 extends keyof T> = Omit<T, K$1> & Partial<Pick<T, K$1>>;
|
|
11
11
|
interface ComponentSlot {
|
|
12
12
|
name: string;
|
|
13
13
|
component?: Component | Slot;
|
|
@@ -17,6 +17,7 @@ interface ComponentSlot {
|
|
|
17
17
|
isSlot?: boolean;
|
|
18
18
|
}
|
|
19
19
|
type SlotDef = ComponentSlot | string | RegExp;
|
|
20
|
+
type OrRef<T> = T | Ref<T>;
|
|
20
21
|
//#endregion
|
|
21
22
|
//#region src/form/utils.d.ts
|
|
22
23
|
type TdFieldsProps = {
|
|
@@ -28,11 +29,11 @@ declare const objectFieldPropsDef: {
|
|
|
28
29
|
required: true;
|
|
29
30
|
};
|
|
30
31
|
hide: {
|
|
31
|
-
type: PropType<OrFunction<boolean> |
|
|
32
|
+
type: PropType<OrFunction<boolean> | OrRef<boolean>>;
|
|
32
33
|
default: boolean;
|
|
33
34
|
};
|
|
34
35
|
label: {
|
|
35
|
-
type: PropType<OrFunction<string> |
|
|
36
|
+
type: PropType<OrFunction<string> | OrRef<string>>;
|
|
36
37
|
};
|
|
37
38
|
labelWidth: {
|
|
38
39
|
type: PropType<OrFunction<string | number>>;
|
|
@@ -56,11 +57,11 @@ declare const widgetFieldPropsDef: {
|
|
|
56
57
|
required: true;
|
|
57
58
|
};
|
|
58
59
|
hide: {
|
|
59
|
-
type: PropType<OrFunction<boolean> |
|
|
60
|
+
type: PropType<OrFunction<boolean> | OrRef<boolean>>;
|
|
60
61
|
default: boolean;
|
|
61
62
|
};
|
|
62
63
|
label: {
|
|
63
|
-
type: PropType<OrFunction<string> |
|
|
64
|
+
type: PropType<OrFunction<string> | OrRef<string>>;
|
|
64
65
|
};
|
|
65
66
|
labelWidth: {
|
|
66
67
|
type: PropType<OrFunction<string | number>>;
|
|
@@ -88,7 +89,7 @@ declare const widgetFieldPropsDef: {
|
|
|
88
89
|
default: (value: any) => any;
|
|
89
90
|
};
|
|
90
91
|
item: {
|
|
91
|
-
type: PropType<TdFormItemProps
|
|
92
|
+
type: PropType<OrRef<TdFormItemProps>>;
|
|
92
93
|
default: () => {};
|
|
93
94
|
};
|
|
94
95
|
widget: {
|
|
@@ -100,7 +101,7 @@ declare const widgetFieldPropsDef: {
|
|
|
100
101
|
default: () => {};
|
|
101
102
|
};
|
|
102
103
|
rules: {
|
|
103
|
-
type: PropType<OrArray<FormItemRule
|
|
104
|
+
type: PropType<OrRef<OrArray<FormItemRule>>>;
|
|
104
105
|
default: () => never[];
|
|
105
106
|
};
|
|
106
107
|
slots: {
|
|
@@ -134,11 +135,11 @@ declare const arrayFieldPropsDef: {
|
|
|
134
135
|
required: true;
|
|
135
136
|
};
|
|
136
137
|
hide: {
|
|
137
|
-
type: PropType<OrFunction<boolean> |
|
|
138
|
+
type: PropType<OrFunction<boolean> | OrRef<boolean>>;
|
|
138
139
|
default: boolean;
|
|
139
140
|
};
|
|
140
141
|
label: {
|
|
141
|
-
type: PropType<OrFunction<string> |
|
|
142
|
+
type: PropType<OrFunction<string> | OrRef<string>>;
|
|
142
143
|
};
|
|
143
144
|
labelWidth: {
|
|
144
145
|
type: PropType<OrFunction<string | number>>;
|
|
@@ -186,11 +187,11 @@ declare const layoutFieldPropsDef: {
|
|
|
186
187
|
required: true;
|
|
187
188
|
};
|
|
188
189
|
hide: {
|
|
189
|
-
type: PropType<OrFunction<boolean> |
|
|
190
|
+
type: PropType<OrFunction<boolean> | OrRef<boolean>>;
|
|
190
191
|
default: boolean;
|
|
191
192
|
};
|
|
192
193
|
label: {
|
|
193
|
-
type: PropType<OrFunction<string> |
|
|
194
|
+
type: PropType<OrFunction<string> | OrRef<string>>;
|
|
194
195
|
};
|
|
195
196
|
labelWidth: {
|
|
196
197
|
type: PropType<OrFunction<string | number>>;
|
|
@@ -227,7 +228,7 @@ declare const formPropsDef: {
|
|
|
227
228
|
type TdFormProps = ExtractPublicPropTypes<typeof formPropsDef> & FormProps;
|
|
228
229
|
declare const tdformItemProps: {
|
|
229
230
|
messageLabel: {
|
|
230
|
-
type: PropType<
|
|
231
|
+
type: PropType<OrRef<string>>;
|
|
231
232
|
default: string;
|
|
232
233
|
};
|
|
233
234
|
formatMessage: {
|
|
@@ -240,13 +241,13 @@ declare const tdformItemProps: {
|
|
|
240
241
|
};
|
|
241
242
|
};
|
|
242
243
|
type TdFormItemProps = ExtractPublicPropTypes<typeof tdformItemProps> & Partial<FormItemProps>;
|
|
243
|
-
declare function widget<T>(c: T
|
|
244
|
-
component: T
|
|
245
|
-
widget:
|
|
244
|
+
declare function widget<T>(c: T | Raw<T>, props?: OrRef<PropsOf<T>>): {
|
|
245
|
+
component: T | Raw<T>;
|
|
246
|
+
widget: any;
|
|
246
247
|
};
|
|
247
248
|
//#endregion
|
|
248
249
|
//#region src/form/form.vue.d.ts
|
|
249
|
-
declare function reValidateErrorFields(): void;
|
|
250
|
+
declare function reValidateErrorFields(props?: FormItemProp): void;
|
|
250
251
|
declare const expose$1: {
|
|
251
252
|
reValidateErrorFields: typeof reValidateErrorFields;
|
|
252
253
|
model: vue41.ComputedRef<unknown>;
|
|
@@ -299,7 +300,7 @@ declare var __VLS_10: string | number, __VLS_11: any;
|
|
|
299
300
|
type __VLS_Slots$2 = {} & { [K in NonNullable<typeof __VLS_10>]?: (props: typeof __VLS_11) => any };
|
|
300
301
|
declare const __VLS_base$2: vue41.DefineComponent<vue41.ExtractPropTypes<{
|
|
301
302
|
messageLabel: {
|
|
302
|
-
type: vue41.PropType<
|
|
303
|
+
type: vue41.PropType<OrRef<string>>;
|
|
303
304
|
default: string;
|
|
304
305
|
};
|
|
305
306
|
formatMessage: {
|
|
@@ -312,7 +313,7 @@ declare const __VLS_base$2: vue41.DefineComponent<vue41.ExtractPropTypes<{
|
|
|
312
313
|
};
|
|
313
314
|
}>, {}, {}, {}, {}, vue41.ComponentOptionsMixin, vue41.ComponentOptionsMixin, {}, string, vue41.PublicProps, Readonly<vue41.ExtractPropTypes<{
|
|
314
315
|
messageLabel: {
|
|
315
|
-
type: vue41.PropType<
|
|
316
|
+
type: vue41.PropType<OrRef<string>>;
|
|
316
317
|
default: string;
|
|
317
318
|
};
|
|
318
319
|
formatMessage: {
|
|
@@ -324,7 +325,7 @@ declare const __VLS_base$2: vue41.DefineComponent<vue41.ExtractPropTypes<{
|
|
|
324
325
|
default: boolean;
|
|
325
326
|
};
|
|
326
327
|
}>> & Readonly<{}>, {
|
|
327
|
-
messageLabel:
|
|
328
|
+
messageLabel: any;
|
|
328
329
|
formatMessage: AnyFunction;
|
|
329
330
|
hideRequiredAsterisk: boolean;
|
|
330
331
|
}, {}, {}, {}, string, vue41.ComponentProvideOptions, true, {}, any>;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, isRef, markRaw, mergeProps, normalizeClass, normalizeProps, normalizeStyle, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, shallowRef, toDisplayString, toHandlers, toRaw, toRef, unref, useAttrs, useSlots, useTemplateRef, withCtx, withModifiers } from "vue";
|
|
1
|
+
import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, isRef, markRaw, mergeProps, normalizeClass, normalizeProps, normalizeStyle, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, shallowRef, toDisplayString, toHandlers, toRaw, toRef, unref, useAttrs, useSlots, useTemplateRef, withCtx, withModifiers } from "vue";
|
|
2
2
|
import { ElDialog, ElForm, ElFormItem, ElTable, ElTableColumn, useNamespace } from "element-plus";
|
|
3
3
|
import { cut, ensureArray, getDeepValue, groupBy, isFunction, isNullOrUndef, isObject, isString, pick, setDeepValue, toCamelCase, toKebabCase, uid } from "yatter";
|
|
4
4
|
|
|
@@ -316,16 +316,16 @@ var object_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
316
316
|
const labelProps = computed(() => pick(props, [/^label/]));
|
|
317
317
|
const subFields = computed(() => {
|
|
318
318
|
return props.fields.map((field) => {
|
|
319
|
-
return {
|
|
320
|
-
...field,
|
|
321
|
-
"full-prop": [attrs["full-prop"], field.prop].filter(Boolean).join(".")
|
|
322
|
-
};
|
|
319
|
+
return [field, { "full-prop": [attrs["full-prop"], field.prop].filter(Boolean).join(".") }];
|
|
323
320
|
});
|
|
324
321
|
});
|
|
325
322
|
return (_ctx, _cache) => {
|
|
326
323
|
return openBlock(), createBlock(form_item_default, mergeProps(labelProps.value, { class: "layout-form-item" }), {
|
|
327
324
|
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(subFields.value, (field) => {
|
|
328
|
-
return openBlock(), createBlock(form_field_default, mergeProps({ key: unref(getKey)(field) }, { ref_for: true },
|
|
325
|
+
return openBlock(), createBlock(form_field_default, mergeProps({ key: unref(getKey)(field[0]) }, { ref_for: true }, {
|
|
326
|
+
...field[0],
|
|
327
|
+
...field[1]
|
|
328
|
+
}), null, 16);
|
|
329
329
|
}), 128))]),
|
|
330
330
|
_: 1
|
|
331
331
|
}, 16);
|
|
@@ -578,11 +578,11 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
578
578
|
if (props.mandatory && !values.value?.length) lineAction.add(-1);
|
|
579
579
|
});
|
|
580
580
|
return (_ctx, _cache) => {
|
|
581
|
-
return
|
|
581
|
+
return unref(OuterEmptySlot) && !values.value.length ? (openBlock(), createBlock(resolveDynamicComponent(unref(OuterEmptySlot).component), {
|
|
582
582
|
key: 0,
|
|
583
583
|
add: lineAction.add.bind(null, -1),
|
|
584
584
|
empty: true
|
|
585
|
-
}, null, 8, ["add"])) :
|
|
585
|
+
}, null, 8, ["add"])) : (openBlock(), createBlock(form_item_default, mergeProps({ key: 1 }, labelProps.value, { class: "layout-form-item" }), {
|
|
586
586
|
default: withCtx(() => [unref(EmptySlot) && !values.value.length ? (openBlock(), createBlock(resolveDynamicComponent(unref(EmptySlot).component), {
|
|
587
587
|
key: 0,
|
|
588
588
|
add: lineAction.add.bind(null, -1),
|
|
@@ -628,7 +628,7 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
628
628
|
])) : createCommentVNode("v-if", true)])], 4);
|
|
629
629
|
}), 128))]),
|
|
630
630
|
_: 1
|
|
631
|
-
}, 16))
|
|
631
|
+
}, 16));
|
|
632
632
|
};
|
|
633
633
|
}
|
|
634
634
|
});
|
|
@@ -651,21 +651,20 @@ var layout_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
651
651
|
const formCtx = inject(formCtxKey);
|
|
652
652
|
const subFields = computed(() => {
|
|
653
653
|
return props.fields.map((field) => {
|
|
654
|
-
return {
|
|
655
|
-
...field,
|
|
656
|
-
"full-prop": [attrs["full-prop"], field.prop].filter(Boolean).join(".")
|
|
657
|
-
};
|
|
654
|
+
return [field, { "full-prop": [attrs["full-prop"], field.prop].filter(Boolean).join(".") }];
|
|
658
655
|
});
|
|
659
656
|
});
|
|
660
|
-
const
|
|
661
|
-
const { prefix: prefixSlots, suffix: suffixSlots } = groupBy(layoutSlots, (slot) => slot.name.match(/^[a-z]+/i)?.[0] ?? "");
|
|
657
|
+
const { prefix: prefixSlots, suffix: suffixSlots } = groupBy(formCtx.getParentSlots(ensureArray(props.slots)), (slot) => slot.name.match(/^[a-z]+/i)?.[0] ?? "");
|
|
662
658
|
return (_ctx, _cache) => {
|
|
663
659
|
return openBlock(), createElementBlock("div", mergeProps({ class: "layout-item" }, layoutProps.value), [
|
|
664
660
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(prefixSlots), (psc) => {
|
|
665
661
|
return openBlock(), createBlock(deep_slot_default, mergeProps({ key: psc.name }, { ref_for: true }, psc, { "ctx-key": unref(formCtxKey) }), null, 16, ["ctx-key"]);
|
|
666
662
|
}), 128)),
|
|
667
663
|
(openBlock(true), createElementBlock(Fragment, null, renderList(subFields.value, (field) => {
|
|
668
|
-
return openBlock(), createBlock(form_field_default, mergeProps({ key: unref(getKey)(field) }, { ref_for: true },
|
|
664
|
+
return openBlock(), createBlock(form_field_default, mergeProps({ key: unref(getKey)(field[0]) }, { ref_for: true }, {
|
|
665
|
+
...field[0],
|
|
666
|
+
...field[1]
|
|
667
|
+
}), null, 16);
|
|
669
668
|
}), 128)),
|
|
670
669
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(suffixSlots), (psc) => {
|
|
671
670
|
return openBlock(), createBlock(deep_slot_default, mergeProps({ key: psc.name }, { ref_for: true }, psc, { "ctx-key": unref(formCtxKey) }), null, 16, ["ctx-key"]);
|
|
@@ -700,15 +699,18 @@ var form_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
700
699
|
return false;
|
|
701
700
|
}
|
|
702
701
|
const FieldComponents = computed(() => {
|
|
703
|
-
if (isHidden()) return
|
|
702
|
+
if (isHidden()) return "div";
|
|
704
703
|
if (attrs.type === "array") return array_field_default;
|
|
705
704
|
if (attrs.type === "layout") return layout_field_default;
|
|
706
705
|
if (attrs.type === "object" || !attrs.type && !!attrs.fields) return object_field_default;
|
|
707
706
|
if (attrs.type === "widget" || !attrs.type && !!attrs.component) return widget_field_default;
|
|
708
|
-
return
|
|
707
|
+
return "div";
|
|
709
708
|
});
|
|
710
709
|
return (_ctx, _cache) => {
|
|
711
|
-
return openBlock(), createBlock(
|
|
710
|
+
return openBlock(), createBlock(Transition, { name: "field" }, {
|
|
711
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(FieldComponents.value), mergeProps(fieldAttrs.value, { "full-prop": fullProp.value }), null, 16, ["full-prop"]))]),
|
|
712
|
+
_: 1
|
|
713
|
+
});
|
|
712
714
|
};
|
|
713
715
|
}
|
|
714
716
|
});
|
|
@@ -738,8 +740,12 @@ var form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
|
|
|
738
740
|
itemOption: props.item,
|
|
739
741
|
getParentSlots: getSlotsFactory(slots)
|
|
740
742
|
}));
|
|
741
|
-
function reValidateErrorFields() {
|
|
742
|
-
|
|
743
|
+
function reValidateErrorFields(props$1) {
|
|
744
|
+
let fields = formRef.value?.fields ?? [];
|
|
745
|
+
if (props$1) fields = fields.filter((f) => {
|
|
746
|
+
return ensureArray(props$1).includes(f.propString);
|
|
747
|
+
});
|
|
748
|
+
for (const field of fields) if (field.validateState === "error") field.validate("");
|
|
743
749
|
}
|
|
744
750
|
const expose = {
|
|
745
751
|
reValidateErrorFields,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiddy",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"packageManager": "pnpm@10.11.0",
|
|
5
5
|
"description": "A set of Vue 3 components based on element-plus",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"docs:preview": "vitepress preview docs"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"element-plus": "^2.
|
|
40
|
+
"element-plus": "^2.11.7",
|
|
41
41
|
"vue": "^3.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"@vue/test-utils": "^2.4.6",
|
|
48
48
|
"async-validator": "^4.2.5",
|
|
49
49
|
"decimal-format": "^4.0.3",
|
|
50
|
-
"element-plus": "^2.
|
|
50
|
+
"element-plus": "^2.11.7",
|
|
51
51
|
"happy-dom": "^17.4.7",
|
|
52
52
|
"sass-embedded": "^1.89.1",
|
|
53
|
-
"tsdown": "^0.
|
|
53
|
+
"tsdown": "^0.16.4",
|
|
54
54
|
"tsx": "^4.19.4",
|
|
55
55
|
"typescript": "^5.8.3",
|
|
56
56
|
"vite": "npm:rolldown-vite@latest",
|
|
@@ -62,6 +62,6 @@
|
|
|
62
62
|
"vue-tsc": "^3.1.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"yatter": "^
|
|
65
|
+
"yatter": "^3.0.0"
|
|
66
66
|
}
|
|
67
67
|
}
|