tor-univer-sheet 1.0.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 (79) hide show
  1. package/README.md +2 -0
  2. package/dist/App.vue.d.ts +2 -0
  3. package/dist/components/ContentWrap/index.d.ts +2 -0
  4. package/dist/components/ContentWrap/src/ContentWrap.vue.d.ts +57 -0
  5. package/dist/components/Form/src/componentMap.d.ts +4 -0
  6. package/dist/components/Form/src/components/InputNumberWrapper.vue.d.ts +2 -0
  7. package/dist/components/Form/src/types.d.ts +16 -0
  8. package/dist/components/GlobalLoading/GlobalLoading.vue.d.ts +8 -0
  9. package/dist/components/GlobalLoading/index.d.ts +7 -0
  10. package/dist/components/IndicatorPointSelect/IndicatorPointSelect.vue.d.ts +2 -0
  11. package/dist/components/UniverSheet/UniverSheet.data.d.ts +23 -0
  12. package/dist/components/UniverSheet/UniverSheet.vue.d.ts +515 -0
  13. package/dist/components/UniverSheet/data.d.ts +9 -0
  14. package/dist/components/UniverSheet/plugins/Plugins.d.ts +29 -0
  15. package/dist/components/UniverSheet/plugins/importFile/ImportFileIcon.vue.d.ts +2 -0
  16. package/dist/components/UniverSheet/plugins/importFile/ImportFilePlugin.d.ts +14 -0
  17. package/dist/components/UniverSheet/plugins/index.d.ts +2 -0
  18. package/dist/components/UniverSheet/plugins/indicatorsContextMenu/IndicatorsContextMenuPlugin.d.ts +16 -0
  19. package/dist/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsMenu.vue.d.ts +2 -0
  20. package/dist/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsUniverSheetConfigDialog.vue.d.ts +234 -0
  21. package/dist/components/UniverSheet/plugins/saveButton/ButtonIcon.vue.d.ts +2 -0
  22. package/dist/components/UniverSheet/plugins/saveButton/SaveButton.d.ts +14 -0
  23. package/dist/components/UniverSheet/plugins/syncContextMenu/SyncContextMenu.vue.d.ts +2 -0
  24. package/dist/components/UniverSheet/plugins/syncContextMenu/SyncContextMenuPlugin.d.ts +14 -0
  25. package/dist/components/UniverSheet/plugins/timeConfigContextMenu/TimeConfigContextMenuPlugin.d.ts +16 -0
  26. package/dist/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigMenu.vue.d.ts +2 -0
  27. package/dist/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigUniverSheetConfigDialog.vue.d.ts +234 -0
  28. package/dist/favicon.ico +0 -0
  29. package/dist/hooks/useMessage.d.ts +18 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/main.d.ts +0 -0
  32. package/dist/tor-univer-sheet.es.js +213 -0
  33. package/dist/tor-univer-sheet.umd.js +1 -0
  34. package/dist/types/components.d.ts +52 -0
  35. package/dist/types/external-components.d.ts +14 -0
  36. package/dist/types/form.d.ts +51 -0
  37. package/dist/utils/decimal.d.ts +59 -0
  38. package/dist/utils/fileHelp.d.ts +8 -0
  39. package/dist/utils/index.d.ts +2 -0
  40. package/dist/utils/is.d.ts +33 -0
  41. package/dist/utils/propTypes.d.ts +10 -0
  42. package/package.json +88 -0
  43. package/src/App.vue +16 -0
  44. package/src/components/ContentWrap/index.ts +3 -0
  45. package/src/components/ContentWrap/src/ContentWrap.vue +50 -0
  46. package/src/components/Form/src/componentMap.ts +51 -0
  47. package/src/components/Form/src/components/InputNumberWrapper.vue +12 -0
  48. package/src/components/Form/src/types.ts +18 -0
  49. package/src/components/GlobalLoading/GlobalLoading.vue +89 -0
  50. package/src/components/GlobalLoading/index.ts +45 -0
  51. package/src/components/IndicatorPointSelect/IndicatorPointSelect.vue +9 -0
  52. package/src/components/UniverSheet/UniverSheet.data.ts +521 -0
  53. package/src/components/UniverSheet/UniverSheet.vue +339 -0
  54. package/src/components/UniverSheet/data.ts +18 -0
  55. package/src/components/UniverSheet/plugins/Plugins.ts +246 -0
  56. package/src/components/UniverSheet/plugins/importFile/ImportFileIcon.vue +26 -0
  57. package/src/components/UniverSheet/plugins/importFile/ImportFilePlugin.ts +109 -0
  58. package/src/components/UniverSheet/plugins/index.ts +10 -0
  59. package/src/components/UniverSheet/plugins/indicatorsContextMenu/IndicatorsContextMenuPlugin.ts +134 -0
  60. package/src/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsMenu.vue +49 -0
  61. package/src/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsUniverSheetConfigDialog.vue +153 -0
  62. package/src/components/UniverSheet/plugins/saveButton/ButtonIcon.vue +19 -0
  63. package/src/components/UniverSheet/plugins/saveButton/SaveButton.ts +68 -0
  64. package/src/components/UniverSheet/plugins/syncContextMenu/SyncContextMenu.vue +24 -0
  65. package/src/components/UniverSheet/plugins/syncContextMenu/SyncContextMenuPlugin.ts +65 -0
  66. package/src/components/UniverSheet/plugins/timeConfigContextMenu/TimeConfigContextMenuPlugin.ts +133 -0
  67. package/src/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigMenu.vue +10 -0
  68. package/src/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigUniverSheetConfigDialog.vue +152 -0
  69. package/src/hooks/useMessage.ts +93 -0
  70. package/src/index.ts +10 -0
  71. package/src/main.ts +14 -0
  72. package/src/types/components.d.ts +52 -0
  73. package/src/types/external-components.d.ts +16 -0
  74. package/src/types/form.d.ts +52 -0
  75. package/src/utils/decimal.ts +98 -0
  76. package/src/utils/fileHelp.ts +71 -0
  77. package/src/utils/index.ts +32 -0
  78. package/src/utils/is.ts +168 -0
  79. package/src/utils/propTypes.ts +24 -0
