intable 0.0.8 → 0.0.9
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.
- package/README.md +263 -16
- package/dist/__uno.css +1 -0
- package/dist/chevron-right.js +6 -0
- package/dist/components/Columns.d.ts +3 -0
- package/dist/components/Columns.js +71 -0
- package/dist/components/DocTree.d.ts +4 -0
- package/dist/components/DocTree.js +32 -0
- package/dist/components/Menu.d.ts +1 -0
- package/dist/components/Menu.js +107 -0
- package/dist/components/Popover.d.ts +14 -0
- package/dist/components/Popover.js +41 -0
- package/dist/components/RecycleList.d.ts +26 -0
- package/dist/components/RecycleList.js +39 -0
- package/dist/components/Render.d.ts +4 -0
- package/dist/components/Render.js +20 -0
- package/dist/components/Split.d.ts +15 -0
- package/dist/components/Split.js +76 -0
- package/dist/components/Tree.d.ts +37 -0
- package/dist/components/Tree.js +82 -0
- package/dist/components/utils.d.ts +3 -0
- package/dist/components/utils.js +8 -0
- package/dist/hooks/index.d.ts +40 -0
- package/dist/hooks/index.js +157 -0
- package/dist/hooks/useDir.d.ts +11 -0
- package/dist/hooks/useDir.js +42 -0
- package/dist/hooks/useSelector.d.ts +16 -0
- package/dist/hooks/useSelector.js +69 -0
- package/dist/hooks/useSort.d.ts +18 -0
- package/dist/hooks/useSort.js +83 -0
- package/dist/hooks/useVirtualizer.d.ts +30 -0
- package/dist/hooks/useVirtualizer.js +97 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +386 -0
- package/dist/loading.js +6 -0
- package/dist/plugins/CellChangeHighlightPlugin.d.ts +2 -0
- package/dist/plugins/CellChangeHighlightPlugin.js +4 -0
- package/dist/plugins/CellMergePlugin.d.ts +45 -0
- package/dist/plugins/CellMergePlugin.js +78 -0
- package/dist/plugins/CellSelectionPlugin.d.ts +15 -0
- package/dist/plugins/CellSelectionPlugin.js +113 -0
- package/dist/plugins/CommandPlugin.d.ts +14 -0
- package/dist/plugins/CommandPlugin.js +31 -0
- package/dist/plugins/CopyPastePlugin.d.ts +14 -0
- package/dist/plugins/CopyPastePlugin.js +47 -0
- package/dist/plugins/DiffPlugin.d.ts +29 -0
- package/dist/plugins/DiffPlugin.js +66 -0
- package/dist/plugins/DragPlugin.d.ts +14 -0
- package/dist/plugins/DragPlugin.js +47 -0
- package/dist/plugins/EditablePlugin.d.ts +51 -0
- package/dist/plugins/EditablePlugin.js +177 -0
- package/dist/plugins/ExpandPlugin.d.ts +18 -0
- package/dist/plugins/ExpandPlugin.js +46 -0
- package/dist/plugins/HeaderGroup.d.ts +11 -0
- package/dist/plugins/HeaderGroup.js +171 -0
- package/dist/plugins/HistoryPlugin.d.ts +10 -0
- package/dist/plugins/HistoryPlugin.js +27 -0
- package/dist/plugins/MenuPlugin.d.ts +19 -0
- package/dist/plugins/MenuPlugin.js +132 -0
- package/dist/plugins/RenderPlugin/components.d.ts +5 -0
- package/dist/plugins/RenderPlugin/components.js +87 -0
- package/dist/plugins/RenderPlugin/index.d.ts +30 -0
- package/dist/plugins/RenderPlugin/index.js +49 -0
- package/dist/plugins/ResizePlugin.d.ts +27 -0
- package/dist/plugins/ResizePlugin.js +82 -0
- package/dist/plugins/RowGroupPlugin.d.ts +18 -0
- package/dist/plugins/RowGroupPlugin.js +88 -0
- package/dist/plugins/RowSelectionPlugin.d.ts +20 -0
- package/dist/plugins/RowSelectionPlugin.js +42 -0
- package/dist/plugins/TreePlugin.d.ts +24 -0
- package/dist/plugins/TreePlugin.js +110 -0
- package/dist/plugins/VirtualScrollPlugin.d.ts +15 -0
- package/dist/plugins/VirtualScrollPlugin.js +123 -0
- package/dist/plugins/ZodValidatorPlugin.d.ts +38 -0
- package/dist/plugins/ZodValidatorPlugin.js +12 -0
- package/dist/plus.js +6 -0
- package/dist/rolldown_runtime.js +9 -0
- package/dist/style.css +3 -0
- package/dist/tree.d.ts +1 -0
- package/dist/tree.js +12 -0
- package/dist/types/auto-imports.d.js +0 -0
- package/dist/utils.d.ts +31 -0
- package/dist/utils.js +71 -0
- package/dist/wc.d.ts +1 -0
- package/dist/wc.js +21 -0
- package/dist/web-component.d.ts +1 -0
- package/dist/web-component.js +2 -0
- package/dist/x.js +6 -0
- package/package.json +38 -35
- package/.github/copilot-instructions.md +0 -102
- package/docs/index-BaMALNy6.css +0 -1
- package/docs/index-CDN48t9E.js +0 -3
- package/docs/index-Cc4RNkLY.css +0 -1
- package/docs/index-MRnbkYmU.js +0 -3
- package/docs/index.html +0 -15
- package/docs/vite.svg +0 -1
- package/index.html +0 -13
- package/packages/intable/README.md +0 -379
- package/packages/intable/package.json +0 -51
- package/packages/intable/src/assets/ClearFormat.svg +0 -3
- package/packages/intable/src/assets/Forms.svg +0 -4
- package/packages/intable/src/assets/MergeCell.svg +0 -4
- package/packages/intable/src/assets/SplitCell.svg +0 -4
- package/packages/intable/src/assets/gap.svg +0 -3
- package/packages/intable/src/assets/loading.svg +0 -12
- package/packages/intable/src/assets/paint.svg +0 -9
- package/packages/intable/src/assets/solid.svg +0 -1
- package/packages/intable/src/components/Columns.tsx +0 -86
- package/packages/intable/src/components/DocTree.tsx +0 -36
- package/packages/intable/src/components/Menu.tsx +0 -109
- package/packages/intable/src/components/Popover.tsx +0 -55
- package/packages/intable/src/components/RecycleList.tsx +0 -99
- package/packages/intable/src/components/Render.tsx +0 -26
- package/packages/intable/src/components/Split.tsx +0 -56
- package/packages/intable/src/components/Tree.tsx +0 -115
- package/packages/intable/src/components/utils.tsx +0 -12
- package/packages/intable/src/hooks/index.ts +0 -200
- package/packages/intable/src/hooks/useDir.ts +0 -78
- package/packages/intable/src/hooks/useSelector.ts +0 -91
- package/packages/intable/src/hooks/useSort.tsx +0 -118
- package/packages/intable/src/hooks/useVirtualizer.ts +0 -180
- package/packages/intable/src/index.tsx +0 -489
- package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +0 -5
- package/packages/intable/src/plugins/CellMergePlugin.tsx +0 -153
- package/packages/intable/src/plugins/CellSelectionPlugin.tsx +0 -175
- package/packages/intable/src/plugins/CommandPlugin.tsx +0 -74
- package/packages/intable/src/plugins/CopyPastePlugin.tsx +0 -99
- package/packages/intable/src/plugins/DiffPlugin.tsx +0 -120
- package/packages/intable/src/plugins/DragPlugin.tsx +0 -81
- package/packages/intable/src/plugins/EditablePlugin.tsx +0 -252
- package/packages/intable/src/plugins/ExpandPlugin.tsx +0 -80
- package/packages/intable/src/plugins/HeaderGroup.tsx +0 -289
- package/packages/intable/src/plugins/HistoryPlugin.tsx +0 -49
- package/packages/intable/src/plugins/MenuPlugin.tsx +0 -195
- package/packages/intable/src/plugins/RenderPlugin/components.tsx +0 -51
- package/packages/intable/src/plugins/RenderPlugin/index.tsx +0 -81
- package/packages/intable/src/plugins/ResizePlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowGroupPlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowSelectionPlugin.tsx +0 -65
- package/packages/intable/src/plugins/TreePlugin.tsx +0 -212
- package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +0 -190
- package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +0 -61
- package/packages/intable/src/style.scss +0 -244
- package/packages/intable/src/tree.ts +0 -13
- package/packages/intable/src/types/auto-imports.d.ts +0 -13
- package/packages/intable/src/utils.ts +0 -122
- package/packages/intable/src/wc.tsx +0 -35
- package/packages/intable/src/web-component.ts +0 -1
- package/packages/react/package.json +0 -36
- package/packages/react/src/index.ts +0 -44
- package/packages/react/src/plugins/antd.ts +0 -94
- package/packages/react/src/style.scss +0 -12
- package/packages/react/src/types/auto-imports.d.ts +0 -10
- package/packages/vue/package.json +0 -34
- package/packages/vue/src/index.ts +0 -63
- package/packages/vue/src/plugins/element-plus.ts +0 -69
- package/packages/vue/src/style.scss +0 -12
- package/packages/vue/src/types/auto-imports.d.ts +0 -10
- package/pnpm-workspace.yaml +0 -2
- package/public/vite.svg +0 -1
- package/scripts/build.js +0 -184
- package/scripts/publish.js +0 -95
- package/src/assets/ClearFormat.svg +0 -3
- package/src/assets/Forms.svg +0 -4
- package/src/assets/MergeCell.svg +0 -4
- package/src/assets/SplitCell.svg +0 -4
- package/src/assets/gap.svg +0 -3
- package/src/assets/loading.svg +0 -12
- package/src/assets/paint.svg +0 -9
- package/src/assets/solid.svg +0 -1
- package/src/demo-vue.ts +0 -54
- package/src/index.scss +0 -105
- package/src/index.tsx +0 -20
- package/src/pages/demo/BasicDemo.tsx +0 -19
- package/src/pages/demo/CellMergeDemo.tsx +0 -41
- package/src/pages/demo/CellSelectionDemo.tsx +0 -24
- package/src/pages/demo/CompositeDemo.tsx +0 -60
- package/src/pages/demo/CopyPasteDemo.tsx +0 -26
- package/src/pages/demo/DiffDemo.tsx +0 -33
- package/src/pages/demo/DragDemo.tsx +0 -25
- package/src/pages/demo/EditableDemo.tsx +0 -58
- package/src/pages/demo/ExpandDemo.tsx +0 -32
- package/src/pages/demo/HeaderGroupDemo.tsx +0 -36
- package/src/pages/demo/HistoryDemo.tsx +0 -28
- package/src/pages/demo/ReactDemo.tsx +0 -59
- package/src/pages/demo/ResizeDemo.tsx +0 -24
- package/src/pages/demo/RowGroupDemo.tsx +0 -43
- package/src/pages/demo/RowSelectionDemo.tsx +0 -27
- package/src/pages/demo/TreeDemo.tsx +0 -45
- package/src/pages/demo/VirtualScrollDemo.tsx +0 -21
- package/src/pages/demo/helpers.tsx +0 -39
- package/src/pages/demo/index.tsx +0 -180
- package/src/pages/index.tsx +0 -2
- package/src/pages/website.scss +0 -37
- package/src/pages/website.tsx +0 -651
- package/src/styles/index.scss +0 -172
- package/src/types/auto-imports.d.ts +0 -13
- package/stats.html +0 -4949
- package/tsconfig.app.json +0 -34
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -70
- /package/{packages/intable/src → dist}/theme/antd.scss +0 -0
- /package/{packages/intable/src → dist}/theme/dark.scss +0 -0
- /package/{packages/intable/src → dist}/theme/element-plus.scss +0 -0
- /package/{packages/intable/src → dist}/theme/github.scss +0 -0
- /package/{packages/intable/src → dist}/theme/material.scss +0 -0
- /package/{packages/intable/src → dist}/theme/shadcn.scss +0 -0
- /package/{packages/intable/src → dist}/theme/stripe.scss +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
)
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createMutable } from 'solid-js/store'
|
|
2
|
-
import { range } from 'es-toolkit'
|
|
3
|
-
import { Intable } from '../../../packages/intable/src'
|
|
4
|
-
import { replaceArray } from './helpers'
|
|
5
|
-
|
|
6
|
-
const cols = createMutable([
|
|
7
|
-
{ id: 'name', name: 'Name', width: 120 },
|
|
8
|
-
{ id: 'category', name: 'Category', width: 120 },
|
|
9
|
-
{ id: 'region', name: 'Region', width: 120 },
|
|
10
|
-
{ id: 'value', name: 'Value', width: 100 },
|
|
11
|
-
])
|
|
12
|
-
|
|
13
|
-
const categories = ['Electronics', 'Clothing', 'Food']
|
|
14
|
-
const regions = ['East', 'West', 'North', 'South']
|
|
15
|
-
|
|
16
|
-
const data = createMutable(
|
|
17
|
-
range(40).map(i => ({
|
|
18
|
-
id: i,
|
|
19
|
-
name: 'Item ' + i,
|
|
20
|
-
category: categories[i % 3],
|
|
21
|
-
region: regions[i % 4],
|
|
22
|
-
value: Math.round(Math.random() * 1000),
|
|
23
|
-
})),
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Rows are grouped by `category` then `region`.
|
|
28
|
-
* Click group headers to expand/collapse.
|
|
29
|
-
*/
|
|
30
|
-
export const RowGroupDemo = () => (
|
|
31
|
-
<Intable
|
|
32
|
-
class='w-full h-60vh'
|
|
33
|
-
columns={cols}
|
|
34
|
-
onColumnsChange={v => replaceArray(cols, v)}
|
|
35
|
-
data={data}
|
|
36
|
-
onDataChange={v => replaceArray(data, v)}
|
|
37
|
-
index
|
|
38
|
-
border
|
|
39
|
-
stickyHeader
|
|
40
|
-
size='small'
|
|
41
|
-
rowGroup={{ fields: ['category', 'region'] }}
|
|
42
|
-
/>
|
|
43
|
-
)
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
* Checkbox column on the left. Click to select, header checkbox for select-all.
|
|
9
|
-
*/
|
|
10
|
-
export const RowSelectionDemo = () => (
|
|
11
|
-
<Intable
|
|
12
|
-
class='w-full h-60vh'
|
|
13
|
-
columns={cols}
|
|
14
|
-
onColumnsChange={v => replaceArray(cols, v)}
|
|
15
|
-
data={data}
|
|
16
|
-
onDataChange={v => replaceArray(data, v)}
|
|
17
|
-
index
|
|
18
|
-
border
|
|
19
|
-
stickyHeader
|
|
20
|
-
size='small'
|
|
21
|
-
rowSelection={{
|
|
22
|
-
enable: true,
|
|
23
|
-
multiple: true,
|
|
24
|
-
onChange: (selected, unselected) => console.log('selected:', selected, 'unselected:', unselected),
|
|
25
|
-
}}
|
|
26
|
-
/>
|
|
27
|
-
)
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { createMutable } from 'solid-js/store'
|
|
2
|
-
import { Intable } from '../../../packages/intable/src'
|
|
3
|
-
import { replaceArray } from './helpers'
|
|
4
|
-
|
|
5
|
-
const cols = createMutable([
|
|
6
|
-
{ id: 'name', name: 'Name', width: 200 },
|
|
7
|
-
{ id: 'size', name: 'Size', width: 100 },
|
|
8
|
-
{ id: 'type', name: 'Type', width: 120 },
|
|
9
|
-
])
|
|
10
|
-
|
|
11
|
-
const data = createMutable([
|
|
12
|
-
{ id: 1, name: 'src', size: '-', type: 'folder', children: [
|
|
13
|
-
{ id: 2, name: 'index.ts', size: '2KB', type: 'file' },
|
|
14
|
-
{ id: 3, name: 'utils', size: '-', type: 'folder', children: [
|
|
15
|
-
{ id: 4, name: 'helper.ts', size: '1KB', type: 'file' },
|
|
16
|
-
{ id: 5, name: 'math.ts', size: '3KB', type: 'file' },
|
|
17
|
-
]},
|
|
18
|
-
{ id: 6, name: 'components', size: '-', type: 'folder', children: [
|
|
19
|
-
{ id: 7, name: 'App.tsx', size: '4KB', type: 'file' },
|
|
20
|
-
{ id: 8, name: 'Button.tsx', size: '1KB', type: 'file' },
|
|
21
|
-
]},
|
|
22
|
-
]},
|
|
23
|
-
{ id: 9, name: 'package.json', size: '1KB', type: 'file' },
|
|
24
|
-
{ id: 10, name: 'README.md', size: '2KB', type: 'file' },
|
|
25
|
-
])
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Tree-structured data with expand/collapse.
|
|
29
|
-
* TreePlugin must be added manually.
|
|
30
|
-
*/
|
|
31
|
-
export const TreeDemo = () => (
|
|
32
|
-
<Intable
|
|
33
|
-
class='w-full h-60vh'
|
|
34
|
-
columns={cols}
|
|
35
|
-
onColumnsChange={v => replaceArray(cols, v)}
|
|
36
|
-
data={data}
|
|
37
|
-
onDataChange={v => replaceArray(data, v)}
|
|
38
|
-
index
|
|
39
|
-
border
|
|
40
|
-
stickyHeader
|
|
41
|
-
size='small'
|
|
42
|
-
tree={{ children: 'children' }}
|
|
43
|
-
rowKey='id'
|
|
44
|
-
/>
|
|
45
|
-
)
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Intable } from '../../../packages/intable/src'
|
|
2
|
-
import { VirtualScrollPlugin } from '../../../packages/intable/src/plugins/VirtualScrollPlugin'
|
|
3
|
-
import { makeCols, makeData, replaceArray } from './helpers'
|
|
4
|
-
|
|
5
|
-
const cols = makeCols(50, { width: 80 })
|
|
6
|
-
const data = makeData(1000, 50)
|
|
7
|
-
|
|
8
|
-
export const VirtualScrollDemo = () => (
|
|
9
|
-
<Intable
|
|
10
|
-
class='h-60vh'
|
|
11
|
-
columns={cols}
|
|
12
|
-
onColumnsChange={v => replaceArray(cols, v)}
|
|
13
|
-
data={data}
|
|
14
|
-
onDataChange={v => replaceArray(data, v)}
|
|
15
|
-
index
|
|
16
|
-
border
|
|
17
|
-
stickyHeader
|
|
18
|
-
size='small'
|
|
19
|
-
plugins={[VirtualScrollPlugin]}
|
|
20
|
-
/>
|
|
21
|
-
)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared helpers for demo data generation.
|
|
3
|
-
*/
|
|
4
|
-
import { createMutable } from 'solid-js/store'
|
|
5
|
-
import { batch } from 'solid-js'
|
|
6
|
-
import { range } from 'es-toolkit'
|
|
7
|
-
|
|
8
|
-
/** Generate flat tabular data */
|
|
9
|
-
export function makeData(rows: number, colCount: number) {
|
|
10
|
-
const colIds = range(colCount).map(i => 'col_' + i)
|
|
11
|
-
return createMutable(
|
|
12
|
-
range(rows).map((_, i) =>
|
|
13
|
-
Object.fromEntries([
|
|
14
|
-
['id', i],
|
|
15
|
-
...colIds.map(id => [id, `${id}_${i + 1}`]),
|
|
16
|
-
]),
|
|
17
|
-
),
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Generate column definitions */
|
|
22
|
-
export function makeCols(count: number, extra?: Partial<{ width: number; editable: boolean }>) {
|
|
23
|
-
return createMutable(
|
|
24
|
-
range(count).map(i => ({
|
|
25
|
-
id: 'col_' + i,
|
|
26
|
-
name: 'Col ' + i,
|
|
27
|
-
width: 100,
|
|
28
|
-
...extra,
|
|
29
|
-
})),
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** Shortcut for batch-replacing a reactive array */
|
|
34
|
-
export function replaceArray<T>(arr: T[], next: T[]) {
|
|
35
|
-
batch(() => {
|
|
36
|
-
arr.length = 0
|
|
37
|
-
arr.push(...next)
|
|
38
|
-
})
|
|
39
|
-
}
|