@king-design/intact 3.1.0-beta.3 → 3.1.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 (55) hide show
  1. package/components/cascader/index.vdt +1 -0
  2. package/components/config/demos/basic.md +19 -0
  3. package/components/config/index.md +20 -0
  4. package/components/config/index.ts +8 -4
  5. package/components/dialog/index.spec.ts +41 -2
  6. package/components/drawer/index.spec.ts +4 -2
  7. package/components/icon/demos/icons.md +20 -9
  8. package/components/input/demos/blocks.md +16 -1
  9. package/components/input/styles.ts +2 -1
  10. package/components/portal.ts +6 -1
  11. package/components/table/styles.ts +2 -0
  12. package/components/tree/demos/expandAll.md +36 -8
  13. package/components/tree/index.md +1 -1
  14. package/components/tree/useExpanded.ts +14 -2
  15. package/components/treeSelect/index.md +1 -1
  16. package/components/upload/demos/files.md +14 -12
  17. package/components/upload/index.md +5 -5
  18. package/components/upload/index.ts +6 -5
  19. package/components/upload/useFiles.ts +19 -8
  20. package/es/components/cascader/index.vdt.js +1 -0
  21. package/es/components/config/index.d.ts +9 -2
  22. package/es/components/config/index.js +4 -3
  23. package/es/components/dialog/index.spec.js +87 -5
  24. package/es/components/drawer/index.spec.js +6 -4
  25. package/es/components/input/styles.js +1 -1
  26. package/es/components/portal.js +7 -1
  27. package/es/components/table/styles.js +3 -2
  28. package/es/components/tree/useExpanded.js +21 -6
  29. package/es/components/upload/index.d.ts +6 -5
  30. package/es/components/upload/index.js +1 -0
  31. package/es/components/upload/useFiles.js +21 -8
  32. package/es/index.d.ts +2 -2
  33. package/es/index.js +2 -2
  34. package/es/site/data/components/config/demos/basic/index.d.ts +5 -0
  35. package/es/site/data/components/config/demos/basic/index.js +17 -0
  36. package/es/site/data/components/config/demos/basic/react.d.ts +4 -0
  37. package/es/site/data/components/config/demos/basic/react.js +29 -0
  38. package/es/site/data/components/config/index.d.ts +57 -0
  39. package/es/site/data/components/config/index.js +42 -0
  40. package/es/site/data/components/icon/demos/icons/index.js +3 -2
  41. package/es/site/data/components/input/demos/blocks/react.js +11 -1
  42. package/es/site/data/components/tree/demos/draggable/react.js +1 -1
  43. package/es/site/data/components/tree/demos/expandAll/index.d.ts +9 -1
  44. package/es/site/data/components/tree/demos/expandAll/index.js +14 -2
  45. package/es/site/data/components/tree/demos/expandAll/react.d.ts +10 -1
  46. package/es/site/data/components/tree/demos/expandAll/react.js +24 -5
  47. package/es/site/data/components/upload/demos/files/index.d.ts +2 -5
  48. package/es/site/data/components/upload/demos/files/index.js +5 -1
  49. package/es/site/data/components/upload/demos/files/react.d.ts +2 -5
  50. package/es/site/data/components/upload/demos/files/react.js +13 -2
  51. package/es/site/src/pages/document/styles.js +1 -1
  52. package/index.ts +2 -2
  53. package/package.json +2 -2
  54. package/es/site/data/components/icon/demos/icons/react.d.ts +0 -15
  55. package/es/site/data/components/icon/demos/icons/react.js +0 -107
@@ -5,6 +5,7 @@ import {makeMenuStyles, makeFilterMenuStyles} from './styles';
5
5
 
6
6
  const {data, trigger, filterable, fields} = this.get();
7
7
  const { k } = this.config;
