@ticatec/uniface-flexi-module 0.0.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.
Files changed (136) hide show
  1. package/FLEXICRITERIASET_GUIDE.md +1559 -0
  2. package/FLEXICRITERIASET_GUIDE_CN.md +1133 -0
  3. package/FLEXIDATATABLE_GUIDE.md +1650 -0
  4. package/FLEXIDATATABLE_GUIDE_CN.md +1650 -0
  5. package/FLEXIFORM_GUIDE.md +1068 -0
  6. package/FLEXIFORM_GUIDE_CN.md +1068 -0
  7. package/FLEXI_CONTEXT_GUIDE_CN.md +172 -0
  8. package/MODULE_LOADER_CN.md +228 -0
  9. package/README.md +307 -0
  10. package/README_CN.md +51 -0
  11. package/SANDBOX_CN.md +201 -0
  12. package/dist/FlexiContext.d.ts +28 -0
  13. package/dist/FlexiContext.js +45 -0
  14. package/dist/ModuleLoader.d.ts +41 -0
  15. package/dist/ModuleLoader.js +55 -0
  16. package/dist/Sandbox.d.ts +33 -0
  17. package/dist/Sandbox.js +101 -0
  18. package/dist/criteria-panel/CriteriaFieldsPanel.svelte +26 -0
  19. package/dist/criteria-panel/CriteriaFieldsPanel.svelte.d.ts +22 -0
  20. package/dist/criteria-panel/components/CascadeSelectSearchField.svelte +10 -0
  21. package/dist/criteria-panel/components/CascadeSelectSearchField.svelte.d.ts +25 -0
  22. package/dist/criteria-panel/components/DateRangeField.svelte +11 -0
  23. package/dist/criteria-panel/components/DateRangeField.svelte.d.ts +25 -0
  24. package/dist/criteria-panel/components/DateSearchField.svelte +10 -0
  25. package/dist/criteria-panel/components/DateSearchField.svelte.d.ts +24 -0
  26. package/dist/criteria-panel/components/DateTimeSearchField.svelte +10 -0
  27. package/dist/criteria-panel/components/DateTimeSearchField.svelte.d.ts +24 -0
  28. package/dist/criteria-panel/components/InputOptionSelectSearchField.svelte +9 -0
  29. package/dist/criteria-panel/components/InputOptionSelectSearchField.svelte.d.ts +24 -0
  30. package/dist/criteria-panel/components/NumberRangeField.svelte +11 -0
  31. package/dist/criteria-panel/components/NumberRangeField.svelte.d.ts +25 -0
  32. package/dist/criteria-panel/components/NumberSearchField.svelte +9 -0
  33. package/dist/criteria-panel/components/NumberSearchField.svelte.d.ts +24 -0
  34. package/dist/criteria-panel/components/OptionMultiSelectSearchField.svelte +9 -0
  35. package/dist/criteria-panel/components/OptionMultiSelectSearchField.svelte.d.ts +24 -0
  36. package/dist/criteria-panel/components/OptionSelectSearchField.svelte +9 -0
  37. package/dist/criteria-panel/components/OptionSelectSearchField.svelte.d.ts +24 -0
  38. package/dist/criteria-panel/components/SearchField.svelte +14 -0
  39. package/dist/criteria-panel/components/SearchField.svelte.d.ts +33 -0
  40. package/dist/criteria-panel/components/TextSearchField.svelte +9 -0
  41. package/dist/criteria-panel/components/TextSearchField.svelte.d.ts +24 -0
  42. package/dist/criteria-panel/components/UnknownCriteriaField.svelte +9 -0
  43. package/dist/criteria-panel/components/UnknownCriteriaField.svelte.d.ts +24 -0
  44. package/dist/criteria-panel/index.d.ts +6 -0
  45. package/dist/criteria-panel/index.js +6 -0
  46. package/dist/criteria-panel/lib/CriteriaComponentBuilder.d.ts +19 -0
  47. package/dist/criteria-panel/lib/CriteriaComponentBuilder.js +31 -0
  48. package/dist/criteria-panel/lib/CriteriaFieldBuilder.d.ts +1 -0
  49. package/dist/criteria-panel/lib/CriteriaFieldBuilder.js +127 -0
  50. package/dist/criteria-panel/lib/FlexiCriteriaField.d.ts +38 -0
  51. package/dist/criteria-panel/lib/FlexiCriteriaField.js +31 -0
  52. package/dist/criteria-panel/lib/FlexiCriteriaSet.d.ts +24 -0
  53. package/dist/criteria-panel/lib/FlexiCriteriaSet.js +48 -0
  54. package/dist/flexi-datatable/FlexiDataTable.d.ts +111 -0
  55. package/dist/flexi-datatable/FlexiDataTable.js +90 -0
  56. package/dist/flexi-datatable/index.d.ts +2 -0
  57. package/dist/flexi-datatable/index.js +2 -0
  58. package/dist/flexi-form/FlexiCompound.d.ts +34 -0
  59. package/dist/flexi-form/FlexiCompound.js +84 -0
  60. package/dist/flexi-form/FlexiFormDialog.svelte +24 -0
  61. package/dist/flexi-form/FlexiFormDialog.svelte.d.ts +21 -0
  62. package/dist/flexi-form/FlexiFormPage.svelte +26 -0
  63. package/dist/flexi-form/FlexiFormPage.svelte.d.ts +25 -0
  64. package/dist/flexi-form/Schema.d.ts +6 -0
  65. package/dist/flexi-form/Schema.js +1 -0
  66. package/dist/flexi-form/components/BreakLine.svelte +1 -0
  67. package/dist/flexi-form/components/BreakLine.svelte.d.ts +26 -0
  68. package/dist/flexi-form/components/CardTitleBar.svelte +18 -0
  69. package/dist/flexi-form/components/CardTitleBar.svelte.d.ts +22 -0
  70. package/dist/flexi-form/components/CascadeOptionSelectField.svelte +13 -0
  71. package/dist/flexi-form/components/CascadeOptionSelectField.svelte.d.ts +24 -0
  72. package/dist/flexi-form/components/CellFieldBuilder.d.ts +1 -0
  73. package/dist/flexi-form/components/CellFieldBuilder.js +178 -0
  74. package/dist/flexi-form/components/DateField.svelte +12 -0
  75. package/dist/flexi-form/components/DateField.svelte.d.ts +24 -0
  76. package/dist/flexi-form/components/DateTimeField.svelte +13 -0
  77. package/dist/flexi-form/components/DateTimeField.svelte.d.ts +24 -0
  78. package/dist/flexi-form/components/InputOptionSelectField.svelte +13 -0
  79. package/dist/flexi-form/components/InputOptionSelectField.svelte.d.ts +24 -0
  80. package/dist/flexi-form/components/MemoField.svelte +12 -0
  81. package/dist/flexi-form/components/MemoField.svelte.d.ts +24 -0
  82. package/dist/flexi-form/components/NumberField.svelte +12 -0
  83. package/dist/flexi-form/components/NumberField.svelte.d.ts +24 -0
  84. package/dist/flexi-form/components/OptionsMultiSelectField.svelte +13 -0
  85. package/dist/flexi-form/components/OptionsMultiSelectField.svelte.d.ts +24 -0
  86. package/dist/flexi-form/components/OptionsSelectField.svelte +13 -0
  87. package/dist/flexi-form/components/OptionsSelectField.svelte.d.ts +24 -0
  88. package/dist/flexi-form/components/TextField.svelte +12 -0
  89. package/dist/flexi-form/components/TextField.svelte.d.ts +24 -0
  90. package/dist/flexi-form/components/UnitNumberField.svelte +12 -0
  91. package/dist/flexi-form/components/UnitNumberField.svelte.d.ts +24 -0
  92. package/dist/flexi-form/components/UnknownTypeField.svelte +5 -0
  93. package/dist/flexi-form/components/UnknownTypeField.svelte.d.ts +18 -0
  94. package/dist/flexi-form/containers/FlexiPanel.svelte +13 -0
  95. package/dist/flexi-form/containers/FlexiPanel.svelte.d.ts +33 -0
  96. package/dist/flexi-form/flexi_card/FlexiCard.d.ts +64 -0
  97. package/dist/flexi-form/flexi_card/FlexiCard.js +66 -0
  98. package/dist/flexi-form/flexi_card/FlexiCardPanel.svelte +57 -0
  99. package/dist/flexi-form/flexi_card/FlexiCardPanel.svelte.d.ts +22 -0
  100. package/dist/flexi-form/flexi_composite/FlexiComposite.d.ts +50 -0
  101. package/dist/flexi-form/flexi_composite/FlexiComposite.js +26 -0
  102. package/dist/flexi-form/flexi_composite/FlexiCompositePanel.svelte +42 -0
  103. package/dist/flexi-form/flexi_composite/FlexiCompositePanel.svelte.d.ts +25 -0
  104. package/dist/flexi-form/flexi_composite/README.md +50 -0
  105. package/dist/flexi-form/flexi_datasheet/FlexiDataSheet.d.ts +4 -0
  106. package/dist/flexi-form/flexi_datasheet/FlexiDataSheet.js +2 -0
  107. package/dist/flexi-form/flexi_field/FlexiField.d.ts +76 -0
  108. package/dist/flexi-form/flexi_field/FlexiField.js +128 -0
  109. package/dist/flexi-form/flexi_field/FlexiFieldCell.svelte +35 -0
  110. package/dist/flexi-form/flexi_field/FlexiFieldCell.svelte.d.ts +25 -0
  111. package/dist/flexi-form/flexi_field/UnknownField.d.ts +3 -0
  112. package/dist/flexi-form/flexi_field/UnknownField.js +3 -0
  113. package/dist/flexi-form/flexi_form/FlexiForm.d.ts +127 -0
  114. package/dist/flexi-form/flexi_form/FlexiForm.js +160 -0
  115. package/dist/flexi-form/flexi_form/FlexiFormPanel.svelte +57 -0
  116. package/dist/flexi-form/flexi_form/FlexiFormPanel.svelte.d.ts +25 -0
  117. package/dist/flexi-form/index.d.ts +11 -0
  118. package/dist/flexi-form/index.js +11 -0
  119. package/dist/flexi-form/lib/ComponentBuilder.d.ts +15 -0
  120. package/dist/flexi-form/lib/ComponentBuilder.js +31 -0
  121. package/dist/flexi-form/lib/index.d.ts +5 -0
  122. package/dist/flexi-form/lib/index.js +2 -0
  123. package/dist/flexi-form/lib/types.d.ts +7 -0
  124. package/dist/flexi-form/lib/types.js +6 -0
  125. package/dist/flexi-form/lib/utils.d.ts +10 -0
  126. package/dist/flexi-form/lib/utils.js +48 -0
  127. package/dist/i18n-res/i18nRes.d.ts +2 -0
  128. package/dist/i18n-res/i18nRes.js +8 -0
  129. package/dist/i18n-res/index.d.ts +2 -0
  130. package/dist/i18n-res/index.js +2 -0
  131. package/dist/index.d.ts +5 -0
  132. package/dist/index.js +5 -0
  133. package/dist/uniface-flexi-module.css +46 -0
  134. package/dist/utils.d.ts +4 -0
  135. package/dist/utils.js +8 -0
  136. package/package.json +135 -0
