@king-design/intact 3.1.0 → 3.1.1-beta.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.
@@ -137,6 +137,7 @@ export function makeDialogStyles(k: string) {
137
137
  // body
138
138
  .${k}-dialog-body {
139
139
  padding: ${dialog.body.padding};
140
+ position: relative;
140
141
  }
141
142
 
142
143
  // footer
@@ -180,7 +181,6 @@ export function makeAlertStyles(k: string) {
180
181
  margin-top: ${dialog.alert.bodyMarginTop};
181
182
  padding: ${dialog.alert.padding};
182
183
  text-align: center;
183
- position: relative;
184
184
  z-index: 1;
185
185
  }
186
186
  .${k}-dialog-header,
@@ -11,7 +11,6 @@ export async function exportTable(
11
11
  parentComponet: ComponentClass,
12
12
  filename: string,
13
13
  ) {
14
- const download = (await import('downloadjs')).default;
15
14
  const collection: string[] = [];
16
15
  const {columns, cols} = getData();
17
16
 
@@ -58,11 +57,7 @@ export async function exportTable(
58
57
  );
59
58
 
60
59
  const content = collection.join('\r\n');
61
- download(
62
- '\uFEFF' + content,
63
- filename + '.csv',
64
- 'text/comma-separated-values;charset=utf-8'
65
- );
60
+ download(content, filename + '.csv');
66
61
 
67
62
  return content;
68
63
  }
@@ -72,3 +67,24 @@ function pushTextContext(rows: string[], dom: HTMLElement, content: string | und
72
67
  text = '"' + String(text!.trim()).replace(/"/g, '""') + '"';
73
68
  rows.push(text);
74
69
  }
70
+
71
+ export function download(content: string, filename: string) {
72
+ if ((navigator as any).msSaveBlob) { // IE10+
73
+ const blob = new Blob([content], { type: 'text/csv;charset=utf-8' });
74
+ (navigator as any).msSaveBlob(blob, filename);
75
+ } else {
76
+ const link = document.createElement('a');
77
+ if ('download' in link) {
78
+ const blob = new Blob([content], { type: 'text/csv;charset=utf-8' });
79
+ const url = URL.createObjectURL(blob);
80
+ link.setAttribute('href', url);
81
+ link.setAttribute('download', filename);
82
+ link.style.display = 'none';
83
+ document.body.appendChild(link);
84
+ link.click();
85
+ document.body.removeChild(link);
86
+ } else {
87
+ window.open(`data:text/csv,charset=utf-8,%EF%BB%BF` + encodeURI(content));
88
+ }
89
+ }
90
+ }
@@ -21,6 +21,7 @@ import {Dropdown, DropdownMenu, DropdownItem} from '../dropdown';
21
21
  import {Icon} from '../icon';
22
22
  import {useChecked, AllCheckedStatus} from './useChecked';
23
23
  import PaginationDemo from '~/components/table/demos/pagination';
24
+ import { download } from './exportTable';
24
25
 
25
26
  describe('Table', () => {
26
27
  afterEach(() => {
@@ -370,6 +371,11 @@ describe('Table', () => {
370
371
  {a: '1', b: 2, c: 3}
371
372
  ]);
372
373
  expect(content1.replace(/\r\n|\r/g, '\n')).to.matchSnapshot();
374
+
375
+ // it will be error codes if downloadjs exports below contents
376
+ // use custom download function instead
377
+ const csv = '"镜像名称","系统大小","镜像类型","状态","操作系统","创建时间","是否支持快速开机","可用区","镜像描述","关联快照"\r\n"a12321","20GB","普通镜像","错误 详情","centos-7","2023-11-23 15:54:10","否","--","--","q"';
378
+ download(csv, 'test.csv');
373
379
  });
374
380
 
375
381
  it('selectedKeys', async () => {
@@ -87,7 +87,7 @@ export function makeDialogStyles(k) {
87
87
 
88
88
  return /*#__PURE__*/css("position:absolute;width:", dialog.width, ";border-radius:", dialog.borderRadius, ";background:", dialog.bgColor, ";font-size:", dialog.fontSize, ";color:", dialog.color, ";box-shadow:", dialog.boxShadow, ";max-width:100%;z-index:", theme.maxZIndex, ";&.", k, "-dragging{cursor:move;user-select:none;}&.transition-enter-active,&.transition-leave-active,&.transition-appear-active{transition:all ", dialog.transition, ";}&.transition-enter-from,&.transition-leave-to,&.transition-appear-from{transform:", dialog.transform, ";opacity:0;}", _mapInstanceProperty(_context = ['large', 'small', 'mini']).call(_context, function (size) {
89
89
  return /*#__PURE__*/css("&.", k, "-", size, "{width:", dialog[size + "Width"], ";}");
90
- }), ".", k, "-dialog-header{padding:0 ", dialog.padding, ";margin:", dialog.margin, ";border-bottom:", dialog.header.border, ";height:", dialog.header.height, ";line-height:", dialog.header.height, ";font-size:", dialog.header.fontSize, ";color:", dialog.header.color, ";position:relative;font-weight:", dialog.header.fontWeight, ";}.", k, "-dialog-title{display:inline-block;}.", k, "-dialog-close{position:absolute;right:", dialog.header.closeRight, ";top:", dialog.header.closeTop, ";.", k, "-icon{font-size:", dialog.header.closeIconFontSize, ";}}.", k, "-dialog-body{padding:", dialog.body.padding, ";}.", k, "-dialog-footer{text-align:right;padding:", dialog.footer.padding, ";margin:", dialog.margin, ";border-top:", dialog.footer.border, ";.", k, "-btn{margin-left:", dialog.footer.btnGap, ";}}");
90
+ }), ".", k, "-dialog-header{padding:0 ", dialog.padding, ";margin:", dialog.margin, ";border-bottom:", dialog.header.border, ";height:", dialog.header.height, ";line-height:", dialog.header.height, ";font-size:", dialog.header.fontSize, ";color:", dialog.header.color, ";position:relative;font-weight:", dialog.header.fontWeight, ";}.", k, "-dialog-title{display:inline-block;}.", k, "-dialog-close{position:absolute;right:", dialog.header.closeRight, ";top:", dialog.header.closeTop, ";.", k, "-icon{font-size:", dialog.header.closeIconFontSize, ";}}.", k, "-dialog-body{padding:", dialog.body.padding, ";position:relative;}.", k, "-dialog-footer{text-align:right;padding:", dialog.footer.padding, ";margin:", dialog.margin, ";border-top:", dialog.footer.border, ";.", k, "-btn{margin-left:", dialog.footer.btnGap, ";}}");
91
91
  }
92
92
  export function makeWrapperStyles(k) {
93
93
  //.${k}-fade-leave-active will add position absolute to the styles
@@ -97,7 +97,7 @@ export function makeWrapperStyles(k) {
97
97
  export function makeAlertStyles(k) {
98
98
  var _context2;
99
99
 
100
- return /*#__PURE__*/css("&.", k, "-alert-dialog{.", k, "-dialog-body{margin-top:", dialog.alert.bodyMarginTop, ";padding:", dialog.alert.padding, ";text-align:center;position:relative;z-index:1;}.", k, "-dialog-header,.", k, "-dialog-footer{border:none;}.", k, "-dialog-tip-icon{margin-bottom:", dialog.alert.tipIconMarginBottom, ";.", k, "-icon{font-size:", dialog.alert.tipIconFontSize, ";line-height:", dialog.alert.tipIconLineHeight, ";}}", _mapInstanceProperty(_context2 = ['success', 'warning', 'error', 'confirm']).call(_context2, function (type) {
100
+ return /*#__PURE__*/css("&.", k, "-alert-dialog{.", k, "-dialog-body{margin-top:", dialog.alert.bodyMarginTop, ";padding:", dialog.alert.padding, ";text-align:center;z-index:1;}.", k, "-dialog-header,.", k, "-dialog-footer{border:none;}.", k, "-dialog-tip-icon{margin-bottom:", dialog.alert.tipIconMarginBottom, ";.", k, "-icon{font-size:", dialog.alert.tipIconFontSize, ";line-height:", dialog.alert.tipIconLineHeight, ";}}", _mapInstanceProperty(_context2 = ['success', 'warning', 'error', 'confirm']).call(_context2, function (type) {
101
101
  var color = type === 'error' ? theme.color.danger : type === 'confirm' ? theme.color.primary : theme.color[type];
102
102
  return /*#__PURE__*/css("&.", k, "-", type, "{.", k, "-dialog-tip-icon{color:", color, ";}}");
103
103
  }), " &:not(.", k, "-confirm){.", k, "-dialog-cancel{display:none;}}&.", k, "-with-title{.", k, "-dialog-body{margin-top:", dialog.alert.titleBodyMarginTop, ";text-align:left;}.", k, "-dialog-tip-icon{float:left;.", k, "-icon{font-size:", dialog.alert.titleTipIconFontSize, ";}}.", k, "-alert-dialog-wrapper{overflow:hidden;padding-left:", dialog.alert.wrapperPaddingLeft, ";}.", k, "-alert-dialog-title{line-height:", dialog.alert.tipIconLineHeight, ";font-size:", dialog.alert.titleFontSize, ";font-weight:", dialog.alert.titleFontWeight, ";}}}");
@@ -1,3 +1,4 @@
1
1
  import { ComponentClass } from 'intact';
2
2
  import type { useColumns } from './useColumns';
3
3
  export declare function exportTable(getData: ReturnType<typeof useColumns>['getData'], data: any[] | undefined, childrenKey: string | undefined, parentComponet: ComponentClass, filename: string): Promise<string>;
4
+ export declare function download(content: string, filename: string): void;
@@ -1,6 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
3
3
  import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
4
+ import _URL from "@babel/runtime-corejs3/core-js/url";
4
5
  import { findDomFromVNode, createVNode as h, mount } from 'intact';
5
6
  import { loopDataWithChildrenKey } from './useTree';
6
7
  import { get, noop, isNullOrUndefined } from 'intact-shared';
@@ -10,17 +11,12 @@ export function exportTable(_x, _x2, _x3, _x4, _x5) {
10
11
 
11
12
  function _exportTable() {
12
13
  _exportTable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(getData, data, childrenKey, parentComponet, filename) {
13
- var download, collection, _getData, columns, cols, content;
14
+ var collection, _getData, columns, cols, content;
14
15
 
15
16
  return _regeneratorRuntime.wrap(function _callee$(_context) {
16
17
  while (1) {
17
18
  switch (_context.prev = _context.next) {
18
19
  case 0:
19
- _context.next = 2;
20
- return import('downloadjs');
21
-
22
- case 2:
23
- download = _context.sent.default;
24
20
  collection = [];
25
21
  _getData = getData(), columns = _getData.columns, cols = _getData.cols; // head
26
22
 
@@ -60,10 +56,10 @@ function _exportTable() {
60
56
  collection.push(rows.join(','));
61
57
  }, false);
62
58
  content = collection.join('\r\n');
63
- download("\uFEFF" + content, filename + '.csv', 'text/comma-separated-values;charset=utf-8');
59
+ download(content, filename + '.csv');
64
60
  return _context.abrupt("return", content);
65
61
 
66
- case 10:
62
+ case 7:
67
63
  case "end":
68
64
  return _context.stop();
69
65
  }
@@ -77,4 +73,33 @@ function pushTextContext(rows, dom, content) {
77
73
  var text = isNullOrUndefined(content) ? dom.textContent : content;
78
74
  text = '"' + String(_trimInstanceProperty(text).call(text)).replace(/"/g, '""') + '"';
79
75
  rows.push(text);
76
+ }
77
+
78
+ export function download(content, filename) {
79
+ if (navigator.msSaveBlob) {
80
+ // IE10+
81
+ var blob = new Blob([content], {
82
+ type: 'text/csv;charset=utf-8'
83
+ });
84
+ navigator.msSaveBlob(blob, filename);
85
+ } else {
86
+ var link = document.createElement('a');
87
+
88
+ if ('download' in link) {
89
+ var _blob = new Blob([content], {
90
+ type: 'text/csv;charset=utf-8'
91
+ });
92
+
93
+ var url = _URL.createObjectURL(_blob);
94
+
95
+ link.setAttribute('href', url);
96
+ link.setAttribute('download', filename);
97
+ link.style.display = 'none';
98
+ document.body.appendChild(link);
99
+ link.click();
100
+ document.body.removeChild(link);
101
+ } else {
102
+ window.open("data:text/csv,charset=utf-8,%EF%BB%BF" + encodeURI(content));
103
+ }
104
+ }
80
105
  }
@@ -24,6 +24,7 @@ import DraggableTable from '~/components/table/demos/draggable';
24
24
  import MergeCellDemo from '~/components/table/demos/mergeCell';
25
25
  import { AllCheckedStatus } from './useChecked';
26
26
  import PaginationDemo from '~/components/table/demos/pagination';
27
+ import { download } from './exportTable';
27
28
  describe('Table', function () {
28
29
  afterEach(function () {
29
30
  unmount();
@@ -682,7 +683,7 @@ describe('Table', function () {
682
683
  }, _callee13);
683
684
  })));
684
685
  it('export', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
685
- var _mount15, instance, element, content, content1;
686
+ var _mount15, instance, element, content, content1, csv;
686
687
 
687
688
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
688
689
  while (1) {
@@ -705,9 +706,13 @@ describe('Table', function () {
705
706
 
706
707
  case 8:
707
708
  content1 = _context14.sent;
708
- expect(content1.replace(/\r\n|\r/g, '\n')).to.matchSnapshot();
709
+ expect(content1.replace(/\r\n|\r/g, '\n')).to.matchSnapshot(); // it will be error codes if downloadjs exports below contents
710
+ // use custom download function instead
709
711
 
710
- case 10:
712
+ csv = '"镜像名称","系统大小","镜像类型","状态","操作系统","创建时间","是否支持快速开机","可用区","镜像描述","关联快照"\r\n"a12321","20GB","普通镜像","错误 详情","centos-7","2023-11-23 15:54:10","否","--","--","q"';
713
+ download(csv, 'test.csv');
714
+
715
+ case 12:
711
716
  case "end":
712
717
  return _context14.stop();
713
718
  }
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.0
2
+ * @king-design v3.1.1-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -60,4 +60,4 @@ export * from './components/tree';
60
60
  export * from './components/treeSelect';
61
61
  export * from './components/upload';
62
62
  export * from './components/wave';
63
- export declare const version = "3.1.0";
63
+ export declare const version = "3.1.1-beta.0";
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.0
2
+ * @king-design v3.1.1-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -62,5 +62,5 @@ export * from './components/tree';
62
62
  export * from './components/treeSelect';
63
63
  export * from './components/upload';
64
64
  export * from './components/wave';
65
- export var version = '3.1.0';
65
+ export var version = '3.1.1-beta.0';
66
66
  /* generate end */
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.0
2
+ * @king-design v3.1.1-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -65,6 +65,6 @@ export * from './components/treeSelect';
65
65
  export * from './components/upload';
66
66
  export * from './components/wave';
67
67
 
68
- export const version = '3.1.0';
68
+ export const version = '3.1.1-beta.0';
69
69
 
70
70
  /* generate end */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/intact",
3
- "version": "3.1.0",
3
+ "version": "3.1.1-beta.0",
4
4
  "description": "A component library written in Intact for Intact, Vue, React and Angular",
5
5
  "main": "es/index.js",
6
6
  "engines": {
@@ -36,7 +36,8 @@
36
36
  "prelease-minor": "lerna version preminor --preid beta --force-publish && npm run _publish -- --tag=beta",
37
37
  "prelease-major": "lerna version premajor --preid beta --force-publish && npm run _publish -- --tag=beta",
38
38
  "upload:resources": "gulp upload:resources",
39
- "update:deps": "lerna exec -- yarn --registry=https://registry.npmjs.org"
39
+ "update:deps": "lerna exec -- yarn --registry=https://registry.npmjs.org",
40
+ "proxychains4:deploy:doc": "proxychains4 npx gulp doc:build && npx gulp doc:upload && proxychains4 npx gulp doc:push"
40
41
  },
41
42
  "repository": {
42
43
  "type": "git",
@@ -179,7 +180,7 @@
179
180
  "dependencies": {
180
181
  "@babel/runtime-corejs3": "^7.16.0",
181
182
  "@emotion/css": "^11.5.0",
182
- "@king-design/react": "^3.1.0",
183
+ "@king-design/react": "^3.1.1-beta.0",
183
184
  "dayjs": "^1.10.7",
184
185
  "downloadjs": "^1.4.7",
185
186
  "enquire.js": "^2.1.6",