intable 0.0.6 → 0.0.7

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 (169) hide show
  1. package/README.md +16 -263
  2. package/docs/index-BaMALNy6.css +1 -0
  3. package/docs/index-CDN48t9E.js +3 -0
  4. package/docs/index-Cc4RNkLY.css +1 -0
  5. package/docs/index-MRnbkYmU.js +3 -0
  6. package/docs/index.html +15 -0
  7. package/docs/vite.svg +1 -0
  8. package/index.html +14 -0
  9. package/package.json +30 -38
  10. package/packages/intable/README.md +379 -0
  11. package/packages/intable/package.json +51 -0
  12. package/packages/intable/src/assets/ClearFormat.svg +3 -0
  13. package/packages/intable/src/assets/Forms.svg +4 -0
  14. package/packages/intable/src/assets/MergeCell.svg +4 -0
  15. package/packages/intable/src/assets/SplitCell.svg +4 -0
  16. package/packages/intable/src/assets/gap.svg +3 -0
  17. package/packages/intable/src/assets/loading.svg +12 -0
  18. package/packages/intable/src/assets/paint.svg +9 -0
  19. package/packages/intable/src/assets/solid.svg +1 -0
  20. package/packages/intable/src/components/Columns.tsx +86 -0
  21. package/packages/intable/src/components/DocTree.tsx +36 -0
  22. package/packages/intable/src/components/Menu.tsx +109 -0
  23. package/packages/intable/src/components/Popover.tsx +55 -0
  24. package/packages/intable/src/components/RecycleList.tsx +99 -0
  25. package/packages/intable/src/components/Render.tsx +26 -0
  26. package/packages/intable/src/components/Split.tsx +56 -0
  27. package/packages/intable/src/components/Tree.tsx +115 -0
  28. package/packages/intable/src/components/utils.tsx +12 -0
  29. package/packages/intable/src/hooks/index.ts +200 -0
  30. package/packages/intable/src/hooks/useDir.ts +78 -0
  31. package/packages/intable/src/hooks/useSelector.ts +91 -0
  32. package/packages/intable/src/hooks/useSort.tsx +118 -0
  33. package/packages/intable/src/hooks/useVirtualizer.ts +180 -0
  34. package/packages/intable/src/index.tsx +481 -0
  35. package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +5 -0
  36. package/packages/intable/src/plugins/CellMergePlugin.tsx +153 -0
  37. package/packages/intable/src/plugins/CellSelectionPlugin.tsx +175 -0
  38. package/packages/intable/src/plugins/CommandPlugin.tsx +74 -0
  39. package/packages/intable/src/plugins/CopyPastePlugin.tsx +63 -0
  40. package/packages/intable/src/plugins/DiffPlugin.tsx +107 -0
  41. package/packages/intable/src/plugins/DragPlugin.tsx +81 -0
  42. package/packages/intable/src/plugins/EditablePlugin.tsx +252 -0
  43. package/packages/intable/src/plugins/ExpandPlugin.tsx +80 -0
  44. package/packages/intable/src/plugins/HeaderGroup.tsx +289 -0
  45. package/packages/intable/src/plugins/HistoryPlugin.tsx +49 -0
  46. package/packages/intable/src/plugins/MenuPlugin.tsx +195 -0
  47. package/packages/intable/src/plugins/RenderPlugin/components.tsx +51 -0
  48. package/packages/intable/src/plugins/RenderPlugin/index.tsx +81 -0
  49. package/packages/intable/src/plugins/ResizePlugin.tsx +122 -0
  50. package/packages/intable/src/plugins/RowGroupPlugin.tsx +122 -0
  51. package/packages/intable/src/plugins/RowSelectionPlugin.tsx +65 -0
  52. package/packages/intable/src/plugins/TreePlugin.tsx +212 -0
  53. package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +190 -0
  54. package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +61 -0
  55. package/packages/intable/src/style.scss +244 -0
  56. package/{dist → packages/intable/src}/theme/antd.scss +14 -5
  57. package/{dist → packages/intable/src}/theme/element-plus.scss +6 -5
  58. package/packages/intable/src/tree.ts +13 -0
  59. package/packages/intable/src/types/auto-imports.d.ts +13 -0
  60. package/packages/intable/src/utils.ts +122 -0
  61. package/packages/intable/src/wc.tsx +35 -0
  62. package/packages/intable/src/web-component.ts +1 -0
  63. package/packages/react/package.json +31 -0
  64. package/packages/react/src/index.ts +44 -0
  65. package/packages/react/src/plugins/antd.ts +94 -0
  66. package/packages/react/src/style.scss +12 -0
  67. package/packages/react/src/types/auto-imports.d.ts +10 -0
  68. package/packages/vue/package.json +34 -0
  69. package/packages/vue/src/index.ts +63 -0
  70. package/packages/vue/src/plugins/element-plus.ts +69 -0
  71. package/packages/vue/src/style.scss +12 -0
  72. package/packages/vue/src/types/auto-imports.d.ts +10 -0
  73. package/pnpm-workspace.yaml +2 -0
  74. package/public/vite.svg +1 -0
  75. package/scripts/build.js +184 -0
  76. package/scripts/publish.js +95 -0
  77. package/src/assets/ClearFormat.svg +3 -0
  78. package/src/assets/Forms.svg +4 -0
  79. package/src/assets/MergeCell.svg +4 -0
  80. package/src/assets/SplitCell.svg +4 -0
  81. package/src/assets/gap.svg +3 -0
  82. package/src/assets/loading.svg +12 -0
  83. package/src/assets/paint.svg +9 -0
  84. package/src/assets/solid.svg +1 -0
  85. package/src/demo-vue.ts +54 -0
  86. package/src/demo.tsx +107 -0
  87. package/src/index.scss +105 -0
  88. package/src/styles/index.scss +172 -0
  89. package/src/types/auto-imports.d.ts +13 -0
  90. package/stats.html +4949 -0
  91. package/tsconfig.app.json +34 -0
  92. package/tsconfig.json +7 -0
  93. package/tsconfig.node.json +26 -0
  94. package/vite.config.ts +63 -0
  95. package/dist/__uno.css +0 -1
  96. package/dist/chevron-right.js +0 -6
  97. package/dist/components/Columns.d.ts +0 -3
  98. package/dist/components/Columns.js +0 -71
  99. package/dist/components/DocTree.d.ts +0 -4
  100. package/dist/components/DocTree.js +0 -32
  101. package/dist/components/Menu.d.ts +0 -1
  102. package/dist/components/Menu.js +0 -107
  103. package/dist/components/Popover.d.ts +0 -14
  104. package/dist/components/Popover.js +0 -41
  105. package/dist/components/Render.d.ts +0 -4
  106. package/dist/components/Render.js +0 -20
  107. package/dist/components/Split.d.ts +0 -15
  108. package/dist/components/Split.js +0 -76
  109. package/dist/components/Tree.d.ts +0 -37
  110. package/dist/components/Tree.js +0 -82
  111. package/dist/components/utils.d.ts +0 -3
  112. package/dist/components/utils.js +0 -8
  113. package/dist/hooks/index.d.ts +0 -40
  114. package/dist/hooks/index.js +0 -157
  115. package/dist/hooks/useDir.d.ts +0 -11
  116. package/dist/hooks/useDir.js +0 -42
  117. package/dist/hooks/useSelector.d.ts +0 -16
  118. package/dist/hooks/useSelector.js +0 -35
  119. package/dist/hooks/useSort.d.ts +0 -18
  120. package/dist/hooks/useSort.js +0 -83
  121. package/dist/hooks/useVirtualizer.d.ts +0 -25
  122. package/dist/hooks/useVirtualizer.js +0 -67
  123. package/dist/index.d.ts +0 -130
  124. package/dist/index.js +0 -347
  125. package/dist/loading.js +0 -6
  126. package/dist/plugins/CellChangeHighlightPlugin.d.ts +0 -2
  127. package/dist/plugins/CellChangeHighlightPlugin.js +0 -4
  128. package/dist/plugins/CellMergePlugin.d.ts +0 -12
  129. package/dist/plugins/CellMergePlugin.js +0 -2
  130. package/dist/plugins/CellSelectionPlugin.d.ts +0 -15
  131. package/dist/plugins/CellSelectionPlugin.js +0 -115
  132. package/dist/plugins/CommandPlugin.d.ts +0 -14
  133. package/dist/plugins/CommandPlugin.js +0 -12
  134. package/dist/plugins/CopyPastePlugin.d.ts +0 -14
  135. package/dist/plugins/CopyPastePlugin.js +0 -42
  136. package/dist/plugins/DiffPlugin.d.ts +0 -23
  137. package/dist/plugins/DiffPlugin.js +0 -56
  138. package/dist/plugins/DragPlugin.d.ts +0 -14
  139. package/dist/plugins/DragPlugin.js +0 -47
  140. package/dist/plugins/EditablePlugin.d.ts +0 -48
  141. package/dist/plugins/EditablePlugin.js +0 -141
  142. package/dist/plugins/ExpandPlugin.d.ts +0 -18
  143. package/dist/plugins/ExpandPlugin.js +0 -50
  144. package/dist/plugins/HistoryPlugin.d.ts +0 -10
  145. package/dist/plugins/HistoryPlugin.js +0 -30
  146. package/dist/plugins/MenuPlugin.d.ts +0 -18
  147. package/dist/plugins/MenuPlugin.js +0 -107
  148. package/dist/plugins/RenderPlugin/components.d.ts +0 -5
  149. package/dist/plugins/RenderPlugin/components.js +0 -87
  150. package/dist/plugins/RenderPlugin/index.d.ts +0 -30
  151. package/dist/plugins/RenderPlugin/index.js +0 -49
  152. package/dist/plugins/ResizePlugin.d.ts +0 -27
  153. package/dist/plugins/ResizePlugin.js +0 -81
  154. package/dist/plugins/RowGroupPlugin.d.ts +0 -17
  155. package/dist/plugins/RowGroupPlugin.js +0 -83
  156. package/dist/plugins/RowSelectionPlugin.d.ts +0 -20
  157. package/dist/plugins/RowSelectionPlugin.js +0 -42
  158. package/dist/plugins/VirtualScrollPlugin.d.ts +0 -15
  159. package/dist/plugins/VirtualScrollPlugin.js +0 -96
  160. package/dist/plus.js +0 -6
  161. package/dist/style.css +0 -3
  162. package/dist/types/auto-imports.d.js +0 -0
  163. package/dist/utils.d.ts +0 -30
  164. package/dist/utils.js +0 -70
  165. package/dist/wc.d.ts +0 -1
  166. package/dist/wc.js +0 -21
  167. package/dist/web-component.d.ts +0 -1
  168. package/dist/web-component.js +0 -2
  169. package/dist/x.js +0 -6