8
+ const baseMenuStyles = makeMenuStyles(k);
8
9
  const classNameObj = {
9
10
  [`${k}-cascader-menu`]: true,
10
11
  [makeMenuStyles(k)]: true,
@@ -0,0 +1,19 @@
1
+ ---
2
+ title: 改变className前缀
3
+ order: 0
4
+ ---
5
+
6
+ 通过配置`classNamePrefix`,可以改变样式名className的前缀,组件默认是`k`开头,如: `k-datepicker`
7
+
8
+ > 本例中,我们将前缀设为`kd`,可以打开调试工具查看
9
+
10
+ ```vdt
11
+ import {ConfigProvider, Button, Input} from 'kpc';
12
+
13
+ <ConfigProvider value={{classNamePrefix: 'kd'}}>
14
+ <Button>Button</Button>
15
+ <div style="margin-top: 8px;">
16
+ <Input />
17
+ </div>
18
+ </ConfigProvider>
19
+ ```
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: 全局配置
3
+ category: 组件
4
+ order: 99
5
+ sidebar: doc
6
+ ---
7
+
8
+ # 属性
9
+
10
+ ## ConfigProvider
11
+
12
+ | 属性 | 说明 | 类型 | 默认值 |
13
+ | --- | --- | --- | --- |
14
+ | value | 全局配置参数 | `ConfigProps` | `undefined` |
15
+
16
+ ```ts
17
+ export interface ConfigProps {
18
+ classNamePrefix?: string
19
+ }
20
+ ```
@@ -1,13 +1,12 @@
1
1
  import { createContext, ProviderProps } from '../context';
2
- import { EMPTY_OBJ } from 'intact';
3
- import {makeIconStyles} from '../../styles/fonts/iconfont';
2
+ import { EMPTY_OBJ, Component } from 'intact';
4
3
 
5
4
  export interface ConfigProps {
6
5
  classNamePrefix?: string
7
6
  }
8
7
 
9
8
  const {
10
- Provider: ConfigProvider,
9
+ Provider,
11
10
  Consumer: ConfigConsumer,
12
11
  useContext,
13
12
  } = createContext<ConfigProps>(EMPTY_OBJ);
@@ -21,8 +20,13 @@ function useConfigContext() {
21
20
  }
22
21
  }
23
22
 
23
+ /**
24
+ * for vue/react type checking
25
+ */
26
+ export declare class _ConfigProvider extends Component<ProviderProps<ConfigProps>> { }
27
+ export const ConfigProvider = Provider as typeof _ConfigProvider;
28
+
24
29
  export {
25
- ConfigProvider,
26
30
  ConfigConsumer,
27
31
  useConfigContext,
28
32
  }
@@ -1,7 +1,7 @@
1
1
  import {Component} from 'intact';
2
2
  import {Dialog, BaseDialog, DialogProps} from './';
3
3
  import {bind} from '../utils';
4
- import {getElement, mount, unmount, dispatchEvent, wait} from '../../test/utils';
4
+ import {getElement, mount, unmount, dispatchEvent, wait, getElements} from '../../test/utils';
5
5
  import BasicDemo from '~/components/dialog/demos/basic';
6
6
  import AsyncCloseDemo from '~/components/dialog/demos/asyncClose';
7
7
  import TerminateDemo from '~/components/dialog/demos/terminate';
@@ -295,7 +295,46 @@ describe('Dialog', () => {
295
295
  instance.refs.dialog.close();
296
296
 
297
297
  await wait();
298
- expect(document.body.getAttribute('style')).to.be.null;
298
+ const style = document.body.getAttribute('style');
299
+ expect(style === null || style === '').to.be.true;
300
+ });
301
+
302
+ it('show nested dialog', async () => {
303
+ class Test extends Component {
304
+ static template = `
305
+ const { Dialog } = this;
306
+ <Dialog v-model="value">test</Dialog>
307
+ `
308
+ Dialog = Dialog;
309
+ }
310
+
311
+ class Demo extends Component<{show: boolean, testShow: boolean}> {
312
+ static template = `
313
+ const { Test, Dialog } = this;
314
+ <Dialog v-model="show">
315
+ <div ev-click={this.showTest}>click</div>
316
+ <Test v-model="testShow" />
317
+ </Dialog>
318
+ `
319
+ Test = Test;
320
+ Dialog = Dialog;
321
+
322
+ @bind
323
+ showTest() {
324
+ this.set('testShow', true);
325
+ }
326
+ }
327
+
328
+ const [instance, element] = mount(Demo);
329
+
330
+ instance.set('show', true);
331
+ await wait();
332
+
333
+ instance.showTest();
334
+ await wait();
335
+
336
+ const [dialog1, dialog2] = getElements('.k-dialog');
337
+ expect(dialog2.querySelector('.k-dialog-body')!.textContent).to.eql('test');
299
338
  });
