intable 0.0.6 → 0.0.8

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 (197) hide show
  1. package/.github/copilot-instructions.md +102 -0
  2. package/README.md +16 -263
  3. package/docs/index-BaMALNy6.css +1 -0
  4. package/docs/index-CDN48t9E.js +3 -0
  5. package/docs/index-Cc4RNkLY.css +1 -0
  6. package/docs/index-MRnbkYmU.js +3 -0
  7. package/docs/index.html +15 -0
  8. package/docs/vite.svg +1 -0
  9. package/index.html +13 -0
  10. package/package.json +35 -38
  11. package/packages/intable/README.md +379 -0
  12. package/packages/intable/package.json +51 -0
  13. package/packages/intable/src/assets/ClearFormat.svg +3 -0
  14. package/packages/intable/src/assets/Forms.svg +4 -0
  15. package/packages/intable/src/assets/MergeCell.svg +4 -0
  16. package/packages/intable/src/assets/SplitCell.svg +4 -0
  17. package/packages/intable/src/assets/gap.svg +3 -0
  18. package/packages/intable/src/assets/loading.svg +12 -0
  19. package/packages/intable/src/assets/paint.svg +9 -0
  20. package/packages/intable/src/assets/solid.svg +1 -0
  21. package/packages/intable/src/components/Columns.tsx +86 -0
  22. package/packages/intable/src/components/DocTree.tsx +36 -0
  23. package/packages/intable/src/components/Menu.tsx +109 -0
  24. package/packages/intable/src/components/Popover.tsx +55 -0
  25. package/packages/intable/src/components/RecycleList.tsx +99 -0
  26. package/packages/intable/src/components/Render.tsx +26 -0
  27. package/packages/intable/src/components/Split.tsx +56 -0
  28. package/packages/intable/src/components/Tree.tsx +115 -0
  29. package/packages/intable/src/components/utils.tsx +12 -0
  30. package/packages/intable/src/hooks/index.ts +200 -0
  31. package/packages/intable/src/hooks/useDir.ts +78 -0
  32. package/packages/intable/src/hooks/useSelector.ts +91 -0
  33. package/packages/intable/src/hooks/useSort.tsx +118 -0
  34. package/packages/intable/src/hooks/useVirtualizer.ts +180 -0
  35. package/packages/intable/src/index.tsx +489 -0
  36. package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +5 -0
  37. package/packages/intable/src/plugins/CellMergePlugin.tsx +153 -0
  38. package/packages/intable/src/plugins/CellSelectionPlugin.tsx +175 -0
  39. package/packages/intable/src/plugins/CommandPlugin.tsx +74 -0
  40. package/packages/intable/src/plugins/CopyPastePlugin.tsx +99 -0
  41. package/packages/intable/src/plugins/DiffPlugin.tsx +120 -0
  42. package/packages/intable/src/plugins/DragPlugin.tsx +81 -0
  43. package/packages/intable/src/plugins/EditablePlugin.tsx +252 -0
  44. package/packages/intable/src/plugins/ExpandPlugin.tsx +80 -0
  45. package/packages/intable/src/plugins/HeaderGroup.tsx +289 -0
  46. package/packages/intable/src/plugins/HistoryPlugin.tsx +49 -0
  47. package/packages/intable/src/plugins/MenuPlugin.tsx +195 -0
  48. package/packages/intable/src/plugins/RenderPlugin/components.tsx +51 -0
  49. package/packages/intable/src/plugins/RenderPlugin/index.tsx +81 -0
  50. package/packages/intable/src/plugins/ResizePlugin.tsx +122 -0
  51. package/packages/intable/src/plugins/RowGroupPlugin.tsx +122 -0
  52. package/packages/intable/src/plugins/RowSelectionPlugin.tsx +65 -0
  53. package/packages/intable/src/plugins/TreePlugin.tsx +212 -0
  54. package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +190 -0
  55. package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +61 -0
  56. package/packages/intable/src/style.scss +244 -0
  57. package/{dist → packages/intable/src}/theme/antd.scss +14 -5
  58. package/packages/intable/src/theme/dark.scss +46 -0
  59. package/{dist → packages/intable/src}/theme/element-plus.scss +6 -5
  60. package/packages/intable/src/theme/github.scss +80 -0
  61. package/packages/intable/src/theme/material.scss +73 -0
  62. package/packages/intable/src/theme/shadcn.scss +66 -0
  63. package/packages/intable/src/theme/stripe.scss +57 -0
  64. package/packages/intable/src/tree.ts +13 -0
  65. package/packages/intable/src/types/auto-imports.d.ts +13 -0
  66. package/packages/intable/src/utils.ts +122 -0
  67. package/packages/intable/src/wc.tsx +35 -0
  68. package/packages/intable/src/web-component.ts +1 -0
  69. package/packages/react/package.json +36 -0
  70. package/packages/react/src/index.ts +44 -0
  71. package/packages/react/src/plugins/antd.ts +94 -0
  72. package/packages/react/src/style.scss +12 -0
  73. package/packages/react/src/types/auto-imports.d.ts +10 -0
  74. package/packages/vue/package.json +34 -0
  75. package/packages/vue/src/index.ts +63 -0
  76. package/packages/vue/src/plugins/element-plus.ts +69 -0
  77. package/packages/vue/src/style.scss +12 -0
  78. package/packages/vue/src/types/auto-imports.d.ts +10 -0
  79. package/pnpm-workspace.yaml +2 -0
  80. package/public/vite.svg +1 -0
  81. package/scripts/build.js +184 -0
  82. package/scripts/publish.js +95 -0
  83. package/src/assets/ClearFormat.svg +3 -0
  84. package/src/assets/Forms.svg +4 -0
  85. package/src/assets/MergeCell.svg +4 -0
  86. package/src/assets/SplitCell.svg +4 -0
  87. package/src/assets/gap.svg +3 -0
  88. package/src/assets/loading.svg +12 -0
  89. package/src/assets/paint.svg +9 -0
  90. package/src/assets/solid.svg +1 -0
  91. package/src/demo-vue.ts +54 -0
  92. package/src/index.scss +105 -0
  93. package/src/index.tsx +20 -0
  94. package/src/pages/demo/BasicDemo.tsx +19 -0
  95. package/src/pages/demo/CellMergeDemo.tsx +41 -0
  96. package/src/pages/demo/CellSelectionDemo.tsx +24 -0
  97. package/src/pages/demo/CompositeDemo.tsx +60 -0
  98. package/src/pages/demo/CopyPasteDemo.tsx +26 -0
  99. package/src/pages/demo/DiffDemo.tsx +33 -0
  100. package/src/pages/demo/DragDemo.tsx +25 -0
  101. package/src/pages/demo/EditableDemo.tsx +58 -0
  102. package/src/pages/demo/ExpandDemo.tsx +32 -0
  103. package/src/pages/demo/HeaderGroupDemo.tsx +36 -0
  104. package/src/pages/demo/HistoryDemo.tsx +28 -0
  105. package/src/pages/demo/ReactDemo.tsx +59 -0
  106. package/src/pages/demo/ResizeDemo.tsx +24 -0
  107. package/src/pages/demo/RowGroupDemo.tsx +43 -0
  108. package/src/pages/demo/RowSelectionDemo.tsx +27 -0
  109. package/src/pages/demo/TreeDemo.tsx +45 -0
  110. package/src/pages/demo/VirtualScrollDemo.tsx +21 -0
  111. package/src/pages/demo/helpers.tsx +39 -0
  112. package/src/pages/demo/index.tsx +180 -0
  113. package/src/pages/index.tsx +2 -0
  114. package/src/pages/website.scss +37 -0
  115. package/src/pages/website.tsx +651 -0
  116. package/src/styles/index.scss +172 -0
  117. package/src/types/auto-imports.d.ts +13 -0
  118. package/stats.html +4949 -0
  119. package/tsconfig.app.json +34 -0
  120. package/tsconfig.json +7 -0
  121. package/tsconfig.node.json +26 -0
  122. package/vite.config.ts +70 -0
  123. package/dist/__uno.css +0 -1
  124. package/dist/chevron-right.js +0 -6
  125. package/dist/components/Columns.d.ts +0 -3
  126. package/dist/components/Columns.js +0 -71
  127. package/dist/components/DocTree.d.ts +0 -4
  128. package/dist/components/DocTree.js +0 -32
  129. package/dist/components/Menu.d.ts +0 -1
  130. package/dist/components/Menu.js +0 -107
  131. package/dist/components/Popover.d.ts +0 -14
  132. package/dist/components/Popover.js +0 -41
  133. package/dist/components/Render.d.ts +0 -4
  134. package/dist/components/Render.js +0 -20
  135. package/dist/components/Split.d.ts +0 -15
  136. package/dist/components/Split.js +0 -76
  137. package/dist/components/Tree.d.ts +0 -37
  138. package/dist/components/Tree.js +0 -82
  139. package/dist/components/utils.d.ts +0 -3
  140. package/dist/components/utils.js +0 -8
  141. package/dist/hooks/index.d.ts +0 -40
  142. package/dist/hooks/index.js +0 -157
  143. package/dist/hooks/useDir.d.ts +0 -11
  144. package/dist/hooks/useDir.js +0 -42
  145. package/dist/hooks/useSelector.d.ts +0 -16
  146. package/dist/hooks/useSelector.js +0 -35
  147. package/dist/hooks/useSort.d.ts +0 -18
  148. package/dist/hooks/useSort.js +0 -83
  149. package/dist/hooks/useVirtualizer.d.ts +0 -25
  150. package/dist/hooks/useVirtualizer.js +0 -67
  151. package/dist/index.d.ts +0 -130
  152. package/dist/index.js +0 -347
  153. package/dist/loading.js +0 -6
  154. package/dist/plugins/CellChangeHighlightPlugin.d.ts +0 -2
  155. package/dist/plugins/CellChangeHighlightPlugin.js +0 -4
  156. package/dist/plugins/CellMergePlugin.d.ts +0 -12
  157. package/dist/plugins/CellMergePlugin.js +0 -2
  158. package/dist/plugins/CellSelectionPlugin.d.ts +0 -15
  159. package/dist/plugins/CellSelectionPlugin.js +0 -115
  160. package/dist/plugins/CommandPlugin.d.ts +0 -14
  161. package/dist/plugins/CommandPlugin.js +0 -12
  162. package/dist/plugins/CopyPastePlugin.d.ts +0 -14
  163. package/dist/plugins/CopyPastePlugin.js +0 -42
  164. package/dist/plugins/DiffPlugin.d.ts +0 -23
  165. package/dist/plugins/DiffPlugin.js +0 -56
  166. package/dist/plugins/DragPlugin.d.ts +0 -14
  167. package/dist/plugins/DragPlugin.js +0 -47
  168. package/dist/plugins/EditablePlugin.d.ts +0 -48
  169. package/dist/plugins/EditablePlugin.js +0 -141
  170. package/dist/plugins/ExpandPlugin.d.ts +0 -18
  171. package/dist/plugins/ExpandPlugin.js +0 -50
  172. package/dist/plugins/HistoryPlugin.d.ts +0 -10
  173. package/dist/plugins/HistoryPlugin.js +0 -30
  174. package/dist/plugins/MenuPlugin.d.ts +0 -18
  175. package/dist/plugins/MenuPlugin.js +0 -107
  176. package/dist/plugins/RenderPlugin/components.d.ts +0 -5
  177. package/dist/plugins/RenderPlugin/components.js +0 -87
  178. package/dist/plugins/RenderPlugin/index.d.ts +0 -30
  179. package/dist/plugins/RenderPlugin/index.js +0 -49
  180. package/dist/plugins/ResizePlugin.d.ts +0 -27
  181. package/dist/plugins/ResizePlugin.js +0 -81
  182. package/dist/plugins/RowGroupPlugin.d.ts +0 -17
  183. package/dist/plugins/RowGroupPlugin.js +0 -83
  184. package/dist/plugins/RowSelectionPlugin.d.ts +0 -20
  185. package/dist/plugins/RowSelectionPlugin.js +0 -42
  186. package/dist/plugins/VirtualScrollPlugin.d.ts +0 -15
  187. package/dist/plugins/VirtualScrollPlugin.js +0 -96
  188. package/dist/plus.js +0 -6
  189. package/dist/style.css +0 -3
  190. package/dist/types/auto-imports.d.js +0 -0
  191. package/dist/utils.d.ts +0 -30
  192. package/dist/utils.js +0 -70
  193. package/dist/wc.d.ts +0 -1
  194. package/dist/wc.js +0 -21
  195. package/dist/web-component.d.ts +0 -1
  196. package/dist/web-component.js +0 -2
  197. package/dist/x.js +0 -6
