tiddy 2.4.0 → 2.5.1

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as vue14 from "vue";
2
- import { AllowedComponentProps, CSSProperties, Component, ComputedRef, DefineComponent, ExtractPublicPropTypes, PropType, Raw, Ref as Ref$1, Slot } from "vue";
2
+ import { AllowedComponentProps, CSSProperties, Component, ComputedRef, DefineComponent, ExtractPublicPropTypes, HTMLAttributes, PropType, Raw, Ref, Slot } from "vue";
3
3
  import * as element_plus0 from "element-plus";
4
4
  import { DialogInstance, DialogProps, FormInstance, FormItemProp, FormItemProps, FormItemRule, FormProps, SelectInstance, TableColumnInstance, TableInstance } from "element-plus";
5
5
 
@@ -23,6 +23,9 @@ type OrRef<T> = T | Ref<T>;
23
23
  type TdFieldsProps = {
24
24
  fields: TdFormFieldProps[];
25
25
  };
26
+ type TdArrayFieldsProps = {
27
+ fields: OrFunction<TdFormFieldProps[]>;
28
+ };
26
29
  declare const objectFieldPropsDef: {
27
30
  prop: {
28
31
  type: PropType<OrFunction<string>>;
@@ -125,7 +128,7 @@ declare const widgetFieldPropsDef: {
125
128
  default: undefined;
126
129
  };
127
130
  };
128
- type PropsOf<C> = C extends DefineComponent<infer P, any, any, any, any> ? P : C extends (new (...args: any) => any) ? InstanceType<C> extends {
131
+ type PropsOf<C> = C extends (new (...args: any[]) => any) ? InstanceType<C>['$props'] : C extends DefineComponent<any, any, any, any, any, any, any, any> ? InstanceType<C> extends {
129
132
  $props: infer P;
130
133
  } ? P : Record<string, any> : Record<string, any>;
131
134
  type TdWidgetFieldProps = ExtractPublicPropTypes<typeof widgetFieldPropsDef> & AllowedComponentProps & Record<PropertyKey, any>;
@@ -148,7 +151,7 @@ declare const arrayFieldPropsDef: {
148
151
  type: PropType<FormProps["labelPosition"]>;
149
152
  };
150
153
  fields: {
151
- type: PropType<any[]>;
154
+ type: PropType<OrFunction<any[]>>;
152
155
  default: () => never[];
153
156
  };
154
157
  type: {
@@ -180,7 +183,7 @@ declare const arrayFieldPropsDef: {
180
183
  default: boolean;
181
184
  };
182
185
  };
183
- type TdArrayFieldProps = TdFieldsProps & ExtractPublicPropTypes<typeof arrayFieldPropsDef> & AllowedComponentProps;
186
+ type TdArrayFieldProps = TdArrayFieldsProps & ExtractPublicPropTypes<typeof arrayFieldPropsDef> & AllowedComponentProps;
184
187
  declare const layoutFieldPropsDef: {
185
188
  prop: {
186
189
  type: PropType<OrFunction<string>>;
@@ -241,10 +244,10 @@ declare const tdformItemProps: {
241
244
  };
242
245
  };
243
246
  type TdFormItemProps = ExtractPublicPropTypes<typeof tdformItemProps> & Partial<FormItemProps>;
244
- type PropsOrRef<T> = { [K in keyof T]?: OrRef<T[K]> };
245
- declare function widget<T>(c: T | Raw<T>, props?: OrRef<PropsOrRef<PropsOf<T>>>): {
247
+ type PropsOrRef<T> = { [K in keyof T]?: OrRef<T[K]> } | Ref<T>;
248
+ declare function widget<T>(c: T | Raw<T>, props?: PropsOrRef<PropsOf<T> & HTMLAttributes>): {
246
249
  component: T | Raw<T>;
247
- widget: any;
250
+ widget: PropsOrRef<PropsOf<T> & HTMLAttributes> | undefined;
248
251
  };
249
252
  //#endregion
250
253
  //#region src/form/form.vue.d.ts
@@ -329,7 +332,7 @@ declare const __VLS_base$3: vue14.DefineComponent<vue14.ExtractPropTypes<{
329
332
  };
330
333
  }>> & Readonly<{}>, {
331
334
  hideRequiredAsterisk: boolean;
332
- messageLabel: any;
335
+ messageLabel: OrRef<string>;
333
336
  formatMessage: AnyFunction;
334
337
  }, {}, {}, {}, string, vue14.ComponentProvideOptions, true, {}, any>;
335
338
  declare const __VLS_export$5: __VLS_WithSlots$3<typeof __VLS_base$3, __VLS_Slots$3>;
@@ -364,11 +367,11 @@ type TableColumnProp = {
364
367
  default: () => never[];
365
368
  };
366
369
  hide: {
367
- type: PropType<boolean | Ref$1<boolean>>;
370
+ type: PropType<boolean | Ref<boolean>>;
368
371
  default: false;
369
372
  };
370
373
  dangerouslyUseHTMLString: {
371
- type: PropType<boolean | Ref$1<boolean>>;
374
+ type: PropType<boolean | Ref<boolean>>;
372
375
  default: false;
373
376
  };
374
377
  };
package/dist/index.js CHANGED
@@ -46,6 +46,10 @@ const fieldsPropsDef = { fields: {
46
46
  type: Array,
47
47
  default: () => []
48
48
  } };
49
+ const arrayFieldsPropsDef = { fields: {
50
+ type: [Array, Function],
51
+ default: () => []
52
+ } };
49
53
  const commonFieldPropsDef = {
50
54
  prop: {
51
55
  type: [String, Function],
@@ -188,7 +192,7 @@ const arrayFieldPropsDef = {
188
192
  type: Boolean,
189
193
  default: false
190
194
  },
191
- ...fieldsPropsDef,
195
+ ...arrayFieldsPropsDef,
192
196
  ...commonFieldPropsDef
193
197
  };
194
198
  const layoutFieldPropsDef = {
@@ -684,9 +688,11 @@ var form_field_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
684
688
  setup(__props) {
685
689
  const attrs = useAttrs();
686
690
  const fullProp = computed(() => attrs["full-prop"] || attrs.prop);
691
+ const formCtx = inject(formCtxKey);
687
692
  const fieldAttrs = computed(() => {
688
693
  const attr = {};
689
694
  for (const [k, v] of Object.entries(attrs)) if (k === "component" && v) attr[k] = markRaw(toRaw(v));
695
+ else if (k === "fields" && isFunction(v) && !attrs.type) attr[k] = v(getDeepValue(formCtx.model, attrs["full-prop"]));
690
696
  else attr[k] = v;
691
697
  return attr;
692
698
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiddy",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "packageManager": "pnpm@10.11.0",
5
5
  "description": "A set of Vue 3 components based on element-plus",
6
6
  "type": "module",
@@ -30,6 +30,7 @@
30
30
  "play": "vite",
31
31
  "test": "vitest",
32
32
  "type": "vue-tsc --noEmit",
33
+ "pretype": "pnpm run build",
33
34
  "format": "biome format --write .",
34
35
  "prepublishOnly": "pnpm run build",
35
36
  "docs:dev": "vitepress dev docs",