tntd 1.3.64 → 1.4.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.
Files changed (170) hide show
  1. package/.eslintignore +2 -1
  2. package/babel.config.js +12 -2
  3. package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
  4. package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  5. package/dist/1.tntd.js +12 -0
  6. package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
  7. package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  8. package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  9. package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  10. package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  11. package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  12. package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
  13. package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  14. package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  15. package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  16. package/dist/stats.json +45855 -0
  17. package/dist/tntd.css +1 -0
  18. package/dist/tntd.js +15 -0
  19. package/es/ArrayInput/README.md +129 -0
  20. package/es/ArrayInput/icon.js +24 -0
  21. package/es/ArrayInput/index.js +282 -0
  22. package/es/ArrayInput/index.less +20 -0
  23. package/es/AuthContext.js +4 -0
  24. package/es/Columns/README.md +149 -0
  25. package/es/Columns/index.js +86 -0
  26. package/es/Columns/index.less +75 -0
  27. package/es/DevelopmentLogin/LoginModal.js +126 -0
  28. package/es/DevelopmentLogin/README.md +49 -0
  29. package/es/DevelopmentLogin/index.js +40 -0
  30. package/es/Ellipsis/README.md +104 -0
  31. package/es/Ellipsis/Svg/CopySVG.js +63 -0
  32. package/es/Ellipsis/Svg/TickSVG.js +41 -0
  33. package/es/Ellipsis/index.js +143 -0
  34. package/es/Ellipsis/index.less +56 -0
  35. package/es/Handle/README.md +104 -0
  36. package/es/Handle/index.js +92 -0
  37. package/es/Handle/index.less +9 -0
  38. package/es/Icon/README.md +119 -0
  39. package/es/Icon/fonts/demo.css +539 -0
  40. package/es/Icon/fonts/demo_index.html +3345 -0
  41. package/es/Icon/fonts/iconfont.css +569 -0
  42. package/es/Icon/fonts/iconfont.eot +0 -0
  43. package/es/Icon/fonts/iconfont.js +41 -0
  44. package/es/Icon/fonts/iconfont.json +975 -0
  45. package/es/Icon/fonts/iconfont.svg +440 -0
  46. package/es/Icon/fonts/iconfont.ttf +0 -0
  47. package/es/Icon/fonts/iconfont.woff +0 -0
  48. package/es/Icon/fonts/iconfont.woff2 +0 -0
  49. package/es/Icon/iconList.js +1 -0
  50. package/es/Icon/index.js +26 -0
  51. package/es/Icon/index.less +9 -0
  52. package/es/Img/Contain.js +69 -0
  53. package/es/Img/Cover.js +126 -0
  54. package/es/Img/README.md +131 -0
  55. package/es/Img/index.js +76 -0
  56. package/es/Layout/ActionsContext.js +3 -0
  57. package/es/Layout/AppList.js +233 -0
  58. package/es/Layout/Application.js +115 -0
  59. package/es/Layout/Avatar.js +116 -0
  60. package/es/Layout/CompatibleLanguage.js +179 -0
  61. package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
  62. package/es/Layout/EnterpriseLayout/Language.js +81 -0
  63. package/es/Layout/EnterpriseLayout/Theme.js +77 -0
  64. package/es/Layout/EnterpriseLayout/index.js +31 -0
  65. package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
  66. package/es/Layout/GlobalNavigation/index.js +137 -0
  67. package/es/Layout/Header.js +95 -0
  68. package/es/Layout/HeaderActions.js +107 -0
  69. package/es/Layout/HeaderNavs.js +93 -0
  70. package/es/Layout/HeaderTabs.js +264 -0
  71. package/es/Layout/Iconfont.js +4 -0
  72. package/es/Layout/Language.js +81 -0
  73. package/es/Layout/Layout.js +234 -0
  74. package/es/Layout/Logo.js +86 -0
  75. package/es/Layout/OrgAppList.js +310 -0
  76. package/es/Layout/README.md +783 -0
  77. package/es/Layout/SideMenu.js +340 -0
  78. package/es/Layout/Theme.js +107 -0
  79. package/es/Layout/checkAuth.js +29 -0
  80. package/es/Layout/createActions.js +39 -0
  81. package/es/Layout/images/avatar/empty.png +0 -0
  82. package/es/Layout/images/avatar/female1.png +0 -0
  83. package/es/Layout/images/avatar/female2.png +0 -0
  84. package/es/Layout/images/avatar/female3.png +0 -0
  85. package/es/Layout/images/avatar/female4.png +0 -0
  86. package/es/Layout/images/avatar/female5.png +0 -0
  87. package/es/Layout/images/avatar/female6.png +0 -0
  88. package/es/Layout/images/avatar/male1.png +0 -0
  89. package/es/Layout/images/avatar/male2.png +0 -0
  90. package/es/Layout/images/avatar/male3.png +0 -0
  91. package/es/Layout/images/avatar/male4.png +0 -0
  92. package/es/Layout/images/avatar/male5.png +0 -0
  93. package/es/Layout/images/avatar/male6.png +0 -0
  94. package/es/Layout/images/index.js +35 -0
  95. package/es/Layout/images/logo/baldur.svg +14 -0
  96. package/es/Layout/images/logo/bi.svg +14 -0
  97. package/es/Layout/images/logo/bridge.svg +15 -0
  98. package/es/Layout/images/logo/convert.svg +18 -0
  99. package/es/Layout/images/logo/dataocean.svg +31 -0
  100. package/es/Layout/images/logo/default.svg +19 -0
  101. package/es/Layout/images/logo/dispatch.svg +14 -0
  102. package/es/Layout/images/logo/graph.svg +26 -0
  103. package/es/Layout/images/logo/handle.svg +10 -0
  104. package/es/Layout/images/logo/indicator.svg +41 -0
  105. package/es/Layout/images/logo/kafka.svg +12 -0
  106. package/es/Layout/images/logo/logo-custom.svg +13 -0
  107. package/es/Layout/images/logo/model.svg +17 -0
  108. package/es/Layout/images/logo/mysql.svg +15 -0
  109. package/es/Layout/images/logo/orion.svg +24 -0
  110. package/es/Layout/images/logo/salaxy.svg +11 -0
  111. package/es/Layout/images/logo/storage.svg +16 -0
  112. package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
  113. package/es/Layout/images/logo/turing.svg +35 -0
  114. package/es/Layout/images/theme/theme1.svg +35 -0
  115. package/es/Layout/images/theme/theme2.svg +33 -0
  116. package/es/Layout/index.js +122 -0
  117. package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
  118. package/es/Layout/paaslayout/Header.js +77 -0
  119. package/es/Layout/paaslayout/Logo.js +22 -0
  120. package/es/Layout/paaslayout/SideMenu.js +168 -0
  121. package/es/Layout/paaslayout/index.js +235 -0
  122. package/es/Layout/storage.js +47 -0
  123. package/es/Layout/utils.js +136 -0
  124. package/es/LoadingButton/README.md +75 -0
  125. package/es/LoadingButton/index.js +45 -0
  126. package/es/Modal/README.md +59 -0
  127. package/es/Modal/index.js +96 -0
  128. package/es/Modal/index.less +86 -0
  129. package/es/Page/Box.js +74 -0
  130. package/es/Page/README.md +180 -0
  131. package/es/Page/index.js +165 -0
  132. package/es/Page/index.less +144 -0
  133. package/es/Page/utils.js +23 -0
  134. package/es/QueryForm/Field/Checkbox.js +21 -0
  135. package/es/QueryForm/Field/Select.js +80 -0
  136. package/es/QueryForm/Field/SelectInput.js +92 -0
  137. package/es/QueryForm/Field/fieldsMap.js +32 -0
  138. package/es/QueryForm/Field/index.js +157 -0
  139. package/es/QueryForm/README.md +512 -0
  140. package/es/QueryForm/createActions.js +53 -0
  141. package/es/QueryForm/index.js +384 -0
  142. package/es/QueryForm/index.less +133 -0
  143. package/es/QueryForm/useForm.js +7 -0
  144. package/es/QueryListScene/List.js +378 -0
  145. package/es/QueryListScene/QueryForm.js +166 -0
  146. package/es/QueryListScene/QueryListScene.js +76 -0
  147. package/es/QueryListScene/README.md +790 -0
  148. package/es/QueryListScene/Title.js +12 -0
  149. package/es/QueryListScene/Toolbar.js +20 -0
  150. package/es/QueryListScene/createActions.js +72 -0
  151. package/es/QueryListScene/index.js +19 -0
  152. package/es/QueryListScene/index.less +97 -0
  153. package/es/QueryListScene/useActions.js +7 -0
  154. package/es/Select/DropDownWrap.js +116 -0
  155. package/es/Select/README.md +68 -0
  156. package/es/Select/index.js +622 -0
  157. package/es/Table/README.md +109 -0
  158. package/es/Table/ResizableTable/index.js +110 -0
  159. package/es/Table/ResizableTable/index.less +36 -0
  160. package/es/Table/index.js +35 -0
  161. package/es/Title/README.md +106 -0
  162. package/es/Title/index.js +40 -0
  163. package/es/Title/index.less +170 -0
  164. package/es/index.js +19 -0
  165. package/es/locale.js +60 -0
  166. package/package.json +4 -1
  167. package/scripts/postbuild.sh +5 -0
  168. package/doc-scripts.config.js +0 -37
  169. package/doc-scripts.renderer.js +0 -11
  170. package/docs/README.md +0 -1643
