@gridsheet/preact-core 3.0.3 → 3.0.5
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/dist/index.js +40 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2901,6 +2901,7 @@ const safePreventDefault = (e) => {
|
|
|
2901
2901
|
}
|
|
2902
2902
|
};
|
|
2903
2903
|
const Cell = memo(({ y, x }) => {
|
|
2904
|
+
var _a;
|
|
2904
2905
|
const rowId = y2r(y);
|
|
2905
2906
|
const colId = x2c(x);
|
|
2906
2907
|
const address = `${colId}${rowId}`;
|
|
@@ -2926,8 +2927,8 @@ const Cell = memo(({ y, x }) => {
|
|
|
2926
2927
|
const editing = editingAddress === address;
|
|
2927
2928
|
const pointed = choosing.y === y && choosing.x === x;
|
|
2928
2929
|
const _setEditorRect = useCallback(() => {
|
|
2929
|
-
var
|
|
2930
|
-
const rect = (
|
|
2930
|
+
var _a2;
|
|
2931
|
+
const rect = (_a2 = cellRef.current) == null ? void 0 : _a2.getBoundingClientRect();
|
|
2931
2932
|
if (rect == null) {
|
|
2932
2933
|
return null;
|
|
2933
2934
|
}
|
|
@@ -3104,8 +3105,8 @@ const Cell = memo(({ y, x }) => {
|
|
|
3104
3105
|
[dispatch, x, y]
|
|
3105
3106
|
);
|
|
3106
3107
|
const handleErrorTriangleEnter = useCallback(() => {
|
|
3107
|
-
var
|
|
3108
|
-
const rect = (
|
|
3108
|
+
var _a2;
|
|
3109
|
+
const rect = (_a2 = cellRef.current) == null ? void 0 : _a2.getBoundingClientRect();
|
|
3109
3110
|
if (!rect) {
|
|
3110
3111
|
return;
|
|
3111
3112
|
}
|
|
@@ -3184,7 +3185,7 @@ const Cell = memo(({ y, x }) => {
|
|
|
3184
3185
|
className: "gs-cell-inner",
|
|
3185
3186
|
style: {
|
|
3186
3187
|
...cell == null ? void 0 : cell.style,
|
|
3187
|
-
|
|
3188
|
+
textAlign: ((_a = cell == null ? void 0 : cell.style) == null ? void 0 : _a.textAlign) || (cell == null ? void 0 : cell.justifyContent) || "left",
|
|
3188
3189
|
alignItems: (cell == null ? void 0 : cell.alignItems) || "start"
|
|
3189
3190
|
},
|
|
3190
3191
|
children: [
|
|
@@ -3196,7 +3197,18 @@ const Cell = memo(({ y, x }) => {
|
|
|
3196
3197
|
onMouseLeave: handleErrorTriangleLeave
|
|
3197
3198
|
}
|
|
3198
3199
|
),
|
|
3199
|
-
/* @__PURE__ */ jsx(
|
|
3200
|
+
/* @__PURE__ */ jsx(
|
|
3201
|
+
"div",
|
|
3202
|
+
{
|
|
3203
|
+
className: "gs-cell-rendered",
|
|
3204
|
+
style: (cell == null ? void 0 : cell.alignItems) ? {
|
|
3205
|
+
display: "flex",
|
|
3206
|
+
flexDirection: "column",
|
|
3207
|
+
justifyContent: cell.alignItems === "center" ? "center" : cell.alignItems === "end" ? "flex-end" : void 0
|
|
3208
|
+
} : void 0,
|
|
3209
|
+
children: rendered
|
|
3210
|
+
}
|
|
3211
|
+
)
|
|
3200
3212
|
]
|
|
3201
3213
|
}
|
|
3202
3214
|
),
|
|
@@ -4099,10 +4111,13 @@ const CellStateOverlay = ({ refs = {} }) => {
|
|
|
4099
4111
|
return;
|
|
4100
4112
|
}
|
|
4101
4113
|
container.addEventListener("scroll", handleScroll);
|
|
4114
|
+
const ro = new ResizeObserver(() => drawCanvas());
|
|
4115
|
+
ro.observe(container);
|
|
4102
4116
|
return () => {
|
|
4103
4117
|
container.removeEventListener("scroll", handleScroll);
|
|
4118
|
+
ro.disconnect();
|
|
4104
4119
|
};
|
|
4105
|
-
}, [tabularRef, handleScroll]);
|
|
4120
|
+
}, [tabularRef, handleScroll, drawCanvas]);
|
|
4106
4121
|
return /* @__PURE__ */ jsx(
|
|
4107
4122
|
"div",
|
|
4108
4123
|
{
|
|
@@ -4262,8 +4277,9 @@ const Tabular = () => {
|
|
|
4262
4277
|
{
|
|
4263
4278
|
className: "gs-tabular-inner",
|
|
4264
4279
|
style: {
|
|
4265
|
-
width: sheet.totalWidth
|
|
4266
|
-
height: sheet.totalHeight
|
|
4280
|
+
width: sheet.totalWidth,
|
|
4281
|
+
height: sheet.totalHeight,
|
|
4282
|
+
overflow: "clip"
|
|
4267
4283
|
},
|
|
4268
4284
|
children: [
|
|
4269
4285
|
/* @__PURE__ */ jsx(CellStateOverlay, { refs: mergedRefs }),
|
|
@@ -5039,12 +5055,21 @@ function GridSheet({
|
|
|
5039
5055
|
const [sheetHeight, setSheetHeight] = useState((options == null ? void 0 : options.sheetHeight) || estimateSheetHeight(initialCells));
|
|
5040
5056
|
const [sheetWidth, setSheetWidth] = useState((options == null ? void 0 : options.sheetWidth) || estimateSheetWidth(initialCells));
|
|
5041
5057
|
useEffect(() => {
|
|
5042
|
-
const
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5058
|
+
const el = mainRef.current;
|
|
5059
|
+
if (!el) {
|
|
5060
|
+
return;
|
|
5061
|
+
}
|
|
5062
|
+
let first = true;
|
|
5063
|
+
const ro = new ResizeObserver(() => {
|
|
5064
|
+
if (first) {
|
|
5065
|
+
first = false;
|
|
5066
|
+
return;
|
|
5067
|
+
}
|
|
5068
|
+
setSheetHeight(options.sheetHeight ? Math.min(options.sheetHeight, el.clientHeight) : el.clientHeight);
|
|
5069
|
+
setSheetWidth(options.sheetWidth ? Math.min(options.sheetWidth, el.clientWidth) : el.clientWidth);
|
|
5070
|
+
});
|
|
5071
|
+
ro.observe(el);
|
|
5072
|
+
return () => ro.disconnect();
|
|
5048
5073
|
}, []);
|
|
5049
5074
|
useEffect(() => {
|
|
5050
5075
|
if (options.sheetHeight) {
|
|
@@ -5080,7 +5105,6 @@ function GridSheet({
|
|
|
5080
5105
|
//width: '100%',
|
|
5081
5106
|
maxWidth: (((_c = store.sheetReactive.current) == null ? void 0 : _c.totalWidth) || 0) + 2,
|
|
5082
5107
|
maxHeight: (((_d = store.sheetReactive.current) == null ? void 0 : _d.fullHeight) || 0) + 2,
|
|
5083
|
-
overflow: "auto",
|
|
5084
5108
|
resize: sheetResize,
|
|
5085
5109
|
...style
|
|
5086
5110
|
},
|