@spacecorexdev/core 0.0.4 → 0.0.5

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 (132) hide show
  1. package/package.json +2 -36
  2. package/src/api/_base.ts +243 -0
  3. package/src/api/index.ts +17 -0
  4. package/src/api/project.ts +1345 -0
  5. package/src/api/user.ts +1174 -0
  6. package/src/contract.ts +50 -0
  7. package/src/hooks/index.ts +2 -0
  8. package/{dist/hooks/index.js → src/hooks/useLongPress.ts} +53 -49
  9. package/src/hooks/useOnlineStatus.ts +22 -0
  10. package/src/index.ts +14 -0
  11. package/src/types/id.ts +2 -0
  12. package/src/types/index.ts +5 -0
  13. package/src/types/project/base.ts +63 -0
  14. package/src/types/project/contract.ts +79 -0
  15. package/src/types/project/contractStatus.tsx +15 -0
  16. package/src/types/project/index.ts +5 -0
  17. package/src/types/project/member.ts +46 -0
  18. package/src/types/project/progress.ts +43 -0
  19. package/src/types/projectRole.ts +17 -0
  20. package/src/types/theme.ts +1 -0
  21. package/src/types/user/index.ts +1 -0
  22. package/src/types/user/role.ts +7 -0
  23. package/src/ui/CommentTimeline/index.tsx +330 -0
  24. package/src/ui/FileManager/FileContextMenu.tsx +628 -0
  25. package/src/ui/FileManager/FileGridView.tsx +529 -0
  26. package/src/ui/FileManager/FileTableView.tsx +405 -0
  27. package/src/ui/FileManager/FileToolbar.tsx +119 -0
  28. package/src/ui/FileManager/FileVersionHistoryModal.tsx +175 -0
  29. package/src/ui/FileManager/MoveCopyToProjectModal.tsx +119 -0
  30. package/src/ui/FileManager/ShareToWechatModal.tsx +419 -0
  31. package/src/ui/FileManager/hooks/useFileManagerActions.ts +2532 -0
  32. package/src/ui/FileManager/hooks/useFileManagerState.ts +419 -0
  33. package/src/ui/FileManager/index.tsx +580 -0
  34. package/src/ui/FileManager/projectFileManagerApi.ts +57 -0
  35. package/src/ui/FileManager/types.ts +184 -0
  36. package/src/ui/FileManager/utils/fileDeltaWorker.ts +193 -0
  37. package/src/ui/FileManager/utils/fileTree.ts +178 -0
  38. package/src/ui/FileManager/utils/fileUpload.ts +714 -0
  39. package/src/ui/FileManager/utils/fileUtils.ts +65 -0
  40. package/src/ui/InvoiceRecordsList/index.tsx +813 -0
  41. package/src/ui/MyFileSelectorModal.tsx +261 -0
  42. package/src/ui/ProjectSelector/index.tsx +472 -0
  43. package/src/ui/ProjectSelector/projectCache.ts +40 -0
  44. package/src/ui/RoleSelector/index.tsx +473 -0
  45. package/src/ui/RoleSelector/roleCache.ts +40 -0
  46. package/src/ui/UIAlert.tsx +399 -0
  47. package/src/ui/UIAlertExample.tsx +129 -0
  48. package/src/ui/UIConfirm.tsx +335 -0
  49. package/src/ui/UIConfirmExample.tsx +165 -0
  50. package/src/ui/UIDatePicker.tsx +146 -0
  51. package/src/ui/UIDateRangePicker.tsx +38 -0
  52. package/src/ui/UIFilePreview/ExcelEditor/index.tsx +617 -0
  53. package/src/ui/UIFilePreview/ExcelEditor/types.ts +24 -0
  54. package/src/ui/UIFilePreview/ExportDropdown.css +85 -0
  55. package/src/ui/UIFilePreview/ExportDropdown.tsx +109 -0
  56. package/src/ui/UIFilePreview/IndexedDBUtils.ts +564 -0
  57. package/src/ui/UIFilePreview/MarkdownEditor/exportMarkdownPdf.ts +576 -0
  58. package/src/ui/UIFilePreview/MarkdownEditor/index.tsx +677 -0
  59. package/src/ui/UIFilePreview/MarkdownEditor/markdownEditor.css +1005 -0
  60. package/src/ui/UIFilePreview/MarkdownEditor/types.ts +15 -0
  61. package/src/ui/UIFilePreview/PPTXEditor/index.tsx +602 -0
  62. package/src/ui/UIFilePreview/RichDocEditor/exportRDocMarkdown.ts +77 -0
  63. package/src/ui/UIFilePreview/RichDocEditor/exportRDocPdf.ts +374 -0
  64. package/src/ui/UIFilePreview/RichDocEditor/index.tsx +730 -0
  65. package/src/ui/UIFilePreview/RichDocEditor/richdoc-editor.css +59 -0
  66. package/src/ui/UIFilePreview/UIFilePreview.tsx +611 -0
  67. package/src/ui/UIFilePreview/WordEditor/index.tsx +3933 -0
  68. package/src/ui/UIFilePreview/WordEditor/style.ts +1213 -0
  69. package/src/ui/UIFilePreview/WordEditor/word-editor.css +999 -0
  70. package/src/ui/UIFilePreview/filePreview.css +193 -0
  71. package/src/ui/UIFilePreview/filetypes/archive.tsx +66 -0
  72. package/src/ui/UIFilePreview/filetypes/cad.tsx +287 -0
  73. package/src/ui/UIFilePreview/filetypes/excel.tsx +355 -0
  74. package/src/ui/UIFilePreview/filetypes/image.tsx +20 -0
  75. package/src/ui/UIFilePreview/filetypes/imageLoader.ts +63 -0
  76. package/src/ui/UIFilePreview/filetypes/pdf.tsx +156 -0
  77. package/src/ui/UIFilePreview/filetypes/ppt.tsx +535 -0
  78. package/src/ui/UIFilePreview/filetypes/pptExportPdf.ts +523 -0
  79. package/src/ui/UIFilePreview/filetypes/video.tsx +482 -0
  80. package/src/ui/UIFilePreview/filetypes/word.tsx +245 -0
  81. package/src/ui/UIFilePreview/filetypes/wordExportMarkdown.ts +86 -0
  82. package/src/ui/UIFilePreview/filetypes/wordExportPdf.tsx +427 -0
  83. package/src/ui/UIFilePreview/index.ts +35 -0
  84. package/src/ui/UIFilePreview/pdfPagination.ts +143 -0
  85. package/src/ui/UIFilePreview/previewUtils.tsx +531 -0
  86. package/src/ui/UIFileUpload.tsx +382 -0
  87. package/src/ui/UIImageUpload.tsx +195 -0
  88. package/src/ui/UILoading.tsx +255 -0
  89. package/src/ui/UILoadingExample.tsx +139 -0
  90. package/src/ui/UISelect.tsx +105 -0
  91. package/src/ui/UIToast.tsx +381 -0
  92. package/src/ui/UIToastExample.tsx +69 -0
  93. package/src/ui/UIToastSingle.tsx +279 -0
  94. package/src/ui/UIViewToggle.tsx +64 -0
  95. package/src/ui/UserSelector/index.tsx +583 -0
  96. package/src/ui/index.ts +84 -0
  97. package/src/ui/upload/image.ts +135 -0
  98. package/src/ui/upload/index.ts +73 -0
  99. package/src/ui/upload/submitFile.ts +106 -0
  100. package/src/ui/upload/submitForm.ts +124 -0
  101. package/src/ui/upload/upload.err.ts +15 -0
  102. package/src/ui/upload/upload.ts +250 -0
  103. package/src/utils/CacheDepartmentInfo.ts +372 -0
  104. package/src/utils/CacheFileContent.ts +315 -0
  105. package/src/utils/CachePermissionInfo.ts +235 -0
  106. package/src/utils/CacheRoleInfo.ts +303 -0
  107. package/src/utils/CacheUserInfo.ts +818 -0
  108. package/src/utils/CacheViewToggleInfo.ts +182 -0
  109. package/src/utils/MessageContentUtils.ts +268 -0
  110. package/src/utils/clipboard.ts +70 -0
  111. package/src/utils/companyEmail.ts +19 -0
  112. package/src/utils/forbidDebugger.ts +59 -0
  113. package/src/utils/formatters.ts +94 -0
  114. package/src/utils/htmlUtils.tsx +59 -0
  115. package/src/utils/index.ts +18 -0
  116. package/src/utils/keyboard.ts +114 -0
  117. package/src/utils/mammothApi.ts +16 -0
  118. package/src/utils/polyfills.ts +928 -0
  119. package/src/utils/regex.ts +14 -0
  120. package/src/utils/storage.ts +95 -0
  121. package/src/utils/workerBootstrap.ts +87 -0
  122. package/dist/api/index.js +0 -1553
  123. package/dist/contract.js +0 -5
  124. package/dist/index.js +0 -4492
  125. package/dist/types/index.js +0 -49
  126. package/dist/ui/index.css +0 -1876
  127. package/dist/ui/index.js +0 -22245
  128. package/dist/utils/index.js +0 -4296
  129. /package/{dist → src}/styles/ant-modal.css +0 -0
  130. /package/{dist → src}/styles/ant-spin.css +0 -0
  131. /package/{dist → src}/styles/ant-table.css +0 -0
  132. /package/{dist → src}/styles/index.css +0 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * DocxEditor 的工具栏/弹窗层级很高,antd Dropdown 默认 z-index(1050)会被盖住,