300
339
 
301
340
  // it('should handle v-if and v-model at the same time correctly in Vue', async () => {
@@ -1,7 +1,7 @@
1
1
  import BasicDemo from '~/components/drawer/demos/basic';
2
2
  import PlacementDemo from '~/components/drawer/demos/placement';
3
3
  import overlayDemo from '~/components/drawer/demos/overlay';
4
- import {mount, unmount, dispatchEvent, getElement, wait} from '../../test/utils';
4
+ import {mount, unmount, dispatchEvent, getElement, wait, getElements} from '../../test/utils';
5
5
  import {Component} from 'intact';
6
6
  import {Drawer} from '.';
7
7
  import {Dialog} from '../dialog';
@@ -85,6 +85,8 @@ describe('Drawer', () => {
85
85
  const [instance, element] = mount(Demo);
86
86
 
87
87
  await wait();
88
- expect(instance.refs.dialog.dialogRef.value.parentElement.parentElement).to.eql(document.body);
88
+ // expect(instance.refs.dialog.dialogRef.value.parentElement.parentElement).to.eql(document.body);
89
+ const [dialog1, dialog2] = getElements('.k-dialog');
90
+ expect(dialog2.querySelector('.k-dialog-body')!.textContent).to.eql('Dialog');
89
91
  });
90
92
  });
@@ -6,18 +6,20 @@ order: 3
6
6
 
7
7
 
8
8
  ```vdt
9
- import {Icon, Input} from 'kpc';
9
+ import {Icon, Input, Copy} from 'kpc';
10
10
 
11
11
  <div>
12
12
  <Input v-model="keywords" placeholder="Search icon" clearable />
13
13
  <div class="icons">
14
- <div class="icon" v-for={this.filter()}>
15
- <Icon
16
- class={this.config.k + '-icon-' + $value[0]}
17
- size="large"
18
- />
19
- <div>{this.config.k + '-icon-' + $value[0]}</div>
20
- </div>
14
+ <Copy v-for={this.filter()} text={this.config.k + '-icon-' + $value[0]}>
15
+ <div class="icon">
16
+ <Icon
17
+ class={this.config.k + '-icon-' + $value[0]}
18
+ size="large"
19
+ />
20
+ <div>{this.config.k + '-icon-' + $value[0]}</div>
21
+ </div>
22
+ </Copy>
21
23
  </div>
22
24
  </div>
23
25
  ```
@@ -158,8 +160,17 @@ export default class extends Component<Props> {
158
160
  if (!keywords) return fonts;
159
161
 
160
162
  return fonts.filter((font) => {
161
- return font[0].includes(keywords) || font[1] && font[1].includes(keywords);
163
+ return `${this.config.k}-icon-${font[0]}`.includes(keywords) ||
164
+ font[1] && font[1].includes(keywords);
162
165
  });
163
166
  }
164
167
  }
165
168
  ```
169
+
170
+ ```vue-ignore
171
+ 该示例无展示代码
172
+ ```
173
+
174
+ ```react-ignore
175
+ 该示例无展示代码
176
+ ```
@@ -6,7 +6,7 @@ order: 1
6
6
  使用`append`,`prepend`,`suffix`,`prefix`扩展点,可以往组件追加内容
7
7
 
8
8
  ```vdt
9
- import {Input, Button, Icon} from 'kpc';
9
+ import {Input, Button, Icon, ButtonGroup} from 'kpc';
10
10
 
11
11
  <div>
12
12
  <Input placeholder="please enter">
@@ -22,6 +22,21 @@ import {Input, Button, Icon} from 'kpc';
22
22
  </b:append>
23
23
  </Input>
24
24
  <br />
