@rowsncolumns/grid 9.0.4 → 13.2.32
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/LICENSE.md +100 -0
- package/Readme.md +53 -59
- package/dist/cjs/Cell.d.ts +35 -0
- package/dist/cjs/Cell.d.ts.map +1 -0
- package/dist/cjs/Cell.js +29 -0
- package/dist/{CellOverlay.d.ts → cjs/CellOverlay.d.ts} +5 -5
- package/dist/cjs/CellOverlay.d.ts.map +1 -0
- package/dist/cjs/CellOverlay.js +126 -0
- package/dist/cjs/Context.d.ts +8 -0
- package/dist/cjs/Context.d.ts.map +1 -0
- package/dist/cjs/Context.js +13 -0
- package/dist/{FillHandle.d.ts → cjs/FillHandle.d.ts} +2 -1
- package/dist/cjs/FillHandle.d.ts.map +1 -0
- package/dist/cjs/FillHandle.js +26 -0
- package/dist/cjs/Grid.d.ts +558 -0
- package/dist/cjs/Grid.d.ts.map +1 -0
- package/dist/cjs/Grid.js +2446 -0
- package/dist/{GridLine.d.ts → cjs/GridLine.d.ts} +2 -1
- package/dist/cjs/GridLine.d.ts.map +1 -0
- package/dist/cjs/GridLine.js +10 -0
- package/dist/cjs/Image.d.ts +11 -0
- package/dist/cjs/Image.d.ts.map +1 -0
- package/dist/cjs/Image.js +57 -0
- package/dist/cjs/MemoizedGrid.d.ts +49 -0
- package/dist/cjs/MemoizedGrid.d.ts.map +1 -0
- package/dist/cjs/MemoizedGrid.js +105 -0
- package/dist/cjs/Selection.d.ts +5 -0
- package/dist/cjs/Selection.d.ts.map +1 -0
- package/dist/cjs/Selection.js +10 -0
- package/dist/{helpers.d.ts → cjs/helpers.d.ts} +59 -39
- package/dist/cjs/helpers.d.ts.map +1 -0
- package/dist/cjs/helpers.js +1409 -0
- package/dist/{hooks → cjs/hooks}/useCopyPaste.d.ts +3 -2
- package/dist/cjs/hooks/useCopyPaste.d.ts.map +1 -0
- package/dist/cjs/hooks/useCopyPaste.js +230 -0
- package/dist/{hooks → cjs/hooks}/useEditable.d.ts +21 -8
- package/dist/cjs/hooks/useEditable.d.ts.map +1 -0
- package/dist/cjs/hooks/useEditable.js +491 -0
- package/dist/{hooks → cjs/hooks}/useFilter.d.ts +3 -2
- package/dist/cjs/hooks/useFilter.d.ts.map +1 -0
- package/dist/cjs/hooks/useFilter.js +97 -0
- package/dist/{hooks → cjs/hooks}/useImage.d.ts +1 -0
- package/dist/cjs/hooks/useImage.d.ts.map +1 -0
- package/dist/cjs/hooks/useImage.js +80 -0
- package/dist/{hooks → cjs/hooks}/usePagination.d.ts +3 -2
- package/dist/cjs/hooks/usePagination.d.ts.map +1 -0
- package/dist/cjs/hooks/usePagination.js +53 -0
- package/dist/{hooks → cjs/hooks}/useSizer.d.ts +28 -29
- package/dist/cjs/hooks/useSizer.d.ts.map +1 -0
- package/dist/cjs/hooks/useSizer.js +176 -0
- package/dist/{hooks → cjs/hooks}/useTooltip.d.ts +2 -1
- package/dist/cjs/hooks/useTooltip.d.ts.map +1 -0
- package/dist/cjs/hooks/useTooltip.js +82 -0
- package/dist/{hooks → cjs/hooks}/useUndo.d.ts +2 -1
- package/dist/cjs/hooks/useUndo.d.ts.map +1 -0
- package/dist/cjs/hooks/useUndo.js +87 -0
- package/dist/cjs/index.d.ts +19 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +29 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/{types.d.ts → cjs/types.d.ts} +8 -3
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/{types.js → cjs/types.js} +7 -8
- package/dist/cjs/utils.d.ts +9 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +58 -0
- package/dist/cjs/vitest.config.d.ts +3 -0
- package/dist/cjs/vitest.config.d.ts.map +1 -0
- package/dist/cjs/vitest.config.js +24 -0
- package/dist/esm/Cell.d.ts +35 -0
- package/dist/esm/Cell.d.ts.map +1 -0
- package/dist/esm/Cell.js +24 -0
- package/dist/esm/CellOverlay.d.ts +21 -0
- package/dist/esm/CellOverlay.d.ts.map +1 -0
- package/dist/esm/CellOverlay.js +120 -0
- package/dist/esm/Context.d.ts +8 -0
- package/dist/esm/Context.d.ts.map +1 -0
- package/dist/esm/Context.js +9 -0
- package/dist/esm/FillHandle.d.ts +8 -0
- package/dist/esm/FillHandle.d.ts.map +1 -0
- package/dist/{FillHandle.js → esm/FillHandle.js} +5 -11
- package/dist/esm/Grid.d.ts +558 -0
- package/dist/esm/Grid.d.ts.map +1 -0
- package/dist/esm/Grid.js +2451 -0
- package/dist/esm/GridLine.d.ts +5 -0
- package/dist/esm/GridLine.d.ts.map +1 -0
- package/dist/esm/GridLine.js +7 -0
- package/dist/esm/Image.d.ts +11 -0
- package/dist/esm/Image.d.ts.map +1 -0
- package/dist/esm/Image.js +53 -0
- package/dist/esm/MemoizedGrid.d.ts +49 -0
- package/dist/esm/MemoizedGrid.d.ts.map +1 -0
- package/dist/esm/MemoizedGrid.js +98 -0
- package/dist/esm/Selection.d.ts +5 -0
- package/dist/esm/Selection.d.ts.map +1 -0
- package/dist/esm/Selection.js +7 -0
- package/dist/esm/helpers.d.ts +281 -0
- package/dist/esm/helpers.d.ts.map +1 -0
- package/dist/esm/helpers.js +1260 -0
- package/dist/esm/hooks/useCopyPaste.d.ts +53 -0
- package/dist/esm/hooks/useCopyPaste.d.ts.map +1 -0
- package/dist/{hooks → esm/hooks}/useCopyPaste.js +40 -46
- package/dist/esm/hooks/useEditable.d.ts +253 -0
- package/dist/esm/hooks/useEditable.d.ts.map +1 -0
- package/dist/esm/hooks/useEditable.js +482 -0
- package/dist/esm/hooks/useFilter.d.ts +69 -0
- package/dist/esm/hooks/useFilter.d.ts.map +1 -0
- package/dist/{hooks → esm/hooks}/useFilter.js +22 -42
- package/dist/esm/hooks/useImage.d.ts +13 -0
- package/dist/esm/hooks/useImage.d.ts.map +1 -0
- package/dist/esm/hooks/useImage.js +76 -0
- package/dist/esm/hooks/usePagination.d.ts +69 -0
- package/dist/esm/hooks/usePagination.d.ts.map +1 -0
- package/dist/esm/hooks/usePagination.js +47 -0
- package/dist/esm/hooks/useSizer.d.ts +114 -0
- package/dist/esm/hooks/useSizer.d.ts.map +1 -0
- package/dist/esm/hooks/useSizer.js +176 -0
- package/dist/esm/hooks/useTooltip.d.ts +43 -0
- package/dist/esm/hooks/useTooltip.d.ts.map +1 -0
- package/dist/esm/hooks/useTooltip.js +80 -0
- package/dist/esm/hooks/useUndo.d.ts +36 -0
- package/dist/esm/hooks/useUndo.d.ts.map +1 -0
- package/dist/{hooks → esm/hooks}/useUndo.js +16 -25
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +70 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +68 -0
- package/dist/esm/utils.d.ts +9 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +104 -0
- package/dist/esm/vitest.config.d.ts +3 -0
- package/dist/esm/vitest.config.d.ts.map +1 -0
- package/dist/esm/vitest.config.js +22 -0
- package/package.json +28 -29
- package/dist/Cell.d.ts +0 -23
- package/dist/Cell.js +0 -55
- package/dist/Cell.js.map +0 -1
- package/dist/CellOverlay.js +0 -116
- package/dist/CellOverlay.js.map +0 -1
- package/dist/FillHandle.js.map +0 -1
- package/dist/Grid.d.ts +0 -385
- package/dist/Grid.js +0 -1684
- package/dist/Grid.js.map +0 -1
- package/dist/GridLine.js +0 -13
- package/dist/GridLine.js.map +0 -1
- package/dist/Image.d.ts +0 -8
- package/dist/Image.js +0 -50
- package/dist/Image.js.map +0 -1
- package/dist/Selection.d.ts +0 -4
- package/dist/Selection.js +0 -9
- package/dist/Selection.js.map +0 -1
- package/dist/helpers.js +0 -1033
- package/dist/helpers.js.map +0 -1
- package/dist/hooks/useCopyPaste.js.map +0 -1
- package/dist/hooks/useEditable.js +0 -477
- package/dist/hooks/useEditable.js.map +0 -1
- package/dist/hooks/useFilter.js.map +0 -1
- package/dist/hooks/useImage.js +0 -42
- package/dist/hooks/useImage.js.map +0 -1
- package/dist/hooks/usePagination.js +0 -73
- package/dist/hooks/usePagination.js.map +0 -1
- package/dist/hooks/useSelection.d.ts +0 -175
- package/dist/hooks/useSelection.js +0 -982
- package/dist/hooks/useSelection.js.map +0 -1
- package/dist/hooks/useSizer.js +0 -150
- package/dist/hooks/useSizer.js.map +0 -1
- package/dist/hooks/useTooltip.js +0 -106
- package/dist/hooks/useTooltip.js.map +0 -1
- package/dist/hooks/useTouch.d.ts +0 -21
- package/dist/hooks/useTouch.js +0 -73
- package/dist/hooks/useTouch.js.map +0 -1
- package/dist/hooks/useUndo.js.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -61
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +0 -153
- package/dist/utils.js.map +0 -1
- package/src/Cell.tsx +0 -100
- package/src/CellOverlay.tsx +0 -191
- package/src/FillHandle.tsx +0 -37
- package/src/Grid.tsx +0 -2677
- package/src/GridLine.tsx +0 -23
- package/src/Image.tsx +0 -43
- package/src/Selection.tsx +0 -9
- package/src/helpers.ts +0 -1455
- package/src/hooks/useCopyPaste.ts +0 -265
- package/src/hooks/useEditable.tsx +0 -945
- package/src/hooks/useFilter.tsx +0 -233
- package/src/hooks/useImage.ts +0 -57
- package/src/hooks/usePagination.tsx +0 -153
- package/src/hooks/useSelection.ts +0 -1440
- package/src/hooks/useSizer.ts +0 -312
- package/src/hooks/useTooltip.tsx +0 -172
- package/src/hooks/useTouch.ts +0 -116
- package/src/hooks/useUndo.ts +0 -134
- package/src/index.tsx +0 -46
- package/src/tests/Grid.spec.tsx +0 -47
- package/src/tests/helpers.test.ts +0 -292
- package/src/tests/usePagination.test.ts +0 -28
- package/src/tests/useSelection.test.ts +0 -27
- package/src/tests/useUndo.test.ts +0 -73
- package/src/types.ts +0 -69
- package/src/utils.tsx +0 -287
package/LICENSE.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Rows n' Columns Commercial License Agreement
|
|
2
|
+
|
|
3
|
+
This Rows n' Columns Commercial License Agreement (the "Agreement") governs
|
|
4
|
+
the use of the Rows n' Columns software packages published under the
|
|
5
|
+
`@rowsncolumns` npm scope, including associated JavaScript, WebAssembly
|
|
6
|
+
binaries, stylesheets, type definitions and documentation (the "Software").
|
|
7
|
+
|
|
8
|
+
The Software is **not** open source. Downloading or installing the Software
|
|
9
|
+
from a public package registry does not grant any right to use it beyond the
|
|
10
|
+
evaluation use described below.
|
|
11
|
+
|
|
12
|
+
## 1. Definitions
|
|
13
|
+
|
|
14
|
+
- **"Licensor"** means Rows n' Columns (rowsncolumns.app).
|
|
15
|
+
- **"Licensee"** means the individual or legal entity identified in an Order.
|
|
16
|
+
- **"Order"** means a purchase of a license for the Software from Licensor,
|
|
17
|
+
identified by an order ID and associated with a License Key.
|
|
18
|
+
- **"License Key"** means the signed key issued by Licensor that identifies
|
|
19
|
+
the Licensee, license tier, and Update Window.
|
|
20
|
+
- **"Update Window"** means the period stated in the Order during which
|
|
21
|
+
Software versions released by Licensor are covered by the License Key.
|
|
22
|
+
|
|
23
|
+
## 2. License Grant
|
|
24
|
+
|
|
25
|
+
Subject to payment of the applicable fees and compliance with this Agreement,
|
|
26
|
+
Licensor grants Licensee a non-exclusive, non-transferable, worldwide license
|
|
27
|
+
to use, and to distribute in compiled form as an embedded component of
|
|
28
|
+
Licensee's own applications, any version of the Software released during the
|
|
29
|
+
Update Window, in accordance with the license tier stated in the Order.
|
|
30
|
+
|
|
31
|
+
This grant is perpetual for versions released during the Update Window:
|
|
32
|
+
Licensee may continue to use those versions after the Update Window ends.
|
|
33
|
+
Versions released after the Update Window ends require a new or renewed
|
|
34
|
+
Order.
|
|
35
|
+
|
|
36
|
+
## 3. Evaluation Use
|
|
37
|
+
|
|
38
|
+
The Software may be used without a License Key solely for internal
|
|
39
|
+
evaluation and development purposes. Evaluation use in production, or
|
|
40
|
+
removal or suppression of evaluation notices, is not permitted.
|
|
41
|
+
|
|
42
|
+
## 4. Restrictions
|
|
43
|
+
|
|
44
|
+
Except as expressly permitted by this Agreement or by applicable law that
|
|
45
|
+
cannot be contractually waived, Licensee shall not:
|
|
46
|
+
|
|
47
|
+
1. redistribute, resell, sublicense, or otherwise make the Software
|
|
48
|
+
available as a standalone product, library, or development component;
|
|
49
|
+
2. use the Software to build a product that competes with the Software;
|
|
50
|
+
3. remove, alter, or circumvent License Key validation, evaluation notices,
|
|
51
|
+
watermarks, or copyright notices in the Software;
|
|
52
|
+
4. share License Keys with any third party, or use a License Key outside
|
|
53
|
+
the scope of the tier stated in the Order;
|
|
54
|
+
5. reverse engineer, decompile, or disassemble the Software except to the
|
|
55
|
+
extent permitted by applicable law.
|
|
56
|
+
|
|
57
|
+
## 5. Ownership
|
|
58
|
+
|
|
59
|
+
The Software is licensed, not sold. Licensor and its licensors retain all
|
|
60
|
+
right, title, and interest in and to the Software, including all
|
|
61
|
+
intellectual property rights.
|
|
62
|
+
|
|
63
|
+
## 6. Third-Party Components
|
|
64
|
+
|
|
65
|
+
The Software may include third-party open-source components. Those
|
|
66
|
+
components remain governed by their own license terms, which are included
|
|
67
|
+
with the applicable component and are not limited by this Agreement.
|
|
68
|
+
|
|
69
|
+
## 7. Termination
|
|
70
|
+
|
|
71
|
+
This Agreement terminates automatically upon material breach by Licensee
|
|
72
|
+
that remains uncured 30 days after written notice. Upon termination,
|
|
73
|
+
Licensee must cease use and distribution of the Software, except that
|
|
74
|
+
end-user copies of Licensee applications already distributed in compliance
|
|
75
|
+
with this Agreement are unaffected.
|
|
76
|
+
|
|
77
|
+
## 8. Warranty Disclaimer
|
|
78
|
+
|
|
79
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
80
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
81
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
82
|
+
|
|
83
|
+
## 9. Limitation of Liability
|
|
84
|
+
|
|
85
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL LICENSOR BE LIABLE
|
|
86
|
+
FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES,
|
|
87
|
+
OR ANY LOSS OF PROFITS, DATA, OR GOODWILL, ARISING OUT OF OR RELATED TO THIS
|
|
88
|
+
AGREEMENT, AND LICENSOR'S AGGREGATE LIABILITY SHALL NOT EXCEED THE FEES PAID
|
|
89
|
+
BY LICENSEE IN THE TWELVE MONTHS PRECEDING THE CLAIM.
|
|
90
|
+
|
|
91
|
+
## 10. General
|
|
92
|
+
|
|
93
|
+
This Agreement constitutes the entire agreement between the parties
|
|
94
|
+
concerning the Software and supersedes any prior agreements. If any
|
|
95
|
+
provision is held unenforceable, the remainder remains in effect. Failure to
|
|
96
|
+
enforce a provision is not a waiver.
|
|
97
|
+
|
|
98
|
+
For licensing inquiries, visit <https://www.rowsncolumns.app/pricing>.
|
|
99
|
+
|
|
100
|
+
Copyright © Rows n' Columns. All rights reserved.
|
package/Readme.md
CHANGED
|
@@ -10,8 +10,6 @@ Canvas table grid to render large set of tabular data. Uses virtualization simil
|
|
|
10
10
|
|
|
11
11
|
[](https://lbesson.mit-license.org/) [](https://travis-ci.org/rowsncolumns/grid)
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
[Demo](https://rowsncolumns.github.io/grid) | [Usage](#Usage) | [Wiki](https://github.com/rowsncolumns/grid/wiki/Extending-Konva-Grid-using-hooks)
|
|
16
14
|
|
|
17
15
|
<kbd></kbd>
|
|
@@ -20,7 +18,7 @@ Canvas table grid to render large set of tabular data. Uses virtualization simil
|
|
|
20
18
|
|
|
21
19
|
- :electron: React powered declarative library
|
|
22
20
|
- :100: Virtualized: Only visible cells are rendered
|
|
23
|
-
- :bulb: Performant: Canvas implementation - 55-60fps (re-render) and
|
|
21
|
+
- :bulb: Performant: Canvas implementation - 55-60fps (re-render) and 40-60fps (scroll)
|
|
24
22
|
- :scroll: Supports scrolling using native scrollbars
|
|
25
23
|
- :computer: Supports both Fixed and Variable sized grids
|
|
26
24
|
- :fire: Freeze rows and columns
|
|
@@ -43,9 +41,11 @@ Born out of frustration, having to deal with complicated imperative canvas libra
|
|
|
43
41
|
## Installation
|
|
44
42
|
|
|
45
43
|
#### npm
|
|
44
|
+
|
|
46
45
|
```
|
|
47
46
|
npm install @rowsncolumns/grid --save
|
|
48
47
|
```
|
|
48
|
+
|
|
49
49
|
#### yarn
|
|
50
50
|
|
|
51
51
|
```
|
|
@@ -74,18 +74,18 @@ Uses [react-table](https://github.com/tannerlinsley/react-table) to create group
|
|
|
74
74
|
|
|
75
75
|
[https://github.com/rowsncolumns/grid/tree/master/examples/zustand](https://github.com/rowsncolumns/grid/tree/master/examples/zustand)
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
_More examples coming soon._
|
|
78
78
|
|
|
79
79
|
## Usage
|
|
80
80
|
|
|
81
81
|
```js
|
|
82
|
-
import { Grid, Cell } from
|
|
83
|
-
import { Group, Text, Rect } from
|
|
82
|
+
import { Grid, Cell } from "@rowsncolumns/grid";
|
|
83
|
+
import { Group, Text, Rect } from "react-konva";
|
|
84
84
|
|
|
85
85
|
const App = () => {
|
|
86
86
|
const data = {
|
|
87
|
-
[[1, 2]]:
|
|
88
|
-
}
|
|
87
|
+
[[1, 2]]: "Hello world",
|
|
88
|
+
};
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<Grid
|
|
@@ -96,54 +96,50 @@ const App = () => {
|
|
|
96
96
|
rowHeight={(rowIndex) => 20}
|
|
97
97
|
columnWidth={(columnIndex) => 100}
|
|
98
98
|
itemRenderer={(props) => (
|
|
99
|
-
<Cell
|
|
100
|
-
{...props}
|
|
101
|
-
value={
|
|
102
|
-
data[[props.rowIndex, props.columnIndex]]
|
|
103
|
-
}
|
|
104
|
-
/>
|
|
99
|
+
<Cell {...props} value={data[[props.rowIndex, props.columnIndex]]} />
|
|
105
100
|
)}
|
|
106
101
|
/>
|
|
107
|
-
)
|
|
108
|
-
}
|
|
102
|
+
);
|
|
103
|
+
};
|
|
109
104
|
```
|
|
110
105
|
|
|
111
106
|
## Props
|
|
107
|
+
|
|
112
108
|
This is the list of props that are meant to be used to customise the `konva-grid` behavior.
|
|
113
109
|
|
|
114
|
-
| Name
|
|
115
|
-
|
|
116
|
-
| width
|
|
117
|
-
| height| true
|
|
118
|
-
| columnCount
|
|
119
|
-
| rowCount
|
|
120
|
-
| rowHeight
|
|
121
|
-
| columnWidth
|
|
122
|
-
| itemRenderer
|
|
123
|
-
| selectionRenderer
|
|
124
|
-
| scrollbarSize
|
|
125
|
-
| showScrollbar
|
|
126
|
-
| selectionBackgroundColor | false
|
|
127
|
-
| selectionBorderColor
|
|
128
|
-
| selectionStrokeWidth
|
|
129
|
-
| activeCellStrokeWidth
|
|
130
|
-
| activeCell
|
|
131
|
-
| selections
|
|
132
|
-
| mergedCells
|
|
133
|
-
| cellAreas
|
|
134
|
-
| snap
|
|
135
|
-
| frozenRows
|
|
136
|
-
| frozenColumns
|
|
137
|
-
| showFrozenShadow| false
|
|
138
|
-
| shadowSettings| false
|
|
139
|
-
| onBeforeRenderRow
|
|
140
|
-
| stageProps
|
|
141
|
-
| children
|
|
142
|
-
| wrapper
|
|
143
|
-
| showFillHandle
|
|
144
|
-
| onFillHandleMouseDown
|
|
145
|
-
| fillSelection
|
|
146
|
-
| overscanCount
|
|
110
|
+
| Name | Required | Type | Description | Default |
|
|
111
|
+
| ------------------------ | -------- | ------------------------- | ---------------------------------------------------------------------------- | ----------------------- |
|
|
112
|
+
| width | true | number | Width of the grid container | 800 |
|
|
113
|
+
| height | true | number | Height of the grid container | 800 |
|
|
114
|
+
| columnCount | true | number | No of columns in the grid | 200 |
|
|
115
|
+
| rowCount | true | number | No of rows in the grid | 200 |
|
|
116
|
+
| rowHeight | true | function | Function that returns height of the row based on rowIndex | (rowIndex) => 20 |
|
|
117
|
+
| columnWidth | true | function | Function that returns width of the column based on columnIndex | (columnIndex) => 100 |
|
|
118
|
+
| itemRenderer | true | Function | React component to render the cell | null |
|
|
119
|
+
| selectionRenderer | true | Function | React component to render selected cell | null |
|
|
120
|
+
| scrollbarSize | false | number | Size of the scrollbar | 17 |
|
|
121
|
+
| showScrollbar | false | boolean | Always show scrollbar | true |
|
|
122
|
+
| selectionBackgroundColor | false | string | Background color of selected cells | rgba(66, 133, 244, 0.3) |
|
|
123
|
+
| selectionBorderColor | false | string | Border color of bounding box of selected cells | rgba(66, 133, 244, 1) |
|
|
124
|
+
| selectionStrokeWidth | false | number | Border width of selection | 1 |
|
|
125
|
+
| activeCellStrokeWidth | false | number | Border width of activeCell | 2 |
|
|
126
|
+
| activeCell | false | { rowIndex, columnIndex } | Recently active cell that user has clicked | null |
|
|
127
|
+
| selections | false | Array | Array of selected cell areas | [] |
|
|
128
|
+
| mergedCells | false | Array | Array of merged cell areas | [] |
|
|
129
|
+
| cellAreas | false | Array | Increase the range of certain cells | [] |
|
|
130
|
+
| snap | false | boolean | Snaps to the next row or column as you scroll | false |
|
|
131
|
+
| frozenRows | false | number | No of frozen rows | 0 |
|
|
132
|
+
| frozenColumns | false | number | No of frozen columns | 0 |
|
|
133
|
+
| showFrozenShadow | false | boolean | Show shadow in frozen columns/rows | true |
|
|
134
|
+
| shadowSettings | false | object | Customize shadow of frozen columns/rows | true |
|
|
135
|
+
| onBeforeRenderRow | false | Function | Called right before a row is rendered, useful for `react-table` | null |
|
|
136
|
+
| stageProps | false | Object | Konva stage props | null |
|
|
137
|
+
| children | false | Function | Inject React Konva shapes using children | null |
|
|
138
|
+
| wrapper | false | Function | Inject custom context using a wrapper | (children) => children |
|
|
139
|
+
| showFillHandle | false | boolean | Show fill handle at bottom right corner | true |
|
|
140
|
+
| onFillHandleMouseDown | false | Function | Callback fired user selects fill handle | null |
|
|
141
|
+
| fillSelection | false | SelectionProp | Area of selected fill | null |
|
|
142
|
+
| overscanCount | false | number | Number of items outside the visible viewport should be renderer at all times | 1 |
|
|
147
143
|
|
|
148
144
|
## Methods
|
|
149
145
|
|
|
@@ -155,15 +151,14 @@ Scrolls the grid to a specified `x,y` position relative to the container
|
|
|
155
151
|
|
|
156
152
|
Imperatively trigger re-render of the grid after specified `rowIndex` or `columnIndex`
|
|
157
153
|
|
|
158
|
-
|
|
159
154
|
#### `getScrollPosition()`
|
|
160
155
|
|
|
161
|
-
Get the current scroll position of the grid.
|
|
156
|
+
Get the current scroll position of the grid.
|
|
162
157
|
|
|
163
|
-
|
|
158
|
+
```
|
|
164
159
|
const gridRef = useRef()
|
|
165
160
|
const { scrollLeft, scrollTop } = gridRef.current.getScrollPosition()
|
|
166
|
-
|
|
161
|
+
```
|
|
167
162
|
|
|
168
163
|
#### `isMergedCell({ rowIndex, columnIndex })`
|
|
169
164
|
|
|
@@ -175,13 +170,12 @@ Returns a selection `IArea` for a particular cell. Useful to get selection area
|
|
|
175
170
|
|
|
176
171
|
#### `getCellCoordsFromOffsets(x , y)`
|
|
177
172
|
|
|
178
|
-
Returns exact `rowIndex` and `columnIndex` from a `x`
|
|
173
|
+
Returns exact `rowIndex` and `columnIndex` from a `x` and `y` cordinate. Useful if you want to get cell coords based on mouse position
|
|
179
174
|
|
|
180
175
|
#### `getCellOffsetFromCoords({ rowIndex, columnIndex })`
|
|
181
176
|
|
|
182
177
|
Returns offset position `{ x, y, width, height }` of a cell
|
|
183
178
|
|
|
184
|
-
|
|
185
179
|
#### `stage`
|
|
186
180
|
|
|
187
181
|
Access Konva `stage` instance
|
|
@@ -194,7 +188,7 @@ const gridRef = useRef()
|
|
|
194
188
|
>
|
|
195
189
|
|
|
196
190
|
const stage = gridRef.current.stage
|
|
197
|
-
|
|
191
|
+
```
|
|
198
192
|
|
|
199
193
|
## Passing Contexts
|
|
200
194
|
|
|
@@ -245,10 +239,10 @@ yarn run storybook
|
|
|
245
239
|
|
|
246
240
|
Feel free to fork and submit pull requests
|
|
247
241
|
|
|
248
|
-
|
|
242
|
+
```
|
|
249
243
|
git clone https://github.com/rowsncolumns/grid.git
|
|
250
244
|
cd grid
|
|
251
245
|
yarn
|
|
252
246
|
// Run storybook
|
|
253
|
-
yarn storybook
|
|
254
|
-
|
|
247
|
+
yarn storybook
|
|
248
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { RendererProps } from "./Grid";
|
|
3
|
+
export interface CellProps extends RendererProps {
|
|
4
|
+
value?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
padding?: number;
|
|
7
|
+
bold?: boolean;
|
|
8
|
+
italic?: boolean;
|
|
9
|
+
strikethrough?: boolean;
|
|
10
|
+
underline?: boolean;
|
|
11
|
+
lineHeight?: number;
|
|
12
|
+
textDecoration?: string;
|
|
13
|
+
verticalAlignment?: string;
|
|
14
|
+
horizontalAlignment?: string;
|
|
15
|
+
fontFamily?: string;
|
|
16
|
+
fontSize?: number;
|
|
17
|
+
wrapStrategy?: string;
|
|
18
|
+
scale?: number;
|
|
19
|
+
backgroundColor?: string;
|
|
20
|
+
image?: string;
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Default cell component
|
|
25
|
+
* @param props
|
|
26
|
+
*/
|
|
27
|
+
declare const Cell: React.FC<CellProps>;
|
|
28
|
+
/**
|
|
29
|
+
* Default CellRenderer
|
|
30
|
+
* @param props
|
|
31
|
+
*/
|
|
32
|
+
declare const CellRenderer: (props: RendererProps) => React.JSX.Element;
|
|
33
|
+
export default CellRenderer;
|
|
34
|
+
export { CellRenderer, Cell };
|
|
35
|
+
//# sourceMappingURL=Cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cell.d.ts","sourceRoot":"","sources":["../../Cell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAGpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG5C,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAgD5B,CAAC;AAIH;;;GAGG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,aAAa,sBAEzC,CAAC;AAEF,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/cjs/Cell.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cell = exports.CellRenderer = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
var react_konva_1 = require("react-konva");
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
/**
|
|
9
|
+
* Default cell component
|
|
10
|
+
* @param props
|
|
11
|
+
*/
|
|
12
|
+
var Cell = (0, react_1.memo)(function (props) {
|
|
13
|
+
var _a = props.x, x = _a === void 0 ? 0 : _a, _b = props.y, y = _b === void 0 ? 0 : _b, width = props.width, height = props.height, value = props.value, _c = props.horizontalAlignment, horizontalAlignment = _c === void 0 ? "left" : _c, _d = props.verticalAlignment, verticalAlignment = _d === void 0 ? "bottom" : _d, _e = props.color, color = _e === void 0 ? "#333" : _e, _f = props.padding, padding = _f === void 0 ? 3 : _f, _g = props.fontFamily, fontFamily = _g === void 0 ? "Arial" : _g, _h = props.fontSize, fontSize = _h === void 0 ? 12 : _h, children = props.children, _j = props.wrapStrategy, wrapStrategy = _j === void 0 ? "none" : _j, bold = props.bold, italic = props.italic, textDecoration = props.textDecoration, _k = props.lineHeight, lineHeight = _k === void 0 ? 1 : _k;
|
|
14
|
+
var textStyle = "".concat(bold ? "bold" : "normal", " ").concat(italic ? "italic" : "normal");
|
|
15
|
+
return (react_1.default.createElement(react_konva_1.Group, null,
|
|
16
|
+
(0, helpers_1.isNull)(value) ? null : (react_1.default.createElement(react_konva_1.Text, { x: x, y: y, height: height, width: width, text: value, fill: color, verticalAlign: verticalAlignment, align: horizontalAlignment, fontFamily: fontFamily, fontStyle: textStyle, textDecoration: textDecoration, padding: padding, wrap: wrapStrategy, fontSize: fontSize, hitStrokeWidth: 0, lineHeight: lineHeight })),
|
|
17
|
+
children));
|
|
18
|
+
});
|
|
19
|
+
exports.Cell = Cell;
|
|
20
|
+
Cell.displayName = "Cell";
|
|
21
|
+
/**
|
|
22
|
+
* Default CellRenderer
|
|
23
|
+
* @param props
|
|
24
|
+
*/
|
|
25
|
+
var CellRenderer = function (props) {
|
|
26
|
+
return react_1.default.createElement(Cell, tslib_1.__assign({}, props));
|
|
27
|
+
};
|
|
28
|
+
exports.CellRenderer = CellRenderer;
|
|
29
|
+
exports.default = CellRenderer;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CellProps } from "./Cell";
|
|
3
|
-
import { RendererProps } from "./Grid";
|
|
4
|
-
export
|
|
5
|
-
}
|
|
2
|
+
import type { CellProps } from "./Cell";
|
|
3
|
+
import type { RendererProps } from "./Grid";
|
|
4
|
+
export type StrokeCellProps = Omit<CellProps, "key" | "rowIndex" | "columnIndex">;
|
|
6
5
|
/**
|
|
7
6
|
* Offset helps multiple borders to align properly
|
|
8
7
|
* @param width
|
|
@@ -16,6 +15,7 @@ declare const CellOverlay: React.FC<StrokeCellProps>;
|
|
|
16
15
|
* Default CellRenderer
|
|
17
16
|
* @param props
|
|
18
17
|
*/
|
|
19
|
-
declare const CellRenderer: (props: RendererProps) => JSX.Element | null;
|
|
18
|
+
declare const CellRenderer: (props: RendererProps) => React.JSX.Element | null;
|
|
20
19
|
export default CellRenderer;
|
|
21
20
|
export { CellRenderer, CellOverlay };
|
|
21
|
+
//# sourceMappingURL=CellOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellOverlay.d.ts","sourceRoot":"","sources":["../../CellOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAGpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAK5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,SAAS,EACT,KAAK,GAAG,UAAU,GAAG,aAAa,CACnC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,WAE/C,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAgJzC,CAAC;AAEH;;;GAGG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,aAAa,6BAmEzC,CAAC;AAGF,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CellOverlay = exports.CellRenderer = exports.getOffsetFromWidth = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
var react_konva_1 = require("react-konva");
|
|
7
|
+
/* Array placeholder */
|
|
8
|
+
var EMPTY_ARRAY = [];
|
|
9
|
+
/**
|
|
10
|
+
* Offset helps multiple borders to align properly
|
|
11
|
+
* @param width
|
|
12
|
+
*/
|
|
13
|
+
var getOffsetFromWidth = function (width) {
|
|
14
|
+
return width / 2 - 0.5;
|
|
15
|
+
};
|
|
16
|
+
exports.getOffsetFromWidth = getOffsetFromWidth;
|
|
17
|
+
/**
|
|
18
|
+
* Only used for strokes
|
|
19
|
+
*/
|
|
20
|
+
var CellOverlay = (0, react_1.memo)(function (props) {
|
|
21
|
+
var x = props.x, y = props.y, width = props.width, height = props.height, strokeTopColor = props.strokeTopColor, strokeRightColor = props.strokeRightColor, strokeBottomColor = props.strokeBottomColor, strokeLeftColor = props.strokeLeftColor, strokeDiagonalUpColor = props.strokeDiagonalUpColor, strokeDiagonalDownColor = props.strokeDiagonalDownColor, _a = props.strokeTopDash, strokeTopDash = _a === void 0 ? EMPTY_ARRAY : _a, _b = props.strokeRightDash, strokeRightDash = _b === void 0 ? EMPTY_ARRAY : _b, _c = props.strokeBottomDash, strokeBottomDash = _c === void 0 ? EMPTY_ARRAY : _c, _d = props.strokeLeftDash, strokeLeftDash = _d === void 0 ? EMPTY_ARRAY : _d, _e = props.strokeDiagonalUpDash, strokeDiagonalUpDash = _e === void 0 ? EMPTY_ARRAY : _e, _f = props.strokeDiagonalDownDash, strokeDiagonalDownDash = _f === void 0 ? EMPTY_ARRAY : _f, _g = props.strokeTopWidth, strokeTopWidth = _g === void 0 ? 0 : _g, _h = props.strokeRightWidth, strokeRightWidth = _h === void 0 ? 0 : _h, _j = props.strokeBottomWidth, strokeBottomWidth = _j === void 0 ? 0 : _j, _k = props.strokeLeftWidth, strokeLeftWidth = _k === void 0 ? 0 : _k, _l = props.strokeDiagonalUpWidth, strokeDiagonalUpWidth = _l === void 0 ? 0 : _l, _m = props.strokeDiagonalDownWidth, strokeDiagonalDownWidth = _m === void 0 ? 0 : _m, lineCap = props.lineCap;
|
|
22
|
+
var userStroke = strokeTopColor ||
|
|
23
|
+
strokeRightColor ||
|
|
24
|
+
strokeBottomColor ||
|
|
25
|
+
strokeLeftColor ||
|
|
26
|
+
strokeDiagonalUpColor ||
|
|
27
|
+
strokeDiagonalDownColor;
|
|
28
|
+
if (!userStroke)
|
|
29
|
+
return null;
|
|
30
|
+
return (react_1.default.createElement(react_konva_1.Shape, { x: x, y: y, width: width, height: height, listening: false, perfectDrawEnabled: false, sceneFunc: function (context, shape) {
|
|
31
|
+
/* Top border */
|
|
32
|
+
if (strokeTopColor) {
|
|
33
|
+
context.beginPath();
|
|
34
|
+
context.moveTo(strokeLeftColor ? -(0, exports.getOffsetFromWidth)(strokeLeftWidth) : 0, 0.5);
|
|
35
|
+
context.lineTo(shape.width() +
|
|
36
|
+
(strokeRightColor ? (0, exports.getOffsetFromWidth)(strokeRightWidth) + 1 : 1), 0.5);
|
|
37
|
+
context.setAttr("strokeStyle", strokeTopColor);
|
|
38
|
+
context.setAttr("lineWidth", strokeTopWidth);
|
|
39
|
+
context.setAttr("lineCap", lineCap);
|
|
40
|
+
context.setLineDash(strokeTopDash);
|
|
41
|
+
context.stroke();
|
|
42
|
+
}
|
|
43
|
+
/* Bottom border */
|
|
44
|
+
if (strokeBottomColor) {
|
|
45
|
+
context.beginPath();
|
|
46
|
+
context.moveTo(strokeLeftColor ? -(0, exports.getOffsetFromWidth)(strokeLeftWidth) : 0, shape.height() + 0.5);
|
|
47
|
+
context.lineTo(shape.width() +
|
|
48
|
+
(strokeRightColor ? (0, exports.getOffsetFromWidth)(strokeRightWidth) + 1 : 1), shape.height() + 0.5);
|
|
49
|
+
context.setAttr("lineWidth", strokeBottomWidth);
|
|
50
|
+
context.setAttr("strokeStyle", strokeBottomColor);
|
|
51
|
+
context.setAttr("lineCap", lineCap);
|
|
52
|
+
context.setLineDash(strokeBottomDash);
|
|
53
|
+
context.stroke();
|
|
54
|
+
}
|
|
55
|
+
/* Left border */
|
|
56
|
+
if (strokeLeftColor) {
|
|
57
|
+
context.beginPath();
|
|
58
|
+
context.moveTo(0.5, strokeTopColor ? -(0, exports.getOffsetFromWidth)(strokeTopWidth) : 0);
|
|
59
|
+
context.lineTo(0.5, shape.height() +
|
|
60
|
+
(strokeBottomColor
|
|
61
|
+
? (0, exports.getOffsetFromWidth)(strokeBottomWidth) + 1
|
|
62
|
+
: 1));
|
|
63
|
+
context.setAttr("strokeStyle", strokeLeftColor);
|
|
64
|
+
context.setAttr("lineWidth", strokeLeftWidth);
|
|
65
|
+
context.setAttr("lineCap", lineCap);
|
|
66
|
+
context.setLineDash(strokeLeftDash);
|
|
67
|
+
context.stroke();
|
|
68
|
+
}
|
|
69
|
+
/* Right border */
|
|
70
|
+
if (strokeRightColor) {
|
|
71
|
+
context.beginPath();
|
|
72
|
+
context.moveTo(shape.width() + 0.5, strokeTopColor ? -(0, exports.getOffsetFromWidth)(strokeTopWidth) : 0);
|
|
73
|
+
context.lineTo(shape.width() + 0.5, shape.height() +
|
|
74
|
+
(strokeBottomColor
|
|
75
|
+
? (0, exports.getOffsetFromWidth)(strokeBottomWidth) + 1
|
|
76
|
+
: 1));
|
|
77
|
+
context.setAttr("strokeStyle", strokeRightColor);
|
|
78
|
+
context.setAttr("lineWidth", strokeRightWidth);
|
|
79
|
+
context.setAttr("lineCap", lineCap);
|
|
80
|
+
context.setLineDash(strokeRightDash);
|
|
81
|
+
context.stroke();
|
|
82
|
+
}
|
|
83
|
+
/* Diagonal: top-left to bottom-right (diagonalDown) */
|
|
84
|
+
if (strokeDiagonalDownColor) {
|
|
85
|
+
context.beginPath();
|
|
86
|
+
context.moveTo(0, 0);
|
|
87
|
+
context.lineTo(shape.width(), shape.height());
|
|
88
|
+
context.setAttr("strokeStyle", strokeDiagonalDownColor);
|
|
89
|
+
context.setAttr("lineWidth", strokeDiagonalDownWidth);
|
|
90
|
+
context.setAttr("lineCap", lineCap);
|
|
91
|
+
context.setLineDash(strokeDiagonalDownDash);
|
|
92
|
+
context.stroke();
|
|
93
|
+
}
|
|
94
|
+
/* Diagonal: bottom-left to top-right (diagonalUp) */
|
|
95
|
+
if (strokeDiagonalUpColor) {
|
|
96
|
+
context.beginPath();
|
|
97
|
+
context.moveTo(0, shape.height());
|
|
98
|
+
context.lineTo(shape.width(), 0);
|
|
99
|
+
context.setAttr("strokeStyle", strokeDiagonalUpColor);
|
|
100
|
+
context.setAttr("lineWidth", strokeDiagonalUpWidth);
|
|
101
|
+
context.setAttr("lineCap", lineCap);
|
|
102
|
+
context.setLineDash(strokeDiagonalUpDash);
|
|
103
|
+
context.stroke();
|
|
104
|
+
}
|
|
105
|
+
} }));
|
|
106
|
+
});
|
|
107
|
+
exports.CellOverlay = CellOverlay;
|
|
108
|
+
/**
|
|
109
|
+
* Default CellRenderer
|
|
110
|
+
* @param props
|
|
111
|
+
*/
|
|
112
|
+
var CellRenderer = function (props) {
|
|
113
|
+
var x = props.x, y = props.y, width = props.width, height = props.height, stroke = props.stroke, _a = props.strokeTopColor, strokeTopColor = _a === void 0 ? stroke : _a, _b = props.strokeRightColor, strokeRightColor = _b === void 0 ? stroke : _b, _c = props.strokeBottomColor, strokeBottomColor = _c === void 0 ? stroke : _c, _d = props.strokeLeftColor, strokeLeftColor = _d === void 0 ? stroke : _d, strokeDiagonalUpColor = props.strokeDiagonalUpColor, strokeDiagonalDownColor = props.strokeDiagonalDownColor, _e = props.strokeDash, strokeDash = _e === void 0 ? EMPTY_ARRAY : _e, _f = props.strokeTopDash, strokeTopDash = _f === void 0 ? EMPTY_ARRAY : _f, _g = props.strokeRightDash, strokeRightDash = _g === void 0 ? EMPTY_ARRAY : _g, _h = props.strokeBottomDash, strokeBottomDash = _h === void 0 ? EMPTY_ARRAY : _h, _j = props.strokeLeftDash, strokeLeftDash = _j === void 0 ? EMPTY_ARRAY : _j, _k = props.strokeDiagonalUpDash, strokeDiagonalUpDash = _k === void 0 ? EMPTY_ARRAY : _k, _l = props.strokeDiagonalDownDash, strokeDiagonalDownDash = _l === void 0 ? EMPTY_ARRAY : _l, _m = props.strokeWidth, strokeWidth = _m === void 0 ? 1 : _m, _o = props.strokeTopWidth, strokeTopWidth = _o === void 0 ? strokeWidth : _o, _p = props.strokeRightWidth, strokeRightWidth = _p === void 0 ? strokeWidth : _p, _q = props.strokeBottomWidth, strokeBottomWidth = _q === void 0 ? strokeWidth : _q, _r = props.strokeLeftWidth, strokeLeftWidth = _r === void 0 ? strokeWidth : _r, _s = props.strokeDiagonalUpWidth, strokeDiagonalUpWidth = _s === void 0 ? strokeWidth : _s, _t = props.strokeDiagonalDownWidth, strokeDiagonalDownWidth = _t === void 0 ? strokeWidth : _t, _u = props.lineCap, lineCap = _u === void 0 ? "butt" : _u, key = props.key;
|
|
114
|
+
var userStroke = strokeTopColor ||
|
|
115
|
+
strokeRightColor ||
|
|
116
|
+
strokeBottomColor ||
|
|
117
|
+
strokeLeftColor ||
|
|
118
|
+
strokeDiagonalUpColor ||
|
|
119
|
+
strokeDiagonalDownColor;
|
|
120
|
+
if (!userStroke)
|
|
121
|
+
return null;
|
|
122
|
+
return (react_1.default.createElement(CellOverlay, { key: key, x: x, y: y, width: width, height: height, strokeTopColor: strokeTopColor, strokeRightColor: strokeRightColor, strokeBottomColor: strokeBottomColor, strokeLeftColor: strokeLeftColor, strokeDiagonalUpColor: strokeDiagonalUpColor, strokeDiagonalDownColor: strokeDiagonalDownColor, strokeDash: strokeDash, strokeTopDash: strokeTopDash, strokeRightDash: strokeRightDash, strokeBottomDash: strokeBottomDash, strokeLeftDash: strokeLeftDash, strokeDiagonalUpDash: strokeDiagonalUpDash, strokeDiagonalDownDash: strokeDiagonalDownDash, strokeTopWidth: strokeTopWidth, strokeRightWidth: strokeRightWidth, strokeBottomWidth: strokeBottomWidth, strokeLeftWidth: strokeLeftWidth, strokeDiagonalUpWidth: strokeDiagonalUpWidth, strokeDiagonalDownWidth: strokeDiagonalDownWidth, lineCap: lineCap }));
|
|
123
|
+
};
|
|
124
|
+
exports.CellRenderer = CellRenderer;
|
|
125
|
+
CellOverlay.displayName = "CellOverlay";
|
|
126
|
+
exports.default = CellRenderer;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CellInterface, CellPosition } from "./Grid";
|
|
2
|
+
type GridContext = {
|
|
3
|
+
getCellOffsetFromCoords(coords: CellInterface, readonly?: boolean): CellPosition | undefined;
|
|
4
|
+
};
|
|
5
|
+
export declare const GridContext: import("react").Context<GridContext | undefined>;
|
|
6
|
+
export declare const useGridContext: () => GridContext;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../Context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE1D,KAAK,WAAW,GAAG;IACjB,uBAAuB,CACrB,MAAM,EAAE,aAAa,EACrB,QAAQ,CAAC,EAAE,OAAO,GACjB,YAAY,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,WAAW,kDAAoD,CAAC;AAE7E,eAAO,MAAM,cAAc,mBAM1B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGridContext = exports.GridContext = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
exports.GridContext = (0, react_1.createContext)(undefined);
|
|
6
|
+
var useGridContext = function () {
|
|
7
|
+
var contextValue = (0, react_1.useContext)(exports.GridContext);
|
|
8
|
+
if (!contextValue) {
|
|
9
|
+
throw "Wrap your grid in GridContext.Provider";
|
|
10
|
+
}
|
|
11
|
+
return contextValue;
|
|
12
|
+
};
|
|
13
|
+
exports.useGridContext = useGridContext;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { ShapeConfig } from "konva/lib/Shape";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import { ShapeConfig } from "konva/lib/Shape";
|
|
3
3
|
/**
|
|
4
4
|
* Fill handle component
|
|
5
5
|
*/
|
|
6
6
|
declare const FillHandle: React.FC<ShapeConfig>;
|
|
7
7
|
export default FillHandle;
|
|
8
|
+
//# sourceMappingURL=FillHandle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FillHandle.d.ts","sourceRoot":"","sources":["../../FillHandle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4BrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
/**
|
|
6
|
+
* Fill handle component
|
|
7
|
+
*/
|
|
8
|
+
var FillHandle = function (_a) {
|
|
9
|
+
var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, stroke = _a.stroke, _d = _a.strokeWidth, strokeWidth = _d === void 0 ? 1 : _d, _e = _a.size, size = _e === void 0 ? 8 : _e, borderColor = _a.borderColor, props = tslib_1.__rest(_a, ["x", "y", "stroke", "strokeWidth", "size", "borderColor"]);
|
|
10
|
+
if (x === 0 || y === 0)
|
|
11
|
+
return null;
|
|
12
|
+
return (react_1.default.createElement("div", tslib_1.__assign({ style: {
|
|
13
|
+
position: "absolute",
|
|
14
|
+
transform: "translate3d(".concat(x - size / 2, "px, ").concat(y - size / 2, "px, 0)"),
|
|
15
|
+
transformOrigin: "0, 0",
|
|
16
|
+
width: size,
|
|
17
|
+
height: size,
|
|
18
|
+
border: "".concat(strokeWidth, "px ").concat(borderColor, " solid"),
|
|
19
|
+
borderRightWidth: 0,
|
|
20
|
+
borderBottomWidth: 0,
|
|
21
|
+
background: stroke,
|
|
22
|
+
cursor: "crosshair",
|
|
23
|
+
pointerEvents: "all",
|
|
24
|
+
} }, props)));
|
|
25
|
+
};
|
|
26
|
+
exports.default = FillHandle;
|