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
@@ -9,17 +9,25 @@
9
9
 
10
10
  --table-row-hover-bg: var(--ant-table-row-hover-bg, #fafafa);
11
11
 
12
- @apply text-[14px];
12
+ font-size: 14px;
13
13
 
14
14
  &:not(&--border) thead th {
15
- @apply relative;
15
+ position: relative;
16
16
  &:not(:last-child)::before {
17
- @apply content-[''] absolute top-1/2 right-0 h-[1.6em] w-[1px] bg-[--table-b-c] translate-y-[-50%];
17
+ content: '';
18
+ position: absolute;
19
+ top: 50%;
20
+ right: 0;
21
+ height: 1.6em;
22
+ width: 1px;
23
+ background-color: var(--table-b-c);
24
+ transform: translateY(-50%);
18
25
  }
19
26
  }
20
27
 
21
28
  th, td {
22
- @apply px-2 py-3 lh-[22px];
29
+ padding: 12px 8px;
30
+ line-height: 22px;
23
31
  }
24
32
 
25
33
  .row-selection {
@@ -28,7 +36,8 @@
28
36
 
29
37
  &--small {
30
38
  th, td {
31
- @apply px-2;
39
+ padding-left: 8px;
40
+ padding-right: 8px;
32
41
  }
33
42
  }
34
43
  }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * intable — Dark (OLED) Theme
3
+ * Deep black background, high contrast, WCAG AAA compliant
4
+ * Best for: developer tools, night mode, coding platforms
5
+ */
6
+
7
+ .data-table {
8
+ --bg: #0d1117;
9
+ --c-primary: #388bfd;
10
+
11
+ --menu-bg: #161b22;
12
+ --li-hover-bg: rgba(177, 186, 196, 0.12);
13
+
14
+ --table-b: 1px solid var(--table-b-c);
15
+ --table-b-c: #30363d;
16
+ --table-c: #e6edf3;
17
+ --table-bg: #0d1117;
18
+
19
+ --table-header-c: #8b949e;
20
+ --table-header-bg: #161b22;
21
+
22
+ --table-row-hover-bg: #161b22;
23
+
24
+ --select-area-bg: #388bfd1f;
25
+
26
+ color-scheme: dark;
27
+ font-size: 13px;
28
+
29
+ th, td {
30
+ padding: 8px 12px;
31
+ line-height: 20px;
32
+ }
33
+
34
+ &--small {
35
+ font-size: 12px;
36
+
37
+ th, td {
38
+ padding: 4px 8px;
39
+ }
40
+ }
41
+
42
+ thead th {
43
+ font-weight: 600;
44
+ letter-spacing: 0.01em;
45
+ }
46
+ }
@@ -14,14 +14,15 @@
14
14
 
15
15
  --table-row-hover-bg: var(--el-table-row-hover-bg-color, #f5f7fa);
16
16
 
17
- @apply lh-[23px] text-[14px];
17
+ line-height: 23px;
18
+ font-size: 14px;
18
19
 
19
20
  thead th {
20
- @apply font-600;
21
+ font-weight: 600;
21
22
  }
22
23
 
23
24
  th, td {
24
- @apply px-3 py-2;
25
+ padding: 8px 12px;
25
26
  }
26
27
 
27
28
  .row-selection {
@@ -29,10 +30,10 @@
29
30
  }
30
31
 
31
32
  &--small {
32
- @apply text-3;
33
+ font-size: 12px;
33
34
 
34
35
  th, td {
35
- @apply px-2 py-1;
36
+ padding: 4px 8px;
36
37
  }
37
38
  }
38
39
  }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * intable — GitHub Theme
3
+ * Matches GitHub's Primer design system — light & dark surfaces
4
+ * Best for: developer tools, docs sites, code-adjacent UIs
5
+ */
6
+
7
+ .data-table {
8
+ --bg: #ffffff;
9
+ --c-primary: #0969da;
10
+
11
+ --menu-bg: #ffffff;
12
+ --li-hover-bg: #f3f4f6;
13
+
14
+ --table-b: 1px solid var(--table-b-c);
15
+ --table-b-c: #d0d7de;
16
+ --table-c: #1f2328;
17
+ --table-bg: #ffffff;
18
+
19
+ --table-header-c: #636c76;
20
+ --table-header-bg: #f6f8fa;
21
+
22
+ --table-row-hover-bg: #f6f8fa;
23
+
24
+ --select-area-bg: #0969da1a;
25
+
26
+ font-size: 14px;
27
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
28
+
29
+ th, td {
30
+ padding: 8px 12px;
31
+ line-height: 1.5;
32
+ }
33
+
34
+ thead th {
35
+ font-weight: 600;
36
+ white-space: nowrap;
37
+ }
38
+
39
+ tbody tr:nth-child(even) td {
40
+ background-color: #f6f8fa;
41
+ }
42
+
43
+ tbody tr:nth-child(even):hover td {
44
+ background-color: var(--table-row-hover-bg);
45
+ }
46
+
47
+ &--small {
48
+ font-size: 12px;
49
+
50
+ th, td {
51
+ padding: 4px 8px;
52
+ }
53
+ }
54
+
55
+ // Dark (GitHub Dark Default)
56
+ &.dark, [data-theme="dark"] & {
57
+ --bg: #0d1117;
58
+ --c-primary: #388bfd;
59
+
60
+ --menu-bg: #161b22;
61
+ --li-hover-bg: rgba(177, 186, 196, 0.12);
62
+
63
+ --table-b-c: #30363d;
64
+ --table-c: #e6edf3;
65
+ --table-bg: #0d1117;
66
+
67
+ --table-header-c: #8b949e;
68
+ --table-header-bg: #161b22;
69
+
70
+ --table-row-hover-bg: #161b22;
71
+
72
+ --select-area-bg: #388bfd1f;
73
+
74
+ color-scheme: dark;
75
+
76
+ tbody tr:nth-child(even) td {
77
+ background-color: #161b22;
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * intable — Material Design 3 Theme
3
+ * Google Material You / M3 surface tones and typography
4
+ * Best for: Android-style web apps, admin panels, data management UIs
5
+ */
6
+
7
+ .data-table {
8
+ --bg: #fffbfe;
9
+ --c-primary: #6750a4;
10
+
11
+ --menu-bg: #ece6f0;
12
+ --li-hover-bg: rgba(103, 80, 164, 0.08);
13
+
14
+ --table-b: 1px solid var(--table-b-c);
15
+ --table-b-c: #cac4d0;
16
+ --table-c: #1c1b1f;
17
+ --table-bg: #fffbfe;
18
+
19
+ --table-header-c: #49454f;
20
+ --table-header-bg: #fffbfe;
21
+
22
+ --table-row-hover-bg: rgba(103, 80, 164, 0.08);
23
+
24
+ --select-area-bg: rgba(103, 80, 164, 0.12);
25
+
26
+ font-size: 14px;
27
+ font-family: 'Roboto', sans-serif;
28
+
29
+ th, td {
30
+ padding: 10px 16px;
31
+ line-height: 20px;
32
+ }
33
+
34
+ thead th {
35
+ font-size: 12px;
36
+ font-weight: 500;
37
+ letter-spacing: 0.02em;
38
+ }
39
+
40
+ tr:not(:last-child) td {
41
+ border-bottom: 1px solid var(--table-b-c);
42
+ }
43
+
44
+ &--small {
45
+ font-size: 12px;
46
+
47
+ th, td {
48
+ padding: 6px 12px;
49
+ }
50
+ }
51
+
52
+ // Dark variant (M3 dark)
53
+ &.dark, [data-theme="dark"] & {
54
+ --bg: #1c1b1f;
55
+ --c-primary: #d0bcff;
56
+
57
+ --menu-bg: #2b2930;
58
+ --li-hover-bg: rgba(208, 188, 255, 0.08);
59
+
60
+ --table-b-c: #49454f;
61
+ --table-c: #e6e1e5;
62
+ --table-bg: #1c1b1f;
63
+
64
+ --table-header-c: #cac4d0;
65
+ --table-header-bg: #1c1b1f;
66
+
67
+ --table-row-hover-bg: rgba(208, 188, 255, 0.08);
68
+
69
+ --select-area-bg: rgba(208, 188, 255, 0.12);
70
+
71
+ color-scheme: dark;
72
+ }
73
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * intable — Shadcn/Zinc Theme
3
+ * Neutral zinc/slate tones, clean minimal, matches shadcn/ui palette
4
+ * Best for: modern SaaS dashboards, admin panels, clean productivity tools
5
+ */
6
+
7
+ .data-table {
8
+ --bg: #ffffff;
9
+ --c-primary: #18181b;
10
+
11
+ --menu-bg: #ffffff;
12
+ --li-hover-bg: #f4f4f5;
13
+
14
+ --table-b: 1px solid var(--table-b-c);
15
+ --table-b-c: #e4e4e7;
16
+ --table-c: #09090b;
17
+ --table-bg: #ffffff;
18
+
19
+ --table-header-c: #71717a;
20
+ --table-header-bg: #ffffff;
21
+
22
+ --table-row-hover-bg: #fafafa;
23
+
24
+ --select-area-bg: #18181b14;
25
+
26
+ font-size: 14px;
27
+
28
+ th, td {
29
+ padding: 10px 12px;
30
+ line-height: 20px;
31
+ }
32
+
33
+ thead th {
34
+ font-weight: 500;
35
+ }
36
+
37
+ &--small {
38
+ font-size: 13px;
39
+
40
+ th, td {
41
+ padding: 6px 10px;
42
+ }
43
+ }
44
+
45
+ // Dark mode variant
46
+ &.dark, [data-theme="dark"] & {
47
+ --bg: #09090b;
48
+ --c-primary: #fafafa;
49
+
50
+ --menu-bg: #09090b;
51
+ --li-hover-bg: #27272a;
52
+
53
+ --table-b-c: #27272a;
54
+ --table-c: #fafafa;
55
+ --table-bg: #09090b;
56
+
57
+ --table-header-c: #71717a;
58
+ --table-header-bg: #09090b;
59
+
60
+ --table-row-hover-bg: #18181b;
61
+
62
+ --select-area-bg: #ffffff14;
63
+
64
+ color-scheme: dark;
65
+ }
66
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * intable — Stripe Theme
3
+ * Ultra-clean minimal white, tight spacing, strong typographic hierarchy
4
+ * Best for: fintech, e-commerce, financial dashboards, data-dense UIs
5
+ */
6
+
7
+ .data-table {
8
+ --bg: #ffffff;
9
+ --c-primary: #635bff;
10
+
11
+ --menu-bg: #ffffff;
12
+ --li-hover-bg: #f6f8fa;
13
+
14
+ --table-b: 1px solid var(--table-b-c);
15
+ --table-b-c: #e3e8ee;
16
+ --table-c: #0a2540;
17
+ --table-bg: #ffffff;
18
+
19
+ --table-header-c: #425466;
20
+ --table-header-bg: #f7fafc;
21
+
22
+ --table-row-hover-bg: #f7fafc;
23
+
24
+ --select-area-bg: #635bff1a;
25
+
26
+ font-size: 13.5px;
27
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
28
+
29
+ th, td {
30
+ padding: 9px 14px;
31
+ line-height: 20px;
32
+ }
33
+
34
+ thead th {
35
+ font-size: 11.5px;
36
+ font-weight: 600;
37
+ text-transform: uppercase;
38
+ letter-spacing: 0.04em;
39
+ color: var(--table-header-c);
40
+ }
41
+
42
+ &--small {
43
+ font-size: 12.5px;
44
+
45
+ th, td {
46
+ padding: 5px 10px;
47
+ }
48
+
49
+ thead th {
50
+ font-size: 11px;
51
+ }
52
+ }
53
+
54
+ .row-selection {
55
+ width: 38px;
56
+ }
57
+ }
@@ -0,0 +1,13 @@
1
+ export const findParent = (data: any[], cb, childrenField = 'children'): any => {
2
+ let parent = null
3
+ const stack = [...data]
4
+ while (stack.length) {
5
+ const node = stack.pop()
6
+ if (cb(node)) return parent
7
+ if (Array.isArray(node[childrenField])) {
8
+ stack.push(...node[childrenField])
9
+ parent = node
10
+ }
11
+ }
12
+ return null
13
+ }
@@ -0,0 +1,13 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // noinspection JSUnusedGlobalSymbols
5
+ // Generated by unplugin-auto-import
6
+ // biome-ignore lint: disable
7
+ export {}
8
+ declare global {
9
+ const ILucideChevronRight: typeof import('~icons/lucide/chevron-right.jsx')['default']
10
+ const ILucidePlus: typeof import('~icons/lucide/plus.jsx')['default']
11
+ const ILucideX: typeof import('~icons/lucide/x.jsx')['default']
12
+ const IMyLoading: typeof import('~icons/my/loading.jsx')['default']
13
+ }
@@ -0,0 +1,122 @@
1
+ import { delay, isFunction, isPlainObject, isPromise } from "es-toolkit"
2
+ import { useMemoAsync } from "./hooks"
3
+
4
+ export * as tree from './tree'
5
+
6
+ export function file2base64(file: File) {
7
+ return new Promise<string>((resolve, reject) => {
8
+ const reader = new FileReader()
9
+ reader.readAsDataURL(file)
10
+ reader.onload = () => resolve(reader.result as string)
11
+ })
12
+ }
13
+
14
+ export function chooseFile(opts: { accept?: string; multiple?: false }): Promise<File>
15
+ export function chooseFile(opts: { accept?: string; multiple: true }): Promise<File[]>
16
+
17
+ export function chooseFile(opts?) {
18
+ return new Promise((resolve, reject) => {
19
+ const input = document.createElement('input')
20
+ input.type = 'file'
21
+ input.accept = opts?.accept
22
+ input.multiple = opts?.multiple
23
+ input.onchange = () => {
24
+ if (input.files && input.files.length > 0) {
25
+ resolve(input.multiple ? [...input.files] : input.files[0])
26
+ } else {}
27
+ }
28
+ input.oncancel = reject
29
+ input.click()
30
+ })
31
+ }
32
+
33
+ export function chooseImage() {
34
+ return chooseFile({ accept: 'image/*' })
35
+ }
36
+
37
+ // export async function html2docx(content: string) {
38
+ // const { inline, initWasm } = await import('@css-inline/css-inline-wasm')
39
+ // const wasm = fetch(await import('@css-inline/css-inline-wasm/index_bg.wasm?url').then((e) => e.default))
40
+ // await initWasm(wasm).catch(() => {})
41
+
42
+ // content = inline(content + getStyles())
43
+ // const blob = await import('html-docx-js-typescript').then((e) => e.asBlob(content))
44
+ // return blob as Blob
45
+ // }
46
+
47
+ export async function print(html: string) {
48
+ const iframe = document.createElement('iframe')
49
+ const styles = [...document.querySelectorAll('style'), ...document.querySelectorAll('link[rel="stylesheet"]')] as HTMLElement[]
50
+ iframe.srcdoc = `${styles.map(e => e.outerHTML).join('\n')}\n\n${html}`
51
+ Object.assign(iframe.style, { position: 'fixed', display: 'none' })
52
+ document.body.append(iframe)
53
+ await new Promise(resolve => iframe.contentWindow.addEventListener('load', resolve, { once: true }))
54
+ await delay(300)
55
+ iframe.contentWindow.print()
56
+ iframe.remove()
57
+ }
58
+
59
+ export function mergeRect(rect1: DOMRect, rect2: DOMRect) {
60
+ return DOMRect.fromRect({
61
+ x: Math.min(rect1.x, rect2.x),
62
+ y: Math.min(rect1.y, rect2.y),
63
+ width: Math.max(rect1.right, rect2.right) - Math.min(rect1.x, rect2.x),
64
+ height: Math.max(rect1.bottom, rect2.bottom) - Math.min(rect1.y, rect2.y),
65
+ })
66
+ }
67
+
68
+ export function getStyles(el = document as ParentNode) {
69
+ return [...el.querySelectorAll('style'), ...el.querySelectorAll('link[rel="stylesheet"]')].map(e => e.outerHTML).join('\n')
70
+ }
71
+
72
+ export const unFn = (fn, ...args) => typeof fn == 'function' ? fn(...args) : fn
73
+
74
+ export const log = (...args) => (console.log(...args), args[0])
75
+
76
+ export const toArr = v => Array.isArray(v) ? v : v != null ? [v] : []
77
+
78
+ export const parseStyle = s => s ? s.split(';').reduce((o, e) => ((([k, v]) => o[k.trim()] = v.trim())(e.split(':')), o), {}) : {}
79
+
80
+ export function findret<T, R>(arr: readonly T[], cb: (e: T, i: number) => R): R | undefined {
81
+ for (let i = 0; i < arr.length; i++) {
82
+ const ret = cb(arr[i], i)
83
+ if (ret != null) return ret
84
+ }
85
+ }
86
+
87
+ export function emptyObject(o) {
88
+ for (const k of Object.keys(o)) delete o[k]
89
+ return o
90
+ }
91
+
92
+ export async function findAsync<T>(arr: T[], cb: (e: T, i: number) => Promise<boolean> | boolean) {
93
+ for (let i = 0; i < arr.length; i++) {
94
+ if (await cb(arr[i], i)) return arr[i]
95
+ }
96
+ }
97
+
98
+ type Fnable<T> = T | (() => T)
99
+ type Awatable<T> = T | Promise<T>
100
+ type BaseType = string | number | boolean | null
101
+
102
+ const cache = new WeakMap
103
+
104
+ export function resolveOptions(opts: Fnable<Awatable<Record<string, any> | ({ label: any; value: any } | BaseType)[]>>): { label: any; value: any }[] {
105
+ let ret = opts
106
+ if (isFunction(ret)) ret = ret()
107
+ if (isPromise(ret)) {
108
+ if (cache.has(ret)) return cache.get(ret)()
109
+ cache.set(ret, useMemoAsync(() => ret.then(e => e.map(e => resolveOptions(e)))))
110
+ return cache.get(ret)()
111
+ }
112
+ if (isPlainObject(ret)) ret = Object.entries(ret).map(([k, v]) => ({ value: k, label: v, ...v }))
113
+ return (ret as any[])?.map(e => resolveOpt(e)) || []
114
+ }
115
+
116
+ function resolveOpt(opt) {
117
+ return (
118
+ isPlainObject(opt) ? opt :
119
+ Array.isArray(opt) ? { label: opt[0], value: opt[1] } :
120
+ { label: opt, value: opt }
121
+ )
122
+ }
@@ -0,0 +1,35 @@
1
+ /* @refresh reload */
2
+ import { batch, createEffect, createMemo, createSignal, untrack } from 'solid-js'
3
+ import { customElement, noShadowDOM } from 'solid-element'
4
+ import { createMutable } from 'solid-js/store'
5
+ import { Intable } from './'
6
+ import { useMemoState } from './hooks'
7
+
8
+ const PROPS = {
9
+ options: {},
10
+ css: { value: '', attribute: 'css', notify: true, reflect: false },
11
+ theme: '',
12
+ noShadow: true,
13
+ }
14
+
15
+ export const TableElement = customElement('wc-table', PROPS, (attrs, { element }) => {
16
+ attrs.noShadow && noShadowDOM()
17
+
18
+ const props = useMemoState(() => attrs.options)
19
+
20
+ return (
21
+ <Intable {...props} />
22
+ )
23
+ })
24
+
25
+ function memoAsync(fn) {
26
+ const ret = createSignal('')
27
+ let count = 0
28
+ createEffect(async () => {
29
+ const _count = ++count
30
+ let val = fn()
31
+ if (val instanceof Promise) val = await val
32
+ if (_count == count) ret[1](val)
33
+ })
34
+ return ret[0]
35
+ }
@@ -0,0 +1 @@
1
+ export * from './wc'
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@intable/react",
3
+ "version": "0.0.8",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": "./dist/index.js",
11
+ "./*": {
12
+ "import": "./dist/*.js",
13
+ "types": "./dist/*.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "intable": "workspace:^",
21
+ "solid-js": "^1.9.9"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^18.0.0 || ^19.0.0 || ^20.0.0",
25
+ "react-dom": "^18.0.0 || ^19.0.0 || ^20.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/react": "^18",
29
+ "@types/react-dom": "^18",
30
+ "antd": "^5.22.5"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "registry": "https://registry.npmjs.org/"
35
+ }
36
+ }
@@ -0,0 +1,44 @@
1
+ import { useEffect, useRef, createElement as h, type FC } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import { flushSync } from 'react-dom'
4
+ import { type TableProps } from 'intable'
5
+ import 'intable/wc'
6
+ import './style.scss'
7
+
8
+ import { onCleanup } from 'solid-js'
9
+
10
+
11
+ export const Intable: FC<TableProps> = (props) => {
12
+ const ref = useRef<any>(null)
13
+
14
+ useEffect(() => {
15
+ if (ref.current) {
16
+ ref.current.options = {
17
+ ...props,
18
+ renderer: component,
19
+ plugins: [
20
+ ...(props.plugins || [])
21
+ ],
22
+ } as TableProps
23
+ }
24
+ }, [props])
25
+
26
+ return h('wc-table', { ref, style: { display: 'contents' } })
27
+ }
28
+
29
+
30
+ export const component = <T extends Record<string, any>>(Comp: FC<T>) => {
31
+ return (props: T) => {
32
+ // const el = document.createDocumentFragment()
33
+ const el = document.createElement('div')
34
+ el.remove ??= () => {}
35
+
36
+ const root = createRoot(el)
37
+ flushSync(() => root.render(h(Comp, props)))
38
+ onCleanup(() => root.unmount())
39
+
40
+ return el
41
+ }
42
+ }
43
+
44
+ export default Intable