@@ -0,0 +1,71 @@
1
+ import { read, utils } from 'xlsx'
2
+
3
+ export async function openMultipleFileSelector(acceptTypes = '*', multiple = false) {
4
+ const fileInput = document.createElement('input')
5
+ fileInput.type = 'file'
6
+ fileInput.accept = acceptTypes
7
+ fileInput.multiple = multiple // 允许多选
8
+ fileInput.click()
9
+ return new Promise((resolve, reject) => {
10
+ fileInput.onchange = function () {
11
+ const files = Array.from(fileInput?.files ?? [])
12
+ if (files.length > 0) {
13
+ resolve(files)
14
+ } else {
15
+ reject()
16
+ }
17
+ }
18
+ })
19
+ }
20
+ export function getXlsxData(file: File) {
21
+ return new Promise((resolve, reject) => {
22
+ const reader = new FileReader()
23
+ reader.onload = (ev) => {
24
+ try {
25
+ const data = ev.target?.result
26
+ if (!data) {
27
+ reject('读取文件失败')
28
+ return
29
+ }
30
+ const workbook = read(data, {
31
+ type: 'binary'
32
+ })
33
+ const sheetData: any[] = []
34
+ workbook.SheetNames.forEach((name) => {
35
+ sheetData.push(utils.sheet_to_json(workbook.Sheets[name]))
36
+ })
37
+ resolve(sheetData)
38
+ } catch (e) {
39
+ reject('读取错误!')
40
+ }
41
+ }
42
+ reader.readAsBinaryString(file)
43
+ })
44
+ }
45
+ /**
46
+ * 下载axios导出的文件
47
+ * @param res
48
+ * @param _filename
49
+ */
50
+ export const downloadBlobRes = (res: any, _filename: string | undefined = undefined) => {
51
+ const data = res.data
52
+ if (data instanceof Blob) {
53
+ let filename = res.headers.get('content-disposition')?.split('filename=')?.[1] ?? '未知文件'
54
+ filename = decodeURIComponent(filename)
55
+ if (_filename) filename = _filename
56
+ if (typeof (window as any).chrome !== 'undefined') {
57
+ const link = document.createElement('a')
58
+ const url = URL.createObjectURL(data)
59
+ link.href = url
60
+ link.download = filename
61
+ link.click()
62
+ URL.revokeObjectURL(url)
63
+ } else if (window.navigator.msSaveBlob) {
64
+ window.navigator.msSaveBlob(data, filename)
65
+ } else {
66
+ const url = URL.createObjectURL(data)
67
+ window.open(url)
68
+ URL.revokeObjectURL(url)
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,32 @@
1
+ export const handleClearInput = (model: Recordable, strList: string[]) => {
2
+ for (const str of strList) {
3
+ model[str] = null
4
+ }
5
+ }
6
+ export const generateUUID = () => {
7
+ if (typeof crypto === 'object') {
8
+ if (typeof crypto.randomUUID === 'function') {
9
+ return crypto.randomUUID()
10
+ }
11
+ if (typeof crypto.getRandomValues === 'function' && typeof Uint8Array === 'function') {
12
+ const callback = (c: any) => {
13
+ const num = Number(c)
14
+ return (num ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (num / 4)))).toString(16)
15
+ }
16
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, callback)
17
+ }
18
+ }
19
+ let timestamp = new Date().getTime()
20
+ let performanceNow = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0
21
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
22
+ let random = Math.random() * 16
23
+ if (timestamp > 0) {
24
+ random = (timestamp + random) % 16 | 0
25
+ timestamp = Math.floor(timestamp / 16)
26
+ } else {
27
+ random = (performanceNow + random) % 16 | 0
28
+ performanceNow = Math.floor(performanceNow / 16)
29
+ }
30
+ return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
31
+ })
32
+ }
@@ -0,0 +1,168 @@
1
+ // copy to vben-admin
2
+
3
+ const toString = Object.prototype.toString
4
+
5
+ export const is = (val: unknown, type: string) => {
6
+ return toString.call(val) === `[object ${type}]`
7
+ }
8
+
9
+ export const isDef = <T = unknown>(val?: T): val is T => {
10
+ return typeof val !== 'undefined'
11
+ }
12
+
13
+ export const isUnDef = <T = unknown>(val?: T): val is T => {
14
+ return !isDef(val)
15
+ }
16
+
17
+ export const isObject = (val: any): val is Record<any, any> => {
18
+ return val !== null && is(val, 'Object')
19
+ }
20
+
21
+ export const isEmpty = (val: any): boolean => {
22
+ if (val === null || val === undefined || typeof val === 'undefined') {
23
+ return true
24
+ }
25
+ if (isArray(val) || isString(val)) {
26
+ return val.length === 0
27
+ }
28
+
29
+ if (val instanceof Map || val instanceof Set) {
30
+ return val.size === 0
31
+ }
32
+
33
+ if (isObject(val)) {
34
+ return Object.keys(val).length === 0
35
+ }
36
+
37
+ return false
38
+ }
39
+
40
+ export const isDate = (val: unknown): val is Date => {
41
+ return is(val, 'Date')
42
+ }
43
+
44
+ export const isNull = (val: unknown): val is null => {
45
+ return val === null
46
+ }
47
+
48
+ export const isNullAndUnDef = (val: unknown): val is null | undefined => {
49
+ return isUnDef(val) && isNull(val)
50
+ }
51
+
52
+ export const isNullOrUnDef = (val: unknown): val is null | undefined => {
53
+ return isUnDef(val) || isNull(val)
54
+ }
55
+
56
+ export const isNumber = (val: unknown): val is number => {
57
+ return is(val, 'Number')
58
+ }
59
+
60
+ export const isPromise = <T = any>(val: unknown): val is Promise<T> => {
61
+ return is(val, 'Promise') && isObject(val) && isFunction(val.then) && isFunction(val.catch)
62
+ }
63
+
64
+ export const isString = (val: unknown): val is string => {
65
+ return is(val, 'String')
66
+ }
67
+
68
+ export const isFunction = (val: unknown): val is Function => {
69
+ return typeof val === 'function'
70
+ }
71
+
72
+ export const isBoolean = (val: unknown): val is boolean => {
73
+ return is(val, 'Boolean')
74
+ }
75
+
76
+ export const isRegExp = (val: unknown): val is RegExp => {
77
+ return is(val, 'RegExp')
78
+ }
79
+
80
+ export const isArray = (val: any): val is Array<any> => {
81
+ return val && Array.isArray(val)
82
+ }
83
+
84
+ export const isWindow = (val: any): val is Window => {
85
+ return typeof window !== 'undefined' && is(val, 'Window')
86
+ }
87
+
88
+ export const isElement = (val: unknown): val is Element => {
89
+ return isObject(val) && !!val.tagName
90
+ }
91
+
92
+ export const isMap = (val: unknown): val is Map<any, any> => {
93
+ return is(val, 'Map')
94
+ }
95
+
96
+ export const isServer = typeof window === 'undefined'
97
+
98
+ export const isClient = !isServer
99
+
100
+ export const isUrl = (path: string): boolean => {
101
+ // fix:修复hash路由无法跳转的问题
102
+ const reg =
103
+ /(((^https?:(?:\/\/)?)(?:[-:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%#\/.\w-_]*)?\??(?:[-\+=&%@.\w_]*)#?(?:[\w]*))?)$/
104
+ return reg.test(path)
105
+ }
106
+
107
+ export const isDark = (): boolean => {
108
+ return window.matchMedia('(prefers-color-scheme: dark)').matches
109
+ }
110
+
111
+ // 是否是图片链接
112
+ export const isImgPath = (path: string): boolean => {
113
+ return /(https?:\/\/|data:image\/).*?\.(png|jpg|jpeg|gif|svg|webp|ico)/gi.test(path)
114
+ }
115
+
116
+ // 密码复杂度校验:至少包含大写字母、小写字母、数字、特殊字符中的三种
117
+ export const isPasswordComplex = (value: string): boolean => {
118
+ if (!isString(value)) {
119
+ return false
120
+ }
121
+ let categories = 0
122
+ if (/[A-Z]/.test(value)) {
123
+ categories += 1
124
+ }
125
+ if (/[a-z]/.test(value)) {
126
+ categories += 1
127
+ }
128
+ if (/[0-9]/.test(value)) {
129
+ categories += 1
130
+ }
131
+ if (/[^A-Za-z0-9]/.test(value)) {
132
+ categories += 1
133
+ }
134
+ return categories >= 3
135
+ }
136
+
137
+ // 密码校验:长度 6-20 位并满足复杂度
138
+ export const isValidPassword = (value: string): boolean => {
139
+ if (!isString(value)) {
140
+ return false
141
+ }
142
+ const length = value.length
143
+ if (length < 6 || length > 20) {
144
+ return false
145
+ }
146
+ return isPasswordComplex(value)
147
+ }
148
+
149
+ export const isEmptyVal = (val: any): boolean => {
150
+ return val === '' || val === null || val === undefined
151
+ }
152
+
153
+ export const isContainsChinese = (val: string): boolean => {
154
+ // Chinese character Unicode range: \u4e00-\u9fff
155
+ const chineseRegex = /[\u4e00-\u9fff]/
156
+ return chineseRegex.test(val)
157
+ }
158
+
159
+ /**
160
+ * @description 判断是否为windows环境
161
+ * @returns
162
+ */
163
+ export function isWindows(): boolean {
164
+ return (
165
+ (navigator.userAgentData && navigator.userAgentData.platform === 'Windows') ||
166
+ navigator.platform === 'Win32'
167
+ )
168
+ }
@@ -0,0 +1,24 @@
1
+ import { VueTypeValidableDef, VueTypesInterface, createTypes, toValidableType } from 'vue-types'
2
+ import { CSSProperties } from 'vue'
3
+
4
+ type PropTypes = VueTypesInterface & {
5
+ readonly style: VueTypeValidableDef<CSSProperties>
6
+ }
7
+ const newPropTypes = createTypes({
8
+ func: undefined,
9
+ bool: undefined,
10
+ string: undefined,
11
+ number: undefined,
12
+ object: undefined,
13
+ integer: undefined
14
+ }) as PropTypes
15
+
16
+ class propTypes extends newPropTypes {
17
+ static get style() {
18
+ return toValidableType('style', {
19
+ type: [String, Object]
20
+ })
21
+ }
22
+ }
23
+
24
+ export { propTypes }