@@ -0,0 +1,172 @@
1
+ # FlexiContext 类文档
2
+
3
+ `FlexiContext` 是一个用于管理数据字典加载的单例上下文类,采用 TypeScript 实现。它通过异步方式加载指定的数据字典,并提供统一的访问接口。
4
+
5
+ ---
6
+
7
+ ## 目录
8
+ - [概述](#概述)
9
+ - [类型定义](#类型定义)
10
+ - [静态方法](#静态方法)
11
+ - [`initialize`](#initialize)
12
+ - [`getInstance`](#getinstance)
13
+ - [实例方法](#实例方法)
14
+ - [`loadDictionaries`](#loaddictionaries)
15
+ - [使用示例](#使用示例)
16
+ - [注意事项](#注意事项)
17
+
18
+ ---
19
+
20
+ ## 概述
21
+
22
+ `FlexiContext` 是一个全局单例类,用于统一管理数据字典的加载逻辑。
23
+ 它依赖一个外部传入的 `DictionaryLoad` 函数来实际执行字典数据的获取。
24
+
25
+ ```ts
26
+ export type DictionaryLoad = (dicNames: Array<string>) => Promise<any>;
27
+ export type Dictionaries = { [key: string]: Array<any> };
28
+ ```
29
+
30
+ ---
31
+
32
+ ## 类型定义
33
+
34
+ | 类型 | 说明 |
35
+ |------|------|
36
+ | `DictionaryLoad` | 字典加载函数,接收字典名称数组,返回 `Promise<any>` |
37
+ | `Dictionaries` | 返回的字典数据结构,键为字典名,值为对应数据数组 |
38
+
39
+ ---
40
+
41
+ ## 静态方法
42
+
43
+ ### `initialize`
44
+
45
+ 初始化 `FlexiContext` 单例。
46
+
47
+ ```ts
48
+ static initialize(dictLoad: DictionaryLoad): FlexiContext
49
+ ```
50
+
51
+ **参数:**
52
+ - `dictLoad`: `DictionaryLoad` - 用于实际加载字典数据的函数
53
+
54
+ **返回值:** `FlexiContext` 实例
55
+
56
+ > 必须在调用 `getInstance()` 前先执行 `initialize`,否则会抛出错误。
57
+
58
+ ---
59
+
60
+ ### `getInstance`
61
+
62
+ 获取已初始化的单例实例。
63
+
64
+ ```ts
65
+ static getInstance(): FlexiContext
66
+ ```
67
+
68
+ **返回值:** `FlexiContext` 实例
69
+
70
+ **异常:**
71
+ - 若未调用 `initialize` 初始化,将抛出错误:
72
+ ```
73
+ Error: FlexiContext hasn't been initialized.
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 实例方法
79
+
80
+ ### `loadDictionaries`
81
+
82
+ 异步加载一个或多个数据字典。
83
+
84
+ ```ts
85
+ async loadDictionaries(dicNames: Array<string> | string): Promise<Dictionaries>
86
+ ```
87
+
88
+ **参数:**
89
+ - `dicNames`: `string[] | string` - 要加载的字典名称(支持单个字符串或数组)
90
+
91
+ **返回值:** `Promise<Dictionaries>`
92
+ 返回一个对象,键为字典名称,值为对应的数据数组。
93
+
94
+ **行为:**
95
+ - 若传入空数组或空字符串,返回空对象 `{}`。
96
+ - 自动将单个字符串转换为数组处理。
97
+
98
+ ---
99
+
100
+ ## 使用示例
101
+
102
+ ### 1. 初始化与基本使用
103
+
104
+ ```ts
105
+ import FlexiContext from './FlexiContext';
106
+
107
+ // 定义字典加载函数(实际项目中可能从 API 获取)
108
+ const dictLoad: DictionaryLoad = async (dicNames: string[]) => {
109
+ console.log('正在加载字典:', dicNames);
110
+ // 模拟 API 调用
111
+ const mockData: any = {
112
+ 'gender': [
113
+ { value: 1, label: '男' },
114
+ { value: 2, label: '女' }
115
+ ],
116
+ 'status': [
117
+ { value: 0, label: '禁用' },
118
+ { value: 1, label: '启用' }
119
+ ]
120
+ };
121
+ return dicNames.reduce((acc, name) => {
122
+ acc[name] = mockData[name] || [];
123
+ return acc;
124
+ }, {} as any);
125
+ };
126
+
127
+ // 初始化
128
+ FlexiContext.initialize(dictLoad);
129
+
130
+ // 获取实例
131
+ const context = FlexiContext.getInstance();
132
+
133
+ // 加载字典
134
+ async function loadData() {
135
+ const dicts = await context.loadDictionaries(['gender', 'status']);
136
+ console.log(dicts);
137
+ // 输出:
138
+ // {
139
+ // gender: [ { value: 1, label: '男' }, { value: 2, label: '女' } ],
140
+ // status: [ { value: 0, label: '禁用' }, { value: 1, label: '启用' } ]
141
+ // }
142
+ }
143
+
144
+ loadData();
145
+ ```
146
+
147
+ ### 2. 加载单个字典
148
+
149
+ ```ts
150
+ const dict = await context.loadDictionaries('gender');
151
+ console.log(dict.gender); // [{ value: 1, label: '男' }, ...]
152
+ ```
153
+
154
+ ---
155
+
156
+ ## 注意事项
157
+
158
+ 1. **必须先初始化**
159
+ 在使用 `getInstance()` 前必须调用 `initialize`,否则会抛出异常。
160
+
161
+ 2. **单例模式**
162
+ 多次调用 `initialize` 只会生效第一次,后续调用返回同一实例。
163
+
164
+ 3. **字典加载函数责任**
165
+ `dictLoad` 函数需自行处理:
166
+ - 网络请求
167
+ - 缓存策略
168
+ - 错误处理
169
+ - 数据格式标准化
170
+
171
+ 4. **空输入处理**
172
+ 传入空数组或空字符串将返回 `{}`,不会触发实际加载。
@@ -0,0 +1,228 @@
1
+ # ModuleLoader 类文档
2
+
3
+ `ModuleLoader` 是一个**单例模块加载器**,用于动态加载模块并提供**缓存机制**,确保同一模块只加载一次,后续请求直接返回缓存实例。适用于按需加载组件、插件、微前端模块等场景。
4
+
5
+ ---
6
+
7
+ ## 目录
8
+ - [概述](#概述)
9
+ - [类型定义](#类型定义)
10
+ - [静态方法](#静态方法)
11
+ - [`initialize`](#initialize)
12
+ - [实例方法](#实例方法)
13
+ - [`load`](#load)
14
+ - [使用示例](#使用示例)
15
+ - [高级用法](#高级用法)
16
+ - [注意事项](#注意事项)
17
+
18
+ ---
19
+
20
+ ## 概述
21
+
22
+ `ModuleLoader` 采用 **单例模式 + 依赖注入** 设计,通过外部传入的 `loadModule` 函数实现模块的实际加载逻辑,内部使用 `Map` 实现高效缓存。可以配合`Sandbox`一起使用,实现动态代码的加载和实现。
23
+
24
+ ```ts
25
+ export type LoadModule = (params: any) => Promise<any>;
26
+ ```
27
+
28
+ > 典型应用场景:动态加载远程组件、微前端模块、懒加载插件等。
29
+
30
+ ---
31
+
32
+ ## 类型定义
33
+
34
+ | 类型 | 说明 |
35
+ |------|------|
36
+ | `LoadModule` | 模块加载函数,接收任意参数,返回 `Promise<any>` |
37
+
38
+ ---
39
+
40
+ ## 静态方法
41
+
42
+ ### `initialize`
43
+
44
+ 初始化 `ModuleLoader` 单例实例。
45
+
46
+ ```ts
47
+ static initialize(loadModule: LoadModule): ModuleLoader
48
+ ```
49
+
50
+ **参数:**
51
+ - `loadModule`: `LoadModule` - 实际执行模块加载的函数
52
+
53
+ **返回值:** `ModuleLoader` 实例
54
+
55
+ > 必须先调用 `initialize`,后续才能使用 `load` 方法。
56
+
57
+ ---
58
+
59
+ ## 实例方法
60
+
61
+ ### `load`
62
+
63
+ 通过唯一键加载模块,支持缓存。
64
+
65
+ ```ts
66
+ async load(key: string, params: any): Promise<any>
67
+ ```
68
+
69
+ **参数:**
70
+ - `key`: `string` - 模块的唯一标识符(用于缓存)
71
+ - `params`: `any` - 传递给 `loadModule` 函数的参数
72
+
73
+ **返回值:** `Promise<any>` - 已加载的模块实例
74
+
75
+ **行为:**
76
+ 1. 若缓存中已存在 `key` → 直接返回缓存模块
77
+ 2. 否则调用 `this.#loadModule(params)` 加载 → 缓存结果 → 返回
78
+
79
+ ---
80
+
81
+ ## 使用示例
82
+
83
+ ### 1. 基础使用:动态加载远程组件
84
+
85
+ ```ts
86
+ import ModuleLoader, {LoadModule} from '@ticatec/uniface-flexi-module/ModuleLoader';
87
+ import Sandbox from "@ticatec/uniface-flexi-module/Sandbox";
88
+ import axios from "axios";
89
+
90
+ // 定义模块加载函数(例如使用 import() 动态导入)
91
+ const loadModule: LoadModule = async (params: any) => {
92
+ return axios.get('./scripts', {params})
93
+ };
94
+
95
+ // 初始化 ModuleLoader
96
+ ModuleLoader.initialize(loadModule);
97
+ Sandbox.initialize({AppModule}, [''])
98
+
99
+ // 使用示例
100
+ async function loadComponents() {
101
+ const loader = ModuleLoader.getInstance();
102
+
103
+ // 首次加载
104
+ const userFormScript = await loader.load({form: 'UserForm'});
105
+
106
+
107
+ }
108
+ ```
109
+
110
+ ---
111
+
112
+ ### 2. 加载微前端模块(SystemJS 示例)
113
+
114
+ ```ts
115
+ const systemJsLoader: LoadModule = async (params: { name: string; url: string }) => {
116
+ await System.import(params.url);
117
+ return System.get(params.name);
118
+ };
119
+
120
+ ModuleLoader.initialize(systemJsLoader);
121
+
122
+ const qiankunApp = await ModuleLoader
123
+ .initialize(systemJsLoader)
124
+ .load('qiankun-app', { name: 'app1', url: 'https://app.example.com/app.js' });
125
+ ```
126
+
127
+ ---
128
+
129
+ ### 3. 加载配置驱动的插件
130
+
131
+ ```ts
132
+ const pluginLoader: LoadModule = async (pluginConfig: { id: string; entry: string }) => {
133
+ const resp = await fetch(pluginConfig.entry);
134
+ const code = await resp.text();
135
+ const module = { exports: {} };
136
+ const factory = new Function('module', 'exports', code);
137
+ factory(module, module.exports);
138
+ return module.exports;
139
+ };
140
+
141
+ ModuleLoader.initialize(pluginLoader);
142
+
143
+ const editorPlugin = await ModuleLoader
144
+ .initialize(pluginLoader)
145
+ .load('rich-editor', {
146
+ id: 'editor-v1',
147
+ entry: '/plugins/editor.js'
148
+ });
149
+ ```
150
+
151
+ ---
152
+
153
+ ## 高级用法
154
+
155
+ ### 自定义缓存策略(扩展)
156
+
157
+ ```ts
158
+ class SmartModuleLoader extends ModuleLoader {
159
+ private ttl: Map<string, number> = new Map(); // 缓存过期时间
160
+
161
+ async loadWithTTL(key: string, params: any, ttlMs: number) {
162
+ const now = Date.now();
163
+ if (this.modules.has(key)) {
164
+ const cachedTime = this.ttl.get(key)!;
165
+ if (now - cachedTime < ttlMs) {
166
+ return this.modules.get(key);
167
+ }
168
+ this.modules.delete(key);
169
+ this.ttl.delete(key);
170
+ }
171
+
172
+ const module = await this.#loadModule(params);
173
+ this.modules.set(key, module);
174
+ this.ttl.set(key, now);
175
+ return module;
176
+ }
177
+ }
178
+ ```
179
+
180
+ ---
181
+
182
+ ## 注意事项
183
+
184
+ | 项目 | 说明 |
185
+ |------|------|
186
+ | **单例生命周期** | 整个应用生命周期内只有一份实例 |
187
+ | **必须先初始化** | 未调用 `initialize` 直接使用将导致 `undefined` 行为 |
188
+ | **缓存永久有效** | 当前实现无过期机制,适合静态模块 |
189
+ | **键名敏感** | `key` 区分大小写,建议统一命名规范 |
190
+ | **参数不参与缓存键** | 相同 `key` 不同 `params` 仍返回同一模块 |
191
+
192
+ ---
193
+
194
+ ## 示例项目结构
195
+
196
+ ```
197
+ src/
198
+ ├── loader/
199
+ │ └── ModuleLoader.ts
200
+ ├── modules/
201
+ │ ├── UserProfile.js
202
+ │ └── Dashboard.js
203
+ ├── services/
204
+ │ └── remoteLoader.ts # 实现 loadModule 逻辑
205
+ ├── App.ts
206
+ └── types/
207
+ └── loader.d.ts
208
+ ```
209
+
210
+ ---
211
+
212
+ ## API 汇总
213
+
214
+ | 方法 | 类型 | 描述 |
215
+ |------|------|------|
216
+ | `initialize` | `static` | 初始化单例 |
217
+ | `load` | `async` | 加载并缓存模块 |
218
+
219
+ ---
220
+
221
+ **版本**: 1.0.0
222
+ **语言**: TypeScript
223
+ **设计模式**: 单例 + 缓存代理
224
+ **适用场景**: 动态 import、微前端、插件系统、按需加载
225
+
226
+ ---
227
+
228
+ > 推荐与 `FlexiContext` 结合使用,实现**字典 + 模块**统一加载管理。
package/README.md ADDED
@@ -0,0 +1,307 @@
1
+ # @ticatec/uniface-flexi-form
2
+
3
+ A flexible form framework for Svelte applications with dynamic field types, criteria panels, and modular components.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Dynamic Form Generation**: Create forms dynamically from JSON schemas
8
+ - 🎨 **Multiple Field Types**: Support for text, number, date, select, multi-select, and more
9
+ - 🔍 **Criteria Panel**: Advanced search and filtering capabilities
10
+ - 📱 **Responsive Design**: Mobile-friendly and adaptable layouts
11
+ - 🧩 **Modular Architecture**: Easily extensible with custom components
12
+ - 🎯 **Type Safety**: Full TypeScript support with comprehensive type definitions
13
+ - 🎭 **Svelte 5 Ready**: Built for the latest Svelte version
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @ticatec/uniface-flexi-form
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { FlexiForm, registerFormFieldBuilder } from '@ticatec/uniface-flexi-form';
25
+ import '@ticatec/uniface-flexi-form/uniface-flexi-form.css';
26
+
27
+ // Register form field builders
28
+ registerFormFieldBuilder();
29
+
30
+ // Define your form schema
31
+ const formSchema = {
32
+ id: 'user-form',
33
+ title: 'User Information',
34
+ fields: [
35
+ {
36
+ id: 'name',
37
+ type: 'text-editor',
38
+ label: 'Name',
39
+ required: true
40
+ },
41
+ {
42
+ id: 'email',
43
+ type: 'text-editor',
44
+ label: 'Email',
45
+ required: true
46
+ },
47
+ {
48
+ id: 'birthDate',
49
+ type: 'date-picker',
50
+ label: 'Birth Date'
51
+ }
52
+ ]
53
+ };
54
+ ```
55
+
56
+ ```svelte
57
+ <script>
58
+ import { FlexiFormPage } from '@ticatec/uniface-flexi-form';
59
+
60
+ export let formSchema;
61
+ export let formData = {};
62
+ </script>
63
+
64
+ <FlexiFormPage
65
+ schema={formSchema}
66
+ bind:data={formData}
67
+ />
68
+ ```
69
+
70
+ ## Available Field Types
71
+
72
+ The framework supports various field types out of the box:
73
+
74
+ - `text-editor` - Text input field
75
+ - `memo-editor` - Multi-line text area
76
+ - `number-editor` - Number input field
77
+ - `unit-number-editor` - Number input field with unit support
78
+ - `date-picker` - Date selection field
79
+ - `datetime-picker` - Date and time selection field
80
+ - `options-selector` - Single select dropdown
81
+ - `options-multi-selector` - Multi-select dropdown
82
+ - `cascade-options-selector` - Cascading select field
83
+ - `input-options-selector` - Select with input capability
84
+ - `-` - Break line / separator
85
+ - `unknown-type` - Fallback for unknown field types
86
+
87
+ ## Core Components
88
+
89
+ ### FlexiForm
90
+ The main form component that renders dynamic forms based on schemas.
91
+
92
+ ```typescript
93
+ import { FlexiForm } from '@ticatec/uniface-flexi-form';
94
+ ```
95
+
96
+ ### FlexiFormPage
97
+ A page-level component for full-page forms.
98
+
99
+ ```typescript
100
+ import { FlexiFormPage } from '@ticatec/uniface-flexi-form';
101
+ ```
102
+
103
+ ### FlexiFormDialog
104
+ A dialog/modal component for forms.
105
+
106
+ ```typescript
107
+ import { FlexiFormDialog } from '@ticatec/uniface-flexi-form';
108
+ ```
109
+
110
+ ### CriteriaPanel
111
+ Advanced search and filtering panel.
112
+
113
+ ```typescript
114
+ import CriteriaPanel from '@ticatec/uniface-flexi-form/criteria-panel';
115
+ ```
116
+
117
+ ## Schema Structure
118
+
119
+ ```typescript
120
+ interface FlexiFormSchema {
121
+ mode?: LayoutMode;
122
+ arrangement?: Arrangement;
123
+ props?: any;
124
+ elements: FormElements;
125
+ label$style?: string;
126
+ variant?: 'filled' | 'outlined' | '';
127
+ actions?: Array<FormActionSchema>;
128
+ style?: string;
129
+ }
130
+
131
+ interface FlexiCardSchema {
132
+ title?: string;
133
+ mode?: LayoutMode;
134
+ props?: any;
135
+ arrangement?: Arrangement;
136
+ label$style?: string;
137
+ attrs?: any;
138
+ fields: Array<FlexiFieldSchema | FlexiCompositeFieldSchema>;
139
+ readonly?: boolean;
140
+ disabled?: boolean;
141
+ variant?: 'filled' | 'outlined' | '';
142
+ foldable?: boolean;
143
+ actions?: Array<ActionSchema>;
144
+ }
145
+
146
+ interface FlexiCompositeSchema {
147
+ type?: 'block';
148
+ title?: string;
149
+ fields: Array<FlexiFieldSchema>;
150
+ readonly?: boolean;
151
+ disabled?: boolean;
152
+ label$style?: string;
153
+ variant?: string;
154
+ mode?: LayoutMode;
155
+ props?: any;
156
+ arrangement?: Arrangement;
157
+ }
158
+
159
+ interface FlexiCompositeFieldSchema {
160
+ type: "composite";
161
+ keyField?: string;
162
+ name: string;
163
+ composite: string;
164
+ cell?: any;
165
+ }
166
+
167
+ interface FlexiFieldSchema {
168
+ type: string;
169
+ keyField: string;
170
+ name: string;
171
+ dictName?: string;
172
+ label: string;
173
+ variant?: "" | "outlined" | "filled";
174
+ readonly?: boolean;
175
+ disabled?: boolean;
176
+ required?: boolean;
177
+ events?: Record<string, string>;
178
+ cell?: any;
179
+ props?: any;
180
+ }
181
+ ```
182
+
183
+ ## Advanced Usage
184
+
185
+ ### Custom Field Registration
186
+
187
+ ```typescript
188
+ import { ComponentBuilder } from '@ticatec/uniface-flexi-form/flexi-form/lib/ComponentBuilder';
189
+
190
+ const componentBuilder = ComponentBuilder.getInstance();
191
+
192
+ // Register a custom field type
193
+ componentBuilder.register('custom-field', (schema, dictLoader) => ({
194
+ component: CustomFieldComponent,
195
+ props: schema.props
196
+ }));
197
+ ```
198
+
199
+ ### Form Validation
200
+
201
+ **Note: Form validation is currently in development**. The framework has the infrastructure for validation with error tracking in FlexiField, but full validation implementation is not yet complete. Future versions will integrate with `@ticatec/web-bean-validator` for comprehensive validation support.
202
+
203
+ ```typescript
204
+ // Basic field definition (validation features coming soon)
205
+ const fieldSchema = {
206
+ type: 'text-editor',
207
+ keyField: 'email',
208
+ name: 'email',
209
+ label: 'Email',
210
+ required: true,
211
+ props: {
212
+ placeholder: 'Enter email address'
213
+ }
214
+ };
215
+ ```
216
+
217
+ ### Styling and Theming
218
+
219
+ The framework comes with default styles that can be customized:
220
+
221
+ ```scss
222
+ @import '@ticatec/uniface-flexi-form/uniface-flexi-form.css';
223
+
224
+ // Override default styles
225
+ .flexi-form {
226
+ --primary-color: #your-brand-color;
227
+ --border-radius: 8px;
228
+ --spacing: 16px;
229
+ }
230
+ ```
231
+
232
+ ## API Reference
233
+
234
+ ### Core Exports
235
+
236
+ ```typescript
237
+ // Main module
238
+ import FlexiContext from '@ticatec/uniface-flexi-form';
239
+
240
+ // Form components
241
+ import {
242
+ FlexiForm,
243
+ FlexiCard,
244
+ FlexiField,
245
+ FlexiFormPage,
246
+ FlexiFormDialog,
247
+ ComponentBuilder,
248
+ registerFormFieldBuilder
249
+ } from '@ticatec/uniface-flexi-form/flexi-form';
250
+
251
+ // Schema types
252
+ import type {
253
+ FlexiFormSchema,
254
+ FlexiCardSchema,
255
+ FlexiCompositeSchema,
256
+ FlexiCompositeFieldSchema,
257
+ FlexiFieldSchema
258
+ } from '@ticatec/uniface-flexi-form/flexi-form/Schema';
259
+
260
+ // Type definitions
261
+ import type {
262
+ LayoutMode,
263
+ Arrangement,
264
+ Visibility
265
+ } from '@ticatec/uniface-flexi-form/flexi-form/lib';
266
+
267
+ // Criteria panel
268
+ import CriteriaPanel, {
269
+ FlexiCriteriaSet,
270
+ FlexiCriteriaField
271
+ } from '@ticatec/uniface-flexi-form/criteria-panel';
272
+
273
+ // Utilities
274
+ import utils from '@ticatec/uniface-flexi-form/utils';
275
+ ```
276
+
277
+ ## Development
278
+
279
+ ### Building the Library
280
+
281
+ ```bash
282
+ npm run build
283
+ ```
284
+
285
+ ### Development Mode
286
+
287
+ ```bash
288
+ npm run dev
289
+ ```
290
+
291
+ ### Type Checking
292
+
293
+ ```bash
294
+ npm run check
295
+ ```
296
+
297
+ ## Contributing
298
+
299
+ We welcome contributions! Please read our contributing guidelines and submit pull requests to our repository.
300
+
301
+ ## License
302
+
303
+ MIT License - see LICENSE file for details.
304
+
305
+ ## Support
306
+
307
+ For support and questions, please open an issue on our [GitHub repository](https://github.com/ticatec-auckland/uniface-flexi-form/issues).