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,70 @@
1
+ import { DivModule } from 'wok-ui';
2
+ import './style.css';
3
+ /**
4
+ * 格式化进度值,保留最多两位小数
5
+ */
6
+ function formatProgress(progress) {
7
+ const fixed = progress.toFixed(2);
8
+ // 去掉多余的末尾 0,如 "75.00" 显示为 "75"
9
+ return fixed.replace(/\.?0+$/, '');
10
+ }
11
+ /**
12
+ * 进度条组件
13
+ *
14
+ <div class="progress-item">
15
+ <div class="progress-label"><span>任务进度</span> <span>75%</span></div>
16
+ <div class="progress-bar-bg">
17
+ <div class="progress-bar-fill" style="width:75%"></div>
18
+ </div>
19
+ </div>
20
+ */
21
+ export class Progress extends DivModule {
22
+ /**
23
+ * 进度条组件
24
+ * @param opts.label 进度条标签,支持字符串或子模块
25
+ * @param opts.progress 进度条进度,0-100
26
+ * @param opts.showProgress 是否显示进度数字
27
+ * @param opts.color 进度条颜色,默认 primary
28
+ * @param opts.text 自定义进度文本,如 "85/100分",设置后将替代百分比显示
29
+ */
30
+ constructor(opts) {
31
+ super('wok-ui-ext-progress-item');
32
+ if (opts.color && opts.color !== 'primary') {
33
+ this.el.classList.add(`wok-ui-ext-progress-${opts.color}`);
34
+ }
35
+ if (opts.label || opts.showProgress || opts.text) {
36
+ this.addChild({
37
+ classNames: 'wok-ui-ext-progress-label',
38
+ children: [
39
+ {
40
+ tag: 'span',
41
+ children: opts.label || ''
42
+ },
43
+ {
44
+ tag: 'span',
45
+ classNames: 'wok-ui-ext-progress-percent',
46
+ innerText: opts.text ?? (opts.showProgress ? `${formatProgress(opts.progress)}%` : '')
47
+ }
48
+ ]
49
+ });
50
+ }
51
+ this.addChild({
52
+ classNames: 'wok-ui-ext-progress-bar-bg',
53
+ children: [
54
+ {
55
+ classNames: 'wok-ui-ext-progress-bar-fill',
56
+ style: {
57
+ width: `${formatProgress(opts.progress)}%`
58
+ }
59
+ }
60
+ ]
61
+ });
62
+ }
63
+ setProgress(progress, text) {
64
+ this.el.querySelector('.wok-ui-ext-progress-bar-fill')?.setAttribute('style', `width: ${formatProgress(progress)}%`);
65
+ const percent = this.el.querySelector('.wok-ui-ext-progress-percent');
66
+ if (percent) {
67
+ percent.textContent = text ?? `${formatProgress(progress)}%`;
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,37 @@
1
+ .wok-ui-ext-progress-item {
2
+ margin: 16px 0;
3
+ --progress-fill: linear-gradient(90deg, var(--color-primary), var(--color-primary-dark));
4
+ --progress-bg: var(--color-primary-soft);
5
+ }
6
+ .wok-ui-ext-progress-item.wok-ui-ext-progress-success {
7
+ --progress-fill: var(--color-success);
8
+ --progress-bg: var(--color-success-light);
9
+ }
10
+ .wok-ui-ext-progress-item.wok-ui-ext-progress-warning {
11
+ --progress-fill: var(--color-warning);
12
+ --progress-bg: var(--color-warning-light);
13
+ }
14
+ .wok-ui-ext-progress-item.wok-ui-ext-progress-danger {
15
+ --progress-fill: var(--color-danger);
16
+ --progress-bg: var(--color-danger-light);
17
+ }
18
+ .wok-ui-ext-progress-item .wok-ui-ext-progress-label {
19
+ display: flex;
20
+ justify-content: space-between;
21
+ font-size: 14px;
22
+ color: var(--text-secondary);
23
+ margin-bottom: 4px;
24
+ }
25
+ .wok-ui-ext-progress-item .wok-ui-ext-progress-bar-bg {
26
+ background: var(--progress-bg);
27
+ border-radius: var(--radius-full);
28
+ height: 12px;
29
+ overflow: hidden;
30
+ }
31
+ .wok-ui-ext-progress-item .wok-ui-ext-progress-bar-bg .wok-ui-ext-progress-bar-fill {
32
+ background: var(--progress-fill);
33
+ height: 100%;
34
+ width: 0%;
35
+ border-radius: var(--radius-full);
36
+ transition: width 0.2s;
37
+ }
@@ -0,0 +1,2 @@
1
+ export * from './text';
2
+ export * from './number';
@@ -0,0 +1,2 @@
1
+ export * from './text';
2
+ export * from './number';
@@ -0,0 +1,35 @@
1
+ export interface QuickInputNumberOpts {
2
+ /**
3
+ * 弹窗标题
4
+ */
5
+ title: string;
6
+ /**
7
+ * 输入框标题,不填就不显示
8
+ */
9
+ inputLabel?: string;
10
+ /**
11
+ * 输入框占位符,不填就不显示
12
+ */
13
+ placeholder?: string;
14
+ /**
15
+ * 是否必填,默认false
16
+ */
17
+ required?: boolean;
18
+ /**
19
+ * 最大长度,不填就不限制
20
+ */
21
+ max?: number;
22
+ /**
23
+ * 最小长度,不填就不限制
24
+ */
25
+ min?: number;
26
+ /**
27
+ * 初始值
28
+ */
29
+ value?: number;
30
+ }
31
+ export declare function quickInputNumber(opts: QuickInputNumberOpts): Promise<number | undefined>;
32
+ export declare function quickInputNumber(opts: QuickInputNumberOpts & {
33
+ onSuccess: (value: number) => void;
34
+ onCancel?: () => void;
35
+ }): void;
@@ -0,0 +1,68 @@
1
+ import { NumberInput } from 'wok-ui';
2
+ import { Form, FormItem } from '../form';
3
+ import { showModal } from '../modal';
4
+ /**
5
+ * 快速输入,返回用户输入的值
6
+ *
7
+ * @param opts
8
+ * @returns
9
+ */
10
+ export function quickInputNumber(opts) {
11
+ function doInput(onSuccess, onCancel) {
12
+ let value = opts.value;
13
+ let form;
14
+ let input;
15
+ input = new NumberInput({
16
+ placeholder: opts.placeholder,
17
+ min: opts.min,
18
+ max: opts.max,
19
+ required: opts.required,
20
+ value,
21
+ onChange: val => {
22
+ value = val;
23
+ }
24
+ });
25
+ const modal = showModal({
26
+ title: opts.title,
27
+ width: 500,
28
+ body: (form = new Form({
29
+ labelPosition: 'top',
30
+ children: opts.inputLabel
31
+ ? new FormItem({
32
+ label: opts.inputLabel,
33
+ required: opts.required,
34
+ input
35
+ })
36
+ : input,
37
+ onSubmit: () => {
38
+ onSuccess(value);
39
+ modal.close();
40
+ }
41
+ })),
42
+ buttons: {
43
+ confirm: true,
44
+ cancel: true
45
+ },
46
+ onShown: () => {
47
+ input.focus();
48
+ },
49
+ onConfirm: () => form.submit(),
50
+ onClose: () => {
51
+ modal.close();
52
+ onCancel();
53
+ }
54
+ });
55
+ }
56
+ if (opts.onSuccess) {
57
+ const { onSuccess, onCancel } = opts;
58
+ doInput(val => {
59
+ if (typeof val === 'number') {
60
+ onSuccess(val);
61
+ }
62
+ }, onCancel ?? (() => { }));
63
+ return;
64
+ }
65
+ return new Promise(resolve => {
66
+ doInput(resolve, () => resolve(undefined));
67
+ });
68
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 快速输入,返回用户输入的值,取消时返回 undefined
3
+ *
4
+ * @param opts
5
+ * @param opts.title 弹窗标题
6
+ * @param opts.inputLabel 输入框标题,不填就不显示
7
+ * @param opts.placeholder 输入框占位符,不填就不显示
8
+ * @param opts.required 是否必填,默认false
9
+ * @param opts.maxLength 最大长度,不填就不限制
10
+ * @param opts.value 初始值
11
+ * @returns 输入的值,取消时返回 undefined
12
+ */
13
+ export declare function quickInput(opts: {
14
+ title: string;
15
+ inputLabel?: string;
16
+ placeholder?: string;
17
+ required?: boolean;
18
+ maxLength?: number;
19
+ value?: string;
20
+ }): Promise<string | undefined>;
@@ -0,0 +1,61 @@
1
+ import { TextInput } from 'wok-ui';
2
+ import { Form, FormItem } from '../form';
3
+ import { showModal } from '../modal';
4
+ /**
5
+ * 快速输入,返回用户输入的值,取消时返回 undefined
6
+ *
7
+ * @param opts
8
+ * @param opts.title 弹窗标题
9
+ * @param opts.inputLabel 输入框标题,不填就不显示
10
+ * @param opts.placeholder 输入框占位符,不填就不显示
11
+ * @param opts.required 是否必填,默认false
12
+ * @param opts.maxLength 最大长度,不填就不限制
13
+ * @param opts.value 初始值
14
+ * @returns 输入的值,取消时返回 undefined
15
+ */
16
+ export function quickInput(opts) {
17
+ let value = opts.value || '';
18
+ let form;
19
+ let input;
20
+ return new Promise(resolve => {
21
+ input = new TextInput({
22
+ placeholder: opts.placeholder,
23
+ maxLength: opts.maxLength,
24
+ required: opts.required,
25
+ value,
26
+ onChange: val => {
27
+ value = val;
28
+ }
29
+ });
30
+ const modal = showModal({
31
+ title: opts.title,
32
+ width: 500,
33
+ body: (form = new Form({
34
+ labelPosition: 'top',
35
+ children: opts.inputLabel
36
+ ? new FormItem({
37
+ label: opts.inputLabel,
38
+ required: opts.required,
39
+ input
40
+ })
41
+ : input,
42
+ onSubmit: () => {
43
+ resolve(value);
44
+ modal.close();
45
+ }
46
+ })),
47
+ buttons: {
48
+ confirm: true,
49
+ cancel: true
50
+ },
51
+ onShown: () => {
52
+ input.focus();
53
+ },
54
+ onConfirm: () => form.submit(),
55
+ onClose: () => {
56
+ modal.close();
57
+ resolve(undefined);
58
+ }
59
+ });
60
+ });
61
+ }
@@ -0,0 +1,39 @@
1
+ import { DivModule, SubModulesOpt } from 'wok-ui';
2
+ import './style.less';
3
+ export interface ResultOptions {
4
+ /** 结果状态 */
5
+ status: 'success' | 'error' | 'info' | 'warning';
6
+ /** 主标题 */
7
+ title: string;
8
+ /** 副标题(可选) */
9
+ subTitle?: string;
10
+ /** 操作区(通常放按钮) */
11
+ extra?: SubModulesOpt;
12
+ }
13
+ /**
14
+ * 结果页组件
15
+ *
16
+ * 用于操作反馈的结果展示,支持成功/失败/信息/警告四种状态。
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // 成功结果
21
+ * new Result({
22
+ * status: 'success',
23
+ * title: '操作成功',
24
+ * subTitle: '数据已保存',
25
+ * extra: new Button({ text: '返回列表', onClick: () => router.back() })
26
+ * })
27
+ *
28
+ * // 错误结果
29
+ * new Result({
30
+ * status: 'error',
31
+ * title: '提交失败',
32
+ * subTitle: '请检查网络后重试'
33
+ * })
34
+ * ```
35
+ */
36
+ export declare class Result extends DivModule {
37
+ private opts;
38
+ constructor(opts: ResultOptions);
39
+ }
@@ -0,0 +1,71 @@
1
+ import { DivModule } from 'wok-ui';
2
+ import './style.css';
3
+ import { IconCheckCircle, IconTimesCircle, IconInfoCircle } from '../icons';
4
+ function getStatusIcon(status) {
5
+ switch (status) {
6
+ case 'success':
7
+ return new IconCheckCircle();
8
+ case 'error':
9
+ return new IconTimesCircle();
10
+ case 'warning':
11
+ return new IconInfoCircle();
12
+ case 'info':
13
+ default:
14
+ return new IconInfoCircle();
15
+ }
16
+ }
17
+ /**
18
+ * 结果页组件
19
+ *
20
+ * 用于操作反馈的结果展示,支持成功/失败/信息/警告四种状态。
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // 成功结果
25
+ * new Result({
26
+ * status: 'success',
27
+ * title: '操作成功',
28
+ * subTitle: '数据已保存',
29
+ * extra: new Button({ text: '返回列表', onClick: () => router.back() })
30
+ * })
31
+ *
32
+ * // 错误结果
33
+ * new Result({
34
+ * status: 'error',
35
+ * title: '提交失败',
36
+ * subTitle: '请检查网络后重试'
37
+ * })
38
+ * ```
39
+ */
40
+ export class Result extends DivModule {
41
+ constructor(opts) {
42
+ super('wok-ui-ext-result');
43
+ this.opts = opts;
44
+ // 图标
45
+ this.addChild({
46
+ classNames: ['wok-ui-ext-result-icon', opts.status],
47
+ children: getStatusIcon(opts.status)
48
+ });
49
+ // 标题
50
+ this.addChild({
51
+ tag: 'div',
52
+ classNames: 'wok-ui-ext-result-title',
53
+ innerText: opts.title
54
+ });
55
+ // 副标题
56
+ if (opts.subTitle) {
57
+ this.addChild({
58
+ tag: 'div',
59
+ classNames: 'wok-ui-ext-result-subtitle',
60
+ innerText: opts.subTitle
61
+ });
62
+ }
63
+ // 操作区
64
+ if (opts.extra) {
65
+ this.addChild({
66
+ classNames: 'wok-ui-ext-result-extra',
67
+ children: opts.extra
68
+ });
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,41 @@
1
+ .wok-ui-ext-result {
2
+ text-align: center;
3
+ padding: 48px 24px;
4
+ }
5
+ .wok-ui-ext-result .wok-ui-ext-result-icon {
6
+ font-size: 64px;
7
+ margin-bottom: 20px;
8
+ line-height: 1;
9
+ }
10
+ .wok-ui-ext-result .wok-ui-ext-result-icon svg {
11
+ width: 64px;
12
+ height: 64px;
13
+ }
14
+ .wok-ui-ext-result .wok-ui-ext-result-icon.success {
15
+ color: var(--color-success, #52c41a);
16
+ }
17
+ .wok-ui-ext-result .wok-ui-ext-result-icon.error {
18
+ color: var(--color-danger, #ff4d4f);
19
+ }
20
+ .wok-ui-ext-result .wok-ui-ext-result-icon.info {
21
+ color: var(--color-primary, var(--brand));
22
+ }
23
+ .wok-ui-ext-result .wok-ui-ext-result-icon.warning {
24
+ color: var(--color-warning, #faad14);
25
+ }
26
+ .wok-ui-ext-result .wok-ui-ext-result-title {
27
+ font-size: var(--font-size-large);
28
+ color: var(--text-primary);
29
+ font-weight: 600;
30
+ margin-bottom: 8px;
31
+ line-height: 1.4;
32
+ }
33
+ .wok-ui-ext-result .wok-ui-ext-result-subtitle {
34
+ font-size: var(--font-size-normal);
35
+ color: var(--text-tertiary);
36
+ margin-bottom: 24px;
37
+ line-height: 1.5;
38
+ }
39
+ .wok-ui-ext-result .wok-ui-ext-result-extra {
40
+ margin-top: 8px;
41
+ }
@@ -0,0 +1,26 @@
1
+ import { DivModule } from 'wok-ui';
2
+ import './style.less';
3
+ /**
4
+ * 搜索框
5
+ */
6
+ export declare class SearchBox extends DivModule {
7
+ /**
8
+ * 搜索框
9
+ * @param opts
10
+ * @param opts.placeholder 搜索框占位符
11
+ * @param opts.maxLength 搜索框最大长度
12
+ * @param opts.value 搜索框默认值
13
+ * @param opts.onSearch 触发搜索回调
14
+ */
15
+ constructor(opts: {
16
+ placeholder?: string;
17
+ maxLength?: number;
18
+ value?: string;
19
+ /**
20
+ * 触发搜索
21
+ * @param value
22
+ * @returns
23
+ */
24
+ onSearch?: (value: string) => void;
25
+ });
26
+ }
@@ -0,0 +1,60 @@
1
+ import { DivModule } from 'wok-ui';
2
+ import { getWokUiExtI18n } from '../i18n';
3
+ import { IconSearch } from '../icons';
4
+ import './style.css';
5
+ /**
6
+ * 搜索框
7
+ */
8
+ export class SearchBox extends DivModule {
9
+ /**
10
+ * 搜索框
11
+ * @param opts
12
+ * @param opts.placeholder 搜索框占位符
13
+ * @param opts.maxLength 搜索框最大长度
14
+ * @param opts.value 搜索框默认值
15
+ * @param opts.onSearch 触发搜索回调
16
+ */
17
+ constructor(opts) {
18
+ super('wok-ui-ext-search-box');
19
+ let value = opts.value || '';
20
+ this.addChild({
21
+ tag: 'form',
22
+ events: {
23
+ submit: (e) => {
24
+ e.preventDefault();
25
+ if (!opts.onSearch)
26
+ return;
27
+ const fValue = value.trim();
28
+ opts.onSearch(fValue);
29
+ }
30
+ },
31
+ children: {
32
+ classNames: 'wok-ui-input',
33
+ children: [
34
+ new IconSearch(),
35
+ {
36
+ tag: 'input',
37
+ attrs: {
38
+ type: 'search',
39
+ placeholder: opts.placeholder || getWokUiExtI18n().buildMsg('search-box-placeholder'),
40
+ maxLength: typeof opts.maxLength === 'number' ? `${opts.maxLength}` : '',
41
+ value
42
+ },
43
+ preHandle(el) {
44
+ const input = el;
45
+ input.addEventListener('input', () => {
46
+ value = input.value;
47
+ });
48
+ // input[type="search"]在部分浏览器中还会支持 search事件。当用户点击清除图标时,也会触发这个事件
49
+ input.addEventListener('search', evt => {
50
+ if (input.value === '') {
51
+ opts.onSearch?.('');
52
+ }
53
+ });
54
+ }
55
+ }
56
+ ]
57
+ }
58
+ });
59
+ }
60
+ }
@@ -0,0 +1,22 @@
1
+ .wok-ui-ext-search-box .wok-ui-input {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: 8px;
5
+ }
6
+ .wok-ui-ext-search-box .wok-ui-input > .wok-ui-svg-icon {
7
+ color: var(--text-muted);
8
+ pointer-events: none;
9
+ flex-shrink: 0;
10
+ }
11
+ .wok-ui-ext-search-box .wok-ui-input > input {
12
+ flex: 1;
13
+ border: none;
14
+ outline: none;
15
+ background: transparent;
16
+ appearance: none;
17
+ line-height: 1.5;
18
+ font-size: var(--font-size-body) !important;
19
+ }
20
+ .wok-ui-ext-search-box .wok-ui-input > input::placeholder {
21
+ color: var(--text-placeholder);
22
+ }
@@ -0,0 +1,42 @@
1
+ import { DivModule } from 'wok-ui';
2
+ import './style.less';
3
+ export interface SegmentedItem {
4
+ label: string;
5
+ value: string;
6
+ }
7
+ /**
8
+ * 分段控件
9
+ *
10
+ * 用于筛选条件切换,支持字符串数组或 { label, value } 对象数组。
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // 简单字符串数组
15
+ * new Segmented({
16
+ * items: ['全部', '启用', '禁用'],
17
+ * activeValue: '启用',
18
+ * onChange: v => console.log(v)
19
+ * })
20
+ *
21
+ * // 指定 label/value
22
+ * new Segmented({
23
+ * items: [{ label: '全部', value: '' }, { label: '启用', value: '1' }],
24
+ * activeValue: '',
25
+ * onChange: v => console.log(v)
26
+ * })
27
+ * ```
28
+ */
29
+ export declare class Segmented extends DivModule {
30
+ private opts;
31
+ private activeValue;
32
+ private items;
33
+ constructor(opts: {
34
+ items: Array<SegmentedItem | string>;
35
+ activeValue: string;
36
+ onChange: (activeValue: string) => void;
37
+ });
38
+ /** 获取当前选中值 */
39
+ getValue(): string;
40
+ /** 设置当前选中值 */
41
+ setValue(value: string): void;
42
+ }
@@ -0,0 +1,61 @@
1
+ import { DivModule } from 'wok-ui';
2
+ import './style.css';
3
+ /**
4
+ * 分段控件
5
+ *
6
+ * 用于筛选条件切换,支持字符串数组或 { label, value } 对象数组。
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // 简单字符串数组
11
+ * new Segmented({
12
+ * items: ['全部', '启用', '禁用'],
13
+ * activeValue: '启用',
14
+ * onChange: v => console.log(v)
15
+ * })
16
+ *
17
+ * // 指定 label/value
18
+ * new Segmented({
19
+ * items: [{ label: '全部', value: '' }, { label: '启用', value: '1' }],
20
+ * activeValue: '',
21
+ * onChange: v => console.log(v)
22
+ * })
23
+ * ```
24
+ */
25
+ export class Segmented extends DivModule {
26
+ constructor(opts) {
27
+ super('wok-ui-ext-segmented');
28
+ this.opts = opts;
29
+ this.items = opts.items.map(item => typeof item === 'string' ? { label: item, value: item } : item);
30
+ this.activeValue = opts.activeValue;
31
+ for (const item of this.items) {
32
+ const isActive = item.value === this.activeValue;
33
+ this.addChild({
34
+ tag: 'span',
35
+ classNames: ['wok-ui-ext-segmented-item', isActive ? 'active' : ''],
36
+ innerText: item.label,
37
+ onClick: () => {
38
+ if (item.value === this.activeValue)
39
+ return;
40
+ this.activeValue = item.value;
41
+ // 更新 active 样式
42
+ this.el.querySelectorAll('.wok-ui-ext-segmented-item').forEach((el, i) => {
43
+ el.classList.toggle('active', this.items[i].value === this.activeValue);
44
+ });
45
+ this.opts.onChange(item.value);
46
+ }
47
+ });
48
+ }
49
+ }
50
+ /** 获取当前选中值 */
51
+ getValue() {
52
+ return this.activeValue;
53
+ }
54
+ /** 设置当前选中值 */
55
+ setValue(value) {
56
+ this.activeValue = value;
57
+ this.el.querySelectorAll('.wok-ui-ext-segmented-item').forEach((el, i) => {
58
+ el.classList.toggle('active', this.items[i].value === value);
59
+ });
60
+ }
61
+ }