tiddy 2.6.3 → 2.7.0
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.d.ts +30 -3
- package/dist/index.js +93 -30
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -163,21 +163,37 @@ declare const arrayFieldPropsDef: {
|
|
|
163
163
|
type: PropType<AnyFunction>;
|
|
164
164
|
};
|
|
165
165
|
outerEmptyAction: {
|
|
166
|
-
type:
|
|
166
|
+
type: PropType<OrArray<SlotDef>>;
|
|
167
167
|
default: null;
|
|
168
168
|
};
|
|
169
169
|
emptyAction: {
|
|
170
|
-
type:
|
|
170
|
+
type: PropType<OrArray<SlotDef>>;
|
|
171
171
|
default: null;
|
|
172
172
|
};
|
|
173
173
|
rowAction: {
|
|
174
|
-
type:
|
|
174
|
+
type: PropType<OrArray<SlotDef>>;
|
|
175
175
|
default: null;
|
|
176
176
|
};
|
|
177
177
|
lineStyle: {
|
|
178
178
|
type: PropType<CSSProperties>;
|
|
179
179
|
default: () => {};
|
|
180
180
|
};
|
|
181
|
+
item: {
|
|
182
|
+
type: PropType<OrRef<TdFormItemProps>>;
|
|
183
|
+
default: () => {};
|
|
184
|
+
};
|
|
185
|
+
lineClass: {
|
|
186
|
+
type: StringConstructor;
|
|
187
|
+
default: string;
|
|
188
|
+
};
|
|
189
|
+
rowFieldClass: {
|
|
190
|
+
type: StringConstructor;
|
|
191
|
+
default: string;
|
|
192
|
+
};
|
|
193
|
+
rowActionClass: {
|
|
194
|
+
type: StringConstructor;
|
|
195
|
+
default: string;
|
|
196
|
+
};
|
|
181
197
|
mandatory: {
|
|
182
198
|
type: BooleanConstructor;
|
|
183
199
|
default: boolean;
|
|
@@ -211,6 +227,17 @@ declare const layoutFieldPropsDef: {
|
|
|
211
227
|
default: string;
|
|
212
228
|
required: true;
|
|
213
229
|
};
|
|
230
|
+
component: {
|
|
231
|
+
type: PropType<string | Component | Raw<Component>>;
|
|
232
|
+
};
|
|
233
|
+
widget: {
|
|
234
|
+
type: PropType<Record<string, any>>;
|
|
235
|
+
default: () => {};
|
|
236
|
+
};
|
|
237
|
+
on: {
|
|
238
|
+
type: PropType<Record<string, AnyFunction>>;
|
|
239
|
+
default: () => {};
|
|
240
|
+
};
|
|
214
241
|
slots: {
|
|
215
242
|
type: PropType<OrArray<SlotDef>>;
|
|
216
243
|
default: () => never[];
|
package/dist/index.js
CHANGED
|
@@ -173,21 +173,49 @@ const arrayFieldPropsDef = {
|
|
|
173
173
|
},
|
|
174
174
|
rawValue: { type: Function },
|
|
175
175
|
outerEmptyAction: {
|
|
176
|
-
type:
|
|
176
|
+
type: [
|
|
177
|
+
Array,
|
|
178
|
+
Object,
|
|
179
|
+
String
|
|
180
|
+
],
|
|
177
181
|
default: null
|
|
178
182
|
},
|
|
179
183
|
emptyAction: {
|
|
180
|
-
type:
|
|
184
|
+
type: [
|
|
185
|
+
Array,
|
|
186
|
+
Object,
|
|
187
|
+
String
|
|
188
|
+
],
|
|
181
189
|
default: null
|
|
182
190
|
},
|
|
183
191
|
rowAction: {
|
|
184
|
-
type:
|
|
192
|
+
type: [
|
|
193
|
+
Array,
|
|
194
|
+
Object,
|
|
195
|
+
String
|
|
196
|
+
],
|
|
185
197
|
default: null
|
|
186
198
|
},
|
|
187
199
|
lineStyle: {
|
|
188
200
|
type: Object,
|
|
189
201
|
default: () => ({})
|
|
190
202
|
},
|
|
203
|
+
item: {
|
|
204
|
+
type: Object,
|
|
205
|
+
default: () => ({})
|
|
206
|
+
},
|
|
207
|
+
lineClass: {
|
|
208
|
+
type: String,
|
|
209
|
+
default: ""
|
|
210
|
+
},
|
|
211
|
+
rowFieldClass: {
|
|
212
|
+
type: String,
|
|
213
|
+
default: ""
|
|
214
|
+
},
|
|
215
|
+
rowActionClass: {
|
|
216
|
+
type: String,
|
|
217
|
+
default: ""
|
|
218
|
+
},
|
|
191
219
|
mandatory: {
|
|
192
220
|
type: Boolean,
|
|
193
221
|
default: false
|
|
@@ -201,6 +229,19 @@ const layoutFieldPropsDef = {
|
|
|
201
229
|
default: "layout",
|
|
202
230
|
required: true
|
|
203
231
|
},
|
|
232
|
+
component: { type: [
|
|
233
|
+
String,
|
|
234
|
+
Object,
|
|
235
|
+
Function
|
|
236
|
+
] },
|
|
237
|
+
widget: {
|
|
238
|
+
type: Object,
|
|
239
|
+
default: () => ({})
|
|
240
|
+
},
|
|
241
|
+
on: {
|
|
242
|
+
type: Object,
|
|
243
|
+
default: () => ({})
|
|
244
|
+
},
|
|
204
245
|
slots: {
|
|
205
246
|
type: [
|
|
206
247
|
Array,
|
|
@@ -580,8 +621,6 @@ var widget_field_default = widget_field_vue_vue_type_script_setup_true_lang_defa
|
|
|
580
621
|
|
|
581
622
|
//#endregion
|
|
582
623
|
//#region src/form/array-field.vue?vue&type=script&setup=true&lang.ts
|
|
583
|
-
const _hoisted_1 = { class: "row-item" };
|
|
584
|
-
const _hoisted_2 = { class: "row-action" };
|
|
585
624
|
var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
586
625
|
inheritAttrs: false,
|
|
587
626
|
__name: "array-field",
|
|
@@ -591,14 +630,14 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
591
630
|
const attrs = useAttrs();
|
|
592
631
|
const fieldProps = computed(() => {
|
|
593
632
|
return {
|
|
594
|
-
...cut(props, [(k) => k.endsWith("Action") || ["lineStyle"].includes(k)]),
|
|
633
|
+
...cut(props, [(k) => k.endsWith("Action") || k.endsWith("Class") || ["lineStyle", "item"].includes(k)]),
|
|
595
634
|
...attrs
|
|
596
635
|
};
|
|
597
636
|
});
|
|
598
637
|
const formCtx = inject(formCtxKey);
|
|
599
|
-
const OuterEmptySlot = formCtx.getParentSlots(resolveSlotNames(props.outerEmptyAction
|
|
600
|
-
const EmptySlot = formCtx.getParentSlots(resolveSlotNames(props.emptyAction
|
|
601
|
-
const RowSlot = formCtx.getParentSlots(resolveSlotNames(props.rowAction
|
|
638
|
+
const OuterEmptySlot = formCtx.getParentSlots(resolveSlotNames(props.outerEmptyAction, `${props.prop}-action_outer`))[0];
|
|
639
|
+
const EmptySlot = formCtx.getParentSlots(resolveSlotNames(props.emptyAction, `${props.prop}-action_empty`))[0];
|
|
640
|
+
const RowSlot = formCtx.getParentSlots(resolveSlotNames(props.rowAction, `${props.prop}-action_row`))[0];
|
|
602
641
|
const parentFullProp = computed(() => attrs["full-prop"] || "");
|
|
603
642
|
const values = computed(() => {
|
|
604
643
|
return getDeepValue(formCtx.model, parentFullProp.value, { fallback: [] });
|
|
@@ -610,6 +649,10 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
610
649
|
p.labelPosition = indexProp(p.labelPosition, -1);
|
|
611
650
|
return p;
|
|
612
651
|
});
|
|
652
|
+
const itemAttrs = computed(() => {
|
|
653
|
+
const entries = Object.entries(unref(props.item)).map(([k, v]) => [k, unref(v)]);
|
|
654
|
+
return Object.assign({}, Object.fromEntries(entries), labelProps.value);
|
|
655
|
+
});
|
|
613
656
|
function indexProp(v, index, value) {
|
|
614
657
|
if (isFunction(v)) return v(index);
|
|
615
658
|
if (isNullOrUndef(value)) return v;
|
|
@@ -653,7 +696,7 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
653
696
|
key: 0,
|
|
654
697
|
add: lineAction.add.bind(null, -1),
|
|
655
698
|
empty: true
|
|
656
|
-
}, null, 8, ["add"])) : (openBlock(), createBlock(form_item_default, mergeProps({ key: 1 },
|
|
699
|
+
}, null, 8, ["add"])) : (openBlock(), createBlock(form_item_default, mergeProps({ key: 1 }, itemAttrs.value, { class: "layout-form-item" }), {
|
|
657
700
|
default: withCtx(() => [unref(EmptySlot) && !values.value.length ? (openBlock(), createBlock(resolveDynamicComponent(unref(EmptySlot).component), {
|
|
658
701
|
key: 0,
|
|
659
702
|
add: lineAction.add.bind(null, -1),
|
|
@@ -661,9 +704,9 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
661
704
|
}, null, 8, ["add"])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(values.value, (v, vi) => {
|
|
662
705
|
return openBlock(), createElementBlock("div", {
|
|
663
706
|
key: unref(getKey)(v),
|
|
664
|
-
class: "list-row",
|
|
707
|
+
class: normalizeClass(["list-row", _ctx.lineClass]),
|
|
665
708
|
style: normalizeStyle(_ctx.lineStyle)
|
|
666
|
-
}, [createElementVNode("div",
|
|
709
|
+
}, [createElementVNode("div", { class: normalizeClass(["row-item", _ctx.rowFieldClass]) }, [createVNode(form_field_default, mergeProps({ "name-space": "layout-form-item" }, { ref_for: true }, fieldProps.value, {
|
|
667
710
|
label: indexProp(_ctx.label, vi),
|
|
668
711
|
"label-width": indexProp(_ctx.labelWidth, vi),
|
|
669
712
|
"label-position": indexProp(_ctx.labelPosition, vi),
|
|
@@ -676,7 +719,7 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
676
719
|
"label-position",
|
|
677
720
|
"full-prop",
|
|
678
721
|
"prop"
|
|
679
|
-
])]), createElementVNode("div",
|
|
722
|
+
])], 2), createElementVNode("div", { class: normalizeClass(["row-action", _ctx.rowActionClass]) }, [unref(RowSlot) ? (openBlock(), createBlock(resolveDynamicComponent(unref(RowSlot).component), {
|
|
680
723
|
key: 0,
|
|
681
724
|
up: lineAction.up.bind(null, vi),
|
|
682
725
|
down: lineAction.down.bind(null, vi),
|
|
@@ -700,7 +743,7 @@ var array_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
700
743
|
"single",
|
|
701
744
|
"row",
|
|
702
745
|
"full-prop"
|
|
703
|
-
])) : createCommentVNode("v-if", true)])],
|
|
746
|
+
])) : createCommentVNode("v-if", true)], 2)], 6);
|
|
704
747
|
}), 128))]),
|
|
705
748
|
_: 1
|
|
706
749
|
}, 16));
|
|
@@ -721,7 +764,17 @@ var layout_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
721
764
|
const props = __props;
|
|
722
765
|
const attrs = useAttrs();
|
|
723
766
|
const layoutProps = computed(() => {
|
|
724
|
-
|
|
767
|
+
const p = Object.assign({}, cut(attrs, [
|
|
768
|
+
"full-prop",
|
|
769
|
+
"widget",
|
|
770
|
+
"on"
|
|
771
|
+
]), cut(props, ["fields"]));
|
|
772
|
+
const w = Object.fromEntries(Object.entries(unref(props.widget)).map(([k, v]) => [k, unref(v)]));
|
|
773
|
+
return Object.assign(p, w);
|
|
774
|
+
});
|
|
775
|
+
const LayoutComponent = computed(() => {
|
|
776
|
+
if (props.component) return props.component;
|
|
777
|
+
return "div";
|
|
725
778
|
});
|
|
726
779
|
const formCtx = inject(formCtxKey);
|
|
727
780
|
const subFields = computed(() => {
|
|
@@ -729,22 +782,32 @@ var layout_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
729
782
|
return [field, { "full-prop": [attrs["full-prop"], field.prop].filter(Boolean).join(".") }];
|
|
730
783
|
});
|
|
731
784
|
});
|
|
732
|
-
const
|
|
785
|
+
const layoutSlots = formCtx.getParentSlots(ensureArray(props.slots));
|
|
786
|
+
const subSlots = props.component ? layoutSlots : [];
|
|
787
|
+
const { prefix: prefixSlots, suffix: suffixSlots } = groupBy(layoutSlots, (slot) => slot.name.match(/^[a-z]+/i)?.[0] ?? "");
|
|
733
788
|
return (_ctx, _cache) => {
|
|
734
|
-
return openBlock(),
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
789
|
+
return openBlock(), createBlock(resolveDynamicComponent(LayoutComponent.value), mergeProps({ class: "layout-item" }, layoutProps.value, toHandlers(_ctx.on)), createSlots({
|
|
790
|
+
default: withCtx(() => [
|
|
791
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(prefixSlots), (psc) => {
|
|
792
|
+
return openBlock(), createBlock(deep_slot_default, mergeProps({ key: psc.name }, { ref_for: true }, psc, { "ctx-key": unref(formCtxKey) }), null, 16, ["ctx-key"]);
|
|
793
|
+
}), 128)),
|
|
794
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(subFields.value, (field) => {
|
|
795
|
+
return openBlock(), createBlock(form_field_default, mergeProps({ key: unref(getKey)(field[0]) }, { ref_for: true }, {
|
|
796
|
+
...field[0],
|
|
797
|
+
...field[1]
|
|
798
|
+
}), null, 16);
|
|
799
|
+
}), 128)),
|
|
800
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(suffixSlots), (psc) => {
|
|
801
|
+
return openBlock(), createBlock(deep_slot_default, mergeProps({ key: psc.name }, { ref_for: true }, psc, { "ctx-key": unref(formCtxKey) }), null, 16, ["ctx-key"]);
|
|
802
|
+
}), 128))
|
|
803
|
+
]),
|
|
804
|
+
_: 2
|
|
805
|
+
}, [renderList(unref(subSlots), (sl) => {
|
|
806
|
+
return {
|
|
807
|
+
name: sl.name,
|
|
808
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, sl.name, normalizeProps(guardReactiveProps(scope)))])
|
|
809
|
+
};
|
|
810
|
+
})]), 1040);
|
|
748
811
|
};
|
|
749
812
|
}
|
|
750
813
|
});
|