3
+ * 表现成「点击导出没反应」。这里对齐 WordEditor 里样式下拉的处理(z-index 10000)。
4
+ */
5
+ .vendorsys-export-dropdown {
6
+ z-index: 10000 !important;
7
+ }
8
+
9
+ /**
10
+ * 「导出」下拉按钮的配色。
11
+ *
12
+ * 不依赖 antd 主题自动取色(实测不可靠:type=text 按钮容易拿到与容器底色
13
+ * 同向的颜色),改为显式声明「按钮所在的底色」:
14
+ *
15
+ * - 默认(编辑器头部):深色模式下是深底(`bg-gray-50` 走 CSS 变量,
16
+ * 深色主题下是近黑色 13 17 23),用浅色字。
17
+ * - `.vendorsys-export-trigger-on-light`:底色恒为浅色/白色,用深色字。
18
+ * 目前用于 Word 只读预览(浮在白色文档页上)。
19
+ * - `.vendorsys-export-trigger-on-dark`:底色恒为深色,用浅色字。
20
+ * 目前用于 PPT 只读预览(`.ui-file-preview-ppt` 的 background 是 #000)。
21
+ *
22
+ * 后两条不跟随主题(预览底色不随主题变化),因此同时声明 dark/light 两种
23
+ * 作用域并放在默认规则之后,靠「同优先级 + 靠后」覆盖默认规则。
24
+ */
25
+ [data-theme='dark'] .vendorsys-export-trigger.ant-btn {
26
+ color: rgba(255, 255, 255, 0.65) !important;
27
+ }
28
+
29
+ [data-theme='dark'] .vendorsys-export-trigger.ant-btn:not(:disabled):hover {
30
+ color: #69b1ff !important;
31
+ background-color: rgba(255, 255, 255, 0.08) !important;
32
+ }
33
+
34
+ [data-theme='dark'] .vendorsys-export-trigger.ant-btn:not(:disabled):active {
35
+ color: #91caff !important;
36
+ }
37
+
38
+ [data-theme='dark'] .vendorsys-export-trigger.ant-btn[disabled],
39
+ [data-theme='dark'] .vendorsys-export-trigger.ant-btn.ant-btn-disabled {
40
+ color: rgba(255, 255, 255, 0.3) !important;
41
+ }
42
+
43
+ /* --- 浅色底(Word 只读预览,浮在白色文档页上)--- */
44
+ [data-theme='dark'] .vendorsys-export-trigger-on-light.ant-btn,
45
+ [data-theme='light'] .vendorsys-export-trigger-on-light.ant-btn {
46
+ color: rgba(59, 59, 59, 0.68) !important;
47
+ }
48
+
49
+ [data-theme='dark'] .vendorsys-export-trigger-on-light.ant-btn:not(:disabled):hover,
50
+ [data-theme='light'] .vendorsys-export-trigger-on-light.ant-btn:not(:disabled):hover {
51
+ color: #1677ff !important;
52
+ background-color: rgba(0, 0, 0, 0.04) !important;
53
+ }
54
+
55
+ [data-theme='dark'] .vendorsys-export-trigger-on-light.ant-btn:not(:disabled):active,
56
+ [data-theme='light'] .vendorsys-export-trigger-on-light.ant-btn:not(:disabled):active {
57
+ color: #0958d9 !important;
58
+ }
59
+
60
+ [data-theme='dark'] .vendorsys-export-trigger-on-light.ant-btn[disabled],
61
+ [data-theme='light'] .vendorsys-export-trigger-on-light.ant-btn[disabled] {
62
+ color: rgba(0, 0, 0, 0.25) !important;
63
+ }
64
+
65
+ /* --- 深色底(PPT 只读预览,容器 background 是 #000)--- */
66
+ [data-theme='dark'] .vendorsys-export-trigger-on-dark.ant-btn,
67
+ [data-theme='light'] .vendorsys-export-trigger-on-dark.ant-btn {
68
+ color: rgba(255, 255, 255, 0.85) !important;
69
+ }
70
+
71
+ [data-theme='dark'] .vendorsys-export-trigger-on-dark.ant-btn:not(:disabled):hover,
72
+ [data-theme='light'] .vendorsys-export-trigger-on-dark.ant-btn:not(:disabled):hover {
73
+ color: #69b1ff !important;
74
+ background-color: rgba(255, 255, 255, 0.12) !important;
75
+ }
76
+
77
+ [data-theme='dark'] .vendorsys-export-trigger-on-dark.ant-btn:not(:disabled):active,
78
+ [data-theme='light'] .vendorsys-export-trigger-on-dark.ant-btn:not(:disabled):active {
79
+ color: #91caff !important;
80
+ }
81
+
82
+ [data-theme='dark'] .vendorsys-export-trigger-on-dark.ant-btn[disabled],
83
+ [data-theme='light'] .vendorsys-export-trigger-on-dark.ant-btn[disabled] {
84
+ color: rgba(255, 255, 255, 0.3) !important;
85
+ }
@@ -0,0 +1,109 @@
1
+ import React, { useMemo } from 'react';
2
+ import { Button, Dropdown, type ButtonProps, type MenuProps } from 'antd';
3
+ import { DownOutlined, DownloadOutlined, FilePdfFilled } from '@ant-design/icons';
4
+ import './ExportDropdown.css';
5
+
6
+ export interface ExportDropdownProps {
7
+ /** 导出 PDF(不传则菜单里不出现该项) */
8
+ onExportPdf?: () => void;
9
+ /** 下载原始文件(不传则菜单里不出现该项) */
10
+ onDownload?: () => void | Promise<void>;
11
+ exportingPdf?: boolean;
12
+ downloading?: boolean;
13
+ disabled?: boolean;
14
+ /** 触发按钮文案,默认「导出」 */
15
+ label?: string;
16
+ /** 透传给触发按钮,用于各出入口保留原有 type / size / className / style */
17
+ buttonProps?: ButtonProps;
18
+ /** 透传给 Dropdown,默认 'vendorsys-export-dropdown' */
19
+ overlayClassName?: string;
20
+ /** 额外的自定义菜单项,插入在「导出PDF」与「下载」之间 */
21
+ extraItems?: MenuProps['items'];
22
+ }
23
+
24
+ /**
25
+ * 统一的「导出」下拉按钮:「导出PDF」+ 自定义项 + 「下载」。
26
+ * 两项都没有时整体不渲染,避免出现空下拉。
27
+ */
28
+ export const ExportDropdown: React.FC<ExportDropdownProps> = ({
29
+ onExportPdf,
30
+ onDownload,
31
+ exportingPdf = false,
32
+ downloading = false,
33
+ disabled,
34
+ label = '导出',
35
+ buttonProps,
36
+ overlayClassName = 'vendorsys-export-dropdown',
37
+ extraItems,
38
+ }) => {
39
+ const items = useMemo<MenuProps['items']>(() => {
40
+ const result: NonNullable<MenuProps['items']> = [];
41
+
42
+ if (onExportPdf) {
43
+ result.push({
44
+ key: 'pdf',
45
+ icon: <FilePdfFilled />,
46
+ label: '导出PDF',
47
+ disabled: exportingPdf,
48
+ onClick: () => {
49
+ onExportPdf();
50
+ },
51
+ });
52
+ }
53
+
54
+ if (extraItems && extraItems.length > 0) {
55
+ result.push(...extraItems);
56
+ }
57
+
58
+ if (onDownload) {
59
+ result.push({
60
+ key: 'download',
61
+ icon: <DownloadOutlined />,
62
+ label: '下载',
63
+ disabled: downloading,
64
+ onClick: () => {
65
+ void onDownload();
66
+ },
67
+ });
68
+ }
69
+
70
+ return result;
71
+ }, [onExportPdf, onDownload, exportingPdf, downloading, extraItems]);
72
+
73
+ if (!items || items.length === 0) {
74
+ return null;
75
+ }
76
+
77
+ return (
78
+ <Dropdown
79
+ menu={{ items }}
80
+ trigger={['click']}
81
+ overlayClassName={overlayClassName}
82
+ placement="bottomRight"
83
+ // DocxEditor 内部的工具栏层级很高,antd 默认把 popup 挂在 trigger 的父节点上且
84
+ // z-index 只有 1050,会被编辑器工具栏/弹窗盖住,表现成「点了没反应」。
85
+ // 这里统一挂到 body,配合 CSS 里的高 z-index 保证可见。
86
+ getPopupContainer={(triggerNode) => triggerNode?.ownerDocument?.body ?? document.body}
87
+ >
88
+ <Button
89
+ {...buttonProps}
90
+ className={['vendorsys-export-trigger', buttonProps?.className].filter(Boolean).join(' ')}
91
+ type={buttonProps?.type ?? 'text'}
92
+ loading={exportingPdf || downloading || buttonProps?.loading}
93
+ disabled={disabled || buttonProps?.disabled}
94
+ // DocxEditor / ProseMirror 在 document 上挂了全局 mousedown 监听并做编辑器 blur 检测,
95
+ // 点击头部按钮会让编辑器失焦 → 重渲染,下拉 popup 刚打开就被关掉(表现为「点了没反应」)。
96
+ // 沿用 WordEditor 里自定义样式下拉的做法:在 mousedown 阶段阻止默认行为,避免 focus 被抢。
97
+ onMouseDown={(e) => {
98
+ buttonProps?.onMouseDown?.(e);
99
+ e.preventDefault();
100
+ }}
101
+ icon={<DownloadOutlined />}
102
+ >
103
+ {label}
104
+ </Button>
105
+ </Dropdown>
106
+ );
107
+ };
108
+
109
+ export default ExportDropdown;