25
+ <Input placeholder="please enter">
26
+ <b:append>
27
+ <Button>提交</Button>
28
+ </b:append>
29
+ </Input>
30
+ <br />
31
+ <Input placeholder="please enter">
32
+ <b:append>
33
+ <ButtonGroup>
34
+ <Button type="primary">提交</Button>
35
+ <Button type="primary">创建</Button>
36
+ </ButtonGroup>
37
+ </b:append>
38
+ </Input>
39
+ <br />
25
40
  <Input placeholder="please enter">
26
41
  <b:append>
27
42
  <Button icon type="primary">
@@ -167,6 +167,7 @@ export function makeStyles(k: string) {
167
167
  display: inline-flex;
168
168
  .${k}-input-wrapper {
169
169
  border-radius: 0;
170
+ flex: 1;
170
171
  }
171
172
  .${k}-input-wrapper:first-child {
172
173
  border-radius: ${input.borderRadius} 0 0 ${input.borderRadius};
@@ -184,7 +185,7 @@ export function makeStyles(k: string) {
184
185
  white-space: nowrap;
185
186
  .${k}-btn {
186
187
  margin: -1px;
187
- border: none;
188
+ // border: none;
188
189
  &.${k}-none:hover {
189
190
  background: transparent;
190
191
  }
@@ -146,7 +146,12 @@ export class Portal<T extends PortalProps = PortalProps> extends Component<T> {
146
146
  if (!this.container) {
147
147
  if (this.$senior instanceof BaseDialog) {
148
148
  // Dialog and Drawer must be inserted into document.body
149
- this.container = document.body;
149
+ // this.container = document.body;
150
+ /**
151
+ * @Modify https://github.com/ksc-fe/kpc/issues/915
152
+ * shoud insert to parent .k-dialog-wrapper to show nested dialog in Vue
153
+ */
154
+ this.container = parentDom.closest(`.${this.config.k}-dialog-wrapper`) || document.body;
150
155
  } else {
151
156
  // find the closest dialog if exists
152
157
  this.container = parentDom.closest(`.${this.config.k}-dialog`) || document.body;
@@ -60,6 +60,7 @@ const defaults = {
60
60
  // tree
61
61
  arrow: {
62
62
  gap: `4px`,
63
+ width: `16px`,
63
64
  },
64
65
 
65
66
  resizeWidth: `5px`,
@@ -311,6 +312,7 @@ export function makeStyles(k: string) {
311
312
  // display: none;
312
313
  // }
313
314
  .${k}-table-arrow {
315
+ width: ${table.arrow.width} !important;
314
316
  margin-right: ${table.arrow.gap};
315
317
  transition: transform ${table.transition};
316
318
  position: relative;
@@ -5,19 +5,40 @@ order: 7
5
5
 
6
6
  给组件添加`defaultExpandAll`属性,可以默认展开所有节点
7
7
 
8
- > 仅限首次渲染`Tree`时生效,后续添加节点不会默认展开
8
+ > `@before v3.1.0` 仅限首次渲染`Tree`时生效,后续添加节点不会默认展开
9
+ > `@since v3.1.0` 当首次渲染时,如果不存在`data`或者`data`为空数组,则待接收到新的`data`后,展开所有节点
9
10
 
10
11
  ```vdt
11
- import {Tree} from 'kpc';
12
+ import {Tree, Button} from 'kpc';
12
13
 
13
- <Tree
14
- defaultExpandAll
15
- data={this.get('data')}
16
- />
14
+ <div class="wrapper">
15
+ <Tree
16
+ defaultExpandAll
17
+ data={this.get('data')}
18
+ />
19
+ <Tree
20
+ defaultExpandAll
21
+ data={this.get('delayData')}
22
+ />
23
+ <Button ev-click={this.load}>加载数据</Button>
24
+ </div>
25
+ ```
26
+
27
+ ```styl
28
+ .wrapper
29
+ display flex
30
+ gap 18px
17
31
  ```
18
32
 
19
33
  ```ts
20
- export default class extends Component {
34
+ import {bind, TreeDataItem} from 'kpc';
35
+
36
+ interface Props {
37
+ data: TreeDataItem<string>[]
38
+ delayData?: TreeDataItem<string>[]
39
+ }
40
+
41
+ export default class extends Component<Props> {
21
42
  static template = template;
22
43
  static defaults() {
23
44
  return {
@@ -62,8 +83,15 @@ export default class extends Component {
62
83
  }
63
84
  ]
64
85
  }
65
- ]
86
+ ],
87
+
88
+ delayData: undefined
66
89
  }
67
90
  }
91
+
92
+ @bind
93
+ load() {
94
+ this.set('delayData', this.get('data'));
95
+ }
68
96
  }
69
97
  ```
@@ -14,7 +14,7 @@ sidebar: doc
14
14
  | uncorrelated | 是否让父子`checkbox`选中状态互不关联 | `boolean` | `false` |
15
15
  | checkedKeys | 通过`key`指定勾选的数据节点 | `K[]` | `undefined` |
16
16
  | expandedKeys | 通过`key`指定展开的数据节点 | `K[]` | `undefined` |
17
- | defaultExpandAll | 是否默认展开所有节点 (该属性只在首次渲染时起作用,渲染后再更新数据`data`,没有效果) | `boolean` | `false` |
17
+ | defaultExpandAll | 是否默认展开所有节点 | `boolean` | `false` |
18
18
  | selectable | 节点是否可选中,默认为`true`可选中 | `boolean` | `true` |
19
19
  | selectedKeys | 通过`key`指定选中的数据节点 | `K[]` | `undefined` |
20
20
  | multiple | `selectedKeys`是否支持多选 | `boolean` | `false` |
@@ -11,8 +11,20 @@ export function useExpanded(getNodes: () => Node<Key>[]) {
11
11
  });
12
12
 
13
13
  onBeforeMount(() => {
14
- if (instance.get('defaultExpandAll')) {
15
- expandAll();
14
+ /**
15
+ * change the behavior
16
+ * if the data is undefined, we expand all keys after we received data
17
+ */
18
+ const { defaultExpandAll, data } = instance.get();
19
+ if (defaultExpandAll) {
20
+ if (data && data.length) {
21
+ expandAll();
22
+ } else {
23
+ instance.on(`$receive:data`, function cb() {
24
+ expandAll();
25
+ instance.off(`$receive:data`, cb);
26
+ });
27
+ }
16
28
  }
17
29
  });
18
30
 
@@ -29,7 +29,7 @@ sidebar: doc
29
29
  | uncorrelated | 是否让父子`checkbox`选中状态互不关联 | `boolean` | `false` |
30
30
  | load | 指定异步加载节点数据的函数,该函数通过`Promise`返回数组来添加子节点数据 | <code>(node: TreeNode<K>) => Proomise<void> &#124; void</code> | `undefined` |
31
31
  | showLine | 是否展示`Tree`的对齐线 | `boolean` | `true` |
32
- | defaultExpandAll | 是否默认展开所有节点 (该属性只在首次渲染时起作用,渲染后再更新数据`data`,没有效果) | `boolean` | `false` |
32
+ | defaultExpandAll | 是否默认展开所有节点 | `boolean` | `false` |
33
33
  | checkbox | 是否展示复选框 | `boolean` | `false` |
34
34
  | filter | 当支持筛选时,可以自定义筛选规则 | `(keywords: string, data: TreeDataItem<K>) => boolean` | `undefined` |
35
35
  | show | 是否展示菜单项 | `boolean` | `false` |
@@ -3,16 +3,20 @@ title: 定义初始化列表
3
3
  order: 3
4
4
  ---
5
5
 
6
- 你可以通过`defaultFiles`定义初始化上传列表,该属性取值为数组,数组每一项结构如下:
7
- 1. `name` 文件名
8
- 2. `url` 文件对应的url地址
6
+ 你可以通过`files`定义初始化上传列表,该属性取值为数组,数组每一项结构如下:
7
+ 1. `name` 文件名,必填
8
+ 2. `url` 文件对应的url地址,非必填
9
+ 3. `status` 状态`UploadFileStatus`,默认成功,非必填
10
+ 4. `uid` 文件唯一标识id,非必填
11
+
12
+ > @since 3.1.0,defaultFiles已被废弃,使用files来代替,支持响应式更新
9
13
 
10
14
  ```vdt
11
15
  import {Upload} from 'kpc';
12
16
 
13
17
  <Upload multiple
14
18
  action="//fakestoreapi.com/products"
15
- defaultFiles={this.get('defaultFiles')}
19
+ v-model:files="files"
16
20
  />
17
21
  ```
18
22
 
@@ -22,22 +26,20 @@ import {Upload} from 'kpc';
22
26
  ```
23
27
 
24
28
  ```ts
25
- interface Props {
26
- defaultFiles: DefaultFile[]
27
- }
29
+ import {UploadFileStatus, UploadFile} from 'kpc';
28
30
 
29
- type DefaultFile = {
30
- name: string
31
- url: string
31
+ interface Props {
32
+ files?: UploadFile[]
32
33
  }
33
34
 
34
35
  export default class extends Component<Props> {
35
36
  static template = template;
36
37
  static defaults() {
37
38
  return {
38
- defaultFiles: [
39
+ files: [
39
40
  {name: 'test1.jpg', url: 'http://www.example.com/test1.jpg'},
40
- {name: 'test2.png', url: 'http://www.example.com/test2.png'}
41
+ {name: 'test2.png', url: 'http://www.example.com/test2.png'},
42
+ {name: 'test3.png', status: UploadFileStatus.Error},
41
43
  ]
42
44
  } as Props;
43
45
  }
@@ -11,7 +11,7 @@ sidebar: doc
11
11
  | --- | --- | --- | --- |
12
12
  | accept | `input`的[accept](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept)属性,支持的文件的类型 | `string` | `undefined` |
13
13
  | files | 所有已上传和待上传的文件列表 | `UploadFile[]` | `[]` |
14
- | defaultFiles | 指定初始化上传列表,见示例 | <code>(Partial&lt;UploadFile&gt; & Pick&lt;UploadFile, 'name' &#124; 'url'&gt;)[]</code> | `undefined` |
14
+ | defaultFiles `@deprecated` | 指定初始化上传列表,见示例 | <code>(Partial&lt;UploadFile&gt; & Pick&lt;UploadFile, 'name' &#124; 'url'&gt;)[]</code> | `undefined` |
15
15
  | maxSize | 最大上传文件大小限制(kb),默认无限制 | `number` | `undefined` |
16
16
  | limit | 最大上传文件数量限制,默认无限制 | `number` | `undefined` |
17
17
  | autoUpload | 是否选择文件后即自动上传 | `boolean` | `true` |
@@ -29,13 +29,13 @@ sidebar: doc
29
29
 
30
30
  ```ts
31
31
  export type UploadFile = {
32
- status: UploadFileStatus
32
+ status?: UploadFileStatus
33
33
  type?: string
34
34
  size?: number
35
35
  name: string
36
- percent: number
37
- uid: number
38
- raw: File | Partial<UploadFile>
36
+ percent?: number
37
+ uid?: number
38
+ raw?: File | Partial<UploadFile>
39
39
  url?: string
40
40
  request?: any
41
41
  }
@@ -10,7 +10,8 @@ import type {RequestError} from './ajaxUploader';
10
10
  import type {Events} from '../types';
11
11
  import { useConfigContext } from '../config';
12
12
 
13
- export type {RequestError, UploadFileStatus};
13
+ export type {RequestError};
14
+ export {UploadFileStatus};
14
15
 
15
16
  export interface UploadProps {
16
17
  accept?: string
@@ -45,13 +46,13 @@ export interface UploadBlocks {
45
46
  }
46
47
 
47
48
  export type UploadFile = {
48
- status: UploadFileStatus
49
+ status?: UploadFileStatus
49
50
  type?: string
50
51
  size?: number
51
52
  name: string
52
- percent: number
53
- uid: number
54
- raw: File | Partial<UploadFile>
53
+ percent?: number
54
+ uid?: number | string
55
+ raw?: File | Partial<UploadFile>
55
56
  url?: string
56
57
  request?: any
57
58
  }
@@ -17,21 +17,22 @@ export function useFiles(
17
17
  const {files, defaultFiles} = instance.get();
18
18
  const _files = files!.slice(0);
19
19
  if (defaultFiles) {
20
+ if (process.env.NODE_ENV !== 'production') {
21
+ console.warn(`'defaultFiles' is deprecated, use 'files' instead for reactive updating.`)
22
+ }
20
23
  defaultFiles.forEach(file => {
21
- _files.push({
22
- status: UploadFileStatus.Done,
23
- name: file.name,
24
- percent: 100,
25
- uid: uid++,
26
- raw: file,
27
- url: file.url,
28
- });
24
+ _files.push(normalizeFile(file));
29
25
  });
30
26
 
31
27
  instance.set('files', _files);
32
28
  }
33
29
  }
34
30
 
31
+ instance.on(`$receive:files`, (files) => {
32
+ if (!files) return;
33
+ instance.set('files', files.map(normalizeFile));
34
+ });
35
+
35
36
  async function addFiles(fileList: FileList) {
36
37
  const files = instance.get('files')!.slice(0);
37
38
  const newFiles = Array.from(fileList);
@@ -100,3 +101,13 @@ export function useFiles(
100
101
 
101
102
  return {addFiles, removeFile};
102
103
  }
104
+
105
+ function normalizeFile(file: UploadFile) {
106
+ return {
107
+ status: UploadFileStatus.Done,
108
+ percent: 100,
109
+ uid: uid++,
110
+ raw: file,
111
+ ...file
112
+ };
113
+ }
@@ -21,6 +21,7 @@ export default function ($props, $blocks, $__proto__) {
21
21
  fields = _this$get.fields;
22
22
 
23
23
  var k = this.config.k;
24
+ var baseMenuStyles = makeMenuStyles(k);
24
25
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-cascader-menu"] = true, _classNameObj[makeMenuStyles(k)] = true, _classNameObj);
25
26
  var getField = this.fields;
26
27
 
@@ -1,10 +1,17 @@
1
1
  import { ProviderProps } from '../context';
2
+ import { Component } from 'intact';
2
3
  export interface ConfigProps {
3
4
  classNamePrefix?: string;
4
5
  }
5
- declare const ConfigProvider: import("intact").ComponentConstructor<import("intact").Component<ProviderProps<ConfigProps>, {}, {}, {}>>, ConfigConsumer: import("intact").ComponentConstructor<import("intact").Component<import("../context").ConsumerProps<ConfigProps>, {}, {}, {}>>;
6
+ declare const ConfigConsumer: import("intact").ComponentConstructor<Component<import("../context").ConsumerProps<ConfigProps>, {}, {}, {}>>;
6
7
  declare function useConfigContext(): {
7
8
  cls: (name: string) => string;
8
9
  readonly k: string;
9
10
  };
10
- export { ConfigProvider, ConfigConsumer, useConfigContext, };
11
+ /**
12
+ * for vue/react type checking
13
+ */
14
+ export declare class _ConfigProvider extends Component<ProviderProps<ConfigProps>> {
15
+ }
16
+ export declare const ConfigProvider: typeof _ConfigProvider;
17
+ export { ConfigConsumer, useConfigContext, };
@@ -1,8 +1,8 @@
1
1
  import { createContext } from '../context';
2
- import { EMPTY_OBJ } from 'intact';
2
+ import { EMPTY_OBJ, Component } from 'intact';
3
3
 
4
4
  var _createContext = createContext(EMPTY_OBJ),
5
- ConfigProvider = _createContext.Provider,
5
+ Provider = _createContext.Provider,
6
6
  ConfigConsumer = _createContext.Consumer,
7
7
  useContext = _createContext.useContext;
8
8
 
@@ -20,4 +20,5 @@ function useConfigContext() {
20
20
  };
21
21
  }
22
22
 
23
- export { ConfigProvider, ConfigConsumer, useConfigContext };
23
+ export var ConfigProvider = Provider;
24
+ export { ConfigConsumer, useConfigContext };