@@ -0,0 +1,512 @@
1
+ ,## QueryForm
2
+ 查询表单
3
+
4
+
5
+ ### 安装
6
+ ```
7
+ npm install tntd --save
8
+ ```
9
+
10
+ ### 代码演示
11
+
12
+ ### 展开/收起查询条件
13
+ ```jsx
14
+ import React, { useState, Fragment } from 'react';
15
+ import ReactDOM from 'react-dom';
16
+ import { Button, Popconfirm, Divider, ButtonGroup, TreeSelect, Cascader, Checkbox } from 'antd';
17
+ import { QueryForm } from 'tntd';
18
+ import 'antd/dist/antd.css';
19
+
20
+ const { Field } = QueryForm;
21
+ const ExtraActions = (
22
+ <Button.Group>
23
+ <Button icon="cloud-upload" />
24
+ <Button icon="cloud-download" />
25
+ <Button icon="setting" />
26
+ </Button.Group>
27
+ );
28
+
29
+ ReactDOM.render(
30
+ <QueryForm
31
+ extraActions={ExtraActions}
32
+ initialValues={{
33
+ name: 'zhangsan',
34
+ status: 'initial'
35
+ }}
36
+ onChange={console.log}
37
+ onSearch={console.log}
38
+ onReset={console.log}
39
+ onToggleExpand={console.log}
40
+ >
41
+ <Field
42
+ name="tree"
43
+ component={TreeSelect}
44
+ props={{
45
+ placeholder: "树形选择",
46
+ dropdownStyle:{
47
+ maxHeight: 400,
48
+ overflow: 'auto'
49
+ },
50
+ treeData: [
51
+ {
52
+ title: 'Node1',
53
+ value: '0-0',
54
+ key: '0-0',
55
+ children: [
56
+ {
57
+ title: 'Child Node1',
58
+ value: '0-0-1',
59
+ key: '0-0-1',
60
+ },
61
+ {
62
+ title: 'Child Node2',
63
+ value: '0-0-2',
64
+ key: '0-0-2',
65
+ },
66
+ ],
67
+ },
68
+ {
69
+ title: 'Node2',
70
+ value: '0-1',
71
+ key: '0-1',
72
+ }
73
+ ]
74
+ }}
75
+ />
76
+ <Field
77
+ type="input"
78
+ name="name"
79
+ props={{
80
+ placeholder: "名称"
81
+ }}
82
+ />
83
+ <Field
84
+ type="select"
85
+ name="status"
86
+ props={{
87
+ placeholder: '状态',
88
+ options: [
89
+ { label: '初始化', value: 'initial' },
90
+ { label: '运行中', value: 'running' },
91
+ { label: '成功', value: 'success', disabled: true },
92
+ { label: '失败', value: 'fail' }
93
+ ]
94
+ }}
95
+ />
96
+ <Field
97
+ type="select"
98
+ name="select1"
99
+ props={{
100
+ placeholder: '状态',
101
+ loadData: () => new Promise(resolve => resolve(['初始化', '运行中', '成功', '失败']))
102
+ }}
103
+ />
104
+ <Field
105
+ type="input"
106
+ name="name2"
107
+ props={{ placeholder: "名称" }}
108
+ />
109
+ <Field
110
+ type="search"
111
+ name="search"
112
+ props={{
113
+ placeholder: '搜索'
114
+ }}
115
+ />
116
+ <Field
117
+ type="select"
118
+ name="select2"
119
+ props={{
120
+ placeholder: '状态',
121
+ options: ['初始化', '运行中', '成功', '失败']
122
+ }}
123
+ />
124
+ <Field type="date" name="date3" />
125
+ <Field type="input" name="field1" />
126
+ <Field type="input" name="field2" />
127
+ <Field type="dateRange" name="date2" />
128
+ <Field type="checkbox" name="checkbox" />
129
+ </QueryForm>,
130
+ document.getElementById('root')
131
+ )
132
+ ```
133
+
134
+ ### 类组件示例
135
+ ```jsx
136
+ import React from 'react';
137
+ import { Button } from 'antd';
138
+ import { QueryForm } from 'tntd';
139
+
140
+ const { Field, createForm } = QueryForm;
141
+
142
+ class QueryFormDemo extends React.Component {
143
+ form = createForm();
144
+
145
+ render() {
146
+ return (
147
+ <QueryForm
148
+ form={this.form}
149
+ initialValues={{ name: 'Hello', job: 'Developer', status: 'init' }}
150
+ extraActions={(
151
+ <Button.Group>
152
+ <Button onClick={() => this.form.setValues({ name: 'World', status: 'running' })}>设置值</Button>
153
+ <Button onClick={() => this.form.setValue('job', 'Designer')}>设置单个值</Button>
154
+ <Button onClick={() => alert(JSON.stringify(this.form.getValues(), null, 4))}>获取值</Button>
155
+ </Button.Group>
156
+ )}
157
+ >
158
+ <Field type="input" name="name" />
159
+ <Field type="input" name="job" />
160
+ <Field type="select" name="status" props={{ options: ['init', 'running', 'error', 'success']}} />
161
+ </QueryForm>
162
+ );
163
+ }
164
+
165
+ componentDidMount() {
166
+ console.log('form:', this.form);
167
+ }
168
+ }
169
+
170
+ ReactDOM.render(
171
+ <QueryFormDemo />,
172
+ document.getElementById('root')
173
+ )
174
+ ```
175
+
176
+
177
+ ### 抽屉显示更多条件
178
+ ```jsx
179
+ import React, { useState, Fragment } from 'react';
180
+ import ReactDOM from 'react-dom';
181
+ import { Button, Popconfirm, Divider, ButtonGroup, TreeSelect, Cascader, Icon } from 'antd';
182
+ import { QueryForm } from 'tntd';
183
+ import { createGlobalStyle } from 'styled-components';
184
+ import 'antd/dist/antd.css';
185
+
186
+ const GlobalStyle = createGlobalStyle`
187
+ .site-body {
188
+ .ichYgh {
189
+ overflow: visible;
190
+ }
191
+ }
192
+ `;
193
+
194
+ const { useForm, Field } = QueryForm;
195
+
196
+ const QueryFormDemo = () => {
197
+ const [form] = useForm();
198
+
199
+ const ExtraActions = (
200
+ <Button.Group>
201
+ <Button icon="cloud-upload" onClick={() => form.setValues({ tree: '0-0', name: '张三', obj: { id: '1000' }})}/>
202
+ <Button icon="cloud-upload" onClick={() => form.setValue('name', '')} />
203
+ <Button icon="cloud-download" onClick={() => form.resetValues()}/>
204
+ <Button icon="setting" onClick={() => console.log('form values:', form.getValues())}/>
205
+ </Button.Group>
206
+ );
207
+
208
+ return (
209
+ <QueryForm
210
+ form={form}
211
+ extraActions={ExtraActions}
212
+ // 设置showFieldCount时,则使用抽屉显示更多否则使用展开/收起交互
213
+ showFieldCount={2}
214
+ initialValues={{
215
+ name: 'Jim Green',
216
+ status: 'initial',
217
+ obj: {
218
+ name: 'zhangsan'
219
+ }
220
+ }}
221
+ onChange={console.log}
222
+ onSearch={console.log}
223
+ onReset={console.log}
224
+ onToggleExpand={console.log}
225
+ >
226
+ <Field
227
+ type="selectInput"
228
+ name="obj"
229
+ props={{
230
+ placeholder: "名称",
231
+ options: [
232
+ { label: '名称', value: 'name' },
233
+ { label: 'ID', value: 'id' }
234
+ ],
235
+ addonBeforeStyle: { width: '100px' }
236
+ }}
237
+ />
238
+ <Field
239
+ name="tree"
240
+ component={TreeSelect}
241
+ props={{
242
+ placeholder: "名称222",
243
+ dropdownStyle:{
244
+ maxHeight: 400,
245
+ overflow: 'auto'
246
+ },
247
+ treeData: [
248
+ {
249
+ title: 'Node1',
250
+ value: '0-0',
251
+ key: '0-0',
252
+ children: [
253
+ {
254
+ title: 'Child Node1',
255
+ value: '0-0-1',
256
+ key: '0-0-1',
257
+ },
258
+ {
259
+ title: 'Child Node2',
260
+ value: '0-0-2',
261
+ key: '0-0-2',
262
+ },
263
+ ],
264
+ },
265
+ {
266
+ title: 'Node2',
267
+ value: '0-1',
268
+ key: '0-1',
269
+ }
270
+ ]
271
+ }}
272
+ />
273
+ <Field
274
+ type="input"
275
+ name="name"
276
+ props={{
277
+ placeholder: "名称"
278
+ }}
279
+ />
280
+ <Field
281
+ name="cascader"
282
+ component={Cascader}
283
+ props={{
284
+ options: [
285
+ {
286
+ value: 'zhejiang',
287
+ label: 'Zhejiang',
288
+ children: [
289
+ {
290
+ value: 'hangzhou',
291
+ label: 'Hangzhou',
292
+ children: [
293
+ {
294
+ value: 'xihu',
295
+ label: 'West Lake'
296
+ }
297
+ ]
298
+ }
299
+ ]
300
+ }
301
+ ]
302
+ }}
303
+ />
304
+ <Field
305
+ type="date"
306
+ name="date1"
307
+ />
308
+ <Field
309
+ title="状态"
310
+ type="select"
311
+ name="status2"
312
+ props={{
313
+ placeholder: '状态',
314
+ options: [
315
+ { label: '初始化', value: 'initial' },
316
+ { label: '运行中', value: 'running' },
317
+ { label: '成功', value: 'success', disabled: true },
318
+ { label: '失败', value: 'fail' }
319
+ ]
320
+ }}
321
+ />
322
+ <Field title="日期" type="date" name="date" />
323
+ <Field
324
+ title="日期范围"
325
+ type="dateRange"
326
+ name="date2"
327
+ />
328
+ <Field
329
+ title="状态"
330
+ type="select"
331
+ name="select1"
332
+ props={{
333
+ placeholder: '状态',
334
+ fieldNames: {
335
+ label: 'displayName',
336
+ value: 'name'
337
+ },
338
+ loadData: () => new Promise(
339
+ resolve => resolve([
340
+ { name: 'success', displayName: '成功' },
341
+ { name: 'fail', displayName: '失败' }
342
+ ])
343
+ )
344
+ }}
345
+ />
346
+ <Field
347
+ title="名称"
348
+ type="input"
349
+ name="name2"
350
+ props={{ placeholder: "名称" }}
351
+ />
352
+ <Field
353
+ title="状态2"
354
+ type="select"
355
+ name="select2"
356
+ props={{
357
+ placeholder: '状态',
358
+ options: ['初始化', '运行中', '成功', '失败']
359
+ }}
360
+ />
361
+ </QueryForm>
362
+ );
363
+ };
364
+
365
+ ReactDOM.render(
366
+ <Fragment>
367
+ <QueryFormDemo />
368
+ <GlobalStyle />
369
+ </Fragment>,
370
+ document.getElementById('root')
371
+ )
372
+ ```
373
+
374
+ ### API
375
+ #### QueryForm
376
+ | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
377
+ | :------------- | :-------------------------------------------------------- | :-------- | :----- | :------- |
378
+ | initialValues | 表单初始值对象 | object | 无 | 否 |
379
+ | showFieldCount | 显示在外面的表单数量(尽在“更多条件”在Drawer交互时使用) | number | 无 | 否 |
380
+ | showExpand | 展开/收起功能配置,默认开启 | boolean | true | 否 |
381
+ | showSearch | 搜索按钮显示配置,默认开启 | boolean | true | 否 |
382
+ | showReset | 重置按钮显示配置,默认开启 | boolean | true | 否 |
383
+ | drawerProps | Drawer props(参见antd,设置样式宽度时可用) | Object | 无 | 否 |
384
+ | extraActions | 额外操作 | ReactNode | 无 | 否 |
385
+ | renderActions | 表单操作, 自定义操作按钮,默认是查询、重置 | Function | 无 | 否 |
386
+ | onChange | 表单变化事件,onChange(values, { name, value, preValue }) | Function | 无 | 否 |
387
+ | onSearch | 搜索事件,onSearch(values) | Function | 无 | 否 |
388
+ | onReset | 重置表单事件,onReset(values) | Function | 无 | 否 |
389
+
390
+ #### Field
391
+ | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
392
+ | :-------- | :------------------------------------------------------------- | :----- | :----- | :------- |
393
+ | name | 表单项名,保证唯一 | string | 无 | 是 |
394
+ | title | 表单label | string | 无 | 否 |
395
+ | type | 表单类型input、search, number、select、selectInput、 date、 dateRange | 无 | 否 |
396
+ | component | 表单组件,如果内置的type表单组件不满足需求的话,可以直接传ReactNode类型的表单组件,其优先级高于type,如 antd TreeSelect、Cascader等,也可以完全自定义表单组件 | 无 | 否 |
397
+ | props | 表单元素属性,参照antd, Input, InputNumber, Select, DatePicker | Object | 无 | 否 |
398
+ | className | 添加样式class | string | 无 | 否 |
399
+
400
+ type="select", props 扩展了 options, fieldNames, loadData用法如下:
401
+ ```js
402
+ <Field
403
+ type="select"
404
+ name="status"
405
+ props={{
406
+ options: [
407
+ { name: 'success', displayName: '成功' },
408
+ { name: 'fail', displayName: '失败' }
409
+ ],
410
+ fieldNames: {
411
+ label: 'displayName',
412
+ value: 'name'
413
+ }
414
+ }}
415
+ />
416
+ ```
417
+ loadData 是一个function 返回一个promise, 用于异步加载options的场景
418
+ ```js
419
+ <Field
420
+ type="select"
421
+ name="status"
422
+ props={{
423
+ loadData: () => new Promise(
424
+ resolve => resolve([
425
+ { name: 'success', displayName: '成功' },
426
+ { name: 'fail', displayName: '失败' }
427
+ ])
428
+ ),
429
+ fieldNames: {
430
+ label: 'displayName',
431
+ value: 'name'
432
+ }
433
+ }}
434
+ />
435
+ ```
436
+
437
+ type="selectInput", 扩展了addonBeforeStyle属性,用来设置前面Select的样式
438
+ ```js
439
+ <Field
440
+ type="selectInput"
441
+ props={{
442
+ addonBeforeStyle: {
443
+ width: '160px'
444
+ }
445
+ }}
446
+ />
447
+ ```
448
+ #### form
449
+ form是QueryForm组件数据管理的对象,里面包含了数据相关的setter 和 getter方法。
450
+ ```js
451
+ {
452
+ // 设置form表单值
453
+ setValues(values: object): void,
454
+
455
+ // 设置单个field表单项值
456
+ setValue(name: string, value): void,
457
+
458
+ // 重置form表单值
459
+ resetValues(): void,
460
+
461
+ // 获取form表单值
462
+ getValues(): object,
463
+
464
+ // 获取单个field值
465
+ getValue(name): any
466
+ }
467
+ ```
468
+
469
+ #### useForm
470
+ hooks函数组件中使用,返回一个[form]用法如下:
471
+ ```js
472
+ import { QueryForm } from 'tntd';
473
+
474
+ const { Field, useForm } = QueryForm;
475
+
476
+ const Demo = () => {
477
+ const [form] = useForm();
478
+
479
+ return (
480
+ <>
481
+ <Button onClick={() => form.setValues({ name: 'Hello World' })}>设置值</Button>
482
+ <QueryForm form={form}>
483
+ <Field
484
+ type="input"
485
+ name="name"
486
+ />
487
+ </QueryForm>
488
+ <>
489
+ );
490
+ };
491
+ ```
492
+
493
+ #### createForm
494
+ 主要用在class 组件的场景,用法如下:
495
+ ```js
496
+ import React from 'react';
497
+ import { QueryForm } from 'tntd';
498
+
499
+ const { Field, createForm } = QueryForm;
500
+
501
+ class Demo extends React.Component {
502
+ form = createForm();
503
+
504
+ render() {
505
+ return (
506
+ <QueryForm form={this.form}>
507
+ <Field type="input" name="name" />
508
+ </QueryForm>
509
+ )
510
+ }
511
+ }
512
+ ```
@@ -0,0 +1,53 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import EventEmitter from 'eventemitter3';
8
+ import { get, set } from 'lodash';
9
+ export default (function () {
10
+ var eventEmitter = new EventEmitter();
11
+ var data = {
12
+ initialValues: {},
13
+ values: {}
14
+ };
15
+ return {
16
+ setData: function setData(key, value) {
17
+ set(data, key, value);
18
+ },
19
+ getData: function getData(key) {
20
+ get(data, key);
21
+ },
22
+ setValues: function setValues(values) {
23
+ data.values = values;
24
+ eventEmitter.emit('setValues', values);
25
+ },
26
+ getValues: function getValues() {
27
+ return data.values;
28
+ },
29
+ resetValues: function resetValues() {
30
+ data.values = _objectSpread({}, data.initialValues);
31
+ eventEmitter.emit('setValues', data.values);
32
+ },
33
+ setValue: function setValue(name, value) {
34
+ data.values = data.values || {};
35
+ data.values[name] = value;
36
+ eventEmitter.emit('setValue', name, value);
37
+ },
38
+ getValue: function getValue(name) {
39
+ var _data$values;
40
+
41
+ return (_data$values = data.values) == null ? void 0 : _data$values[name];
42
+ },
43
+ on: function on(eventName, callback) {
44
+ eventEmitter.on(eventName, callback);
45
+ },
46
+ emit: function emit() {
47
+ eventEmitter.emit.apply(eventEmitter, arguments);
48
+ },
49
+ off: function off() {
50
+ eventEmitter.removeListener.apply(eventEmitter, arguments);
51
+ }
52
+ };
53
+ });