@@ -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/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
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,20 @@
1
+ import { render, Suspense } from 'solid-js/web'
2
+ import { HashRouter } from '@solidjs/router'
3
+ import routes from '~solid-pages'
4
+
5
+ render(
6
+ () => {
7
+ return (
8
+ <HashRouter
9
+ root={props => (
10
+ <Suspense>
11
+ {props.children}
12
+ </Suspense>
13
+ )}
14
+ >
15
+ {routes}
16
+ </HashRouter>
17
+ )
18
+ },
19
+ document.getElementById('root') as HTMLElement,
20
+ )
@@ -0,0 +1,19 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { makeCols, makeData, replaceArray } from './helpers'
3
+
4
+ const cols = makeCols(6)
5
+ const data = makeData(20, 6)
6
+
7
+ export const BasicDemo = () => (
8
+ <Intable
9
+ class='w-full h-60vh'
10
+ columns={cols}
11
+ onColumnsChange={v => replaceArray(cols, v)}
12
+ data={data}
13
+ onDataChange={v => replaceArray(data, v)}
14
+ index
15
+ border
16
+ stickyHeader
17
+ size='small'
18
+ />
19
+ )
@@ -0,0 +1,41 @@
1
+ import { createMutable } from 'solid-js/store'
2
+ import { range } from 'es-toolkit'
3
+ import { Intable } from '../../../packages/intable/src'
4
+ import { CellMergePlugin } from '../../../packages/intable/src/plugins/CellMergePlugin'
5
+ import { replaceArray } from './helpers'
6
+
7
+ const cols = createMutable([
8
+ { id: 'group', name: 'Group', width: 100, mergeRow: true },
9
+ { id: 'name', name: 'Name', width: 120 },
10
+ { id: 'value', name: 'Value', width: 100 },
11
+ { id: 'score', name: 'Score', width: 100 },
12
+ ] as any[])
13
+
14
+ const data = createMutable(
15
+ range(20).map(i => ({
16
+ id: i,
17
+ group: 'G' + Math.floor(i / 4),
18
+ name: 'Item ' + i,
19
+ value: (i * 7) % 100,
20
+ score: (i * 13) % 100,
21
+ })),
22
+ )
23
+
24
+ /**
25
+ * The "Group" column auto-merges consecutive rows with equal values (mergeRow: true).
26
+ * CellMergePlugin is added manually since it's not a default plugin.
27
+ */
28
+ export const CellMergeDemo = () => (
29
+ <Intable
30
+ class='w-full h-60vh'
31
+ columns={cols}
32
+ onColumnsChange={v => replaceArray(cols, v)}
33
+ data={data}
34
+ onDataChange={v => replaceArray(data, v)}
35
+ index
36
+ border
37
+ stickyHeader
38
+ size='small'
39
+ plugins={[CellMergePlugin]}
40
+ />
41
+ )
@@ -0,0 +1,24 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { makeCols, makeData, replaceArray } from './helpers'
3
+
4
+ const cols = makeCols(8)
5
+ const data = makeData(30, 8)
6
+
7
+ /**
8
+ * CellSelection is auto-loaded.
9
+ * Click a cell then drag or shift+click to select a range.
10
+ * Arrow keys to navigate.
11
+ */
12
+ export const CellSelectionDemo = () => (
13
+ <Intable
14
+ class='w-full h-60vh'
15
+ columns={cols}
16
+ onColumnsChange={v => replaceArray(cols, v)}
17
+ data={data}
18
+ onDataChange={v => replaceArray(data, v)}
19
+ index
20
+ border
21
+ stickyHeader
22
+ size='small'
23
+ />
24
+ )
@@ -0,0 +1,60 @@
1
+ import { batch } from 'solid-js'
2
+ import { createMutable } from 'solid-js/store'
3
+ import { range } from 'es-toolkit'
4
+ import { Intable } from '../../../packages/intable/src'
5
+ import { VirtualScrollPlugin } from '../../../packages/intable/src/plugins/VirtualScrollPlugin'
6
+ import { HistoryPlugin } from '../../../packages/intable/src/plugins/HistoryPlugin'
7
+ import { DiffPlugin } from '../../../packages/intable/src/plugins/DiffPlugin'
8
+ import { replaceArray } from './helpers'
9
+
10
+ const cols = createMutable([
11
+ { name: 'Basic Info', children: [
12
+ { id: 'col_0', name: 'Name', width: 100, editable: true },
13
+ { id: 'col_1', name: 'Age', width: 80, editable: true, editor: 'number' },
14
+ ]},
15
+ { id: 'col_2', name: 'Status', width: 100, editable: true, editor: 'select', enum: { active: 'Active', inactive: 'Inactive' } },
16
+ { name: 'Details', children: [
17
+ { id: 'col_3', name: 'City', width: 100, editable: true },
18
+ { id: 'col_4', name: 'Score', width: 80, editable: true, editor: 'number' },
19
+ ]},
20
+ ...range(5).map(i => ({ id: 'col_' + (i + 5), name: 'Extra ' + i, width: 80, editable: true })),
21
+ ] as any[])
22
+
23
+ const leafColIds = range(10).map(i => 'col_' + i)
24
+ const data = createMutable(
25
+ range(200).map((_, i) => ({
26
+ id: i,
27
+ ...Object.fromEntries(leafColIds.map(id => [id, `${id}_${i + 1}`])),
28
+ g: i % 5,
29
+ })),
30
+ )
31
+
32
+ cols.at(-1)!.fixed = 'right'
33
+
34
+ /**
35
+ * Everything combined: header groups, virtual scroll, editable,
36
+ * expand, row selection, resize, drag, history, diff, index, border.
37
+ */
38
+ export const CompositeDemo = () => (
39
+ <div>
40
+ <p class='text-sm c-gray mb-2'>All features enabled. Edit, drag, resize, select, expand, undo/redo, diff.</p>
41
+ <Intable
42
+ class='w-full h-60vh'
43
+ columns={cols}
44
+ onColumnsChange={v => replaceArray(cols, v)}
45
+ data={data}
46
+ onDataChange={v => replaceArray(data, v)}
47
+ index
48
+ border
49
+ stickyHeader
50
+ size='small'
51
+ colDrag
52
+ rowDrag
53
+ resizable={{ col: { enable: true }, row: { enable: true } }}
54
+ expand={{ enable: true, render: ({ data }) => <div class='p-2 c-blue'>{JSON.stringify(data)}</div> }}
55
+ rowSelection={{ enable: true, multiple: true }}
56
+ plugins={[VirtualScrollPlugin, HistoryPlugin, DiffPlugin]}
57
+ diff={{ onCommit: (d) => console.log('commit', d) }}
58
+ />
59
+ </div>
60
+ )
@@ -0,0 +1,26 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { makeCols, makeData, replaceArray } from './helpers'
3
+
4
+ const cols = makeCols(6, { editable: true })
5
+ const data = makeData(20, 6)
6
+
7
+ /**
8
+ * Select a cell range then Ctrl+C to copy, Ctrl+V to paste.
9
+ * CopyPaste (ClipboardPlugin) is auto-loaded.
10
+ */
11
+ export const CopyPasteDemo = () => (
12
+ <div>
13
+ <p class='text-sm c-gray mb-2'>Select cells → Ctrl+C to copy → click target cell → Ctrl+V to paste.</p>
14
+ <Intable
15
+ class='w-full h-50vh'
16
+ columns={cols}
17
+ onColumnsChange={v => replaceArray(cols, v)}
18
+ data={data}
19
+ onDataChange={v => replaceArray(data, v)}
20
+ index
21
+ border
22
+ stickyHeader
23
+ size='small'
24
+ />
25
+ </div>
26
+ )
@@ -0,0 +1,33 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { DiffPlugin } from '../../../packages/intable/src/plugins/DiffPlugin'
3
+ import { makeCols, makeData, replaceArray } from './helpers'
4
+
5
+ const cols = makeCols(5, { editable: true })
6
+ const data = makeData(15, 5)
7
+
8
+ /**
9
+ * Edit cells — changed cells are highlighted.
10
+ * Right-click → add/delete rows shows added/removed highlights.
11
+ * Press Ctrl+S to commit & clear highlights.
12
+ */
13
+ export const DiffDemo = () => (
14
+ <div>
15
+ <p class='text-sm c-gray mb-2'>Edit cells to see change highlights. Ctrl+S to commit.</p>
16
+ <Intable
17
+ class='w-full h-50vh'
18
+ columns={cols}
19
+ onColumnsChange={v => replaceArray(cols, v)}
20
+ data={data}
21
+ onDataChange={v => replaceArray(data, v)}
22
+ index
23
+ border
24
+ stickyHeader
25
+ size='small'
26
+ plugins={[DiffPlugin]}
27
+ diff={{
28
+ enable: true,
29
+ onCommit: (d) => console.log('Diff committed:', d),
30
+ }}
31
+ />
32
+ </div>
33
+ )
@@ -0,0 +1,25 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { makeCols, makeData, replaceArray } from './helpers'
3
+
4
+ const cols = makeCols(6)
5
+ const data = makeData(20, 6)
6
+
7
+ /**
8
+ * Drag column headers to reorder columns.
9
+ * Drag the index cell (row number) to reorder rows.
10
+ */
11
+ export const DragDemo = () => (
12
+ <Intable
13
+ class='w-full h-60vh'
14
+ columns={cols}
15
+ onColumnsChange={v => replaceArray(cols, v)}
16
+ data={data}
17
+ onDataChange={v => replaceArray(data, v)}
18
+ index
19
+ border
20
+ stickyHeader
21
+ size='small'
22
+ colDrag
23
+ rowDrag
24
+ />
25
+ )
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod'
2
+ import { createMutable } from 'solid-js/store'
3
+ import { Intable } from '../../../packages/intable/src'
4
+ import { ZodValidatorPlugin } from '../../../packages/intable/src/plugins/ZodValidatorPlugin'
5
+ import { makeData, replaceArray } from './helpers'
6
+
7
+ const RESERVED = ['admin', 'root', 'null']
8
+
9
+ const cols = createMutable([
10
+ {
11
+ id: 'col_0', name: 'Text (1–20 chars, no reserved)', width: 180, editable: true,
12
+ zodSchema: z.string().min(1, 'Required').max(20, 'Max 20 characters'),
13
+ validator: (value: string) =>
14
+ RESERVED.includes(value.toLowerCase()) ? `"${value}" is a reserved word` : true,
15
+ },
16
+ {
17
+ id: 'col_1', name: 'Number (0–100)', width: 140, editable: true, editor: 'number',
18
+ zodSchema: z.coerce.number({ error: 'Must be a number' }).min(0, 'Min 0').max(100, 'Max 100'),
19
+ },
20
+ { id: 'col_2', name: 'Date', width: 130, editable: true, editor: 'date' },
21
+ { id: 'col_3', name: 'Color', width: 100, editable: true, editor: 'color' },
22
+ { id: 'col_4', name: 'Checkbox', width: 100, editable: true, editor: 'checkbox' },
23
+ {
24
+ id: 'col_5', name: 'Select', width: 120, editable: true, editor: 'select',
25
+ enum: { A: 'Option A', B: 'Option B', C: 'Option C' },
26
+ },
27
+ { id: 'col_6', name: 'Range', width: 120, editable: true, editor: 'range' },
28
+ { id: 'col_7', name: 'ReadOnly', width: 100 },
29
+ ] as any[])
30
+
31
+ const data = makeData(20, 8)
32
+
33
+ /**
34
+ * Double-click (or start typing) on an editable cell to enter edit mode.
35
+ * Press Enter or click outside to commit. Escape to cancel.
36
+ *
37
+ * Validation:
38
+ * - Text: Zod min/max length + col.validator blocks reserved words
39
+ * - Number: Zod coerce + range 0–100
40
+ * - Table-level validator: blocks any value containing "error"
41
+ */
42
+ export const EditableDemo = () => (
43
+ <Intable
44
+ class='w-full h-60vh'
45
+ columns={cols}
46
+ onColumnsChange={v => replaceArray(cols, v)}
47
+ data={data}
48
+ onDataChange={v => replaceArray(data, v)}
49
+ index
50
+ border
51
+ stickyHeader
52
+ size='small'
53
+ plugins={[ZodValidatorPlugin]}
54
+ validator={(value) =>
55
+ String(value ?? '').toLowerCase().includes('error') ? 'Value must not contain "error"' : true
56
+ }
57
+ />
58
+ )
@@ -0,0 +1,32 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { makeCols, makeData, replaceArray } from './helpers'
3
+
4
+ const cols = makeCols(6)
5
+ const data = makeData(20, 6)
6
+
7
+ /**
8
+ * Click the chevron on the left to expand a row.
9
+ * The expand render shows JSON of the row data.
10
+ */
11
+ export const ExpandDemo = () => (
12
+ <Intable
13
+ class='w-full h-60vh'
14
+ columns={cols}
15
+ onColumnsChange={v => replaceArray(cols, v)}
16
+ data={data}
17
+ onDataChange={v => replaceArray(data, v)}
18
+ index
19
+ border
20
+ stickyHeader
21
+ size='small'
22
+ expand={{
23
+ enable: true,
24
+ render: ({ data }) => (
25
+ <div class='p-3 bg-gray-50 text-sm'>
26
+ <b>Row Detail:</b>
27
+ <pre class='mt-1'>{JSON.stringify(data, null, 2)}</pre>
28
+ </div>
29
+ ),
30
+ }}
31
+ />
32
+ )
@@ -0,0 +1,36 @@
1
+ import { createMutable } from 'solid-js/store'
2
+ import { Intable } from '../../../packages/intable/src'
3
+ import { VirtualScrollPlugin } from '../../../packages/intable/src/plugins/VirtualScrollPlugin'
4
+ import { makeData, replaceArray } from './helpers'
5
+ import { range } from 'es-toolkit'
6
+
7
+ const cols = createMutable([
8
+ { name: 'Basic Info', children: [
9
+ { id: 'col_0', name: 'Name', width: 100 },
10
+ { id: 'col_1', name: 'Age', width: 80 },
11
+ ]},
12
+ { id: 'col_2', name: 'Status', width: 100 },
13
+ { name: 'Address', children: [
14
+ { id: 'col_3', name: 'City', width: 100 },
15
+ { id: 'col_4', name: 'Street', width: 120 },
16
+ { id: 'col_5', name: 'Zip', width: 80 },
17
+ ]},
18
+ ...range(6).map(i => ({ id: 'col_' + (i + 6), name: 'Extra ' + i, width: 80 })),
19
+ ] as any[])
20
+
21
+ const data = makeData(100, 12)
22
+
23
+ export const HeaderGroupDemo = () => (
24
+ <Intable
25
+ class='w-full h-60vh'
26
+ columns={cols}
27
+ onColumnsChange={v => replaceArray(cols, v)}
28
+ data={data}
29
+ onDataChange={v => replaceArray(data, v)}
30
+ index
31
+ border
32
+ stickyHeader
33
+ size='small'
34
+ plugins={[VirtualScrollPlugin]}
35
+ />
36
+ )
@@ -0,0 +1,28 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { HistoryPlugin } from '../../../packages/intable/src/plugins/HistoryPlugin'
3
+ import { makeCols, makeData, replaceArray } from './helpers'
4
+
5
+ const cols = makeCols(5, { editable: true })
6
+ const data = makeData(15, 5)
7
+
8
+ /**
9
+ * Edit cells then press Ctrl+Z to undo, Ctrl+Y to redo.
10
+ * HistoryPlugin must be added manually.
11
+ */
12
+ export const HistoryDemo = () => (
13
+ <div>
14
+ <p class='text-sm c-gray mb-2'>Edit a cell, then Ctrl+Z to undo, Ctrl+Y to redo.</p>
15
+ <Intable
16
+ class='w-full h-50vh'
17
+ columns={cols}
18
+ onColumnsChange={v => replaceArray(cols, v)}
19
+ data={data}
20
+ onDataChange={v => replaceArray(data, v)}
21
+ index
22
+ border
23
+ stickyHeader
24
+ size='small'
25
+ plugins={[HistoryPlugin]}
26
+ />
27
+ </div>
28
+ )
@@ -0,0 +1,59 @@
1
+ import { useEffect, useRef, useState, createElement as h, type FC } from 'react'
2
+
3
+ import { Intable, component } from '../../../packages/react/src'
4
+ import { range } from 'es-toolkit'
5
+
6
+ export const ReactDemo = component(() => {
7
+ const [cols, setCols] = useState([
8
+ { id: 'col_0', name: 'Column 1', width: 120, editable: true },
9
+ { name: 'HeaderGroup', children: [
10
+ { id: 'col_1', name: 'Column 2', width: 120, editable: true, render: (props) => h('div', { style: { color: 'red' } }, props.data[props.col.id]) },
11
+ { id: 'col_2', name: 'Column 3', width: 120, editable: true },
12
+ ] },
13
+ { id: 'col_3', name: 'Column 4', width: 120, editable: true },
14
+ { id: 'col_4', name: 'Column 5', width: 120, editable: true },
15
+ { id: 'col_5', name: 'Column 6', width: 120, editable: true },
16
+ { id: 'col_6', name: 'Column 7', editable: true },
17
+ { id: 'col_7', name: 'Column 8', editable: true },
18
+ ])
19
+
20
+ const [data, setData] = useState(range(20).map(i => {
21
+ const row: Record<string, any> = { id: i }
22
+ for (let j = 0; j < cols.length; j++) {
23
+ row['col_' + j] = `col_${j}_${i + 1}`
24
+ }
25
+ return row
26
+ }))
27
+
28
+ return h(Intable, {
29
+ className: 'w-full h-60vh',
30
+ columns: cols,
31
+ onColumnsChange: v => setCols(v),
32
+ data: data,
33
+ onDataChange: v => setData(v),
34
+ index: true,
35
+ border: true,
36
+ stickyHeader: true,
37
+ size: 'small',
38
+ //
39
+ resizable: { col: { enable: true }, row: { enable: true } },
40
+ //
41
+ colDrag: true,
42
+ rowDrag: true,
43
+ //
44
+ rowSelection: {
45
+ enable: true,
46
+ multiple: true,
47
+ onChange: (selected, unselected) => console.log('selected:', selected, 'unselected:', unselected),
48
+ },
49
+ expand: {
50
+ enable: true,
51
+ render: ({ data }) => (
52
+ h('div', { className: 'p-3 bg-gray-50 text-sm' }, [
53
+ h('b', null, 'Row Detail:'),
54
+ h('pre', { className: 'mt-1' }, JSON.stringify(data, null, 2))
55
+ ])
56
+ )
57
+ },
58
+ })
59
+ })
@@ -0,0 +1,24 @@
1
+ import { Intable } from '../../../packages/intable/src'
2
+ import { makeCols, makeData, replaceArray } from './helpers'
3
+
4
+ const cols = makeCols(6)
5
+ const data = makeData(20, 6)
6
+
7
+ /**
8
+ * Drag column header borders to resize columns.
9
+ * Row resize is also enabled — drag row bottom borders.
10
+ */
11
+ export const ResizeDemo = () => (
12
+ <Intable
13
+ class='w-full h-60vh'
14
+ columns={cols}
15
+ onColumnsChange={v => replaceArray(cols, v)}
16
+ data={data}
17
+ onDataChange={v => replaceArray(data, v)}
18
+ index
19
+ border
20
+ stickyHeader
21
+ size='small'
22
+ resizable={{ col: { enable: true }, row: { enable: true } }}
23
+ />
24
+ )