@sunny-base-web/effects 0.8.39 → 0.8.40

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.
@@ -0,0 +1,62 @@
1
+ import { defineComponent as s, ref as a, onMounted as l, onBeforeUnmount as c, openBlock as g, createBlock as u, unref as i, createCommentVNode as d } from "vue";
2
+ import { WidgetRegistry as p, createBuiltinWidgets as m, MaterialStore as f, createBuiltinMaterials as y, Engine as v, SunnyDesignerLayout as _ } from "@sunny-base-web/designer-studio";
3
+ const j = /* @__PURE__ */ s({
4
+ name: "DesignPage",
5
+ __name: "Design",
6
+ setup(w) {
7
+ const n = new p();
8
+ n.registerAll(m());
9
+ const o = new f();
10
+ o.registerAll(y());
11
+ const e = a(null);
12
+ return l(() => {
13
+ const t = new v({ materialStore: o });
14
+ e.value = t;
15
+ const r = {
16
+ id: "project-1",
17
+ name: "示例项目",
18
+ activePageId: "page-1",
19
+ dependencies: [],
20
+ apis: [],
21
+ pages: [
22
+ {
23
+ id: "page-1",
24
+ name: "首页",
25
+ route: "/home",
26
+ rootNode: {
27
+ id: "root-1",
28
+ name: "div",
29
+ props: {},
30
+ events: {},
31
+ directives: [],
32
+ children: [],
33
+ slots: {}
34
+ },
35
+ state: [],
36
+ computed: [],
37
+ methods: [],
38
+ watch: [],
39
+ css: [],
40
+ props: [],
41
+ emits: [],
42
+ expose: [],
43
+ slots: [],
44
+ lifecycleHooks: [],
45
+ inject: []
46
+ }
47
+ ]
48
+ };
49
+ t.loadProject(r);
50
+ }), c(() => {
51
+ e.value?.destroy(), e.value = null;
52
+ }), (t, r) => e.value ? (g(), u(i(_), {
53
+ key: 0,
54
+ title: "Sunny Designer",
55
+ "widget-registry": i(n),
56
+ engine: e.value
57
+ }, null, 8, ["widget-registry", "engine"])) : d("", !0);
58
+ }
59
+ });
60
+ export {
61
+ j as default
62
+ };
package/dist/index.d.ts CHANGED
@@ -438,6 +438,8 @@ export declare const defaultResponseInterceptor: ({ codeField, dataField, succes
438
438
  */
439
439
  export declare const defaultSelectOptionsAdapter: SelectOptionsAdapter;
440
440
 
441
+ export declare const Design: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
442
+
441
443
  declare type DownloadRequestConfig = {
442
444
  /**
443
445
  * 定义期望获得的数据类型。
@@ -2122,6 +2124,23 @@ export declare interface SchemaOptionsLoaderReturn {
2122
2124
  load: () => Promise<void>;
2123
2125
  }
2124
2126
 
2127
+ /**
2128
+ * Schema 权限选项加载器配置
2129
+ */
2130
+ export declare interface SchemaPermissionLoaderOptions {
2131
+ /**
2132
+ * 是否在 onMounted 时自动加载
2133
+ * @default true
2134
+ */
2135
+ immediate?: boolean;
2136
+ /**
2137
+ * 权限选项加载完成后的回调,用于自动选中默认值
2138
+ * Callback after permission options are loaded, for auto-selecting defaults
2139
+ * @param defaults - 字段默认值映射 { fieldName: firstOptionValue }
2140
+ */
2141
+ onAutoSelect?: (defaults: Record<string, any>) => Promise<void>;
2142
+ }
2143
+
2125
2144
  /**
2126
2145
  * Schema 选项加载器返回值
2127
2146
  * Schema options loader return value
@@ -2147,6 +2166,11 @@ export declare interface SchemaPermissionLoaderReturn {
2147
2166
  * Manual load
2148
2167
  */
2149
2168
  load: () => Promise<void>;
2169
+ /**
2170
+ * 自动选中默认值映射(fieldName -> firstOptionValue)
2171
+ * Auto-select defaults map (fieldName -> firstOptionValue)
2172
+ */
2173
+ autoSelectDefaults: ComputedRef<Record<string, any>>;
2150
2174
  }
2151
2175
 
2152
2176
  /**
@@ -2950,7 +2974,7 @@ export declare function useSchemaOptionsLoader(schema: FormSchema[] | Ref<FormSc
2950
2974
  * Process declarative Schema permission options loading
2951
2975
  *
2952
2976
  * @param schema - 表单 Schema
2953
- * @param immediate - 是否立即加载
2977
+ * @param options - 配置选项
2954
2978
  * @returns 增强后的 Schema 和加载方法
2955
2979
  *
2956
2980
  * @example
@@ -2962,22 +2986,18 @@ export declare function useSchemaOptionsLoader(schema: FormSchema[] | Ref<FormSc
2962
2986
  * component: 'Select',
2963
2987
  * permissionOptions: {
2964
2988
  * code: 'FACTORY',
2965
- * fieldMapping: { label: 'cName', value: 'cXuhao' }
2989
+ * autoSelectFirst: true
2966
2990
  * }
2967
2991
  * }
2968
2992
  * ]
2969
2993
  *
2970
2994
  * // 在组件中使用
2971
- * const { enhancedSchema } = useSchemaPermissionLoader(searchFormSchema);
2972
- *
2973
- * // 传递给 useList
2974
- * useList({
2975
- * searchFormSchema: enhancedSchema.value,
2976
- * ...
2977
- * })
2995
+ * const { enhancedSchema } = useSchemaPermissionLoader(searchFormSchema, {
2996
+ * onAutoSelect: (defaults) => applyAutoSelectDefaults(defaults, formApi)
2997
+ * });
2978
2998
  * ```
2979
2999
  */
2980
- export declare function useSchemaPermissionLoader(schema: FormSchema[] | Ref<FormSchema[]>, immediate?: boolean): SchemaPermissionLoaderReturn;
3000
+ export declare function useSchemaPermissionLoader(schema: FormSchema[] | Ref<FormSchema[]>, options?: SchemaPermissionLoaderOptions): SchemaPermissionLoaderReturn;
2981
3001
 
2982
3002
  /**
2983
3003
  * 查询方案 API 实现