wok-ui-ext 0.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 (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +75 -0
  3. package/README.md +75 -0
  4. package/dist/alert/index.d.ts +10 -0
  5. package/dist/alert/index.js +48 -0
  6. package/dist/alert/style.css +116 -0
  7. package/dist/avatar/index.d.ts +9 -0
  8. package/dist/avatar/index.js +30 -0
  9. package/dist/avatar/style.css +32 -0
  10. package/dist/badge/index.d.ts +32 -0
  11. package/dist/badge/index.js +61 -0
  12. package/dist/badge/style.css +68 -0
  13. package/dist/breadcrumb/index.d.ts +25 -0
  14. package/dist/breadcrumb/index.js +47 -0
  15. package/dist/breadcrumb/style.css +35 -0
  16. package/dist/button/index.d.ts +34 -0
  17. package/dist/button/index.js +57 -0
  18. package/dist/button/style.css +133 -0
  19. package/dist/card/index.d.ts +25 -0
  20. package/dist/card/index.js +29 -0
  21. package/dist/card/style.css +23 -0
  22. package/dist/collapse/index.d.ts +89 -0
  23. package/dist/collapse/index.js +213 -0
  24. package/dist/collapse/style.css +76 -0
  25. package/dist/context-menu/context-menu.d.ts +113 -0
  26. package/dist/context-menu/context-menu.js +150 -0
  27. package/dist/context-menu/index.d.ts +30 -0
  28. package/dist/context-menu/index.js +42 -0
  29. package/dist/context-menu/style.css +46 -0
  30. package/dist/date-picker/calendar-panel.d.ts +44 -0
  31. package/dist/date-picker/calendar-panel.js +180 -0
  32. package/dist/date-picker/date-picker.d.ts +29 -0
  33. package/dist/date-picker/date-picker.js +81 -0
  34. package/dist/date-picker/date-utils.d.ts +63 -0
  35. package/dist/date-picker/date-utils.js +130 -0
  36. package/dist/date-picker/index.d.ts +7 -0
  37. package/dist/date-picker/index.js +5 -0
  38. package/dist/date-picker/layer.d.ts +19 -0
  39. package/dist/date-picker/layer.js +36 -0
  40. package/dist/date-picker/range-picker.d.ts +30 -0
  41. package/dist/date-picker/range-picker.js +117 -0
  42. package/dist/date-picker/style.css +161 -0
  43. package/dist/description-list/index.d.ts +37 -0
  44. package/dist/description-list/index.js +145 -0
  45. package/dist/description-list/style.css +63 -0
  46. package/dist/divider/index.d.ts +29 -0
  47. package/dist/divider/index.js +29 -0
  48. package/dist/divider/style.css +50 -0
  49. package/dist/drawer/index.d.ts +51 -0
  50. package/dist/drawer/index.js +183 -0
  51. package/dist/drawer/style.css +100 -0
  52. package/dist/dropdown/index.d.ts +38 -0
  53. package/dist/dropdown/index.js +97 -0
  54. package/dist/dropdown/style.css +39 -0
  55. package/dist/empty/index.d.ts +11 -0
  56. package/dist/empty/index.js +20 -0
  57. package/dist/empty/style.css +19 -0
  58. package/dist/floating-layer/index.d.ts +109 -0
  59. package/dist/floating-layer/index.js +337 -0
  60. package/dist/floating-layer/style.css +5 -0
  61. package/dist/form/form-item/index.d.ts +26 -0
  62. package/dist/form/form-item/index.js +21 -0
  63. package/dist/form/form-item/style.css +33 -0
  64. package/dist/form/form-modal/index.d.ts +18 -0
  65. package/dist/form/form-modal/index.js +38 -0
  66. package/dist/form/form.d.ts +21 -0
  67. package/dist/form/form.js +28 -0
  68. package/dist/form/index.d.ts +4 -0
  69. package/dist/form/index.js +4 -0
  70. package/dist/form/select/index.d.ts +48 -0
  71. package/dist/form/select/index.js +94 -0
  72. package/dist/form/select/style.css +29 -0
  73. package/dist/global.css +71 -0
  74. package/dist/i18n/de-DE.d.ts +2 -0
  75. package/dist/i18n/de-DE.js +36 -0
  76. package/dist/i18n/en-US.d.ts +2 -0
  77. package/dist/i18n/en-US.js +36 -0
  78. package/dist/i18n/es-ES.d.ts +2 -0
  79. package/dist/i18n/es-ES.js +36 -0
  80. package/dist/i18n/fr-FR.d.ts +2 -0
  81. package/dist/i18n/fr-FR.js +36 -0
  82. package/dist/i18n/index.d.ts +12 -0
  83. package/dist/i18n/index.js +39 -0
  84. package/dist/i18n/ja-JP.d.ts +2 -0
  85. package/dist/i18n/ja-JP.js +36 -0
  86. package/dist/i18n/ko-KR.d.ts +2 -0
  87. package/dist/i18n/ko-KR.js +36 -0
  88. package/dist/i18n/messages.d.ts +40 -0
  89. package/dist/i18n/messages.js +1 -0
  90. package/dist/i18n/wok-ui/de-DE.d.ts +2 -0
  91. package/dist/i18n/wok-ui/de-DE.js +20 -0
  92. package/dist/i18n/wok-ui/es-ES.d.ts +2 -0
  93. package/dist/i18n/wok-ui/es-ES.js +20 -0
  94. package/dist/i18n/wok-ui/fr-FR.d.ts +2 -0
  95. package/dist/i18n/wok-ui/fr-FR.js +20 -0
  96. package/dist/i18n/wok-ui/ja-JP.d.ts +2 -0
  97. package/dist/i18n/wok-ui/ja-JP.js +20 -0
  98. package/dist/i18n/wok-ui/ko-KR.d.ts +2 -0
  99. package/dist/i18n/wok-ui/ko-KR.js +20 -0
  100. package/dist/i18n/wok-ui/zh-TW.d.ts +2 -0
  101. package/dist/i18n/wok-ui/zh-TW.js +20 -0
  102. package/dist/i18n/zh-CN.d.ts +2 -0
  103. package/dist/i18n/zh-CN.js +36 -0
  104. package/dist/i18n/zh-TW.d.ts +2 -0
  105. package/dist/i18n/zh-TW.js +36 -0
  106. package/dist/icons.d.ts +88 -0
  107. package/dist/icons.js +176 -0
  108. package/dist/image/index.d.ts +38 -0
  109. package/dist/image/index.js +97 -0
  110. package/dist/image/style.css +72 -0
  111. package/dist/image-preview/index.d.ts +26 -0
  112. package/dist/image-preview/index.js +134 -0
  113. package/dist/image-preview/style.css +96 -0
  114. package/dist/index.d.ts +46 -0
  115. package/dist/index.js +45 -0
  116. package/dist/list/index.d.ts +32 -0
  117. package/dist/list/index.js +42 -0
  118. package/dist/list/list-item.d.ts +27 -0
  119. package/dist/list/list-item.js +51 -0
  120. package/dist/list/style.css +20 -0
  121. package/dist/loading/index.d.ts +10 -0
  122. package/dist/loading/index.js +46 -0
  123. package/dist/loading/style.css +48 -0
  124. package/dist/menu/index.d.ts +38 -0
  125. package/dist/menu/index.js +62 -0
  126. package/dist/menu/leaf-item.d.ts +12 -0
  127. package/dist/menu/leaf-item.js +41 -0
  128. package/dist/menu/style.css +117 -0
  129. package/dist/menu/sub-menu.d.ts +21 -0
  130. package/dist/menu/sub-menu.js +85 -0
  131. package/dist/menu/types.d.ts +36 -0
  132. package/dist/menu/types.js +1 -0
  133. package/dist/menu/utils.d.ts +11 -0
  134. package/dist/menu/utils.js +24 -0
  135. package/dist/modal/index.d.ts +23 -0
  136. package/dist/modal/index.js +79 -0
  137. package/dist/modal/modal.d.ts +76 -0
  138. package/dist/modal/modal.js +188 -0
  139. package/dist/modal/style.css +90 -0
  140. package/dist/pagination/index.d.ts +31 -0
  141. package/dist/pagination/index.js +215 -0
  142. package/dist/pagination/style.css +50 -0
  143. package/dist/popconfirm/api.d.ts +43 -0
  144. package/dist/popconfirm/api.js +77 -0
  145. package/dist/popconfirm/component.d.ts +47 -0
  146. package/dist/popconfirm/component.js +48 -0
  147. package/dist/popconfirm/index.d.ts +3 -0
  148. package/dist/popconfirm/index.js +3 -0
  149. package/dist/popconfirm/style.css +22 -0
  150. package/dist/popover/api.d.ts +36 -0
  151. package/dist/popover/api.js +61 -0
  152. package/dist/popover/component.d.ts +38 -0
  153. package/dist/popover/component.js +51 -0
  154. package/dist/popover/index.d.ts +3 -0
  155. package/dist/popover/index.js +3 -0
  156. package/dist/popover/style.css +102 -0
  157. package/dist/progress/index.d.ts +34 -0
  158. package/dist/progress/index.js +70 -0
  159. package/dist/progress/style.css +37 -0
  160. package/dist/quick-input/index.d.ts +2 -0
  161. package/dist/quick-input/index.js +2 -0
  162. package/dist/quick-input/number.d.ts +35 -0
  163. package/dist/quick-input/number.js +68 -0
  164. package/dist/quick-input/text.d.ts +20 -0
  165. package/dist/quick-input/text.js +61 -0
  166. package/dist/result/index.d.ts +39 -0
  167. package/dist/result/index.js +71 -0
  168. package/dist/result/style.css +41 -0
  169. package/dist/search-box/index.d.ts +26 -0
  170. package/dist/search-box/index.js +60 -0
  171. package/dist/search-box/style.css +22 -0
  172. package/dist/segmented/index.d.ts +42 -0
  173. package/dist/segmented/index.js +61 -0
  174. package/dist/segmented/style.css +28 -0
  175. package/dist/skeleton/index.d.ts +22 -0
  176. package/dist/skeleton/index.js +68 -0
  177. package/dist/skeleton/style.css +31 -0
  178. package/dist/steps/index.d.ts +46 -0
  179. package/dist/steps/index.js +95 -0
  180. package/dist/steps/style.css +181 -0
  181. package/dist/switch/index.d.ts +32 -0
  182. package/dist/switch/index.js +74 -0
  183. package/dist/switch/style.css +52 -0
  184. package/dist/table/body.d.ts +21 -0
  185. package/dist/table/body.js +35 -0
  186. package/dist/table/column.d.ts +78 -0
  187. package/dist/table/column.js +113 -0
  188. package/dist/table/header.d.ts +13 -0
  189. package/dist/table/header.js +15 -0
  190. package/dist/table/index.d.ts +41 -0
  191. package/dist/table/index.js +84 -0
  192. package/dist/table/row.d.ts +25 -0
  193. package/dist/table/row.js +74 -0
  194. package/dist/table/style.css +98 -0
  195. package/dist/tabs/index.d.ts +49 -0
  196. package/dist/tabs/index.js +76 -0
  197. package/dist/tabs/style.css +41 -0
  198. package/dist/tag/index.d.ts +53 -0
  199. package/dist/tag/index.js +100 -0
  200. package/dist/tag/style.css +134 -0
  201. package/dist/text/index.d.ts +104 -0
  202. package/dist/text/index.js +143 -0
  203. package/dist/text/style.css +113 -0
  204. package/dist/theme/index.d.ts +14 -0
  205. package/dist/theme/index.js +94 -0
  206. package/dist/theme/themes.d.ts +3 -0
  207. package/dist/theme/themes.js +323 -0
  208. package/dist/theme/types.d.ts +58 -0
  209. package/dist/theme/types.js +1 -0
  210. package/dist/timeline/index.d.ts +28 -0
  211. package/dist/timeline/index.js +35 -0
  212. package/dist/timeline/style.css +53 -0
  213. package/dist/toast/index.d.ts +53 -0
  214. package/dist/toast/index.js +131 -0
  215. package/dist/toast/style.css +76 -0
  216. package/dist/tooltip/api.d.ts +44 -0
  217. package/dist/tooltip/api.js +103 -0
  218. package/dist/tooltip/component.d.ts +28 -0
  219. package/dist/tooltip/component.js +35 -0
  220. package/dist/tooltip/index.d.ts +3 -0
  221. package/dist/tooltip/index.js +3 -0
  222. package/dist/tooltip/style.css +46 -0
  223. package/dist/tree/dragging-img.d.ts +13 -0
  224. package/dist/tree/dragging-img.js +23 -0
  225. package/dist/tree/index.d.ts +180 -0
  226. package/dist/tree/index.js +385 -0
  227. package/dist/tree/node-info.d.ts +63 -0
  228. package/dist/tree/node-info.js +128 -0
  229. package/dist/tree/node.d.ts +132 -0
  230. package/dist/tree/node.js +264 -0
  231. package/dist/tree/style.css +99 -0
  232. package/dist/upload/index.d.ts +48 -0
  233. package/dist/upload/index.js +141 -0
  234. package/dist/upload/style.css +41 -0
  235. package/package.json +51 -0
@@ -0,0 +1,78 @@
1
+ import { SubModulesOpt } from 'wok-ui';
2
+ /**
3
+ * 列设定.
4
+ */
5
+ export interface TableColumnSetting<T> {
6
+ /**
7
+ * 列名称.特殊需要传入模块来处理,比如文字需要变色等.
8
+ */
9
+ name: string | (() => SubModulesOpt);
10
+ /**
11
+ * 将列固定
12
+ */
13
+ fixed?: boolean;
14
+ /**
15
+ * 列宽度,默认 80
16
+ */
17
+ width?: number;
18
+ /**
19
+ * 内容生成.
20
+ */
21
+ content: (data: T, rowIdx: number) => SubModulesOpt;
22
+ }
23
+ /**
24
+ * 列.
25
+ */
26
+ export declare class TableColumn<T> {
27
+ readonly setting: TableColumnSetting<T>;
28
+ constructor(setting: TableColumnSetting<T>);
29
+ }
30
+ /**
31
+ * 勾选框列.
32
+ */
33
+ export declare class TableCheckboxColumn<T> extends TableColumn<T> {
34
+ private opts;
35
+ private checkAllBox?;
36
+ private boxes;
37
+ constructor(opts: {
38
+ /**
39
+ * 将列固定
40
+ */
41
+ fixed?: boolean;
42
+ /**
43
+ * 勾选框绑定的值.
44
+ */
45
+ value: (data: T, rowIdx: number) => string;
46
+ /**
47
+ * 初始状态,可选.
48
+ */
49
+ checked?: (data: T, rowIdx: number) => boolean;
50
+ /**
51
+ * 列名称,可选,如果有值,则不会在头部显示全选的勾选框.
52
+ */
53
+ name?: string;
54
+ /**
55
+ * 是否禁用函数, 适用于一些无权限或不支持批量操作的场景
56
+ * @param data
57
+ * @returns
58
+ */
59
+ disabled?: (data: T) => boolean;
60
+ /**
61
+ * 更改事件.
62
+ */
63
+ onChange?: (checkedVals: string[]) => void;
64
+ });
65
+ /**
66
+ * 更新全选勾选框.
67
+ */
68
+ private updateCheckAllBox;
69
+ getCheckedValues(): string[];
70
+ checkAll(): void;
71
+ uncheckAll(): void;
72
+ }
73
+ /**
74
+ * 序号列.
75
+ */
76
+ export declare class TableIndexColumn<T> extends TableColumn<T> {
77
+ constructor();
78
+ }
@@ -0,0 +1,113 @@
1
+ import { Checkbox, rem } from 'wok-ui';
2
+ /**
3
+ * 列.
4
+ */
5
+ export class TableColumn {
6
+ constructor(setting) {
7
+ this.setting = setting;
8
+ }
9
+ }
10
+ /**
11
+ * 勾选框列.
12
+ */
13
+ export class TableCheckboxColumn extends TableColumn {
14
+ constructor(opts) {
15
+ let name = '';
16
+ if (opts.name) {
17
+ name = opts.name;
18
+ }
19
+ else {
20
+ name = () => {
21
+ const checkbox = new Checkbox({
22
+ status: 'unchecked',
23
+ onChange: status => {
24
+ if (checkbox.isChecked()) {
25
+ // 全选
26
+ this.boxes.forEach(b => b.setStatus('checked'));
27
+ }
28
+ else {
29
+ // 全不选
30
+ this.boxes.forEach(b => b.setStatus('unchecked'));
31
+ }
32
+ if (opts.onChange) {
33
+ opts.onChange(this.getCheckedValues());
34
+ }
35
+ },
36
+ value: ''
37
+ });
38
+ this.checkAllBox = checkbox;
39
+ return checkbox;
40
+ };
41
+ }
42
+ super({
43
+ name,
44
+ fixed: opts.fixed,
45
+ content: (data, idx) => {
46
+ const disabled = opts.disabled ? opts.disabled(data) : false;
47
+ const value = opts.value(data, idx);
48
+ const checked = opts.checked ? opts.checked(data, idx) : false;
49
+ const box = new Checkbox({
50
+ status: checked ? 'checked' : 'unchecked',
51
+ value,
52
+ disabled,
53
+ onChange: () => {
54
+ const checkedValues = this.getCheckedValues();
55
+ if (opts.onChange) {
56
+ opts.onChange(checkedValues);
57
+ }
58
+ this.updateCheckAllBox();
59
+ }
60
+ });
61
+ if (!disabled) {
62
+ this.boxes.push(box);
63
+ }
64
+ this.updateCheckAllBox();
65
+ return box;
66
+ },
67
+ width: rem(2)
68
+ });
69
+ this.opts = opts;
70
+ this.boxes = [];
71
+ }
72
+ /**
73
+ * 更新全选勾选框.
74
+ */
75
+ updateCheckAllBox() {
76
+ if (!this.checkAllBox) {
77
+ return;
78
+ }
79
+ const checkedValues = this.getCheckedValues();
80
+ if (this.boxes.length > 0 && checkedValues.length === this.boxes.length) {
81
+ this.checkAllBox.setStatus('checked');
82
+ }
83
+ else if (checkedValues.length === 0) {
84
+ this.checkAllBox.setStatus('unchecked');
85
+ }
86
+ else {
87
+ this.checkAllBox.setStatus('indeterminate');
88
+ }
89
+ }
90
+ getCheckedValues() {
91
+ return this.boxes.filter(b => b.isChecked()).map(b => b.value);
92
+ }
93
+ checkAll() {
94
+ if (this.checkAllBox) {
95
+ this.checkAllBox.setStatus('checked');
96
+ }
97
+ this.boxes.forEach(b => b.setStatus('checked'));
98
+ }
99
+ uncheckAll() {
100
+ if (this.checkAllBox) {
101
+ this.checkAllBox.setStatus('unchecked');
102
+ }
103
+ this.boxes.forEach(b => b.setStatus('unchecked'));
104
+ }
105
+ }
106
+ /**
107
+ * 序号列.
108
+ */
109
+ export class TableIndexColumn extends TableColumn {
110
+ constructor() {
111
+ super({ name: '#', content: (data, idx) => `${idx + 1}`, width: rem(3) });
112
+ }
113
+ }
@@ -0,0 +1,13 @@
1
+ import { Module } from 'wok-ui';
2
+ import { TableColumn } from './column';
3
+ /**
4
+ * 头部
5
+ */
6
+ export declare class Header<T> extends Module {
7
+ constructor(opts: {
8
+ /**
9
+ * 列设置.
10
+ */
11
+ cols: TableColumn<T>[];
12
+ });
13
+ }
@@ -0,0 +1,15 @@
1
+ import { Module } from 'wok-ui';
2
+ import { Row } from './row';
3
+ /**
4
+ * 头部
5
+ */
6
+ export class Header extends Module {
7
+ constructor(opts) {
8
+ super(document.createElement('thead'));
9
+ this.el.classList.add('wok-ui-ext-table-header');
10
+ this.addChild(new Row({
11
+ cols: opts.cols,
12
+ isHeader: true
13
+ }));
14
+ }
15
+ }
@@ -0,0 +1,41 @@
1
+ import { FullRenderingModule } from 'wok-ui';
2
+ import { TableColumn } from './column';
3
+ import './style.less';
4
+ /**
5
+ * 表格
6
+ */
7
+ export declare class Table<T> extends FullRenderingModule {
8
+ private opts;
9
+ /**
10
+ * 展开后的列数组
11
+ */
12
+ private cols;
13
+ constructor(opts: {
14
+ /**
15
+ * 数据列表.
16
+ */
17
+ list: T[];
18
+ /**
19
+ * 列设置,支持数组或动态构建函数。
20
+ */
21
+ cols: TableColumn<T>[] | ((add: (col: TableColumn<T>) => void) => void);
22
+ /**
23
+ * 固定头部,开启后表头在滚动时保持固定,需配合 height 使用(未指定时默认 300px)
24
+ */
25
+ fixedHeader?: boolean;
26
+ /**
27
+ * 表格高度,超出后容器内部滚动
28
+ */
29
+ height?: number | string;
30
+ /**
31
+ * 表格的标题
32
+ */
33
+ caption?: string;
34
+ /**
35
+ * 空状态的描述
36
+ */
37
+ emptyDesc?: string;
38
+ });
39
+ protected buildContent(): void;
40
+ }
41
+ export * from './column';
@@ -0,0 +1,84 @@
1
+ import { FullRenderingModule } from 'wok-ui';
2
+ import { Body } from './body';
3
+ import { Header } from './header';
4
+ import './style.css';
5
+ /**
6
+ * 表格
7
+ */
8
+ export class Table extends FullRenderingModule {
9
+ constructor(opts) {
10
+ // 外层为滚动容器,内部是原生 table 布局
11
+ super(document.createElement('div'));
12
+ this.opts = opts;
13
+ this.el.classList.add('wok-ui-ext-table');
14
+ // 高度控制
15
+ const { height } = opts;
16
+ if (typeof height === 'number') {
17
+ this.el.style.height = `${height}px`;
18
+ }
19
+ else if (typeof height === 'string') {
20
+ this.el.style.height = height;
21
+ }
22
+ else if (opts?.fixedHeader) {
23
+ this.el.style.height = '300px';
24
+ }
25
+ if (opts?.fixedHeader) {
26
+ this.el.classList.add('wok-ui-ext-fixed-header');
27
+ }
28
+ // 展开列
29
+ if (typeof opts.cols === 'function') {
30
+ const cols = [];
31
+ opts.cols(col => cols.push(col));
32
+ this.cols = cols;
33
+ }
34
+ else {
35
+ this.cols = opts.cols;
36
+ }
37
+ // 校验
38
+ if (!this.cols.length) {
39
+ throw new Error('必须设置列');
40
+ }
41
+ // 检查列名称是否有重复
42
+ const colNames = [];
43
+ let fixedColCount = 0;
44
+ for (const col of this.cols) {
45
+ if (fixedColCount > 4) {
46
+ throw new Error('被固定的列不能超过4个');
47
+ }
48
+ if (col.setting.fixed) {
49
+ fixedColCount++;
50
+ }
51
+ const { name } = col.setting;
52
+ if (typeof name !== 'string') {
53
+ continue;
54
+ }
55
+ if (colNames.includes(name)) {
56
+ throw new Error(`列名称“${name}”重复`);
57
+ }
58
+ colNames.push(name);
59
+ }
60
+ // 立即渲染, render() 无参是异步的,当表格内容过长时,会丢失滚动位置
61
+ this.render();
62
+ }
63
+ buildContent() {
64
+ this.addChild({
65
+ tag: 'table',
66
+ classNames: 'wok-ui-ext-table-inner',
67
+ children: add => {
68
+ if (this.opts.caption) {
69
+ add({
70
+ tag: 'caption',
71
+ innerText: this.opts.caption
72
+ });
73
+ }
74
+ add(new Header({ cols: this.cols }));
75
+ add(new Body({
76
+ emptyDesc: this.opts.emptyDesc,
77
+ list: this.opts.list,
78
+ cols: this.cols
79
+ }));
80
+ }
81
+ });
82
+ }
83
+ }
84
+ export * from './column';
@@ -0,0 +1,25 @@
1
+ import { Module } from 'wok-ui';
2
+ import { TableColumn } from './column';
3
+ /**
4
+ * 行
5
+ */
6
+ export declare class Row<T> extends Module {
7
+ constructor(opts: {
8
+ /**
9
+ * 列设置.
10
+ */
11
+ cols: TableColumn<T>[];
12
+ /**
13
+ * 数据,如果没有数据就表示是头部
14
+ */
15
+ data?: T;
16
+ /**
17
+ * 行索引,如果没有则表示是头部
18
+ */
19
+ rowIdx?: number;
20
+ /**
21
+ * 是否为表头行
22
+ */
23
+ isHeader?: boolean;
24
+ });
25
+ }
@@ -0,0 +1,74 @@
1
+ import { Module } from 'wok-ui';
2
+ /**
3
+ * 行
4
+ */
5
+ export class Row extends Module {
6
+ constructor(opts) {
7
+ super(document.createElement('tr'));
8
+ this.el.classList.add('wok-ui-ext-table-row');
9
+ // 计算左右连续固定列的数量
10
+ let leftFixedCount = 0;
11
+ for (const col of opts.cols) {
12
+ if (col.setting.fixed) {
13
+ leftFixedCount++;
14
+ }
15
+ else {
16
+ break;
17
+ }
18
+ }
19
+ let rightFixedCount = 0;
20
+ for (let i = opts.cols.length - 1; i >= 0; i--) {
21
+ if (opts.cols[i].setting.fixed) {
22
+ rightFixedCount++;
23
+ }
24
+ else {
25
+ break;
26
+ }
27
+ }
28
+ for (let idx = 0; idx < opts.cols.length; idx++) {
29
+ const col = opts.cols[idx];
30
+ const { name } = col.setting;
31
+ this.addChild({
32
+ tag: opts.isHeader ? 'th' : 'td',
33
+ classNames: 'table-cell',
34
+ preHandle: el => {
35
+ // 宽度
36
+ const width = col.setting.width && col.setting.width > 0 ? col.setting.width : 80;
37
+ el.style.width = `${width}px`;
38
+ // 列固定处理
39
+ if (col.setting.fixed) {
40
+ const isLeft = idx < leftFixedCount;
41
+ const isRight = idx >= opts.cols.length - rightFixedCount;
42
+ if (isLeft) {
43
+ el.classList.add('wok-ui-ext-fixed-left');
44
+ let left = 0;
45
+ for (let i = 0; i < idx; i++) {
46
+ if (opts.cols[i].setting.fixed) {
47
+ left += opts.cols[i].setting.width || 80;
48
+ }
49
+ }
50
+ if (left > 0) {
51
+ el.style.left = `${left}px`;
52
+ }
53
+ }
54
+ else if (isRight) {
55
+ el.classList.add('wok-ui-ext-fixed-right');
56
+ let right = 0;
57
+ for (let i = idx + 1; i < opts.cols.length; i++) {
58
+ if (opts.cols[i].setting.fixed) {
59
+ right += opts.cols[i].setting.width || 80;
60
+ }
61
+ }
62
+ if (right > 0) {
63
+ el.style.right = `${right}px`;
64
+ }
65
+ }
66
+ }
67
+ },
68
+ children: opts.data && typeof opts.rowIdx === 'number'
69
+ ? col.setting.content(opts.data, opts.rowIdx)
70
+ : name
71
+ });
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,98 @@
1
+ .wok-ui-ext-table {
2
+ overflow: auto;
3
+ font-size: 15px;
4
+ box-sizing: border-box;
5
+ width: 100%;
6
+ scrollbar-width: thin;
7
+ scrollbar-color: var(--border-medium) var(--bg-hover);
8
+ }
9
+ .wok-ui-ext-table::-webkit-scrollbar {
10
+ width: 5px;
11
+ height: 5px;
12
+ }
13
+ .wok-ui-ext-table::-webkit-scrollbar-track {
14
+ background: var(--bg-hover);
15
+ }
16
+ .wok-ui-ext-table::-webkit-scrollbar-thumb {
17
+ background: var(--border-medium);
18
+ border-radius: var(--radius-full);
19
+ }
20
+ .wok-ui-ext-table .wok-ui-ext-table-inner {
21
+ width: 100%;
22
+ border-collapse: separate;
23
+ border-spacing: 0;
24
+ table-layout: fixed;
25
+ }
26
+ .wok-ui-ext-table caption {
27
+ padding: 12px 8px;
28
+ font-weight: 600;
29
+ text-align: left;
30
+ caption-side: top;
31
+ }
32
+ .wok-ui-ext-table thead {
33
+ font-weight: 600;
34
+ color: var(--text-tertiary);
35
+ }
36
+ .wok-ui-ext-table thead th {
37
+ background-color: var(--bg-card);
38
+ border-bottom: 2px solid var(--border-medium);
39
+ text-align: left;
40
+ padding: 16px 8px;
41
+ font-weight: 600;
42
+ }
43
+ .wok-ui-ext-table tbody {
44
+ color: var(--text-secondary);
45
+ }
46
+ .wok-ui-ext-table tbody tr {
47
+ background-color: var(--bg-card);
48
+ }
49
+ .wok-ui-ext-table tbody tr:last-child td {
50
+ border-bottom: none;
51
+ }
52
+ .wok-ui-ext-table tbody tr:hover td {
53
+ background-color: var(--bg-hover);
54
+ }
55
+ .wok-ui-ext-table tbody tr:hover td.wok-ui-ext-fixed-left,
56
+ .wok-ui-ext-table tbody tr:hover td.wok-ui-ext-fixed-right {
57
+ background-color: var(--bg-hover);
58
+ }
59
+ .wok-ui-ext-table tbody td {
60
+ padding: 16px 8px;
61
+ text-align: left;
62
+ background-color: var(--bg-card);
63
+ vertical-align: middle;
64
+ border-bottom: 1px solid var(--border-light);
65
+ }
66
+ .wok-ui-ext-table tbody td.wok-ui-ext-fixed-left {
67
+ border-right: 1px solid var(--border-light);
68
+ box-shadow: 4px 0 8px -4px rgba(0, 20, 40, 0.12);
69
+ }
70
+ .wok-ui-ext-table tbody td.wok-ui-ext-fixed-right {
71
+ border-left: 1px solid var(--border-light);
72
+ box-shadow: -4px 0 8px -4px rgba(0, 20, 40, 0.12);
73
+ }
74
+ .wok-ui-ext-table .wok-ui-ext-fixed-left,
75
+ .wok-ui-ext-table .wok-ui-ext-fixed-right {
76
+ position: sticky;
77
+ background-color: var(--bg-card);
78
+ }
79
+ .wok-ui-ext-table .wok-ui-ext-fixed-left {
80
+ left: 0;
81
+ }
82
+ .wok-ui-ext-table .wok-ui-ext-fixed-right {
83
+ right: 0;
84
+ }
85
+ .wok-ui-ext-table .empty-state {
86
+ padding: 70px 20px;
87
+ background-color: var(--bg-body);
88
+ border-radius: 0;
89
+ }
90
+ .wok-ui-ext-table.wok-ui-ext-fixed-header thead th {
91
+ position: sticky;
92
+ top: 0;
93
+ z-index: 2;
94
+ }
95
+ .wok-ui-ext-table.wok-ui-ext-fixed-header thead th.wok-ui-ext-fixed-left,
96
+ .wok-ui-ext-table.wok-ui-ext-fixed-header thead th.wok-ui-ext-fixed-right {
97
+ z-index: 3;
98
+ }
@@ -0,0 +1,49 @@
1
+ import './style.less';
2
+ import { ConvertibleModule, FullRenderingModule, SubModulesOpt } from 'wok-ui';
3
+ /**
4
+ * 标签页项
5
+ */
6
+ export interface TabsItem {
7
+ /**
8
+ * 唯一标识
9
+ */
10
+ key: string;
11
+ /**
12
+ * 标签页标题
13
+ */
14
+ label: SubModulesOpt;
15
+ /**
16
+ * 标签页内容
17
+ */
18
+ content: ConvertibleModule | (() => ConvertibleModule);
19
+ /**
20
+ * 是否禁用
21
+ */
22
+ disabled?: boolean;
23
+ }
24
+ /**
25
+ * 标签页组件
26
+ */
27
+ export declare class Tabs extends FullRenderingModule {
28
+ private readonly opts;
29
+ private activeKey;
30
+ constructor(opts: {
31
+ /**
32
+ * 标签页项
33
+ */
34
+ items: TabsItem[];
35
+ /**
36
+ * 当前激活的标签页 key
37
+ */
38
+ activeKey?: string;
39
+ /**
40
+ * 标签切换回调
41
+ */
42
+ onChange?: (key: string) => void;
43
+ });
44
+ protected buildContent(): void;
45
+ /**
46
+ * 设置当前激活的标签页
47
+ */
48
+ setActiveKey(key: string): void;
49
+ }
@@ -0,0 +1,76 @@
1
+ import './style.css';
2
+ import { convertToModule, FullRenderingModule } from 'wok-ui';
3
+ /**
4
+ * 标签页组件
5
+ */
6
+ export class Tabs extends FullRenderingModule {
7
+ constructor(opts) {
8
+ const firstEnabled = opts.items.find(item => !item.disabled);
9
+ const activeKey = opts.activeKey ?? firstEnabled?.key ?? opts.items[0]?.key ?? '';
10
+ super('wok-ui-ext-tabs');
11
+ this.opts = opts;
12
+ this.activeKey = activeKey;
13
+ this.render();
14
+ }
15
+ buildContent() {
16
+ // 标签导航
17
+ this.addChild({
18
+ classNames: 'wok-ui-ext-tabs-nav',
19
+ attrs: { role: 'tablist' },
20
+ children: add => {
21
+ for (const item of this.opts.items) {
22
+ const active = item.key === this.activeKey;
23
+ add({
24
+ tag: 'button',
25
+ classNames: ['wok-ui-ext-tabs-tab', active ? 'active' : '', item.disabled ? 'disabled' : ''],
26
+ attrs: {
27
+ role: 'tab',
28
+ 'aria-selected': String(active),
29
+ tabindex: active ? '0' : '-1',
30
+ disabled: item.disabled ? 'true' : undefined
31
+ },
32
+ children: item.label,
33
+ onClick: () => {
34
+ if (item.disabled || item.key === this.activeKey) {
35
+ return;
36
+ }
37
+ this.setActiveKey(item.key);
38
+ if (this.opts.onChange) {
39
+ this.opts.onChange(item.key);
40
+ }
41
+ }
42
+ });
43
+ }
44
+ }
45
+ });
46
+ // 标签内容
47
+ const activeItem = this.opts.items.find(item => item.key === this.activeKey);
48
+ if (activeItem) {
49
+ this.addChild({
50
+ classNames: 'wok-ui-ext-tabs-content',
51
+ attrs: { role: 'tabpanel' },
52
+ children: this.cacheModule({
53
+ key: `tabs-content-${activeItem.key}`,
54
+ module: () => {
55
+ const content = activeItem.content;
56
+ return convertToModule(typeof content === 'function' ? content() : content);
57
+ }
58
+ })
59
+ });
60
+ }
61
+ }
62
+ /**
63
+ * 设置当前激活的标签页
64
+ */
65
+ setActiveKey(key) {
66
+ if (this.activeKey === key) {
67
+ return;
68
+ }
69
+ const target = this.opts.items.find(item => item.key === key);
70
+ if (!target || target.disabled) {
71
+ return;
72
+ }
73
+ this.activeKey = key;
74
+ this.render();
75
+ }
76
+ }