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
package/dist/index.d.ts DELETED
@@ -1,130 +0,0 @@
1
- import { type JSX, type Component } from 'solid-js';
2
- import 'virtual:uno.css';
3
- import './style.scss';
4
- import './plugins/CellSelectionPlugin';
5
- import './plugins/CopyPastePlugin';
6
- import './plugins/EditablePlugin';
7
- import './plugins/RenderPlugin';
8
- import './plugins/MenuPlugin';
9
- import './plugins/CommandPlugin';
10
- import './plugins/RowSelectionPlugin';
11
- import './plugins/ResizePlugin';
12
- import './plugins/DragPlugin';
13
- import './plugins/RowGroupPlugin';
14
- import './plugins/ExpandPlugin';
15
- export declare const Ctx: import("solid-js").Context<{
16
- props: TableProps2;
17
- store: TableStore;
18
- }>;
19
- type Requireds<T, K extends keyof T> = Pri<Omit<T, K> & Required<Pick<T, K>>>;
20
- type Pri<T> = {
21
- [K in keyof T]: T[K];
22
- };
23
- type TableProps2 = Requireds<TableProps, ('Table' | 'Thead' | 'Tbody' | 'Tr' | 'Th' | 'Td' | 'EachRows' | 'EachCells' | 'rowKey' | 'data' | 'columns' | 'newRow')>;
24
- type Each<T = any> = (props: {
25
- each: T[];
26
- children: (e: () => any, i: () => number) => JSX.Element;
27
- }) => JSX.Element;
28
- type ProcessProps = {
29
- [K in keyof TableProps]?: (prev: TableProps2, ctx: {
30
- store: TableStore;
31
- }) => TableProps[K];
32
- };
33
- export interface Plugin {
34
- name?: string;
35
- priority?: number;
36
- store?: (store: TableStore) => Partial<TableStore> | void;
37
- rewriteProps?: ProcessProps;
38
- layers?: Component<TableStore>[];
39
- onMount?: (store: TableStore) => void;
40
- }
41
- export interface TableProps {
42
- columns?: TableColumn[];
43
- data?: any[];
44
- index?: boolean;
45
- border?: boolean;
46
- stickyHeader?: boolean;
47
- class?: any;
48
- style?: any;
49
- rowKey?: any;
50
- size?: string;
51
- newRow?: (i: number) => any;
52
- Table?: Component<any>;
53
- Thead?: Component<any>;
54
- Tbody?: Component<any>;
55
- Td?: TD;
56
- Th?: Component<THProps>;
57
- Tr?: Component<{
58
- y?: number;
59
- data?: any;
60
- children: JSX.Element;
61
- }>;
62
- EachRows?: Each;
63
- EachCells?: Each<TableColumn>;
64
- cellClass?: ((props: Omit<TDProps, 'y' | 'data'> & {
65
- y?: number;
66
- data?: any;
67
- }) => string) | string;
68
- cellStyle?: ((props: Omit<TDProps, 'y' | 'data'> & {
69
- y?: number;
70
- data?: any;
71
- }) => string) | string;
72
- renderer?: (comp: (props: any) => JSX.Element) => ((props: any) => JSX.Element);
73
- plugins?: Plugin[];
74
- onDataChange?: (data: any[]) => void;
75
- }
76
- export type THProps = {
77
- x: number;
78
- col: TableColumn;
79
- children: JSX.Element;
80
- };
81
- export type TDProps = {
82
- x: number;
83
- y: number;
84
- data: any;
85
- col: TableColumn;
86
- children: JSX.Element;
87
- };
88
- export type TD = Component<{
89
- x: number;
90
- y: number;
91
- data: any;
92
- col: TableColumn;
93
- children: JSX.Element;
94
- }>;
95
- type Obj = Record<string | symbol, any>;
96
- export interface TableColumn extends Obj {
97
- id?: any;
98
- name?: string;
99
- width?: number;
100
- fixed?: 'left' | 'right';
101
- class?: any;
102
- style?: any;
103
- props?: (props: any) => JSX.HTMLAttributes<any>;
104
- }
105
- type Nullable<T> = T | undefined;
106
- export interface TableStore extends Obj {
107
- scroll_el?: HTMLElement;
108
- table: HTMLElement;
109
- thead: HTMLElement;
110
- tbody: HTMLElement;
111
- ths: Nullable<Element>[];
112
- thSizes: Nullable<{
113
- width: number;
114
- height: number;
115
- }>[];
116
- trs: Nullable<Element>[];
117
- trSizes: Nullable<{
118
- width: number;
119
- height: number;
120
- }>[];
121
- internal: symbol;
122
- raw: symbol;
123
- props: TableProps2;
124
- rawProps: TableProps;
125
- plugins: Plugin[];
126
- }
127
- export declare const Intable: (props: TableProps) => JSX.Element;
128
- export default Intable;
129
- export declare const ScrollPlugin: Plugin;
130
- export declare const defaultsPlugins: Plugin[];
package/dist/index.js DELETED
@@ -1,347 +0,0 @@
1
- import { unFn } from "./utils.js";
2
- import { toReactive, useMemo } from "./hooks/index.js";
3
- import './style.css';;/* empty css */
4
- /* empty css */
5
- import { CellSelectionPlugin } from "./plugins/CellSelectionPlugin.js";
6
- import { ClipboardPlugin } from "./plugins/CopyPastePlugin.js";
7
- import { EditablePlugin } from "./plugins/EditablePlugin.js";
8
- import { solidComponent } from "./components/utils.js";
9
- import { RenderPlugin } from "./plugins/RenderPlugin/index.js";
10
- import { MenuPlugin } from "./plugins/MenuPlugin.js";
11
- import { CommandPlugin } from "./plugins/CommandPlugin.js";
12
- import { RowSelectionPlugin } from "./plugins/RowSelectionPlugin.js";
13
- import { ResizePlugin } from "./plugins/ResizePlugin.js";
14
- import { DragPlugin } from "./plugins/DragPlugin.js";
15
- import { RowGroupPlugin } from "./plugins/RowGroupPlugin.js";
16
- import { ExpandPlugin } from "./plugins/ExpandPlugin.js";
17
- import { createComponent, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
18
- import { For, batch, createComputed, createContext, createEffect, createMemo, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, on, onCleanup, onMount, runWithOwner, untrack, useContext } from "solid-js";
19
- import { createMutable, reconcile } from "solid-js/store";
20
- import { combineProps } from "@solid-primitives/props";
21
- import { difference, mapValues, sumBy } from "es-toolkit";
22
- import { createElementSize, createResizeObserver } from "@solid-primitives/resize-observer";
23
- import { createScrollPosition } from "@solid-primitives/scroll";
24
- var _tmpl$ = /* @__PURE__ */ template("<table>"), _tmpl$2 = /* @__PURE__ */ template("<thead>"), _tmpl$3 = /* @__PURE__ */ template("<tbody>"), _tmpl$4 = /* @__PURE__ */ template("<tr>"), _tmpl$5 = /* @__PURE__ */ template("<th>"), _tmpl$6 = /* @__PURE__ */ template("<td>"), _tmpl$7 = /* @__PURE__ */ template("<div><div class=data-table__layers></div><table class=data-table--table>");
25
- const Ctx = createContext({
26
- props: {},
27
- store: {}
28
- }), Intable = (_) => {
29
- _ = mergeProps$1({ rowKey: "id" }, _);
30
- let J = createMemo(() => [
31
- ...defaultsPlugins,
32
- ..._.plugins || [],
33
- RenderPlugin
34
- ].sort((_, K) => (K.priority || 0) - (_.priority || 0))), Y = createMutable({
35
- get rawProps() {
36
- return _;
37
- },
38
- get plugins() {
39
- return J();
40
- }
41
- }), X = getOwner();
42
- createComputed((_) => {
43
- let K = difference(J(), _);
44
- return runWithOwner(X, () => {
45
- K.forEach((_) => Object.assign(Y, _.store?.(Y)));
46
- }), J();
47
- }, []);
48
- let Z = mapArray(J, () => createSignal());
49
- Y.props = toReactive(createMemo(() => Z()[Z().length - 1][0]() || _)), createComputed(mapArray(J, (J, X) => {
50
- let Q = createMemo(() => Z()[X() - 1]?.[0]() || _), $ = mergeProps$1(Q, toReactive(mapValues(J.rewriteProps || {}, (_) => useMemo(() => _(Q(), { store: Y })))));
51
- Z()[X()][1]($);
52
- })), onMount(() => {
53
- createEffect(mapArray(J, (_) => _.onMount?.(Y)));
54
- });
55
- let $ = createMutable({
56
- props: Y.props,
57
- store: Y
58
- });
59
- return window.store = Y, window.ctx = $, createComponent(Ctx.Provider, {
60
- value: $,
61
- get children() {
62
- return createComponent($.props.Table, { get children() {
63
- return [createComponent(THead, {}), createComponent(TBody, {})];
64
- } });
65
- }
66
- });
67
- };
68
- var THead = () => {
69
- let { props: _ } = useContext(Ctx);
70
- return createComponent(_.Thead, { get children() {
71
- return createComponent(_.Tr, { get children() {
72
- return createComponent(_.EachCells, {
73
- get each() {
74
- return _.columns || [];
75
- },
76
- children: (K, q) => createComponent(_.Th, {
77
- get col() {
78
- return K();
79
- },
80
- get x() {
81
- return q();
82
- },
83
- get children() {
84
- return K().name;
85
- }
86
- })
87
- });
88
- } });
89
- } });
90
- }, TBody = () => {
91
- let { props: _ } = useContext(Ctx);
92
- return createComponent(_.Tbody, { get children() {
93
- return createComponent(_.EachRows, {
94
- get each() {
95
- return _.data;
96
- },
97
- children: (K, q) => createComponent(_.Tr, {
98
- get y() {
99
- return q();
100
- },
101
- get data() {
102
- return K();
103
- },
104
- get children() {
105
- return createComponent(_.EachCells, {
106
- get each() {
107
- return _.columns;
108
- },
109
- children: (J, Y) => createComponent(_.Td, {
110
- get col() {
111
- return J();
112
- },
113
- get x() {
114
- return Y();
115
- },
116
- get y() {
117
- return q();
118
- },
119
- get data() {
120
- return K();
121
- },
122
- get children() {
123
- return K()[J().id];
124
- }
125
- })
126
- });
127
- }
128
- })
129
- });
130
- } });
131
- }, src_default = Intable;
132
- function BasePlugin() {
133
- let K = {
134
- col: null,
135
- data: null
136
- }, q = (_) => (() => {
137
- var K = _tmpl$();
138
- return spread(K, _, !1, !1), K;
139
- })(), J = (_) => (() => {
140
- var K = _tmpl$2();
141
- return spread(K, _, !1, !1), K;
142
- })(), Y = (_) => (() => {
143
- var K = _tmpl$3();
144
- return spread(K, _, !1, !1), K;
145
- })(), X = (_) => (() => {
146
- var q = _tmpl$4();
147
- return spread(q, mergeProps(_, K), !1, !1), q;
148
- })(), Z = (_) => (() => {
149
- var q = _tmpl$5();
150
- return spread(q, mergeProps(_, K), !1, !1), q;
151
- })(), Q = (_) => (() => {
152
- var q = _tmpl$6();
153
- return spread(q, mergeProps(_, K), !1, !1), q;
154
- })();
155
- return {
156
- name: "base",
157
- priority: Infinity,
158
- store: (_) => ({
159
- ths: [],
160
- thSizes: [],
161
- trs: [],
162
- trSizes: [],
163
- internal: Symbol("internal"),
164
- raw: Symbol("raw")
165
- }),
166
- rewriteProps: {
167
- data: ({ data: _ = [] }) => _,
168
- columns: ({ columns: _ = [] }) => _,
169
- newRow: ({ newRow: _ = () => ({}) }) => _,
170
- Table: ({ Table: _ = q }, { store: K }) => (K) => {
171
- let [q, J] = createSignal(), { props: Y } = useContext(Ctx);
172
- return K = combineProps({
173
- ref: J,
174
- get class() {
175
- return `data-table ${Y.class} ${Y.border && "data-table--border"} data-table--${Y.size}`;
176
- },
177
- get style() {
178
- return Y.style;
179
- }
180
- }, K), createComponent(_, K);
181
- },
182
- Thead: ({ Thead: _ = J }, { store: K }) => (q) => (q = combineProps({ ref: (_) => K.thead = _ }, q), createComponent(_, q)),
183
- Tbody: ({ Tbody: _ = Y }, { store: K }) => (q) => (q = combineProps({ ref: (_) => K.tbody = _ }, q), createComponent(_, q)),
184
- Tr: ({ Tr: _ = X }, { store: K }) => (q) => {
185
- let [J, Y] = createSignal();
186
- return q = combineProps({ ref: Y }, q), createEffect(() => {
187
- let { y: _ } = q;
188
- K.trs[_] = J(), K.trSizes[_] = createElementSize(J()), onCleanup(() => K.trSizes[_] = K.trs[_] = void 0);
189
- }), createComponent(_, q);
190
- },
191
- Th: ({ Th: K = Z }, { store: q }) => (J) => {
192
- let [Y, X] = createSignal(), { props: Z } = useContext(Ctx), Q = combineProps(J, { ref: X }, {
193
- get class() {
194
- return unFn(Z.cellClass, J);
195
- },
196
- get style() {
197
- return unFn(Z.cellStyle, J);
198
- }
199
- }, {
200
- get class() {
201
- return J.col.class;
202
- },
203
- get style() {
204
- return J.col.style;
205
- }
206
- }, { get style() {
207
- return J.col.width ? `width: ${J.col.width}px` : "";
208
- } });
209
- return createEffect(() => {
210
- let { x: _ } = J;
211
- q.ths[_] = Y(), q.thSizes[_] = createElementSize(Y()), onCleanup(() => q.thSizes[_] = q.ths[_] = void 0);
212
- }), createComponent(K, mergeProps(Q, { get children() {
213
- return J.children;
214
- } }));
215
- },
216
- Td: ({ Td: K = Q }, { store: q }) => (q) => {
217
- let { props: J } = useContext(Ctx), Y = combineProps(q, {
218
- get class() {
219
- return unFn(J.cellClass, q);
220
- },
221
- get style() {
222
- return unFn(J.cellStyle, q);
223
- }
224
- }, {
225
- get class() {
226
- return q.col.class;
227
- },
228
- get style() {
229
- return q.col.style;
230
- }
231
- }, { get style() {
232
- return q.col.width ? `width: ${q.col.width}px` : "";
233
- } });
234
- return createComponent(K, mergeProps(Y, { get children() {
235
- return q.children;
236
- } }));
237
- },
238
- EachRows: ({ EachRows: _ }) => _ || ((_) => createComponent(For, {
239
- get each() {
240
- return _.each;
241
- },
242
- children: (K, q) => _.children(() => K, q)
243
- })),
244
- EachCells: ({ EachCells: _ }) => _ || ((_) => createComponent(For, {
245
- get each() {
246
- return _.each;
247
- },
248
- children: (K, q) => _.children(() => K, q)
249
- })),
250
- renderer: ({ renderer: _ = (_) => _ }) => _
251
- }
252
- };
253
- }
254
- var IndexPlugin = {
255
- name: "index",
256
- priority: -Infinity,
257
- store: (_) => ({ $index: {
258
- name: "",
259
- id: Symbol("index"),
260
- fixed: "left",
261
- [_.internal]: 1,
262
- width: 40,
263
- style: "text-align: center",
264
- class: "index",
265
- render: solidComponent((_) => memo(() => _.y + 1))
266
- } }),
267
- rewriteProps: { columns: ({ columns: _ }, { store: K }) => K.props?.index ? [K.$index, ..._ || []] : _ }
268
- }, StickyHeaderPlugin = {
269
- name: "sticky-header",
270
- rewriteProps: { Thead: ({ Thead: _ }) => (K) => {
271
- let { props: q } = useContext(Ctx);
272
- return K = combineProps({ get class() {
273
- return q.stickyHeader ? "sticky-header" : "";
274
- } }, K), createComponent(_, K);
275
- } }
276
- }, FixedColumnPlugin = {
277
- name: "fixed-column",
278
- rewriteProps: {
279
- columns: ({ columns: _ }) => [
280
- ..._?.filter((_) => _.fixed == "left") || [],
281
- ..._?.filter((_) => !_.fixed) || [],
282
- ..._?.filter((_) => _.fixed == "right") || []
283
- ],
284
- cellClass: ({ cellClass: K }) => (q) => (unFn(K, q) || "") + (q.col.fixed ? ` fixed-${q.col.fixed}` : ""),
285
- cellStyle: ({ cellStyle: K }, { store: q }) => (J) => (unFn(K, J) || "") + (J.col.fixed ? `; ${J.col.fixed}: ${sumBy(q.thSizes.slice(J.col.fixed == "left" ? 0 : J.x + 1, J.col.fixed == "left" ? J.x : Infinity), (_) => _?.width || 0)}px` : "")
286
- }
287
- }, FitColWidthPlugin = {
288
- name: "fit-col-width",
289
- priority: -Infinity,
290
- rewriteProps: {
291
- Table: (_, { store: K }) => (q) => {
292
- let J = createMutable({ width: 0 });
293
- return createResizeObserver(() => K.scroll_el, (_, K, q) => J.width = q.contentBoxSize[0].inlineSize), createEffect(on(() => [J.width, _.columns.map((_) => _.width)], async () => {
294
- if (!J.width) return;
295
- K.__fit_col_width__cols_temp = null, await Promise.resolve();
296
- let _ = (J.width - K.table.getBoundingClientRect().width) / K.props.columns.filter((_) => !_.width).length;
297
- K.__fit_col_width__cols_temp = K.props.columns.map((q, J) => q.width ? null : { width: Math.max((K.ths[J]?.getBoundingClientRect().width || 0) + _, 80) });
298
- })), createComponent(_.Table, q);
299
- },
300
- columns: ({ columns: _ }, { store: K }) => (_ = _.map((_, q) => ({
301
- ..._,
302
- ...K.__fit_col_width__cols_temp?.[q],
303
- [K.raw]: _[K.raw] ?? _
304
- })), untrack(() => batch(() => reconcile(_, { key: K.raw })(K.__fit_col_width__cols ??= []))))
305
- }
306
- };
307
- const ScrollPlugin = {
308
- name: "scroll",
309
- priority: Infinity,
310
- rewriteProps: { Table: (_, { store: K }) => (_) => {
311
- let q = createScrollPosition(() => K.scroll_el), J = createElementSize(() => K.scroll_el), Y = createMemo(() => {
312
- let _ = K.scroll_el;
313
- if (!_) return;
314
- let Y = q.x == 0, X = q.x >= _.scrollWidth - (J.width || 0);
315
- return Y && X ? "" : !Y && !X ? "is-scroll-mid" : Y ? "is-scroll-left" : X ? "is-scroll-right" : "";
316
- });
317
- _ = combineProps(_, {
318
- ref: (_) => K.scroll_el = _,
319
- class: "data-table--scroll-view"
320
- }, { get class() {
321
- return Y();
322
- } });
323
- let X = mapArray(() => K.plugins.flatMap((_) => _.layers ?? []), (_) => createComponent(_, K));
324
- return (() => {
325
- var q = _tmpl$7(), J = q.firstChild, Y = J.nextSibling;
326
- return spread(q, _, !1, !0), insert(J, X), use((_) => K.table = _, Y), insert(Y, () => _.children), q;
327
- })();
328
- } }
329
- }, defaultsPlugins = [
330
- ScrollPlugin,
331
- BasePlugin(),
332
- CommandPlugin,
333
- MenuPlugin,
334
- CellSelectionPlugin,
335
- StickyHeaderPlugin,
336
- FixedColumnPlugin,
337
- ResizePlugin,
338
- DragPlugin,
339
- ClipboardPlugin,
340
- ExpandPlugin,
341
- RowSelectionPlugin,
342
- IndexPlugin,
343
- EditablePlugin,
344
- FitColWidthPlugin,
345
- RowGroupPlugin
346
- ];
347
- export { Ctx, Intable, ScrollPlugin, src_default as default, defaultsPlugins };
package/dist/loading.js DELETED
@@ -1,6 +0,0 @@
1
- import { spread, template } from "solid-js/web";
2
- var _tmpl$ = /* @__PURE__ */ template("<svg width=1.2em height=1.2em xmlns=http://www.w3.org/2000/svg viewBox=\"0 0 24 24\"><g><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.14></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.29 transform=\"rotate(30 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.43 transform=\"rotate(60 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.57 transform=\"rotate(90 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.71 transform=\"rotate(120 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.86 transform=\"rotate(150 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor transform=\"rotate(180 12 12)\"></rect><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\">"), loading_default = (n = {}) => (() => {
3
- var r = _tmpl$();
4
- return spread(r, n, !0, !0), r;
5
- })();
6
- export { loading_default as default };
@@ -1,2 +0,0 @@
1
- import type { Plugin } from '..';
2
- export declare function CellChangeHighlightPlugin(): Plugin;
@@ -1,4 +0,0 @@
1
- function CellChangeHighlightPlugin() {
2
- return {};
3
- }
4
- export { CellChangeHighlightPlugin };
@@ -1,12 +0,0 @@
1
- import { type Plugin } from "../index";
2
- declare module '../index' {
3
- interface TableProps {
4
- }
5
- interface TableColumn {
6
- }
7
- interface TableStore {
8
- }
9
- interface Commands {
10
- }
11
- }
12
- export declare const CellMergePlugin: Plugin;
@@ -1,2 +0,0 @@
1
- const CellMergePlugin = { rewriteProps: {} };
2
- export { CellMergePlugin };
@@ -1,15 +0,0 @@
1
- import { type Plugin } from '..';
2
- declare module '../index' {
3
- interface TableProps {
4
- }
5
- interface TableStore {
6
- selected: {
7
- start: number[];
8
- end: number[];
9
- };
10
- }
11
- interface Commands {
12
- getAreaRows(): any[];
13
- }
14
- }
15
- export declare const CellSelectionPlugin: Plugin;
@@ -1,115 +0,0 @@
1
- import { usePointerDrag, useTinykeys } from "../hooks/index.js";
2
- import { Ctx } from "../index.js";
3
- import { createComponent, memo, mergeProps, template } from "solid-js/web";
4
- import { batch, createMemo, useContext } from "solid-js";
5
- import { combineProps } from "@solid-primitives/props";
6
- var _tmpl$ = /* @__PURE__ */ template("<div class=area>"), inrange = (e, a, o) => e <= o && e >= a;
7
- const CellSelectionPlugin = {
8
- name: "cell-selection",
9
- store: () => ({ selected: {
10
- start: [],
11
- end: []
12
- } }),
13
- commands: (e) => ({ getAreaRows() {
14
- let { start: a, end: o } = e.selected, [s, c] = [a[1], o[1]].sort((e, a) => e - a);
15
- return e.props.data.slice(s, c + 1);
16
- } }),
17
- rewriteProps: {
18
- Table: ({ Table: c }, { store: l }) => (u) => {
19
- let { props: f } = useContext(Ctx);
20
- l.cellSelectionRect ??= createMemo(() => {
21
- let { start: e, end: a } = l.selected, o = [e[0], a[0]].sort((e, a) => e - a), s = [e[1], a[1]].sort((e, a) => e - a);
22
- return {
23
- xs: o,
24
- ys: s
25
- };
26
- }), usePointerDrag(() => l.table, {
27
- preventDefault: !1,
28
- start(e, a, o) {
29
- batch(() => {
30
- let o = (e) => e.composedPath().find((e) => e.tagName == "TH" || e.tagName == "TD"), s = (e) => [e.getAttribute("x"), e.getAttribute("y")], c = o(e);
31
- if (c && !(e.buttons != 1 && c.classList.contains("range-selected"))) {
32
- if (c.tagName == "TH") {
33
- let [e, u] = s(c);
34
- if (e == null) return;
35
- l.selected.start = [+e, 0], l.selected.end = [+e, Infinity], a((e) => {
36
- let a = o(e);
37
- if (!a) return;
38
- let [c, u] = s(a);
39
- c != null && (l.selected.end = [+c, Infinity]);
40
- });
41
- }
42
- if (c.classList.contains("index")) {
43
- let [e, u] = s(c);
44
- if (e == null || u == null) return;
45
- l.selected.start = [0, +u], l.selected.end = [Infinity, +u], a((e) => {
46
- let a = o(e);
47
- if (!a) return;
48
- let [c, u] = s(a);
49
- c == null || u == null || (l.selected.end = [Infinity, +u]);
50
- });
51
- } else if (c.tagName == "TD") {
52
- let [e, u] = s(c);
53
- if (e == null || u == null) return;
54
- l.selected.start = [+e, +u], l.selected.end = [...l.selected.start], a((e) => {
55
- let a = o(e);
56
- if (!a) return;
57
- let [c, u] = s(a);
58
- c == null || u == null || (l.selected.end = [+c, +u]);
59
- });
60
- }
61
- }
62
- });
63
- }
64
- }), useTinykeys(() => l.table, {
65
- ArrowLeft: () => {
66
- let { start: e, end: a } = l.selected;
67
- e[0] = a[0] = Math.max(e[0] - 1, 0), a[1] = e[1], p();
68
- },
69
- ArrowRight: () => {
70
- let { start: e, end: a } = l.selected;
71
- e[0] = a[0] = Math.min(e[0] + 1, f.columns.length - 1), a[1] = e[1], p();
72
- },
73
- ArrowUp: () => {
74
- let { start: e, end: a } = l.selected;
75
- e[1] = a[1] = Math.max(e[1] - 1, 0), a[0] = e[0], p();
76
- },
77
- ArrowDown: () => {
78
- let { start: e, end: a } = l.selected;
79
- e[1] = a[1] = Math.min(e[1] + 1, f.data.length - 1), a[0] = e[0], p();
80
- }
81
- });
82
- let p = () => {
83
- let e = l.table.querySelector(`td[x="${l.selected.start[0]}"][y="${l.selected.start[1]}"]`);
84
- e?.scrollIntoViewIfNeeded(!1), e?.focus();
85
- };
86
- return u = combineProps({ class: "select-none" }, u), createComponent(c, u);
87
- },
88
- Th: ({ Th: e }, { store: a }) => (o) => {
89
- let u = createMemo(() => {
90
- let { start: e, end: s } = a.selected;
91
- return inrange(o.x, ...[e[0], s[0]].sort((e, a) => e - a)) ? "col-range-highlight" : "";
92
- }), d = combineProps(o, { get class() {
93
- return u();
94
- } });
95
- return createComponent(e, mergeProps(d, { get children() {
96
- return [memo(() => d.children), memo(() => memo(() => !!u())() && _tmpl$())];
97
- } }));
98
- },
99
- Td: ({ Td: e }, { store: a }) => (o) => {
100
- let u = createMemo(() => {
101
- let e = "", { xs: s, ys: c } = a.cellSelectionRect(), l = inrange(o.x, s[0], s[1]), u = inrange(o.y, c[0], c[1]);
102
- return l && u && (e += "range-selected ", o.x == s[0] && (e += "range-selected-l "), o.x == s[1] && (e += "range-selected-r "), o.y == c[0] && (e += "range-selected-t "), o.y == c[1] && (e += "range-selected-b ")), o.col.id == a.$index.id && u && (e += "row-range-highlight "), e;
103
- }), d = combineProps(o, {
104
- get class() {
105
- return u();
106
- },
107
- tabindex: -1
108
- });
109
- return createComponent(e, mergeProps(d, { get children() {
110
- return [memo(() => d.children), memo(() => memo(() => !!u())() && _tmpl$())];
111
- } }));
112
- }
113
- }
114
- };
115
- export { CellSelectionPlugin };
@@ -1,14 +0,0 @@
1
- import { type Plugin } from '..';
2
- declare module '../index' {
3
- interface TableProps {
4
- }
5
- interface TableStore {
6
- commands: Commands;
7
- }
8
- interface Plugin {
9
- commands?: (store: TableStore, commands: Partial<Commands>) => Partial<Commands> & Record<string, any>;
10
- }
11
- interface Commands {
12
- }
13
- }
14
- export declare const CommandPlugin: Plugin;
@@ -1,12 +0,0 @@
1
- import { createMemo, getOwner, runWithOwner } from "solid-js";
2
- const CommandPlugin = {
3
- name: "command",
4
- priority: Infinity,
5
- store: (r) => {
6
- let i = getOwner(), a = createMemo(() => r.plugins.reduce((e, n) => Object.assign(e, runWithOwner(i, () => n.commands?.(r, { ...e }))), {}));
7
- return { get commands() {
8
- return a();
9
- } };
10
- }
11
- };
12
- export { CommandPlugin };
@@ -1,14 +0,0 @@
1
- import { type Plugin } from '..';
2
- declare module '../index' {
3
- interface TableProps {
4
- }
5
- interface TableStore {
6
- }
7
- interface Plugin {
8
- }
9
- interface Commands {
10
- copy: () => void;
11
- paste: () => void;
12
- }
13
- }
14
- export declare const ClipboardPlugin: Plugin;