@@ -0,0 +1,184 @@
1
+ import { resolve, join, dirname, relative, extname } from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import { readFileSync, readdirSync, existsSync, rmSync, cpSync, writeFileSync } from 'fs'
4
+ import { build } from 'vite'
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url))
7
+ const rootDir = resolve(__dirname, '..')
8
+ const packagesDir = resolve(rootDir, 'packages')
9
+
10
+ // 获取所有包目录
11
+ function getPackages() {
12
+ const packages = []
13
+ const dirs = readdirSync(packagesDir)
14
+
15
+ for (const dir of dirs) {
16
+ const packagePath = join(packagesDir, dir)
17
+ const packageJsonPath = join(packagePath, 'package.json')
18
+
19
+ if (existsSync(packageJsonPath)) {
20
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
21
+ packages.push({
22
+ name: packageJson.name || dir,
23
+ path: packagePath,
24
+ packageJson,
25
+ })
26
+ }
27
+ }
28
+
29
+ return packages
30
+ }
31
+
32
+ // 构建单个包
33
+ async function buildPackage(pkg) {
34
+ console.log(`\n📦 Building ${pkg.name}...`)
35
+
36
+ const distPath = join(pkg.path, 'dist')
37
+
38
+ try {
39
+ await build({
40
+ configFile: process.cwd() + '/vite.config.ts',
41
+ root: pkg.path,
42
+ build: {
43
+ outDir: 'dist',
44
+ lib: {
45
+ // preserve modules
46
+ entry: Object.fromEntries(readdirSync(join(pkg.path, 'src'), { withFileTypes: false, recursive: true }).filter(e => /\.[tj]sx?$/.test(e)).map(e => [
47
+ e.slice(0, e.length - extname(e).length),
48
+ join('src', e)
49
+ ])),
50
+ formats: ['es'],
51
+ cssFileName: 'style',
52
+ },
53
+ rollupOptions: {
54
+ external: id => {
55
+ // 排除所有外部依赖
56
+ const externals = Object.keys({
57
+ ...pkg.packageJson.dependencies,
58
+ ...pkg.packageJson.devDependencies,
59
+ ...pkg.packageJson.peerDependencies,
60
+ })
61
+
62
+ // 排除特定的外部依赖
63
+ return externals.some(ext => id === ext || id.startsWith(ext + '/'))
64
+ },
65
+ output: {
66
+ preserveModules: true,
67
+ // preserveModulesRoot: join(pkg.path, 'src'),
68
+ // entryFileNames: '[name].js',
69
+ // entryFileNames: m => m.moduleIds.some(e => e.includes('node_modules')) ? 'vendor.js' : m.name + '.js',
70
+ advancedChunks: {
71
+ groups: [
72
+ { name: (id) => id.includes('node_modules') ? 'vendor' : null },
73
+ ],
74
+ }
75
+ },
76
+ },
77
+ sourcemap: false,
78
+ minify: true,
79
+ emptyOutDir: true,
80
+ },
81
+ plugins: [
82
+ (await import('vite-plugin-lib-inject-css')).libInjectCss()
83
+ ]
84
+ })
85
+
86
+ // // 复制 style.scss 文件
87
+ // const stylePath = join(pkg.path, 'src/style.scss')
88
+ // if (existsSync(stylePath)) {
89
+ // cpSync(stylePath, join(distPath, 'style.scss'))
90
+ // console.log(' ✓ Copied style.scss')
91
+ // }
92
+
93
+ if (existsSync(join(pkg.path, 'src/theme'))) {
94
+ cpSync(join(pkg.path, 'src/theme'), join(distPath, 'theme'), { recursive: true })
95
+ }
96
+
97
+ // fix: unocss
98
+ if (existsSync(join(pkg.path, 'dist/__uno.css'))) {
99
+ const uno = readFileSync(join(pkg.path, 'dist/__uno.css'), { encoding: 'utf8' })
100
+ const rewrite = (path, fn) => writeFileSync(path, fn(readFileSync(path, { encoding: 'utf8' })))
101
+ rewrite(join(pkg.path, 'dist/style.css'), str => uno + '\n' + str)
102
+ rewrite(join(pkg.path, 'dist/index.js'), str => str.replace(`import './__uno.css'`, ''))
103
+ }
104
+
105
+
106
+ console.log(`✅ ${pkg.name} built successfully!`)
107
+
108
+ await genDts(pkg.path)
109
+ } catch (error) {
110
+ console.error(`❌ Failed to build ${pkg.name}:`, error)
111
+ throw error
112
+ }
113
+ }
114
+
115
+ // 使用 tsc 生成类型定义(跳过错误)
116
+ async function genDts(cwd) {
117
+ console.log(' 📝 Generating TypeScript declarations...')
118
+ try {
119
+ const distPath = join(cwd, 'dist')
120
+ const { execSync } = await import('child_process')
121
+ const { writeFileSync } = await import('fs')
122
+
123
+ // 创建临时 tsconfig 用于生成类型定义
124
+ const tempTsConfig = {
125
+ extends: './tsconfig.app.json',
126
+ compilerOptions: {
127
+ declaration: true,
128
+ emitDeclarationOnly: true,
129
+ noEmit: false,
130
+ outDir: distPath,
131
+ skipLibCheck: true,
132
+ noUnusedLocals: false,
133
+ noUnusedParameters: false,
134
+ jsx: 'preserve',
135
+ jsxImportSource: 'solid-js',
136
+ },
137
+ include: ['src'],
138
+ }
139
+
140
+ const tempConfigPath = join(cwd, 'tsconfig.dts.json')
141
+ writeFileSync(tempConfigPath, JSON.stringify(tempTsConfig, null, 2))
142
+
143
+ try {
144
+ execSync(`pnpm exec tsc --project tsconfig.dts.json --skipLibCheck --noCheck`, { cwd, stdio: 'pipe' })
145
+ } catch (tscExecError) {
146
+ // 即使有错误也尝试查找生成的文件
147
+ const dtsFiles = readdirSync(distPath, { recursive: true }).filter(f => f.endsWith('.d.ts'))
148
+ if (dtsFiles.length > 0) {
149
+ console.log(` ℹ Generated ${dtsFiles.length} declaration files (with some errors)`)
150
+ } else {
151
+ throw tscExecError
152
+ }
153
+ }
154
+
155
+ // 删除临时配置文件
156
+ rmSync(tempConfigPath, { force: true })
157
+
158
+ console.log(' ✓ TypeScript declarations generated')
159
+ } catch (tscError) {
160
+ console.log(' ⚠ TypeScript declarations skipped')
161
+ // 不抛出错误,允许构建继续
162
+ }
163
+ }
164
+
165
+ // 主函数
166
+ async function main() {
167
+ console.log('🚀 Starting package build process...\n')
168
+
169
+ const packages = getPackages()
170
+ console.log(`Found ${packages.length} package(s):`, packages.map(p => p.name).join(', '))
171
+
172
+ // 依次构建每个包
173
+ for (const pkg of packages) {
174
+ await buildPackage(pkg)
175
+ }
176
+
177
+ console.log('\n✨ All packages built successfully!')
178
+ }
179
+
180
+ // 执行构建
181
+ main().catch(error => {
182
+ console.error('Build failed:', error)
183
+ process.exit(1)
184
+ })
@@ -0,0 +1,95 @@
1
+ import { resolve, join, dirname } from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import { readFileSync, writeFileSync, readdirSync, existsSync } from 'fs'
4
+ import { execSync } from 'child_process'
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url))
7
+ const rootDir = resolve(__dirname, '..')
8
+ const packagesDir = resolve(rootDir, 'packages')
9
+
10
+ // 获取根目录的版本号
11
+ function getRootVersion() {
12
+ const rootPackageJsonPath = join(rootDir, 'package.json')
13
+ const rootPackageJson = JSON.parse(readFileSync(rootPackageJsonPath, 'utf-8'))
14
+ return rootPackageJson.version
15
+ }
16
+
17
+ // 获取所有包目录
18
+ function getPackages() {
19
+ const packages = []
20
+ const dirs = readdirSync(packagesDir)
21
+
22
+ for (const dir of dirs) {
23
+ const packagePath = join(packagesDir, dir)
24
+ const packageJsonPath = join(packagePath, 'package.json')
25
+
26
+ if (existsSync(packageJsonPath)) {
27
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
28
+ packages.push({
29
+ name: packageJson.name || dir,
30
+ path: packagePath,
31
+ packageJson,
32
+ packageJsonPath
33
+ })
34
+ }
35
+ }
36
+
37
+ return packages
38
+ }
39
+
40
+ // 同步版本号到子包
41
+ function syncVersion(packages, version) {
42
+ console.log(`\n🔄 Syncing version ${version} to all packages...`)
43
+
44
+ for (const pkg of packages) {
45
+ if (pkg.packageJson.version !== version) {
46
+ pkg.packageJson.version = version
47
+ writeFileSync(pkg.packageJsonPath, JSON.stringify(pkg.packageJson, null, 2))
48
+ console.log(` ✅ Updated ${pkg.name} to version ${version}`)
49
+ } else {
50
+ console.log(` ℹ ${pkg.name} already at version ${version}`)
51
+ }
52
+ }
53
+ }
54
+
55
+ // 发布子包
56
+ function publishPackage(pkg) {
57
+ console.log(`\n📤 Publishing ${pkg.name}...`)
58
+
59
+ try {
60
+ execSync(`pnpm publish --no-git-checks --filter ${pkg.name}`, { stdio: 'inherit' })
61
+ console.log(` ✅ ${pkg.name} published successfully!`)
62
+ } catch (error) {
63
+ console.error(` ❌ Failed to publish ${pkg.name}:`, error.message)
64
+ throw error
65
+ }
66
+ }
67
+
68
+ // 主函数
69
+ async function main() {
70
+ console.log('🚀 Starting publish process...\n')
71
+
72
+ // 获取根目录版本号
73
+ const version = getRootVersion()
74
+ console.log(`Root version: ${version}`)
75
+
76
+ // 获取所有子包
77
+ const packages = getPackages()
78
+ console.log(`Found ${packages.length} package(s):`, packages.map(p => p.name).join(', '))
79
+
80
+ // 同步版本号
81
+ syncVersion(packages, version)
82
+
83
+ // 依次发布每个子包
84
+ for (const pkg of packages) {
85
+ await publishPackage(pkg)
86
+ }
87
+
88
+ console.log('\n✨ All packages published successfully!')
89
+ }
90
+
91
+ // 执行发布
92
+ main().catch(error => {
93
+ console.error('Publish failed:', error)
94
+ process.exit(1)
95
+ })
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor" d="m14.031 1.888l9.657 9.657l-8.345 8.345l-.27.272H20v2H6.748L.253 15.667zm.322 16.164l6.507-6.507l-6.829-6.828l-6.828 6.828l6.828 6.828l.32-.323zM5.788 12.96l-2.707 2.707l4.495 4.495h4.68l.365-.37z" />
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
3
+ d="M12 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3m7-14h7a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-7M5 7H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h1m12-5h.01M13 12h.01" />
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor"
3
+ d="M5 10H3V4h8v2H5zm14 8h-6v2h8v-6h-2zM5 18v-4H3v6h8v-2zM21 4h-8v2h6v4h2zM8 13v2l3-3l-3-3v2H3v2zm8-2V9l-3 3l3 3v-2h5v-2z" />
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor"
3
+ d="M19 14h2v6H3v-6h2v4h14zM3 4v6h2V6h14v4h2V4zm8 7v2H8v2l-3-3l3-3v2zm5 0V9l3 3l-3 3v-2h-3v-2z" />
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <path fill="currentColor" d="M19 5h-4v14h4v-2h-2V7h2zM5 5h4v14H5v-2h2V7H5zm8 2v10h-2V7z" />
3
+ </svg>
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <g>
3
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".14" />
4
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".29" transform="rotate(30 12 12)" />
5
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".43" transform="rotate(60 12 12)" />
6
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".57" transform="rotate(90 12 12)" />
7
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".71" transform="rotate(120 12 12)" />
8
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" opacity=".86" transform="rotate(150 12 12)" />
9
+ <rect width="2" height="5" x="11" y="1" fill="currentColor" transform="rotate(180 12 12)" />
10
+ <animateTransform attributeName="transform" calcMode="discrete" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12" />
11
+ </g>
12
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
3
+ color="currentColor">
4
+ <path
5
+ d="M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12s4.477 10 10 10c.842 0 2 .116 2-1c0-.609-.317-1.079-.631-1.546c-.46-.683-.917-1.359-.369-2.454c.667-1.333 1.778-1.333 3.482-1.333c.851 0 1.851 0 3.018-.167c2.101-.3 2.5-1.592 2.5-3.5M7 15.002L7.009 15" />
6
+ <circle cx="9.5" cy="8.5" r="1.5" />
7
+ <circle cx="16.5" cy="9.5" r="1.5" />
8
+ </g>
9
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 166 155.3"><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" fill="#76b3e1"/><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="27.5" y1="3" x2="152" y2="63.5"><stop offset=".1" stop-color="#76b3e1"/><stop offset=".3" stop-color="#dcf2fd"/><stop offset="1" stop-color="#76b3e1"/></linearGradient><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" opacity=".3" fill="url(#a)"/><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" fill="#518ac8"/><linearGradient id="b" gradientUnits="userSpaceOnUse" x1="95.8" y1="32.6" x2="74" y2="105.2"><stop offset="0" stop-color="#76b3e1"/><stop offset=".5" stop-color="#4377bb"/><stop offset="1" stop-color="#1f3b77"/></linearGradient><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" opacity=".3" fill="url(#b)"/><linearGradient id="c" gradientUnits="userSpaceOnUse" x1="18.4" y1="64.2" x2="144.3" y2="149.8"><stop offset="0" stop-color="#315aa9"/><stop offset=".5" stop-color="#518ac8"/><stop offset="1" stop-color="#315aa9"/></linearGradient><path d="M134 80a45 45 0 00-48-15L24 85 4 120l112 19 20-36c4-7 3-15-2-23z" fill="url(#c)"/><linearGradient id="d" gradientUnits="userSpaceOnUse" x1="75.2" y1="74.5" x2="24.4" y2="260.8"><stop offset="0" stop-color="#4377bb"/><stop offset=".5" stop-color="#1a336b"/><stop offset="1" stop-color="#1a336b"/></linearGradient><path d="M114 115a45 45 0 00-48-15L4 120s53 40 94 30l3-1c17-5 23-21 13-34z" fill="url(#d)"/></svg>
@@ -0,0 +1,54 @@
1
+ // import './index.scss'
2
+ import 'virtual:uno.css'
3
+
4
+ import { createApp, h, ref, shallowRef, toRaw, watchEffect } from 'vue'
5
+ // import Intable from '@intable/vue'
6
+ import Intable from '../packages/vue/src'
7
+
8
+ // import './theme/element-plus.scss'
9
+ import { log } from 'intable/utils'
10
+ import { createMutable } from 'solid-js/store'
11
+ import { effect } from 'solid-js/web'
12
+ import { batch, createComputed, createEffect, createMemo } from 'solid-js'
13
+
14
+ const container = document.createElement('div')
15
+ document.body.append(container)
16
+
17
+ const data = ref([{ id: '1', date: '2016-05-03' },{date: 'xxx'}])
18
+ setTimeout(() => {
19
+ // data.value = [
20
+ // { id: 1, date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
21
+ // { id: 2, date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
22
+ // { id: 3, date: '2016-05-03', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' },
23
+ // ]
24
+ }, 1000);
25
+
26
+ const selected = ref([])
27
+ watchEffect(() => {
28
+ // console.log(selected.value)
29
+ // console.log(data.value)
30
+ })
31
+
32
+ createApp(() => [
33
+ h(Intable, {
34
+ style: 'width: 600px; margin: 64px',
35
+ class: 'w-100 m-4',
36
+ data: data.value,
37
+ 'onUpdate:data': v => data.value = v,
38
+ onDataChange: v => data.value = v,
39
+ border: true,
40
+ index: true,
41
+ size: 'small',
42
+ columns: [
43
+ { name: 'Date', id: 'date', editable: true, enum: { a: 1 }, editor: 'date' },
44
+ { name: 'Name', id: 'name' },
45
+ { name: 'Address', id: 'address', width: 250 },
46
+ // todo re render
47
+ { name: '4', id: '4', render: o => h('div', { class: 'c-red' }, '111'), fixed: 'right' },
48
+ ],
49
+ selected: selected.value,
50
+ 'onUpdate:selected': v => selected.value = v,
51
+ rowSelection: { enable: true }
52
+ }),
53
+ ])
54
+ .mount(container)
package/src/demo.tsx ADDED
@@ -0,0 +1,107 @@
1
+ import { batch, createComputed, createMemo } from 'solid-js'
2
+ import { render } from 'solid-js/web'
3
+ import { createMutable, createStore, produce, reconcile } from 'solid-js/store'
4
+ import { range } from 'es-toolkit'
5
+
6
+ // import Intable from 'intable'
7
+ // import { log } from 'intable/utils'
8
+ // import { VirtualScrollPlugin } from 'intable/plugins/VirtualScrollPlugin'
9
+
10
+ import { Intable } from '../packages/intable/src'
11
+ // import '../packages/intable/src/theme/element-plus.scss'
12
+ import { log } from '../packages/intable/src/utils'
13
+ import { VirtualScrollPlugin } from '../packages/intable/src/plugins/VirtualScrollPlugin'
14
+ import { HistoryPlugin } from '../packages/intable/src/plugins/HistoryPlugin'
15
+ import { DiffPlugin } from '../packages/intable/src/plugins/DiffPlugin'
16
+ // import 'intable/theme/element-plus.scss'
17
+ // import 'intable/dist/theme/element-plus.scss'
18
+
19
+ const root = document.body.appendChild(document.createElement('div'))
20
+
21
+ const state = createMutable({ bool: true })
22
+
23
+ const cols = createMutable([
24
+ { name: '基本信息', children: [
25
+ { id: 'col_0', name: 'col_0', width: 80, editable: true },
26
+ { id: 'col_1', name: 'col_1', width: 80, editable: true },
27
+ { name: '333', width: 80, editable: true },
28
+ ]},
29
+ { name: 'xxx' },
30
+ { name: '详细数据', children: [
31
+ { id: 'col_2', name: 'col_2', width: 80, editable: true },
32
+ { id: 'col_3', name: 'col_3', width: 80, editable: true },
33
+ { id: 'col_4', name: 'col_4', width: 80, editable: true },
34
+ ]},
35
+ ...range(20).map(e => ({ name: 'col_' + (e + 5), id: 'col_' + (e + 5), width: 80, editable: true })),
36
+ ] as any[])
37
+ const leafColIds = range(20).map(e => 'col_' + e)
38
+ let data = createMutable(range(500).map((e, i) => Object.fromEntries(leafColIds.map(id => [id, id + '_' + i + 1]))))
39
+
40
+ // render(() => <input type='checkbox' checked={state.bool} onChange={(e) => state.bool = e.currentTarget.checked} />, root)
41
+ // render(() => <button onClick={() => data[0].col_1 = 'xxx'}>xxx</button>, root)
42
+
43
+ // const cols = [{name:'asd'},{}]
44
+ // const data = [{},{},{}]
45
+ // const data = [{},{},{}]
46
+
47
+ // cols[2].fixed = 'left'
48
+ // cols[0].editable = true
49
+ // cols[0].editor = 'select'
50
+ // cols[0].enum = { 1: 1, 2: 2, 3: 3 }
51
+ // cols[0].render = 'file'
52
+ // cols.forEach(e => (e.editable = true))
53
+
54
+ // cols.at(-3)!.width = undefined
55
+ // cols.at(-1)!.width = undefined
56
+
57
+ cols.unshift({ name: 'qwe' })
58
+
59
+ cols[0].fixed = 'left'
60
+ cols.at(-2)!.fixed = 'right'
61
+ cols.at(-1)!.fixed = 'right'
62
+
63
+ data.forEach(e => e.g = e.col_0 % 10)
64
+ data.forEach(e => e.n = e.col_0 % 3)
65
+
66
+ // render(() => (
67
+ // <Menu items={[
68
+ // { label: 'xx' }
69
+ // ]} />
70
+ // ), root)
71
+
72
+ render(() => <Intable
73
+ class='w-50vw! h-40vh m-10'
74
+ // class='m-10'
75
+ // style='width: 50vw; height: 40vh;'
76
+ rowDrag
77
+ colDrag
78
+ size='small'
79
+ index={state.bool}
80
+ stickyHeader={state.bool}
81
+ columns={cols}
82
+ onColumnsChange={v => batch(() => (cols.length = 0, cols.push(...v)))}
83
+ data={data}
84
+ onDataChange={v => batch(() => (data.length = 0, data.push(...v)))}
85
+ border
86
+ resizable={{ row: { enable: true } }}
87
+ plugins={[
88
+ VirtualScrollPlugin,
89
+ // HistoryPlugin,
90
+ // DiffPlugin,
91
+ ]}
92
+ expand={{ enable: true, render: ({ data }) => <div class='p-2 c-red'>{JSON.stringify(data)}</div> }}
93
+ // rowGroup={{ fields: ['g', 'n'] }}
94
+ // rowGroup={{ fields: ['g'] }}
95
+ diff={{
96
+ onCommit: (...arg) => log(arg)
97
+ }}
98
+ virtual={{
99
+ // x: { enable: true, overscan: 0 },
100
+ // y: { enable: false },
101
+ }}
102
+ rowSelection={{
103
+ // enable: true,
104
+ // multiple: true,
105
+ // onChange: (selected, unselected) => log(selected, unselected)
106
+ }}
107
+ />, root)
package/src/index.scss ADDED
@@ -0,0 +1,105 @@
1
+ :root {
2
+ color-scheme: light;
3
+ --bg: #fff;
4
+ --menu-bg: #fff;
5
+ --header-bg: #f6f6f7;
6
+ }
7
+
8
+ .dark {
9
+ color-scheme: dark;
10
+ --bg: #121212;
11
+ --menu-bg: #121212;
12
+ --header-bg: #161618;
13
+ }
14
+
15
+ body {
16
+ @apply bg-[--bg] m-0;
17
+ }
18
+
19
+ button {
20
+ border-radius: 8px;
21
+ border: 1px solid transparent;
22
+ font-size: 1em;
23
+ cursor: pointer;
24
+ transition: border-color 0.25s;
25
+ }
26
+ button:hover {
27
+ border-color: #646cff;
28
+ }
29
+ button:focus,
30
+ button:focus-visible {
31
+ outline: 4px auto -webkit-focus-ring-color;
32
+ }
33
+
34
+ img, iframe {
35
+ // margin: 1rem 0;
36
+ }
37
+
38
+ mark {
39
+ padding: .1rem .3rem;
40
+ }
41
+
42
+ .col-hand {
43
+ --w: 4px;
44
+ position: absolute;
45
+ top: 0;
46
+ left: 100%;
47
+ height: 100%;
48
+ // flex: 0 0 auto;
49
+ width: var(--gap);
50
+ cursor: w-resize;
51
+ display: flex;
52
+ justify-content: center;
53
+ opacity: 0;
54
+ transition: opacity 100ms linear;
55
+
56
+ &:hover, &:active {
57
+ opacity: 1;
58
+ }
59
+
60
+ &::after {
61
+ content: '';
62
+ display: block;
63
+ flex-shrink: 0;
64
+ width: 4px;
65
+ height: 100%;
66
+ background: rgba(gray, .5);
67
+ }
68
+
69
+ > .dot {
70
+ --w: 20px;
71
+ position: absolute;
72
+ top: 0;
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+ transform: translateY(-50%);
77
+ width: calc(var(--w) * 1);
78
+ height: calc(var(--w) * 1);
79
+
80
+ &:hover {
81
+ &::after {
82
+ content: '+';
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: center;
86
+ width: calc(var(--w) * 1);
87
+ height: calc(var(--w) * 1);
88
+ background-color: rgba(blue, .75);
89
+ box-shadow: 0 4px 6px rgba(#000, .2);
90
+ }
91
+ }
92
+
93
+ &::after {
94
+ content: '';
95
+ display: block;
96
+ width: 8px;
97
+ height: 8px;
98
+ color: #fff;
99
+ background-color: rgba(blue, .5);
100
+ border-radius: 50%;
101
+ transition: all 100ms;
102
+ cursor: pointer;
103
+ }
104
+ }
105
+ }